Skip to content

Commit

Permalink
refactor: 클래스 이름을 NotificationContent로 통일
Browse files Browse the repository at this point in the history
  • Loading branch information
BackFoxx committed Nov 5, 2023
1 parent db17af2 commit 525da58
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import edonymyeon.backend.notification.application.dto.Receiver;
import edonymyeon.backend.notification.domain.Notification;
import edonymyeon.backend.notification.domain.ScreenType;
import edonymyeon.backend.notification.domain.notification_content.application.NotificationMessageHolder;
import edonymyeon.backend.notification.domain.notification_content.application.NotificationContentHolder;
import edonymyeon.backend.notification.domain.notification_content.domain.NotificationContent;
import edonymyeon.backend.notification.domain.notification_content.domain.NotificationContentId;
import edonymyeon.backend.notification.repository.NotificationRepository;
Expand Down Expand Up @@ -58,7 +58,7 @@ public class NotificationService {

private final ConsumptionService consumptionService;

private final NotificationMessageHolder notificationMessageHolder;
private final NotificationContentHolder notificationContentHolder;

/**
* 특정 회원이 받은 알림 내역을 조회합니다.
Expand Down Expand Up @@ -191,7 +191,7 @@ private void sendNotification(
return;
}

final NotificationContent notificationContent = notificationMessageHolder.findById(notificationContentId);
final NotificationContent notificationContent = notificationContentHolder.findById(notificationContentId);

final Long notificationId = saveNotification(
notifyingTarget,
Expand Down Expand Up @@ -272,6 +272,6 @@ public void deleteNotificationByPost(final Long postId) {
*/
@Transactional
public void updateContent(final NotificationContent content) {
notificationMessageHolder.updateMessage(content);
notificationContentHolder.updateMessage(content);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
@Slf4j
@Transactional(readOnly = true)
@Component
public class NotificationMessageHolder {
public class NotificationContentHolder {

private final NotificationMessageRepository notificationMessageRepository;
private final NotificationContentRepository notificationContentRepository;

public NotificationMessageHolder(final NotificationMessageRepository notificationMessageRepository) {
this.notificationMessageRepository = notificationMessageRepository;
public NotificationContentHolder(final NotificationContentRepository notificationContentRepository) {
this.notificationContentRepository = notificationContentRepository;
}

private final Map<NotificationContentId, NotificationContent> holder = new HashMap<>();
Expand All @@ -33,7 +33,7 @@ public NotificationMessageHolder(final NotificationMessageRepository notificatio
public void initialize() {
for (NotificationContentId notificationContentId : NotificationContentId.values()) {
final Optional<NotificationContent> notificationContent
= notificationMessageRepository.findById(notificationContentId);
= notificationContentRepository.findById(notificationContentId);
if (notificationContent.isEmpty()) {
assignDefaultContent(notificationContentId);
} else {
Expand All @@ -59,7 +59,7 @@ private void assignDefaultContent(final NotificationContentId notificationConten
@Transactional
public void updateMessage(final NotificationContent contentToUpdate) {
final Optional<NotificationContent> notificationContent
= notificationMessageRepository.findById(contentToUpdate.getId());
= notificationContentRepository.findById(contentToUpdate.getId());

notificationContent.ifPresentOrElse(content -> content.update(contentToUpdate), () -> {
throw new EdonymyeonException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
import edonymyeon.backend.notification.domain.notification_content.domain.NotificationContent;
import org.springframework.data.jpa.repository.JpaRepository;

public interface NotificationMessageRepository extends JpaRepository<NotificationContent, NotificationContentId> {
public interface NotificationContentRepository extends JpaRepository<NotificationContent, NotificationContentId> {

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import org.junit.jupiter.api.Test;

@RequiredArgsConstructor
class NotificationMessageHolderTest extends IntegrationFixture {
class NotificationContentHolderTest extends IntegrationFixture {

private final NotificationMessageHolder notificationMessageHolder;
private final NotificationContentHolder notificationContentHolder;

@Test
void 스프링_애플리케이션이_실행되면_DB_NotificationContents_정보를_캐시에_올린다() {
for (NotificationContentId notificationContentId : NotificationContentId.values()) {
Assertions.assertThat(notificationMessageHolder.findById(notificationContentId))
Assertions.assertThat(notificationContentHolder.findById(notificationContentId))
.isNotNull();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import edonymyeon.backend.notification.domain.notification_content.application.dto.NotificationContentRequest;
import edonymyeon.backend.notification.domain.notification_content.domain.NotificationContentId;
import edonymyeon.backend.notification.domain.ScreenType;
import edonymyeon.backend.notification.domain.notification_content.application.NotificationMessageRepository;
import edonymyeon.backend.notification.domain.notification_content.application.NotificationContentRepository;
import edonymyeon.backend.notification.domain.notification_content.domain.NotificationContent;
import edonymyeon.backend.notification.repository.NotificationRepository;
import edonymyeon.backend.post.ImageFileCleaner;
Expand Down Expand Up @@ -94,13 +94,13 @@ class NotificationIntegrationTest extends IntegrationFixture implements ImageFil

@Test
void 알림으로_보낼_메시지의_내용을_수정할__있다(
@Autowired NotificationMessageRepository notificationMessageRepository
@Autowired NotificationContentRepository notificationContentRepository
) {
final NotificationContent notificationContent
= new NotificationContent(NotificationContentId.THUMBS_NOTIFICATION_TITLE, "원래 알림 제목", "원래 알림 본문");
notificationMessageRepository.save(notificationContent);
notificationContentRepository.save(notificationContent);

assertThat(notificationMessageRepository.findById(NotificationContentId.THUMBS_NOTIFICATION_TITLE)).contains(notificationContent);
assertThat(notificationContentRepository.findById(NotificationContentId.THUMBS_NOTIFICATION_TITLE)).contains(notificationContent);

final NotificationContentRequest notificationContentToUpdate
= new NotificationContentRequest(NotificationContentId.THUMBS_NOTIFICATION_TITLE, "새로운 알림 제목", "새로운 알림 본문");
Expand All @@ -116,7 +116,7 @@ class NotificationIntegrationTest extends IntegrationFixture implements ImageFil
.statusCode(HttpStatus.OK.value());

final NotificationContent savedNotificationContent
= notificationMessageRepository.findById(NotificationContentId.THUMBS_NOTIFICATION_TITLE).get();
= notificationContentRepository.findById(NotificationContentId.THUMBS_NOTIFICATION_TITLE).get();
assertThat(savedNotificationContent.getId()).isEqualTo(notificationContentToUpdate.id());
assertThat(savedNotificationContent).extracting("title").isEqualTo(notificationContentToUpdate.title());
assertThat(savedNotificationContent).extracting("body").isEqualTo(notificationContentToUpdate.body());
Expand Down

0 comments on commit 525da58

Please sign in to comment.