diff --git a/src/main/java/com/somemore/global/common/event/DomainEventSubType.java b/src/main/java/com/somemore/global/common/event/DomainEventSubType.java new file mode 100644 index 000000000..c23821960 --- /dev/null +++ b/src/main/java/com/somemore/global/common/event/DomainEventSubType.java @@ -0,0 +1,20 @@ +package com.somemore.global.common.event; + +import lombok.RequiredArgsConstructor; + +import java.util.Arrays; + +@RequiredArgsConstructor +public enum DomainEventSubType { + CREATE_RECRUIT_BOARD("모집 글 등록"), + ; + + private final String description; + + public static DomainEventSubType from(String value) { + return Arrays.stream(DomainEventSubType.values()) + .filter(type -> type.name().equalsIgnoreCase(value)) + .findFirst() + .orElseThrow(() -> new IllegalArgumentException("잘못된 도메인 이벤트 타입입니다: " + value)); + } +} diff --git a/src/main/java/com/somemore/global/common/event/ServerEvent.java b/src/main/java/com/somemore/global/common/event/ServerEvent.java index 17636eaba..050b4431d 100644 --- a/src/main/java/com/somemore/global/common/event/ServerEvent.java +++ b/src/main/java/com/somemore/global/common/event/ServerEvent.java @@ -10,13 +10,8 @@ @SuperBuilder public abstract class ServerEvent> { - @JsonProperty("type") private final ServerEventType type; - - @JsonProperty("subType") private final T subType; - - @JsonProperty("createdAt") private final LocalDateTime createdAt; protected ServerEvent( diff --git a/src/main/java/com/somemore/global/common/event/ServerEventType.java b/src/main/java/com/somemore/global/common/event/ServerEventType.java index da65e9573..4bbebfff6 100644 --- a/src/main/java/com/somemore/global/common/event/ServerEventType.java +++ b/src/main/java/com/somemore/global/common/event/ServerEventType.java @@ -9,7 +9,9 @@ @RequiredArgsConstructor @Getter public enum ServerEventType { - NOTIFICATION(NotificationSubType.class); + NOTIFICATION(NotificationSubType.class), + DOMAIN_EVENT(DomainEventSubType.class), + ; private final Class> subtype; diff --git a/src/main/java/com/somemore/global/redis/config/RedisConfig.java b/src/main/java/com/somemore/global/redis/config/RedisConfig.java index 4687c1e53..77c70102a 100644 --- a/src/main/java/com/somemore/global/redis/config/RedisConfig.java +++ b/src/main/java/com/somemore/global/redis/config/RedisConfig.java @@ -1,7 +1,6 @@ package com.somemore.global.redis.config; import com.somemore.global.common.event.ServerEventType; -import java.util.Map; import lombok.RequiredArgsConstructor; import org.apache.commons.lang3.StringUtils; import org.redisson.Redisson; @@ -19,6 +18,8 @@ import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; import org.springframework.data.redis.serializer.StringRedisSerializer; +import java.util.Map; + @Configuration @EnableRedisRepositories @RequiredArgsConstructor @@ -55,13 +56,21 @@ public RedisTemplate redisTemplate(RedisConnectionFactory connec @Bean public ChannelTopic notificationTopic() { - return new ChannelTopic("notifications"); + return new ChannelTopic("notification"); } @Bean - public Map eventTopicMap(ChannelTopic notificationTopic) { + public ChannelTopic domainEventTopic() { + return new ChannelTopic("domainEvent"); + } + + + @Bean + public Map eventTopicMap(ChannelTopic notificationTopic, + ChannelTopic domainEventTopic) { return Map.of( - ServerEventType.NOTIFICATION, notificationTopic + ServerEventType.NOTIFICATION, notificationTopic, + ServerEventType.DOMAIN_EVENT, domainEventTopic ); } diff --git a/src/main/java/com/somemore/global/redis/registrar/RedisListenerRegistrar.java b/src/main/java/com/somemore/global/redis/registrar/RedisListenerRegistrar.java index f5dd3eb94..f03e689aa 100644 --- a/src/main/java/com/somemore/global/redis/registrar/RedisListenerRegistrar.java +++ b/src/main/java/com/somemore/global/redis/registrar/RedisListenerRegistrar.java @@ -1,6 +1,7 @@ package com.somemore.global.redis.registrar; -import com.somemore.notification.subscriber.RedisNotificationSubscriber; +import com.somemore.interestcenter.event.subscriber.RedisCreateRecruitBoardSubscriber; +import com.somemore.notification.event.subscriber.RedisNotificationSubscriber; import jakarta.annotation.PostConstruct; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -15,7 +16,9 @@ public class RedisListenerRegistrar { private final RedisMessageListenerContainer container; private final RedisNotificationSubscriber redisNotificationSubscriber; + private final RedisCreateRecruitBoardSubscriber redisCreateRecruitBoardSubscriber; private final ChannelTopic notificationTopic; + private final ChannelTopic domainEventTopic; @PostConstruct public void registerListeners() { @@ -24,6 +27,7 @@ public void registerListeners() { private void registerNotificationListener() { container.addMessageListener(redisNotificationSubscriber, notificationTopic); - log.info("Redis 알림 리스너가 '{}' 토픽에 성공적으로 등록되었습니다.", notificationTopic.getTopic()); + container.addMessageListener(redisCreateRecruitBoardSubscriber, domainEventTopic); + log.info("리스너가 토픽에 성공적으로 등록되었습니다."); } } diff --git a/src/main/java/com/somemore/interestcenter/event/converter/CreateRecruitBoardMessageConverter.java b/src/main/java/com/somemore/interestcenter/event/converter/CreateRecruitBoardMessageConverter.java new file mode 100644 index 000000000..5c8405946 --- /dev/null +++ b/src/main/java/com/somemore/interestcenter/event/converter/CreateRecruitBoardMessageConverter.java @@ -0,0 +1,37 @@ +package com.somemore.interestcenter.event.converter; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.somemore.global.common.event.DomainEventSubType; +import com.somemore.recruitboard.event.CreateRecruitBoardEvent; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +@Slf4j +@RequiredArgsConstructor +@Component +public class CreateRecruitBoardMessageConverter { + + private final ObjectMapper objectMapper; + + public CreateRecruitBoardEvent from(String message) { + try { + JsonNode rootNode = objectMapper.readTree(message); + String eventType = rootNode.get("subType").asText(); + + return switch (DomainEventSubType.from(eventType)) { + case CREATE_RECRUIT_BOARD -> parseCreateRecruitBoardEvent(message); + }; + } catch (Exception e) { + log.error(e.getMessage()); + throw new IllegalStateException(); + } + } + + private CreateRecruitBoardEvent parseCreateRecruitBoardEvent(String message) throws JsonProcessingException { + + return objectMapper.readValue(message, CreateRecruitBoardEvent.class); + } +} diff --git a/src/main/java/com/somemore/interestcenter/event/domain/InterestCenterCreateRecruitBoardEvent.java b/src/main/java/com/somemore/interestcenter/event/domain/InterestCenterCreateRecruitBoardEvent.java new file mode 100644 index 000000000..11732d136 --- /dev/null +++ b/src/main/java/com/somemore/interestcenter/event/domain/InterestCenterCreateRecruitBoardEvent.java @@ -0,0 +1,32 @@ +package com.somemore.interestcenter.event.domain; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.somemore.global.common.event.ServerEvent; +import com.somemore.global.common.event.ServerEventType; +import com.somemore.notification.domain.NotificationSubType; +import lombok.Getter; +import lombok.experimental.SuperBuilder; + +import java.time.LocalDateTime; +import java.util.UUID; + +@Getter +@SuperBuilder +public class InterestCenterCreateRecruitBoardEvent extends ServerEvent { + private final UUID volunteerId; + private final UUID centerId; + private final Long recruitBoardId; + + @JsonCreator + public InterestCenterCreateRecruitBoardEvent( + @JsonProperty(value = "volunteerId", required = true) UUID volunteerId, + @JsonProperty(value = "centerId", required = true) UUID centerId, + @JsonProperty(value = "recruitBoardId", required = true) Long recruitBoardId + ) { + super(ServerEventType.NOTIFICATION, NotificationSubType.INTEREST_CENTER_CREATE_RECRUIT_BOARD, LocalDateTime.now()); + this.volunteerId = volunteerId; + this.centerId = centerId; + this.recruitBoardId = recruitBoardId; + } +} diff --git a/src/main/java/com/somemore/interestcenter/event/handler/CreateRecruitBoardHandler.java b/src/main/java/com/somemore/interestcenter/event/handler/CreateRecruitBoardHandler.java new file mode 100644 index 000000000..ecd9d6eb1 --- /dev/null +++ b/src/main/java/com/somemore/interestcenter/event/handler/CreateRecruitBoardHandler.java @@ -0,0 +1,9 @@ +package com.somemore.interestcenter.event.handler; + +import com.somemore.recruitboard.event.CreateRecruitBoardEvent; + +public interface CreateRecruitBoardHandler { + + void handle(CreateRecruitBoardEvent event); + +} diff --git a/src/main/java/com/somemore/interestcenter/event/handler/CreateRecruitBoardHandlerImpl.java b/src/main/java/com/somemore/interestcenter/event/handler/CreateRecruitBoardHandlerImpl.java new file mode 100644 index 000000000..41500aca8 --- /dev/null +++ b/src/main/java/com/somemore/interestcenter/event/handler/CreateRecruitBoardHandlerImpl.java @@ -0,0 +1,45 @@ +package com.somemore.interestcenter.event.handler; + +import com.somemore.global.common.event.ServerEventPublisher; +import com.somemore.global.common.event.ServerEventType; +import com.somemore.interestcenter.event.domain.InterestCenterCreateRecruitBoardEvent; +import com.somemore.interestcenter.usecase.InterestCenterQueryUseCase; +import com.somemore.notification.domain.NotificationSubType; +import com.somemore.recruitboard.event.CreateRecruitBoardEvent; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.UUID; + +@Component +@RequiredArgsConstructor +@Transactional +public class CreateRecruitBoardHandlerImpl implements CreateRecruitBoardHandler { + + private final InterestCenterQueryUseCase interestCenterQueryUseCase; + private final ServerEventPublisher serverEventPublisher; + + @Override + public void handle(CreateRecruitBoardEvent createRecruitBoardEvent) { + UUID centerId = createRecruitBoardEvent.getCenterId(); + List volunteerIdsByCenterId = interestCenterQueryUseCase.getVolunteerIdsByCenterId(centerId); + + volunteerIdsByCenterId.forEach(volunteerId -> + publishInterestCenterCreateRecruitBoardEvent(createRecruitBoardEvent, volunteerId, centerId) + ); + } + + private void publishInterestCenterCreateRecruitBoardEvent(CreateRecruitBoardEvent createRecruitBoardEvent, UUID volunteerId, UUID centerId) { + InterestCenterCreateRecruitBoardEvent event = InterestCenterCreateRecruitBoardEvent.builder() + .type(ServerEventType.NOTIFICATION) + .subType(NotificationSubType.INTEREST_CENTER_CREATE_RECRUIT_BOARD) + .volunteerId(volunteerId) + .centerId(centerId) + .recruitBoardId(createRecruitBoardEvent.getRecruitBoardId()) + .build(); + + serverEventPublisher.publish(event); + } +} diff --git a/src/main/java/com/somemore/interestcenter/event/subscriber/RedisCreateRecruitBoardSubscriber.java b/src/main/java/com/somemore/interestcenter/event/subscriber/RedisCreateRecruitBoardSubscriber.java new file mode 100644 index 000000000..639a150b0 --- /dev/null +++ b/src/main/java/com/somemore/interestcenter/event/subscriber/RedisCreateRecruitBoardSubscriber.java @@ -0,0 +1,26 @@ +package com.somemore.interestcenter.event.subscriber; + +import com.somemore.interestcenter.event.converter.CreateRecruitBoardMessageConverter; +import com.somemore.interestcenter.event.handler.CreateRecruitBoardHandler; +import com.somemore.recruitboard.event.CreateRecruitBoardEvent; +import lombok.RequiredArgsConstructor; +import org.springframework.data.redis.connection.Message; +import org.springframework.data.redis.connection.MessageListener; +import org.springframework.stereotype.Component; + +@Component +@RequiredArgsConstructor +public class RedisCreateRecruitBoardSubscriber implements MessageListener { + + private final CreateRecruitBoardHandler createRecruitBoardHandler; + private final CreateRecruitBoardMessageConverter messageConverter; + + @Override + public void onMessage(Message message, byte[] pattern) { + CreateRecruitBoardEvent event = messageConverter.from( + new String(message.getBody()) + ); + + createRecruitBoardHandler.handle(event); + } +} diff --git a/src/main/java/com/somemore/interestcenter/repository/InterestCenterRepository.java b/src/main/java/com/somemore/interestcenter/repository/InterestCenterRepository.java index 70922763f..fba374e57 100644 --- a/src/main/java/com/somemore/interestcenter/repository/InterestCenterRepository.java +++ b/src/main/java/com/somemore/interestcenter/repository/InterestCenterRepository.java @@ -12,6 +12,7 @@ public interface InterestCenterRepository { Optional findById(Long id); Optional findInterestCenterResponseById(Long id); List findInterestCenterIdsByVolunteerId(UUID volunteerId); + List findVolunteerIdsByCenterId(UUID centerId); boolean existsByVolunteerIdAndCenterId(UUID volunteerId, UUID centerId); Optional findByVolunteerIdAndCenterId(UUID volunteerId, UUID centerId); } diff --git a/src/main/java/com/somemore/interestcenter/repository/InterestCenterRepositoryImpl.java b/src/main/java/com/somemore/interestcenter/repository/InterestCenterRepositoryImpl.java index 1d452eb0b..4c30542c4 100644 --- a/src/main/java/com/somemore/interestcenter/repository/InterestCenterRepositoryImpl.java +++ b/src/main/java/com/somemore/interestcenter/repository/InterestCenterRepositoryImpl.java @@ -1,6 +1,7 @@ package com.somemore.interestcenter.repository; import com.querydsl.core.types.Projections; +import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; import com.somemore.interestcenter.domain.InterestCenter; import com.somemore.interestcenter.domain.QInterestCenter; @@ -18,6 +19,8 @@ public class InterestCenterRepositoryImpl implements InterestCenterRepository { private final JPAQueryFactory queryFactory; private final InterestCenterJpaRepository interestCenterJpaRepository; + private final static QInterestCenter interestCenter = QInterestCenter.interestCenter; + @Override public InterestCenter save(InterestCenter interestCenter) { return interestCenterJpaRepository.save(interestCenter); @@ -25,13 +28,12 @@ public InterestCenter save(InterestCenter interestCenter) { @Override public Optional findById(Long id) { - QInterestCenter interestCenter = QInterestCenter.interestCenter; InterestCenter result = queryFactory .selectFrom(interestCenter) .where( interestCenter.id.eq(id) - .and(interestCenter.deleted.eq(false)) + .and(isNotDeleted()) ) .fetchOne(); @@ -40,7 +42,6 @@ public Optional findById(Long id) { @Override public Optional findInterestCenterResponseById(Long id) { - QInterestCenter interestCenter = QInterestCenter.interestCenter; RegisterInterestCenterResponseDto result = queryFactory .select( @@ -54,7 +55,7 @@ public Optional findInterestCenterResponseByI .from(interestCenter) .where( interestCenter.id.eq(id) - .and(interestCenter.deleted.eq(false)) + .and(isNotDeleted()) ) .fetchOne(); @@ -63,21 +64,32 @@ public Optional findInterestCenterResponseByI @Override public List findInterestCenterIdsByVolunteerId(UUID volunteerId) { - QInterestCenter interestCenter = QInterestCenter.interestCenter; return queryFactory .select(interestCenter.centerId) .from(interestCenter) .where( interestCenter.volunteerId.eq(volunteerId) - .and(interestCenter.deleted.eq(false)) + .and(isNotDeleted()) + ) + .fetch(); + } + + @Override + public List findVolunteerIdsByCenterId(UUID centerId) { + + return queryFactory + .select(interestCenter.volunteerId) + .from(interestCenter) + .where( + interestCenter.centerId.eq(centerId), + isNotDeleted() ) .fetch(); } @Override public boolean existsByVolunteerIdAndCenterId(UUID volunteerId, UUID centerId) { - QInterestCenter interestCenter = QInterestCenter.interestCenter; Integer result = queryFactory .selectOne() @@ -85,16 +97,16 @@ public boolean existsByVolunteerIdAndCenterId(UUID volunteerId, UUID centerId) { .where( interestCenter.volunteerId.eq(volunteerId) .and(interestCenter.centerId.eq(centerId)) - .and(interestCenter.deleted.eq(false)) + .and(isNotDeleted()) ) .fetchFirst(); return result != null; } + @Override public Optional findByVolunteerIdAndCenterId(UUID volunteerId, UUID centerId) { - QInterestCenter interestCenter = QInterestCenter.interestCenter; InterestCenter result = queryFactory.selectFrom(interestCenter) .where( @@ -106,4 +118,7 @@ public Optional findByVolunteerIdAndCenterId(UUID volunteerId, U return Optional.ofNullable(result); } + private static BooleanExpression isNotDeleted() { + return interestCenter.deleted.eq(false); + } } diff --git a/src/main/java/com/somemore/interestcenter/service/InterestCenterQueryService.java b/src/main/java/com/somemore/interestcenter/service/InterestCenterQueryService.java index ffd8b38fc..0645a470c 100644 --- a/src/main/java/com/somemore/interestcenter/service/InterestCenterQueryService.java +++ b/src/main/java/com/somemore/interestcenter/service/InterestCenterQueryService.java @@ -31,4 +31,10 @@ public List getInterestCenters(UUID volunteerId) { .map(InterestCentersResponseDto::of) .toList(); } + + @Override + public List getVolunteerIdsByCenterId(UUID centerId) { + + return interestCenterRepository.findVolunteerIdsByCenterId(centerId); + } } diff --git a/src/main/java/com/somemore/interestcenter/usecase/InterestCenterQueryUseCase.java b/src/main/java/com/somemore/interestcenter/usecase/InterestCenterQueryUseCase.java index c3015f597..44bb3eb44 100644 --- a/src/main/java/com/somemore/interestcenter/usecase/InterestCenterQueryUseCase.java +++ b/src/main/java/com/somemore/interestcenter/usecase/InterestCenterQueryUseCase.java @@ -7,4 +7,5 @@ public interface InterestCenterQueryUseCase { List getInterestCenters(UUID volunteerId); + List getVolunteerIdsByCenterId(UUID centerId); } diff --git a/src/main/java/com/somemore/notification/domain/NotificationSubType.java b/src/main/java/com/somemore/notification/domain/NotificationSubType.java index cb7606d35..78ed04510 100644 --- a/src/main/java/com/somemore/notification/domain/NotificationSubType.java +++ b/src/main/java/com/somemore/notification/domain/NotificationSubType.java @@ -6,11 +6,12 @@ @RequiredArgsConstructor public enum NotificationSubType { - NOTE_BLAH_BLAH("쪽지"), + NEW_NOTE("새 쪽지"), VOLUNTEER_REVIEW_REQUEST("봉사 후기 요청"), VOLUNTEER_APPLY_STATUS_CHANGE("신청 상태 변경"), COMMENT_ADDED("댓글 대댓글 추가"), VOLUNTEER_APPLY("봉사 신청"), + INTEREST_CENTER_CREATE_RECRUIT_BOARD("관심 기관 봉사 모집 등록"), ; private final String description; diff --git a/src/main/java/com/somemore/notification/converter/MessageConverter.java b/src/main/java/com/somemore/notification/event/converter/NotificationMessageConverter.java similarity index 76% rename from src/main/java/com/somemore/notification/converter/MessageConverter.java rename to src/main/java/com/somemore/notification/event/converter/NotificationMessageConverter.java index 40453059c..5253efa74 100644 --- a/src/main/java/com/somemore/notification/converter/MessageConverter.java +++ b/src/main/java/com/somemore/notification/event/converter/NotificationMessageConverter.java @@ -1,10 +1,11 @@ -package com.somemore.notification.converter; +package com.somemore.notification.event.converter; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.somemore.community.event.CommentAddedEvent; import com.somemore.facade.event.VolunteerReviewRequestEvent; +import com.somemore.interestcenter.event.domain.InterestCenterCreateRecruitBoardEvent; import com.somemore.notification.domain.Notification; import com.somemore.notification.domain.NotificationSubType; import com.somemore.volunteerapply.domain.ApplyStatus; @@ -17,21 +18,24 @@ @Slf4j @RequiredArgsConstructor @Component -public class MessageConverter { +public class NotificationMessageConverter { private final ObjectMapper objectMapper; + public static final String SUB_TYPE = "subType"; + public Notification from(String message) { try { JsonNode rootNode = objectMapper.readTree(message); - String eventType = rootNode.get("subType").asText(); + String eventType = rootNode.get(SUB_TYPE).asText(); return switch (NotificationSubType.from(eventType)) { - case NOTE_BLAH_BLAH -> throw new UnsupportedOperationException("NOTE 알림 타입 처리 로직 미구현"); + case NEW_NOTE -> buildNewNoteNotification(message); case VOLUNTEER_REVIEW_REQUEST -> buildVolunteerReviewRequestNotification(message); case VOLUNTEER_APPLY_STATUS_CHANGE -> buildVolunteerApplyStatusChangeNotification(message); case COMMENT_ADDED -> buildCommentAddedNotification(message); case VOLUNTEER_APPLY -> buildVolunteerApplyNotification(message); + case INTEREST_CENTER_CREATE_RECRUIT_BOARD -> buildInterestCenterCreateRecruitBoardNotification(message); }; } catch (Exception e) { log.error(e.getMessage()); @@ -39,6 +43,10 @@ public Notification from(String message) { } } + private Notification buildNewNoteNotification(String message) { + throw new UnsupportedOperationException("NOTE 알림 타입 처리 로직 미구현" + message); + } + private Notification buildVolunteerReviewRequestNotification(String message) throws JsonProcessingException { VolunteerReviewRequestEvent event = objectMapper.readValue(message, VolunteerReviewRequestEvent.class); @@ -83,6 +91,17 @@ private Notification buildVolunteerApplyNotification(String message) throws Json .build(); } + private Notification buildInterestCenterCreateRecruitBoardNotification(String message) throws JsonProcessingException { + InterestCenterCreateRecruitBoardEvent event = objectMapper.readValue(message, InterestCenterCreateRecruitBoardEvent.class); + + return Notification.builder() + .receiverId(event.getVolunteerId()) + .title(createInterestCenterCreateRecruitBoardNotificationTitle()) + .type(NotificationSubType.INTEREST_CENTER_CREATE_RECRUIT_BOARD) + .relatedId(event.getRecruitBoardId()) + .build(); + } + private String createVolunteerReviewRequestNotificationTitle() { return "최근 활동하신 활동의 후기를 작성해 주세요!"; } @@ -105,4 +124,8 @@ private String createCommentAddedNotificationTitle() { private String createVolunteerApplyNotificationTitle() { return "봉사 활동 모집에 새로운 신청이 있습니다."; } + + private String createInterestCenterCreateRecruitBoardNotificationTitle() { + return "관심 기관이 봉사 모집을 등록했습니다."; + } } diff --git a/src/main/java/com/somemore/notification/handler/NotificationHandler.java b/src/main/java/com/somemore/notification/event/handler/NotificationHandler.java similarity index 74% rename from src/main/java/com/somemore/notification/handler/NotificationHandler.java rename to src/main/java/com/somemore/notification/event/handler/NotificationHandler.java index 453bd7ece..0f2cbeb06 100644 --- a/src/main/java/com/somemore/notification/handler/NotificationHandler.java +++ b/src/main/java/com/somemore/notification/event/handler/NotificationHandler.java @@ -1,4 +1,4 @@ -package com.somemore.notification.handler; +package com.somemore.notification.event.handler; import com.somemore.notification.domain.Notification; diff --git a/src/main/java/com/somemore/notification/handler/NotificationHandlerImpl.java b/src/main/java/com/somemore/notification/event/handler/NotificationHandlerImpl.java similarity index 96% rename from src/main/java/com/somemore/notification/handler/NotificationHandlerImpl.java rename to src/main/java/com/somemore/notification/event/handler/NotificationHandlerImpl.java index d7254aa47..f2abb6d9f 100644 --- a/src/main/java/com/somemore/notification/handler/NotificationHandlerImpl.java +++ b/src/main/java/com/somemore/notification/event/handler/NotificationHandlerImpl.java @@ -1,4 +1,4 @@ -package com.somemore.notification.handler; +package com.somemore.notification.event.handler; import com.somemore.notification.domain.Notification; import com.somemore.notification.dto.NotificationResponseDto; diff --git a/src/main/java/com/somemore/notification/subscriber/RedisNotificationSubscriber.java b/src/main/java/com/somemore/notification/event/subscriber/RedisNotificationSubscriber.java similarity index 72% rename from src/main/java/com/somemore/notification/subscriber/RedisNotificationSubscriber.java rename to src/main/java/com/somemore/notification/event/subscriber/RedisNotificationSubscriber.java index beada4034..a7a6cc525 100644 --- a/src/main/java/com/somemore/notification/subscriber/RedisNotificationSubscriber.java +++ b/src/main/java/com/somemore/notification/event/subscriber/RedisNotificationSubscriber.java @@ -1,8 +1,8 @@ -package com.somemore.notification.subscriber; +package com.somemore.notification.event.subscriber; -import com.somemore.notification.converter.MessageConverter; +import com.somemore.notification.event.converter.NotificationMessageConverter; import com.somemore.notification.domain.Notification; -import com.somemore.notification.handler.NotificationHandler; +import com.somemore.notification.event.handler.NotificationHandler; import lombok.RequiredArgsConstructor; import org.springframework.data.redis.connection.Message; import org.springframework.data.redis.connection.MessageListener; @@ -13,7 +13,7 @@ public class RedisNotificationSubscriber implements MessageListener { private final NotificationHandler notificationHandler; - private final MessageConverter messageConverter; + private final NotificationMessageConverter messageConverter; @Override public void onMessage(Message message, byte[] pattern) { diff --git a/src/main/java/com/somemore/notification/subscriber/NotificationSubscriber.java b/src/main/java/com/somemore/notification/subscriber/NotificationSubscriber.java deleted file mode 100644 index a64502269..000000000 --- a/src/main/java/com/somemore/notification/subscriber/NotificationSubscriber.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.somemore.notification.subscriber; - -public interface NotificationSubscriber { - - void subscribe(); -} diff --git a/src/main/java/com/somemore/recruitboard/event/CreateRecruitBoardEvent.java b/src/main/java/com/somemore/recruitboard/event/CreateRecruitBoardEvent.java new file mode 100644 index 000000000..155bb31fc --- /dev/null +++ b/src/main/java/com/somemore/recruitboard/event/CreateRecruitBoardEvent.java @@ -0,0 +1,29 @@ +package com.somemore.recruitboard.event; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.somemore.global.common.event.DomainEventSubType; +import com.somemore.global.common.event.ServerEvent; +import com.somemore.global.common.event.ServerEventType; +import lombok.Getter; +import lombok.experimental.SuperBuilder; + +import java.time.LocalDateTime; +import java.util.UUID; + +@Getter +@SuperBuilder +public class CreateRecruitBoardEvent extends ServerEvent { + private final UUID centerId; + private final Long recruitBoardId; + + @JsonCreator + public CreateRecruitBoardEvent( + @JsonProperty(value = "centerId", required = true) UUID centerId, + @JsonProperty(value = "recruitBoardId", required = true) Long recruitBoardId + ) { + super(ServerEventType.DOMAIN_EVENT, DomainEventSubType.CREATE_RECRUIT_BOARD, LocalDateTime.now()); + this.centerId = centerId; + this.recruitBoardId = recruitBoardId; + } +} diff --git a/src/main/java/com/somemore/recruitboard/service/command/CreateRecruitBoardService.java b/src/main/java/com/somemore/recruitboard/service/command/CreateRecruitBoardService.java index c53f1f4d6..49ec4ca05 100644 --- a/src/main/java/com/somemore/recruitboard/service/command/CreateRecruitBoardService.java +++ b/src/main/java/com/somemore/recruitboard/service/command/CreateRecruitBoardService.java @@ -1,15 +1,20 @@ package com.somemore.recruitboard.service.command; +import com.somemore.global.common.event.DomainEventSubType; +import com.somemore.global.common.event.ServerEventPublisher; +import com.somemore.global.common.event.ServerEventType; import com.somemore.location.usecase.command.CreateLocationUseCase; import com.somemore.recruitboard.domain.RecruitBoard; import com.somemore.recruitboard.dto.request.RecruitBoardCreateRequestDto; +import com.somemore.recruitboard.event.CreateRecruitBoardEvent; import com.somemore.recruitboard.repository.RecruitBoardRepository; import com.somemore.recruitboard.usecase.command.CreateRecruitBoardUseCase; -import java.util.UUID; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.UUID; + @RequiredArgsConstructor @Transactional @@ -18,19 +23,31 @@ public class CreateRecruitBoardService implements CreateRecruitBoardUseCase { private final RecruitBoardRepository recruitBoardRepository; private final CreateLocationUseCase createLocationUseCase; + private final ServerEventPublisher serverEventPublisher; @Override public Long createRecruitBoard( - RecruitBoardCreateRequestDto requestDto, - UUID centerId, - String imgUrl + RecruitBoardCreateRequestDto requestDto, + UUID centerId, + String imgUrl ) { Long locationId = createLocationUseCase.createLocation(requestDto.location()); RecruitBoard recruitBoard = requestDto.toEntity(centerId, locationId, imgUrl); recruitBoardRepository.save(recruitBoard); + publishCreateRecruitBoardEvent(centerId, recruitBoard); return recruitBoard.getId(); } + private void publishCreateRecruitBoardEvent(UUID centerId, RecruitBoard recruitBoard) { + CreateRecruitBoardEvent event = CreateRecruitBoardEvent.builder() + .type(ServerEventType.DOMAIN_EVENT) + .subType(DomainEventSubType.CREATE_RECRUIT_BOARD) + .centerId(centerId) + .recruitBoardId(recruitBoard.getId()) + .build(); + + serverEventPublisher.publish(event); + } } diff --git a/src/main/java/com/somemore/sse/sender/SseSenderImpl.java b/src/main/java/com/somemore/sse/sender/SseSenderImpl.java index 11e6dce12..d7665af10 100644 --- a/src/main/java/com/somemore/sse/sender/SseSenderImpl.java +++ b/src/main/java/com/somemore/sse/sender/SseSenderImpl.java @@ -20,7 +20,8 @@ public class SseSenderImpl implements SseSender { public void send(SseEvent sseEvent) { UUID receiverId = sseEvent.getReceiverId(); emitterRepository.findAllByReceiverId(receiverId) - .forEach((emitterId, emitter) -> sendEvent(emitterId, emitter, sseEvent)); + .forEach((emitterId, emitter) + -> sendEvent(emitterId, emitter, sseEvent)); } private void sendEvent(String emitterId, diff --git a/src/main/java/com/somemore/volunteerapply/service/VolunteerApplyStatusChangeService.java b/src/main/java/com/somemore/volunteerapply/service/VolunteerApplyStatusChangeService.java index 0c0a2be86..cac174894 100644 --- a/src/main/java/com/somemore/volunteerapply/service/VolunteerApplyStatusChangeService.java +++ b/src/main/java/com/somemore/volunteerapply/service/VolunteerApplyStatusChangeService.java @@ -50,7 +50,6 @@ private void changeApplyStatus(Long id, UUID centerId, ApplyStatus newStatus) { ApplyStatus oldStatus = apply.getStatus(); apply.changeStatus(newStatus); - volunteerApplyRepository.save(apply); publishVolunteerApplyStatusChangeEvent(apply, recruitBoard, oldStatus); } diff --git a/src/test/java/com/somemore/interestcenter/converter/CreateRecruitBoardMessageConverterTest.java b/src/test/java/com/somemore/interestcenter/converter/CreateRecruitBoardMessageConverterTest.java new file mode 100644 index 000000000..7e7143b61 --- /dev/null +++ b/src/test/java/com/somemore/interestcenter/converter/CreateRecruitBoardMessageConverterTest.java @@ -0,0 +1,65 @@ +package com.somemore.interestcenter.converter; + +import com.somemore.IntegrationTestSupport; +import com.somemore.global.common.event.DomainEventSubType; +import com.somemore.global.common.event.ServerEventType; +import com.somemore.interestcenter.event.converter.CreateRecruitBoardMessageConverter; +import com.somemore.recruitboard.event.CreateRecruitBoardEvent; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; + +import java.util.UUID; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +class CreateRecruitBoardMessageConverterTest extends IntegrationTestSupport { + + @Autowired + private CreateRecruitBoardMessageConverter createRecruitBoardMessageConverter; + + @Test + @DisplayName("CREATE_RECRUIT_BOARD 메시지를 변환하면 CreateRecruitBoardEvent 객체를 반환한다") + void testVolunteerReviewRequestConversion() { + // given + String message = """ + { + "type": "DOMAIN_EVENT", + "subType": "CREATE_RECRUIT_BOARD", + "centerId": "123e4567-e89b-12d3-a456-426614174001", + "recruitBoardId": 456, + "createdAt": "2024-12-05T10:00:00" + } + """; + + // when + CreateRecruitBoardEvent event = createRecruitBoardMessageConverter.from(message); + + // then + assertThat(event.getCenterId()).isEqualTo(UUID.fromString("123e4567-e89b-12d3-a456-426614174001")); + assertThat(event.getRecruitBoardId()).isEqualTo(456); + assertThat(event.getType()).isEqualTo(ServerEventType.DOMAIN_EVENT); + assertThat(event.getSubType()).isEqualTo(DomainEventSubType.CREATE_RECRUIT_BOARD); + } + + @Test + @DisplayName("잘못된 메시지를 변환하려 하면 IllegalStateException이 발생한다") + void testMessageConversion_Failure() { + // given + String invalidMessage = """ + { + "type": "DOMAIN_EVENT", + "subType": "INVALID_TYPE", + "centerId": "123e4567-e89b-12d3-a456-426614174001", + "recruitBoardId": 456, + "createdAt": "2024-12-05T10:00:00" + } + """; + + // when & then + assertThatThrownBy(() -> createRecruitBoardMessageConverter.from(invalidMessage)) + .isInstanceOf(IllegalStateException.class); + } + +} diff --git a/src/test/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandlerImplTest.java b/src/test/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandlerImplTest.java new file mode 100644 index 000000000..4566f18be --- /dev/null +++ b/src/test/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandlerImplTest.java @@ -0,0 +1,67 @@ +package com.somemore.interestcenter.handler; + +import com.somemore.IntegrationTestSupport; +import com.somemore.global.common.event.ServerEventPublisher; +import com.somemore.interestcenter.event.domain.InterestCenterCreateRecruitBoardEvent; +import com.somemore.interestcenter.event.handler.CreateRecruitBoardHandlerImpl; +import com.somemore.interestcenter.usecase.InterestCenterQueryUseCase; +import com.somemore.recruitboard.event.CreateRecruitBoardEvent; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.UUID; + +import static org.mockito.ArgumentMatchers.argThat; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +@Transactional +class CreateRecruitBoardHandlerImplTest extends IntegrationTestSupport { + + @Autowired + private CreateRecruitBoardHandlerImpl createRecruitBoardHandler; + + @MockBean + private InterestCenterQueryUseCase interestCenterQueryUseCase; + + @MockBean + private ServerEventPublisher serverEventPublisher; + + @Test + void handle_ShouldPublishEventsForVolunteers() { + // given + UUID centerId = UUID.randomUUID(); + UUID volunteerId1 = UUID.randomUUID(); + UUID volunteerId2 = UUID.randomUUID(); + UUID volunteerId3 = UUID.randomUUID(); + Long recruitBoardId = 123L; + + List volunteerIds = List.of(volunteerId1, volunteerId2, volunteerId3); + when(interestCenterQueryUseCase.getVolunteerIdsByCenterId(centerId)).thenReturn(volunteerIds); + + CreateRecruitBoardEvent createRecruitBoardEvent = CreateRecruitBoardEvent.builder() + .centerId(centerId) + .recruitBoardId(recruitBoardId) + .build(); + + // when + createRecruitBoardHandler.handle(createRecruitBoardEvent); + + // then + verify(serverEventPublisher, times(volunteerIds.size())).publish(Mockito.any(InterestCenterCreateRecruitBoardEvent.class)); + + for (UUID volunteerId : volunteerIds) { + verify(serverEventPublisher).publish(argThat(event -> + event instanceof InterestCenterCreateRecruitBoardEvent && + ((InterestCenterCreateRecruitBoardEvent) event).getCenterId().equals(centerId) && + ((InterestCenterCreateRecruitBoardEvent) event).getVolunteerId().equals(volunteerId) && + ((InterestCenterCreateRecruitBoardEvent) event).getRecruitBoardId().equals(recruitBoardId) + )); + } + } +} diff --git a/src/test/java/com/somemore/interestcenter/service/InterestCenterQueryServiceTest.java b/src/test/java/com/somemore/interestcenter/service/InterestCenterQueryServiceTest.java index 7a439fae2..1768a9d60 100644 --- a/src/test/java/com/somemore/interestcenter/service/InterestCenterQueryServiceTest.java +++ b/src/test/java/com/somemore/interestcenter/service/InterestCenterQueryServiceTest.java @@ -86,6 +86,47 @@ void getInterestCenters_ReturnsEmptyList_WhenNoInterestCenters() { assertThat(result).isEmpty(); } + @DisplayName("센터 ID로 봉사자 ID 목록을 조회할 수 있다.") + @Test + void getVolunteerIdsByCenterId() { + // given + UUID centerId = UUID.randomUUID(); + UUID volunteerId1 = UUID.randomUUID(); + UUID volunteerId2 = UUID.randomUUID(); + UUID volunteerId3 = UUID.randomUUID(); + + InterestCenter interestCenter1 = createInterestCenter(volunteerId1, centerId); + InterestCenter interestCenter2 = createInterestCenter(volunteerId2, centerId); + InterestCenter interestCenter3 = createInterestCenter(volunteerId3, centerId); + interestCenterJpaRepository.saveAll(List.of(interestCenter1, interestCenter2, interestCenter3)); + + // when + List result = interestCenterQueryService.getVolunteerIdsByCenterId(centerId); + + // then + assertThat(result) + .hasSize(3) + .containsExactlyInAnyOrder(volunteerId1, volunteerId2, volunteerId3); + } + + @DisplayName("센터 ID에 등록된 봉사자가 없을 경우 빈 리스트를 반환한다.") + @Test + void getVolunteerIdsByCenterId_ReturnsEmptyList_WhenNoVolunteers() { + // given + UUID centerId = UUID.randomUUID(); + + Center center = createCenter(); + centerJpaRepository.save(center); + + // when + List result = interestCenterQueryService.getVolunteerIdsByCenterId(centerId); + + // then + assertThat(result).isEmpty(); + } + + + private Center createCenter() { return Center.create( diff --git a/src/test/java/com/somemore/interestcenter/subscriber/RedisCreateRecruitBoardSubscriberTest.java b/src/test/java/com/somemore/interestcenter/subscriber/RedisCreateRecruitBoardSubscriberTest.java new file mode 100644 index 000000000..458345dfa --- /dev/null +++ b/src/test/java/com/somemore/interestcenter/subscriber/RedisCreateRecruitBoardSubscriberTest.java @@ -0,0 +1,56 @@ +package com.somemore.interestcenter.subscriber; + +import com.somemore.interestcenter.event.converter.CreateRecruitBoardMessageConverter; +import com.somemore.interestcenter.event.subscriber.RedisCreateRecruitBoardSubscriber; +import com.somemore.interestcenter.event.handler.CreateRecruitBoardHandler; +import com.somemore.recruitboard.event.CreateRecruitBoardEvent; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.springframework.data.redis.connection.Message; + +import static org.mockito.Mockito.*; + +class RedisCreateRecruitBoardSubscriberTest { + + @Mock + private CreateRecruitBoardMessageConverter messageConverter; + + @Mock + private CreateRecruitBoardHandler createRecruitBoardHandler; + + @InjectMocks + private RedisCreateRecruitBoardSubscriber subscriber; + + @Test + void onMessage_ShouldProcessMessage() { + // given + MockitoAnnotations.openMocks(this); + + String messageBody = """ + { + "type": "DOMAIN_EVENT", + "subType": "CREATE_RECRUIT_BOARD", + "centerId": "123e4567-e89b-12d3-a456-426614174001", + "recruitBoardId": 456 + } + """; + + byte[] bodyBytes = messageBody.getBytes(); + + Message redisMessage = mock(Message.class); + when(redisMessage.getBody()).thenReturn(bodyBytes); + + CreateRecruitBoardEvent expectedEvent = mock(CreateRecruitBoardEvent.class); + + when(messageConverter.from(messageBody)).thenReturn(expectedEvent); + + // when + subscriber.onMessage(redisMessage, null); + + // then + verify(messageConverter, times(1)).from(messageBody); + verify(createRecruitBoardHandler, times(1)).handle(expectedEvent); + } +} diff --git a/src/test/java/com/somemore/notification/converter/MessageConverterTest.java b/src/test/java/com/somemore/notification/converter/NotificationMessageConverterTest.java similarity index 67% rename from src/test/java/com/somemore/notification/converter/MessageConverterTest.java rename to src/test/java/com/somemore/notification/converter/NotificationMessageConverterTest.java index e161e6b11..325970600 100644 --- a/src/test/java/com/somemore/notification/converter/MessageConverterTest.java +++ b/src/test/java/com/somemore/notification/converter/NotificationMessageConverterTest.java @@ -3,6 +3,7 @@ import com.somemore.IntegrationTestSupport; import com.somemore.notification.domain.Notification; import com.somemore.notification.domain.NotificationSubType; +import com.somemore.notification.event.converter.NotificationMessageConverter; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -12,10 +13,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertThrows; -class MessageConverterTest extends IntegrationTestSupport { +class NotificationMessageConverterTest extends IntegrationTestSupport { @Autowired - private MessageConverter messageConverter; + private NotificationMessageConverter notificationMessageConverter; @Test @DisplayName("VOLUNTEER_REVIEW_REQUEST 메시지를 변환하면 Notification 객체를 반환한다") @@ -34,7 +35,7 @@ void testVolunteerReviewRequestConversion() { """; // when - Notification notification = messageConverter.from(message); + Notification notification = notificationMessageConverter.from(message); // then assertThat(notification.getReceiverId()).isEqualTo(UUID.fromString("123e4567-e89b-12d3-a456-426614174000")); @@ -67,7 +68,7 @@ void testVolunteerApplyStatusChangeConversion() { """; // when - Notification notification = messageConverter.from(message); + Notification notification = notificationMessageConverter.from(message); // then assertThat(notification.getReceiverId()).isEqualTo(UUID.fromString("123e4567-e89b-12d3-a456-426614174000")); @@ -76,6 +77,31 @@ void testVolunteerApplyStatusChangeConversion() { assertThat(notification.getRelatedId()).isEqualTo(456L); } + @Test + @DisplayName("INTEREST_CENTER_CREATE_RECRUIT_BOARD 메시지를 변환하면 Notification 객체를 반환한다. ") + void testBuildInterestCenterCreateRecruitBoardNotification() { + // given + String message = """ + { + "type": "NOTIFICATION", + "subType": "INTEREST_CENTER_CREATE_RECRUIT_BOARD", + "volunteerId": "123e4567-e89b-12d3-a456-426614174000", + "centerId": "123e4567-e89b-12d3-a456-426614174001", + "recruitBoardId": 456, + "createdAt": "2024-12-05T10:00:00" + } + """; + + // when + Notification notification = notificationMessageConverter.from(message); + + // then + assertThat(notification.getReceiverId()).isEqualTo(UUID.fromString("123e4567-e89b-12d3-a456-426614174000")); + assertThat(notification.getTitle()).isEqualTo("관심 기관이 봉사 모집을 등록했습니다."); + assertThat(notification.getType()).isEqualTo(NotificationSubType.INTEREST_CENTER_CREATE_RECRUIT_BOARD); + assertThat(notification.getRelatedId()).isEqualTo(456L); + } + @Test @DisplayName("잘못된 JSON 메시지를 변환하면 IllegalStateException을 던진다") void testInvalidJson() { @@ -84,7 +110,7 @@ void testInvalidJson() { // when // then - assertThrows(IllegalStateException.class, () -> messageConverter.from(invalidMessage)); + assertThrows(IllegalStateException.class, () -> notificationMessageConverter.from(invalidMessage)); } @Test @@ -99,6 +125,6 @@ void testMissingFields() { """; // when & then - assertThrows(IllegalStateException.class, () -> messageConverter.from(messageWithMissingFields)); + assertThrows(IllegalStateException.class, () -> notificationMessageConverter.from(messageWithMissingFields)); } -} \ No newline at end of file +} diff --git a/src/test/java/com/somemore/notification/handler/NotificationHandlerTest.java b/src/test/java/com/somemore/notification/handler/NotificationHandlerTest.java index 80c07db63..8e736d48c 100644 --- a/src/test/java/com/somemore/notification/handler/NotificationHandlerTest.java +++ b/src/test/java/com/somemore/notification/handler/NotificationHandlerTest.java @@ -1,9 +1,10 @@ package com.somemore.notification.handler; import com.somemore.IntegrationTestSupport; -import com.somemore.notification.converter.MessageConverter; +import com.somemore.notification.event.converter.NotificationMessageConverter; import com.somemore.notification.domain.Notification; import com.somemore.notification.domain.NotificationSubType; +import com.somemore.notification.event.handler.NotificationHandlerImpl; import com.somemore.notification.repository.NotificationRepository; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -22,7 +23,7 @@ class NotificationHandlerTest extends IntegrationTestSupport { private NotificationHandlerImpl notificationHandler; @Autowired - private MessageConverter messageConverter; + private NotificationMessageConverter notificationMessageConverter; @Autowired private NotificationRepository notificationRepository; @@ -47,7 +48,7 @@ void handle() { UUID receiverId = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); - Notification notification = messageConverter.from(message); + Notification notification = notificationMessageConverter.from(message); // when notificationHandler.handle(notification); diff --git a/src/test/java/com/somemore/notification/repository/NotificationRepositoryTest.java b/src/test/java/com/somemore/notification/repository/NotificationRepositoryTest.java index b98a78aa9..33acb7266 100644 --- a/src/test/java/com/somemore/notification/repository/NotificationRepositoryTest.java +++ b/src/test/java/com/somemore/notification/repository/NotificationRepositoryTest.java @@ -104,7 +104,7 @@ void findAllByIds() { private Notification createNotification(long i, boolean isRead) { Notification notification = Notification.builder() .title("Notification") - .type(NotificationSubType.NOTE_BLAH_BLAH) + .type(NotificationSubType.NEW_NOTE) .receiverId(receiverId) .relatedId(i + 1) .build(); diff --git a/src/test/java/com/somemore/notification/service/NotificationQueryServiceTest.java b/src/test/java/com/somemore/notification/service/NotificationQueryServiceTest.java index 2b3522599..761f87a4f 100644 --- a/src/test/java/com/somemore/notification/service/NotificationQueryServiceTest.java +++ b/src/test/java/com/somemore/notification/service/NotificationQueryServiceTest.java @@ -32,7 +32,7 @@ void getUnreadNotifications() { Notification unreadNotification = Notification.builder() .title("Unread Notification") - .type(NotificationSubType.NOTE_BLAH_BLAH) + .type(NotificationSubType.NEW_NOTE) .receiverId(receiverId) .relatedId(1L) .build();