From a4bb0387a883bbd8ef94a15e1059bc187bd5835e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Mon, 9 Dec 2024 16:39:52 +0900 Subject: [PATCH 01/23] =?UTF-8?q?refactor(NotificationSubscriber):=20?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=ED=95=98=EC=A7=80=20=EC=95=8A=EB=8A=94=20?= =?UTF-8?q?=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/subscriber/NotificationSubscriber.java | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 src/main/java/com/somemore/notification/subscriber/NotificationSubscriber.java 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(); -} From 2469f632d0a3a21d84574cc99a29824cc3b323f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Mon, 9 Dec 2024 16:41:44 +0900 Subject: [PATCH 02/23] =?UTF-8?q?feat(ServerEventType):=20=EB=8F=84?= =?UTF-8?q?=EB=A9=94=EC=9D=B8=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=20DOMAIN=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 도메인 간 이벤트 전달 시 사용될 DOMAIN 타입 추가 --- .../com/somemore/global/common/event/ServerEventType.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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..ddd5b2c1e 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(DomainEventSubType.class), + ; private final Class> subtype; From 566958ae62e9c32d122381c856f989d7fbd014ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Mon, 9 Dec 2024 16:43:12 +0900 Subject: [PATCH 03/23] =?UTF-8?q?feat(ServerEventType):=20=EC=84=9C?= =?UTF-8?q?=EB=B2=84=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=ED=83=80=EC=9E=85=20?= =?UTF-8?q?DOMAIN=5FEVENT=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 도메인 간 이벤트 전달 시 사용될 DOMAIN_EVENT 타입 추가 - DOMAIN 에서 DOMAIN_EVENT 로 변경 --- .../global/common/event/ServerEventType.java | 2 +- .../global/redis/config/RedisConfig.java | 17 +++++++++++++---- .../redis/registrar/RedisListenerRegistrar.java | 2 ++ 3 files changed, 16 insertions(+), 5 deletions(-) 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 ddd5b2c1e..4bbebfff6 100644 --- a/src/main/java/com/somemore/global/common/event/ServerEventType.java +++ b/src/main/java/com/somemore/global/common/event/ServerEventType.java @@ -10,7 +10,7 @@ @Getter public enum ServerEventType { NOTIFICATION(NotificationSubType.class), - DOMAIN(DomainEventSubType.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..1677c0469 100644 --- a/src/main/java/com/somemore/global/redis/registrar/RedisListenerRegistrar.java +++ b/src/main/java/com/somemore/global/redis/registrar/RedisListenerRegistrar.java @@ -16,6 +16,7 @@ public class RedisListenerRegistrar { private final RedisMessageListenerContainer container; private final RedisNotificationSubscriber redisNotificationSubscriber; private final ChannelTopic notificationTopic; + private final ChannelTopic domainEventTopic; @PostConstruct public void registerListeners() { @@ -24,6 +25,7 @@ public void registerListeners() { private void registerNotificationListener() { container.addMessageListener(redisNotificationSubscriber, notificationTopic); + container.addMessageListener(redisNotificationSubscriber, domainEventTopic); log.info("Redis 알림 리스너가 '{}' 토픽에 성공적으로 등록되었습니다.", notificationTopic.getTopic()); } } From 3451d4f6f2fe79fbc41e5811f18574f4eb2bc1b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:02:24 +0900 Subject: [PATCH 04/23] feat(NotificationMessageConverter): rename MessageConverter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 다른 패키지에도 메시지 컨버터 생겨서 명확히 구분. --- ...verter.java => NotificationMessageConverter.java} | 2 +- .../subscriber/RedisNotificationSubscriber.java | 4 ++-- ...st.java => NotificationMessageConverterTest.java} | 12 ++++++------ .../handler/NotificationHandlerTest.java | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) rename src/main/java/com/somemore/notification/converter/{MessageConverter.java => NotificationMessageConverter.java} (99%) rename src/test/java/com/somemore/notification/converter/{MessageConverterTest.java => NotificationMessageConverterTest.java} (87%) diff --git a/src/main/java/com/somemore/notification/converter/MessageConverter.java b/src/main/java/com/somemore/notification/converter/NotificationMessageConverter.java similarity index 99% rename from src/main/java/com/somemore/notification/converter/MessageConverter.java rename to src/main/java/com/somemore/notification/converter/NotificationMessageConverter.java index 40453059c..6a9cb0f2a 100644 --- a/src/main/java/com/somemore/notification/converter/MessageConverter.java +++ b/src/main/java/com/somemore/notification/converter/NotificationMessageConverter.java @@ -17,7 +17,7 @@ @Slf4j @RequiredArgsConstructor @Component -public class MessageConverter { +public class NotificationMessageConverter { private final ObjectMapper objectMapper; diff --git a/src/main/java/com/somemore/notification/subscriber/RedisNotificationSubscriber.java b/src/main/java/com/somemore/notification/subscriber/RedisNotificationSubscriber.java index beada4034..40da6d0ef 100644 --- a/src/main/java/com/somemore/notification/subscriber/RedisNotificationSubscriber.java +++ b/src/main/java/com/somemore/notification/subscriber/RedisNotificationSubscriber.java @@ -1,6 +1,6 @@ package com.somemore.notification.subscriber; -import com.somemore.notification.converter.MessageConverter; +import com.somemore.notification.converter.NotificationMessageConverter; import com.somemore.notification.domain.Notification; import com.somemore.notification.handler.NotificationHandler; import lombok.RequiredArgsConstructor; @@ -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/test/java/com/somemore/notification/converter/MessageConverterTest.java b/src/test/java/com/somemore/notification/converter/NotificationMessageConverterTest.java similarity index 87% rename from src/test/java/com/somemore/notification/converter/MessageConverterTest.java rename to src/test/java/com/somemore/notification/converter/NotificationMessageConverterTest.java index e161e6b11..05b96673b 100644 --- a/src/test/java/com/somemore/notification/converter/MessageConverterTest.java +++ b/src/test/java/com/somemore/notification/converter/NotificationMessageConverterTest.java @@ -12,10 +12,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 +34,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 +67,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")); @@ -84,7 +84,7 @@ void testInvalidJson() { // when // then - assertThrows(IllegalStateException.class, () -> messageConverter.from(invalidMessage)); + assertThrows(IllegalStateException.class, () -> notificationMessageConverter.from(invalidMessage)); } @Test @@ -99,6 +99,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..6803597f5 100644 --- a/src/test/java/com/somemore/notification/handler/NotificationHandlerTest.java +++ b/src/test/java/com/somemore/notification/handler/NotificationHandlerTest.java @@ -1,7 +1,7 @@ package com.somemore.notification.handler; import com.somemore.IntegrationTestSupport; -import com.somemore.notification.converter.MessageConverter; +import com.somemore.notification.converter.NotificationMessageConverter; import com.somemore.notification.domain.Notification; import com.somemore.notification.domain.NotificationSubType; import com.somemore.notification.repository.NotificationRepository; @@ -22,7 +22,7 @@ class NotificationHandlerTest extends IntegrationTestSupport { private NotificationHandlerImpl notificationHandler; @Autowired - private MessageConverter messageConverter; + private NotificationMessageConverter notificationMessageConverter; @Autowired private NotificationRepository notificationRepository; @@ -47,7 +47,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); From 822381f91748d26f9ee9c8dc2da32cc877323430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:04:59 +0900 Subject: [PATCH 05/23] =?UTF-8?q?feat(DomainEventSubType):=20=EB=8F=84?= =?UTF-8?q?=EB=A9=94=EC=9D=B8=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=EC=84=9C?= =?UTF-8?q?=EB=B8=8C=ED=83=80=EC=9E=85=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 기관의 모집 글 등록 추가. --- .../common/event/DomainEventSubType.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/main/java/com/somemore/global/common/event/DomainEventSubType.java 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..8252757b3 --- /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)); + } +} \ No newline at end of file From 3f0788a5940cdcdac11c6013b166cde3e738f374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:08:27 +0900 Subject: [PATCH 06/23] =?UTF-8?q?feat(CreateRecruitBoardService):=20publis?= =?UTF-8?q?hCreateRecruitBoardEvent=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 기관이 봉사 모집을 등록하면 이벤트 발생. - 이는 봉사자의 관심 기관 봉사 모집 등록 알림을 위한 첫 단계. --- .../event/CreateRecruitBoardEvent.java | 15 +++++++++++ .../command/CreateRecruitBoardService.java | 25 ++++++++++++++++--- 2 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/somemore/recruitboard/event/CreateRecruitBoardEvent.java 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..101100266 --- /dev/null +++ b/src/main/java/com/somemore/recruitboard/event/CreateRecruitBoardEvent.java @@ -0,0 +1,15 @@ +package com.somemore.recruitboard.event; + +import com.somemore.global.common.event.DomainEventSubType; +import com.somemore.global.common.event.ServerEvent; +import lombok.Getter; +import lombok.experimental.SuperBuilder; + +import java.util.UUID; + +@Getter +@SuperBuilder +public class CreateRecruitBoardEvent extends ServerEvent { + private final UUID centerId; + private final Long 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); + } } From 83b23f06374aabe9562bb0ca263e9e355bacea35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:13:01 +0900 Subject: [PATCH 07/23] =?UTF-8?q?feat(CreateRecruitBoard):=20CreateRecruit?= =?UTF-8?q?BoardEvent=20subscriber,=20converter=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 직렬화 된 이벤트 메시지를 이벤트로 컨버팅(역직렬화) 후 핸들러에게 전달 --- .../CreateRecruitBoardMessageConverter.java | 37 +++++++++++++++++++ .../handler/CreateRecruitBoardHandler.java | 9 +++++ .../RedisCreateRecruitBoardSubscriber.java | 26 +++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 src/main/java/com/somemore/interestcenter/converter/CreateRecruitBoardMessageConverter.java create mode 100644 src/main/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandler.java create mode 100644 src/main/java/com/somemore/interestcenter/subsciber/RedisCreateRecruitBoardSubscriber.java diff --git a/src/main/java/com/somemore/interestcenter/converter/CreateRecruitBoardMessageConverter.java b/src/main/java/com/somemore/interestcenter/converter/CreateRecruitBoardMessageConverter.java new file mode 100644 index 000000000..65d5c0cab --- /dev/null +++ b/src/main/java/com/somemore/interestcenter/converter/CreateRecruitBoardMessageConverter.java @@ -0,0 +1,37 @@ +package com.somemore.interestcenter.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/handler/CreateRecruitBoardHandler.java b/src/main/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandler.java new file mode 100644 index 000000000..3bb74034a --- /dev/null +++ b/src/main/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandler.java @@ -0,0 +1,9 @@ +package com.somemore.interestcenter.handler; + +import com.somemore.recruitboard.event.CreateRecruitBoardEvent; + +public interface CreateRecruitBoardHandler { + + void handle(CreateRecruitBoardEvent event); + +} diff --git a/src/main/java/com/somemore/interestcenter/subsciber/RedisCreateRecruitBoardSubscriber.java b/src/main/java/com/somemore/interestcenter/subsciber/RedisCreateRecruitBoardSubscriber.java new file mode 100644 index 000000000..f242453fd --- /dev/null +++ b/src/main/java/com/somemore/interestcenter/subsciber/RedisCreateRecruitBoardSubscriber.java @@ -0,0 +1,26 @@ +package com.somemore.interestcenter.subsciber; + +import com.somemore.interestcenter.converter.CreateRecruitBoardMessageConverter; +import com.somemore.interestcenter.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); + } +} From e14f0c190a29b84824c2ceecbdf00d0e134c7069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Mon, 9 Dec 2024 17:16:36 +0900 Subject: [PATCH 08/23] =?UTF-8?q?feat(CreateRecruitBoardHandler):=20Create?= =?UTF-8?q?RecruitBoardEvent=20->=20InterestCenterCreateRecruitBoardEvent?= =?UTF-8?q?=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 해당 기관을 관심 기관으로 설정한 봉사자 N명에게 알림 타입 각 1건, 합 N건의 이벤트 발생. - 알림 서브 타입에 추가. - 컨버팅 추가. - 로직에 필요한 리포지토리, 서비스 메서드 추가. --- ...InterestCenterCreateRecruitBoardEvent.java | 16 +++++++ .../CreateRecruitBoardHandlerImpl.java | 45 +++++++++++++++++++ .../repository/InterestCenterRepository.java | 1 + .../InterestCenterRepositoryImpl.java | 33 ++++++++++---- .../service/InterestCenterQueryService.java | 6 +++ .../usecase/InterestCenterQueryUseCase.java | 1 + .../NotificationMessageConverter.java | 17 +++++++ .../domain/NotificationSubType.java | 2 + 8 files changed, 112 insertions(+), 9 deletions(-) create mode 100644 src/main/java/com/somemore/interestcenter/event/InterestCenterCreateRecruitBoardEvent.java create mode 100644 src/main/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandlerImpl.java diff --git a/src/main/java/com/somemore/interestcenter/event/InterestCenterCreateRecruitBoardEvent.java b/src/main/java/com/somemore/interestcenter/event/InterestCenterCreateRecruitBoardEvent.java new file mode 100644 index 000000000..b85374e89 --- /dev/null +++ b/src/main/java/com/somemore/interestcenter/event/InterestCenterCreateRecruitBoardEvent.java @@ -0,0 +1,16 @@ +package com.somemore.interestcenter.event; + +import com.somemore.global.common.event.ServerEvent; +import com.somemore.notification.domain.NotificationSubType; +import lombok.Getter; +import lombok.experimental.SuperBuilder; + +import java.util.UUID; + +@Getter +@SuperBuilder +public class InterestCenterCreateRecruitBoardEvent extends ServerEvent { + private final UUID volunteerId; + private final UUID centerId; + private final Long recruitBoardId; +} diff --git a/src/main/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandlerImpl.java b/src/main/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandlerImpl.java new file mode 100644 index 000000000..525a46969 --- /dev/null +++ b/src/main/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandlerImpl.java @@ -0,0 +1,45 @@ +package com.somemore.interestcenter.handler; + +import com.somemore.global.common.event.ServerEventPublisher; +import com.somemore.global.common.event.ServerEventType; +import com.somemore.interestcenter.event.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/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/converter/NotificationMessageConverter.java b/src/main/java/com/somemore/notification/converter/NotificationMessageConverter.java index 6a9cb0f2a..0f984d22a 100644 --- a/src/main/java/com/somemore/notification/converter/NotificationMessageConverter.java +++ b/src/main/java/com/somemore/notification/converter/NotificationMessageConverter.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.somemore.community.event.CommentAddedEvent; import com.somemore.facade.event.VolunteerReviewRequestEvent; +import com.somemore.interestcenter.event.InterestCenterCreateRecruitBoardEvent; import com.somemore.notification.domain.Notification; import com.somemore.notification.domain.NotificationSubType; import com.somemore.volunteerapply.domain.ApplyStatus; @@ -32,6 +33,7 @@ public Notification from(String 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()); @@ -83,6 +85,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 +118,8 @@ private String createCommentAddedNotificationTitle() { private String createVolunteerApplyNotificationTitle() { return "봉사 활동 모집에 새로운 신청이 있습니다."; } + + private String createInterestCenterCreateRecruitBoardNotificationTitle() { + return "관심 기관이 봉사 모집을 등록했습니다."; + } } diff --git a/src/main/java/com/somemore/notification/domain/NotificationSubType.java b/src/main/java/com/somemore/notification/domain/NotificationSubType.java index cb7606d35..467bdce55 100644 --- a/src/main/java/com/somemore/notification/domain/NotificationSubType.java +++ b/src/main/java/com/somemore/notification/domain/NotificationSubType.java @@ -11,6 +11,8 @@ public enum NotificationSubType { VOLUNTEER_APPLY_STATUS_CHANGE("신청 상태 변경"), COMMENT_ADDED("댓글 대댓글 추가"), VOLUNTEER_APPLY("봉사 신청"), + INTEREST_CENTER_CREATE_RECRUIT_BOARD("관심 기관 봉사 모집 등록"), + ; private final String description; From 9f6447f30369c54a85dd4d443c4a776b1dbce405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Mon, 9 Dec 2024 21:34:15 +0900 Subject: [PATCH 09/23] =?UTF-8?q?refactor:=20=ED=8C=A8=ED=82=A4=EC=A7=80?= =?UTF-8?q?=20=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RedisCreateRecruitBoardSubscriber.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/main/java/com/somemore/interestcenter/{subsciber => subscriber}/RedisCreateRecruitBoardSubscriber.java (95%) diff --git a/src/main/java/com/somemore/interestcenter/subsciber/RedisCreateRecruitBoardSubscriber.java b/src/main/java/com/somemore/interestcenter/subscriber/RedisCreateRecruitBoardSubscriber.java similarity index 95% rename from src/main/java/com/somemore/interestcenter/subsciber/RedisCreateRecruitBoardSubscriber.java rename to src/main/java/com/somemore/interestcenter/subscriber/RedisCreateRecruitBoardSubscriber.java index f242453fd..4611a45fd 100644 --- a/src/main/java/com/somemore/interestcenter/subsciber/RedisCreateRecruitBoardSubscriber.java +++ b/src/main/java/com/somemore/interestcenter/subscriber/RedisCreateRecruitBoardSubscriber.java @@ -1,4 +1,4 @@ -package com.somemore.interestcenter.subsciber; +package com.somemore.interestcenter.subscriber; import com.somemore.interestcenter.converter.CreateRecruitBoardMessageConverter; import com.somemore.interestcenter.handler.CreateRecruitBoardHandler; From ee2e2343ca55f29b03b3a0d45ed1a46264a0a76b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Mon, 9 Dec 2024 21:35:07 +0900 Subject: [PATCH 10/23] =?UTF-8?q?feat(event):=20=EC=97=AD=EC=A7=81?= =?UTF-8?q?=EB=A0=AC=ED=99=94=20=EC=A7=80=EC=9B=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InterestCenterCreateRecruitBoardEvent.java | 16 ++++++++++++++++ .../event/CreateRecruitBoardEvent.java | 14 ++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/main/java/com/somemore/interestcenter/event/InterestCenterCreateRecruitBoardEvent.java b/src/main/java/com/somemore/interestcenter/event/InterestCenterCreateRecruitBoardEvent.java index b85374e89..f564a6935 100644 --- a/src/main/java/com/somemore/interestcenter/event/InterestCenterCreateRecruitBoardEvent.java +++ b/src/main/java/com/somemore/interestcenter/event/InterestCenterCreateRecruitBoardEvent.java @@ -1,10 +1,14 @@ package com.somemore.interestcenter.event; +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 @@ -13,4 +17,16 @@ public class InterestCenterCreateRecruitBoardEvent 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; + } } From 9c56b00ee2a6bd2faa963cfe29ac58212321107c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Mon, 9 Dec 2024 21:35:39 +0900 Subject: [PATCH 11/23] =?UTF-8?q?test(RedisCreateRecruitBoardSubscriber):?= =?UTF-8?q?=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=BB=A8=EB=B2=84=ED=8C=85,?= =?UTF-8?q?=20=ED=95=B8=EB=93=A4=EB=A7=81=20=EB=AA=A8=ED=82=B9=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...RedisCreateRecruitBoardSubscriberTest.java | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/test/java/com/somemore/interestcenter/subscriber/RedisCreateRecruitBoardSubscriberTest.java 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..fad2ac6df --- /dev/null +++ b/src/test/java/com/somemore/interestcenter/subscriber/RedisCreateRecruitBoardSubscriberTest.java @@ -0,0 +1,55 @@ +package com.somemore.interestcenter.subscriber; + +import com.somemore.interestcenter.converter.CreateRecruitBoardMessageConverter; +import com.somemore.interestcenter.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); + } +} \ No newline at end of file From 96151726463473430179b7a49a6277c8e0a65417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Mon, 9 Dec 2024 21:36:02 +0900 Subject: [PATCH 12/23] =?UTF-8?q?test(CreateRecruitBoardMessageConverterTe?= =?UTF-8?q?st):=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=BB=A8=EB=B2=84?= =?UTF-8?q?=ED=8C=85=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...reateRecruitBoardMessageConverterTest.java | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/test/java/com/somemore/interestcenter/converter/CreateRecruitBoardMessageConverterTest.java 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..417bd742b --- /dev/null +++ b/src/test/java/com/somemore/interestcenter/converter/CreateRecruitBoardMessageConverterTest.java @@ -0,0 +1,44 @@ +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.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; + +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); + } + +} \ No newline at end of file From c014a8c54cb1e95eeb0e7b7e2321736c29262ff8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Mon, 9 Dec 2024 21:45:57 +0900 Subject: [PATCH 13/23] =?UTF-8?q?test(CreateRecruitBoardHandlerImpl):=20?= =?UTF-8?q?=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=ED=95=B8=EB=93=A4=EB=A7=81=20?= =?UTF-8?q?=EB=AA=A8=ED=82=B9=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 호출 확인. --- .../CreateRecruitBoardHandlerImplTest.java | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/test/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandlerImplTest.java 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..2be9615dd --- /dev/null +++ b/src/test/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandlerImplTest.java @@ -0,0 +1,70 @@ +package com.somemore.interestcenter.handler; + +import com.somemore.IntegrationTestSupport; +import com.somemore.global.common.event.ServerEventPublisher; +import com.somemore.interestcenter.event.InterestCenterCreateRecruitBoardEvent; +import com.somemore.interestcenter.usecase.InterestCenterQueryUseCase; +import com.somemore.interestcenter.usecase.RegisterInterestCenterUseCase; +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; + + @Autowired + private RegisterInterestCenterUseCase registerInterestCenterUseCase; + + @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) + )); + } + } +} \ No newline at end of file From f448688b36ada79d88bd4f210725387b497f8469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Mon, 9 Dec 2024 21:55:50 +0900 Subject: [PATCH 14/23] =?UTF-8?q?style(=EA=B0=9C=ED=96=89):=20=EB=A7=88?= =?UTF-8?q?=EC=A7=80=EB=A7=89=20=EC=A4=84=20=EA=B0=9C=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 사용하지 않는 테스트 의존성 삭제. --- .../somemore/global/common/event/DomainEventSubType.java | 2 +- .../converter/CreateRecruitBoardMessageConverterTest.java | 2 +- .../handler/CreateRecruitBoardHandlerImplTest.java | 6 +----- .../subscriber/RedisCreateRecruitBoardSubscriberTest.java | 2 +- .../converter/NotificationMessageConverterTest.java | 2 +- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/somemore/global/common/event/DomainEventSubType.java b/src/main/java/com/somemore/global/common/event/DomainEventSubType.java index 8252757b3..c23821960 100644 --- a/src/main/java/com/somemore/global/common/event/DomainEventSubType.java +++ b/src/main/java/com/somemore/global/common/event/DomainEventSubType.java @@ -17,4 +17,4 @@ public static DomainEventSubType from(String value) { .findFirst() .orElseThrow(() -> new IllegalArgumentException("잘못된 도메인 이벤트 타입입니다: " + value)); } -} \ No newline at end of file +} diff --git a/src/test/java/com/somemore/interestcenter/converter/CreateRecruitBoardMessageConverterTest.java b/src/test/java/com/somemore/interestcenter/converter/CreateRecruitBoardMessageConverterTest.java index 417bd742b..9d396194a 100644 --- a/src/test/java/com/somemore/interestcenter/converter/CreateRecruitBoardMessageConverterTest.java +++ b/src/test/java/com/somemore/interestcenter/converter/CreateRecruitBoardMessageConverterTest.java @@ -41,4 +41,4 @@ void testVolunteerReviewRequestConversion() { assertThat(event.getSubType()).isEqualTo(DomainEventSubType.CREATE_RECRUIT_BOARD); } -} \ No newline at end of file +} diff --git a/src/test/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandlerImplTest.java b/src/test/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandlerImplTest.java index 2be9615dd..e120e04c4 100644 --- a/src/test/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandlerImplTest.java +++ b/src/test/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandlerImplTest.java @@ -4,7 +4,6 @@ import com.somemore.global.common.event.ServerEventPublisher; import com.somemore.interestcenter.event.InterestCenterCreateRecruitBoardEvent; import com.somemore.interestcenter.usecase.InterestCenterQueryUseCase; -import com.somemore.interestcenter.usecase.RegisterInterestCenterUseCase; import com.somemore.recruitboard.event.CreateRecruitBoardEvent; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -26,9 +25,6 @@ class CreateRecruitBoardHandlerImplTest extends IntegrationTestSupport { @Autowired private CreateRecruitBoardHandlerImpl createRecruitBoardHandler; - @Autowired - private RegisterInterestCenterUseCase registerInterestCenterUseCase; - @MockBean private InterestCenterQueryUseCase interestCenterQueryUseCase; @@ -67,4 +63,4 @@ void handle_ShouldPublishEventsForVolunteers() { )); } } -} \ No newline at end of file +} diff --git a/src/test/java/com/somemore/interestcenter/subscriber/RedisCreateRecruitBoardSubscriberTest.java b/src/test/java/com/somemore/interestcenter/subscriber/RedisCreateRecruitBoardSubscriberTest.java index fad2ac6df..b35152f83 100644 --- a/src/test/java/com/somemore/interestcenter/subscriber/RedisCreateRecruitBoardSubscriberTest.java +++ b/src/test/java/com/somemore/interestcenter/subscriber/RedisCreateRecruitBoardSubscriberTest.java @@ -52,4 +52,4 @@ void onMessage_ShouldProcessMessage() { verify(messageConverter, times(1)).from(messageBody); verify(createRecruitBoardHandler, times(1)).handle(expectedEvent); } -} \ No newline at end of file +} diff --git a/src/test/java/com/somemore/notification/converter/NotificationMessageConverterTest.java b/src/test/java/com/somemore/notification/converter/NotificationMessageConverterTest.java index 05b96673b..c3b38be79 100644 --- a/src/test/java/com/somemore/notification/converter/NotificationMessageConverterTest.java +++ b/src/test/java/com/somemore/notification/converter/NotificationMessageConverterTest.java @@ -101,4 +101,4 @@ void testMissingFields() { // when & then assertThrows(IllegalStateException.class, () -> notificationMessageConverter.from(messageWithMissingFields)); } -} \ No newline at end of file +} From 8cbaa543b5980518b7f0d0bf96377e5bbdeb3b61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Mon, 9 Dec 2024 22:09:59 +0900 Subject: [PATCH 15/23] =?UTF-8?q?test(CreateRecruitBoardMessageConverter):?= =?UTF-8?q?=20=EC=98=88=EC=99=B8=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=BC=80?= =?UTF-8?q?=EC=9D=B4=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...reateRecruitBoardMessageConverterTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/test/java/com/somemore/interestcenter/converter/CreateRecruitBoardMessageConverterTest.java b/src/test/java/com/somemore/interestcenter/converter/CreateRecruitBoardMessageConverterTest.java index 9d396194a..c79b73538 100644 --- a/src/test/java/com/somemore/interestcenter/converter/CreateRecruitBoardMessageConverterTest.java +++ b/src/test/java/com/somemore/interestcenter/converter/CreateRecruitBoardMessageConverterTest.java @@ -11,6 +11,7 @@ import java.util.UUID; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; class CreateRecruitBoardMessageConverterTest extends IntegrationTestSupport { @@ -41,4 +42,23 @@ void testVolunteerReviewRequestConversion() { 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); + } + } From 0a2b427b565fb7d93f38116a8657c8098cec8326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Mon, 9 Dec 2024 22:10:27 +0900 Subject: [PATCH 16/23] =?UTF-8?q?test(InterestCenterQueryService):=20?= =?UTF-8?q?=EC=84=BC=ED=84=B0=20=EC=95=84=EC=9D=B4=EB=94=94=EB=A1=9C=20?= =?UTF-8?q?=EB=B4=89=EC=82=AC=EC=9E=90=20=EC=95=84=EC=9D=B4=EB=94=94=20?= =?UTF-8?q?=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InterestCenterQueryServiceTest.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) 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( From f739c4aebca841eb98f1411c8ce18a26794a1fd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Mon, 9 Dec 2024 22:11:05 +0900 Subject: [PATCH 17/23] =?UTF-8?q?test(NotificationMessageConverter):=20INT?= =?UTF-8?q?EREST=5FCENTER=5FCREATE=5FRECRUIT=5FBOARD=20=EB=A9=94=EC=8B=9C?= =?UTF-8?q?=EC=A7=80=20=EC=BB=A8=EB=B2=84=ED=8C=85=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NotificationMessageConverterTest.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/test/java/com/somemore/notification/converter/NotificationMessageConverterTest.java b/src/test/java/com/somemore/notification/converter/NotificationMessageConverterTest.java index c3b38be79..f5b021b4b 100644 --- a/src/test/java/com/somemore/notification/converter/NotificationMessageConverterTest.java +++ b/src/test/java/com/somemore/notification/converter/NotificationMessageConverterTest.java @@ -76,6 +76,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() { From 98598fa4653f93128be7b17abf982afccf408a2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Tue, 10 Dec 2024 00:25:19 +0900 Subject: [PATCH 18/23] =?UTF-8?q?fix(RedisListenerRegistrar):=20=EC=98=AC?= =?UTF-8?q?=EB=B0=94=EB=A5=B8=20=EB=A6=AC=EC=8A=A4=EB=84=88=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/redis/registrar/RedisListenerRegistrar.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 1677c0469..3b1218a11 100644 --- a/src/main/java/com/somemore/global/redis/registrar/RedisListenerRegistrar.java +++ b/src/main/java/com/somemore/global/redis/registrar/RedisListenerRegistrar.java @@ -1,5 +1,6 @@ package com.somemore.global.redis.registrar; +import com.somemore.interestcenter.subscriber.RedisCreateRecruitBoardSubscriber; import com.somemore.notification.subscriber.RedisNotificationSubscriber; import jakarta.annotation.PostConstruct; import lombok.RequiredArgsConstructor; @@ -15,6 +16,7 @@ public class RedisListenerRegistrar { private final RedisMessageListenerContainer container; private final RedisNotificationSubscriber redisNotificationSubscriber; + private final RedisCreateRecruitBoardSubscriber redisCreateRecruitBoardSubscriber; private final ChannelTopic notificationTopic; private final ChannelTopic domainEventTopic; @@ -25,7 +27,7 @@ public void registerListeners() { private void registerNotificationListener() { container.addMessageListener(redisNotificationSubscriber, notificationTopic); - container.addMessageListener(redisNotificationSubscriber, domainEventTopic); + container.addMessageListener(redisCreateRecruitBoardSubscriber, domainEventTopic); log.info("Redis 알림 리스너가 '{}' 토픽에 성공적으로 등록되었습니다.", notificationTopic.getTopic()); } } From 0fb521a7ef6b2d3b35094e7487ba4db3026db2ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Tue, 10 Dec 2024 12:36:57 +0900 Subject: [PATCH 19/23] =?UTF-8?q?refactor(NotificationMessageConverter):?= =?UTF-8?q?=20=EC=83=81=EC=88=98=20=EC=B2=98=EB=A6=AC,=20=EB=85=B8?= =?UTF-8?q?=ED=8A=B8=20=EC=95=8C=EB=A6=BC=20=EB=AA=85=EB=AA=85=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../converter/NotificationMessageConverter.java | 10 ++++++++-- .../notification/domain/NotificationSubType.java | 3 +-- .../repository/NotificationRepositoryTest.java | 2 +- .../service/NotificationQueryServiceTest.java | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/somemore/notification/converter/NotificationMessageConverter.java b/src/main/java/com/somemore/notification/converter/NotificationMessageConverter.java index 0f984d22a..ad4ac0048 100644 --- a/src/main/java/com/somemore/notification/converter/NotificationMessageConverter.java +++ b/src/main/java/com/somemore/notification/converter/NotificationMessageConverter.java @@ -22,13 +22,15 @@ 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); @@ -41,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); diff --git a/src/main/java/com/somemore/notification/domain/NotificationSubType.java b/src/main/java/com/somemore/notification/domain/NotificationSubType.java index 467bdce55..78ed04510 100644 --- a/src/main/java/com/somemore/notification/domain/NotificationSubType.java +++ b/src/main/java/com/somemore/notification/domain/NotificationSubType.java @@ -6,13 +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/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(); From e1a837b90160e3ee2cbaa69453ceed5209d28e03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Tue, 10 Dec 2024 12:37:47 +0900 Subject: [PATCH 20/23] =?UTF-8?q?refactor(RedisListenerRegistrar):=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../somemore/global/redis/registrar/RedisListenerRegistrar.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 3b1218a11..f0f0b0873 100644 --- a/src/main/java/com/somemore/global/redis/registrar/RedisListenerRegistrar.java +++ b/src/main/java/com/somemore/global/redis/registrar/RedisListenerRegistrar.java @@ -28,6 +28,6 @@ public void registerListeners() { private void registerNotificationListener() { container.addMessageListener(redisNotificationSubscriber, notificationTopic); container.addMessageListener(redisCreateRecruitBoardSubscriber, domainEventTopic); - log.info("Redis 알림 리스너가 '{}' 토픽에 성공적으로 등록되었습니다.", notificationTopic.getTopic()); + log.info("리스너가 토픽에 성공적으로 등록되었습니다."); } } From d2d2fcb187e03b4724c1f0e7e7ca11eedc1dd86c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Tue, 10 Dec 2024 12:38:07 +0900 Subject: [PATCH 21/23] =?UTF-8?q?refactor(VolunteerApplyStatusChangeServic?= =?UTF-8?q?e):=20=EB=8D=94=ED=8B=B0=20=EC=B2=B4=ED=82=B9=20=ED=99=9C?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/VolunteerApplyStatusChangeService.java | 1 - 1 file changed, 1 deletion(-) 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); } From 81616ee61ba39a59615f6069bbf1f44f52f0db66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Tue, 10 Dec 2024 12:38:23 +0900 Subject: [PATCH 22/23] =?UTF-8?q?style:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EB=9D=BC=EC=9D=B8=20=EC=82=AD=EC=A0=9C,=20?= =?UTF-8?q?=EA=B0=9C=ED=96=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/somemore/global/common/event/ServerEvent.java | 5 ----- src/main/java/com/somemore/sse/sender/SseSenderImpl.java | 3 ++- 2 files changed, 2 insertions(+), 6 deletions(-) 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/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, From dcfe12e4faba50eaca724b3e58e933ac25b8dec8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=A1=B0=EC=9E=AC=EC=A4=91?= <126754298+m-a-king@users.noreply.github.com> Date: Mon, 16 Dec 2024 16:14:09 +0900 Subject: [PATCH 23/23] =?UTF-8?q?refactor:=20=ED=8C=A8=ED=82=A4=EC=A7=80?= =?UTF-8?q?=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 이벤트와 관련된 패키지를 event 하위로 이동 --- .../global/redis/registrar/RedisListenerRegistrar.java | 4 ++-- .../converter/CreateRecruitBoardMessageConverter.java | 2 +- .../{ => domain}/InterestCenterCreateRecruitBoardEvent.java | 2 +- .../{ => event}/handler/CreateRecruitBoardHandler.java | 2 +- .../{ => event}/handler/CreateRecruitBoardHandlerImpl.java | 4 ++-- .../subscriber/RedisCreateRecruitBoardSubscriber.java | 6 +++--- .../{ => event}/converter/NotificationMessageConverter.java | 4 ++-- .../{ => event}/handler/NotificationHandler.java | 2 +- .../{ => event}/handler/NotificationHandlerImpl.java | 2 +- .../{ => event}/subscriber/RedisNotificationSubscriber.java | 6 +++--- .../converter/CreateRecruitBoardMessageConverterTest.java | 1 + .../handler/CreateRecruitBoardHandlerImplTest.java | 3 ++- .../subscriber/RedisCreateRecruitBoardSubscriberTest.java | 5 +++-- .../converter/NotificationMessageConverterTest.java | 1 + .../notification/handler/NotificationHandlerTest.java | 3 ++- 15 files changed, 26 insertions(+), 21 deletions(-) rename src/main/java/com/somemore/interestcenter/{ => event}/converter/CreateRecruitBoardMessageConverter.java (95%) rename src/main/java/com/somemore/interestcenter/event/{ => domain}/InterestCenterCreateRecruitBoardEvent.java (96%) rename src/main/java/com/somemore/interestcenter/{ => event}/handler/CreateRecruitBoardHandler.java (76%) rename src/main/java/com/somemore/interestcenter/{ => event}/handler/CreateRecruitBoardHandlerImpl.java (93%) rename src/main/java/com/somemore/interestcenter/{ => event}/subscriber/RedisCreateRecruitBoardSubscriber.java (78%) rename src/main/java/com/somemore/notification/{ => event}/converter/NotificationMessageConverter.java (97%) rename src/main/java/com/somemore/notification/{ => event}/handler/NotificationHandler.java (74%) rename src/main/java/com/somemore/notification/{ => event}/handler/NotificationHandlerImpl.java (96%) rename src/main/java/com/somemore/notification/{ => event}/subscriber/RedisNotificationSubscriber.java (79%) 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 f0f0b0873..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,7 +1,7 @@ package com.somemore.global.redis.registrar; -import com.somemore.interestcenter.subscriber.RedisCreateRecruitBoardSubscriber; -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; diff --git a/src/main/java/com/somemore/interestcenter/converter/CreateRecruitBoardMessageConverter.java b/src/main/java/com/somemore/interestcenter/event/converter/CreateRecruitBoardMessageConverter.java similarity index 95% rename from src/main/java/com/somemore/interestcenter/converter/CreateRecruitBoardMessageConverter.java rename to src/main/java/com/somemore/interestcenter/event/converter/CreateRecruitBoardMessageConverter.java index 65d5c0cab..5c8405946 100644 --- a/src/main/java/com/somemore/interestcenter/converter/CreateRecruitBoardMessageConverter.java +++ b/src/main/java/com/somemore/interestcenter/event/converter/CreateRecruitBoardMessageConverter.java @@ -1,4 +1,4 @@ -package com.somemore.interestcenter.converter; +package com.somemore.interestcenter.event.converter; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; diff --git a/src/main/java/com/somemore/interestcenter/event/InterestCenterCreateRecruitBoardEvent.java b/src/main/java/com/somemore/interestcenter/event/domain/InterestCenterCreateRecruitBoardEvent.java similarity index 96% rename from src/main/java/com/somemore/interestcenter/event/InterestCenterCreateRecruitBoardEvent.java rename to src/main/java/com/somemore/interestcenter/event/domain/InterestCenterCreateRecruitBoardEvent.java index f564a6935..11732d136 100644 --- a/src/main/java/com/somemore/interestcenter/event/InterestCenterCreateRecruitBoardEvent.java +++ b/src/main/java/com/somemore/interestcenter/event/domain/InterestCenterCreateRecruitBoardEvent.java @@ -1,4 +1,4 @@ -package com.somemore.interestcenter.event; +package com.somemore.interestcenter.event.domain; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandler.java b/src/main/java/com/somemore/interestcenter/event/handler/CreateRecruitBoardHandler.java similarity index 76% rename from src/main/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandler.java rename to src/main/java/com/somemore/interestcenter/event/handler/CreateRecruitBoardHandler.java index 3bb74034a..ecd9d6eb1 100644 --- a/src/main/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandler.java +++ b/src/main/java/com/somemore/interestcenter/event/handler/CreateRecruitBoardHandler.java @@ -1,4 +1,4 @@ -package com.somemore.interestcenter.handler; +package com.somemore.interestcenter.event.handler; import com.somemore.recruitboard.event.CreateRecruitBoardEvent; diff --git a/src/main/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandlerImpl.java b/src/main/java/com/somemore/interestcenter/event/handler/CreateRecruitBoardHandlerImpl.java similarity index 93% rename from src/main/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandlerImpl.java rename to src/main/java/com/somemore/interestcenter/event/handler/CreateRecruitBoardHandlerImpl.java index 525a46969..41500aca8 100644 --- a/src/main/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandlerImpl.java +++ b/src/main/java/com/somemore/interestcenter/event/handler/CreateRecruitBoardHandlerImpl.java @@ -1,8 +1,8 @@ -package com.somemore.interestcenter.handler; +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.InterestCenterCreateRecruitBoardEvent; +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; diff --git a/src/main/java/com/somemore/interestcenter/subscriber/RedisCreateRecruitBoardSubscriber.java b/src/main/java/com/somemore/interestcenter/event/subscriber/RedisCreateRecruitBoardSubscriber.java similarity index 78% rename from src/main/java/com/somemore/interestcenter/subscriber/RedisCreateRecruitBoardSubscriber.java rename to src/main/java/com/somemore/interestcenter/event/subscriber/RedisCreateRecruitBoardSubscriber.java index 4611a45fd..639a150b0 100644 --- a/src/main/java/com/somemore/interestcenter/subscriber/RedisCreateRecruitBoardSubscriber.java +++ b/src/main/java/com/somemore/interestcenter/event/subscriber/RedisCreateRecruitBoardSubscriber.java @@ -1,7 +1,7 @@ -package com.somemore.interestcenter.subscriber; +package com.somemore.interestcenter.event.subscriber; -import com.somemore.interestcenter.converter.CreateRecruitBoardMessageConverter; -import com.somemore.interestcenter.handler.CreateRecruitBoardHandler; +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; diff --git a/src/main/java/com/somemore/notification/converter/NotificationMessageConverter.java b/src/main/java/com/somemore/notification/event/converter/NotificationMessageConverter.java similarity index 97% rename from src/main/java/com/somemore/notification/converter/NotificationMessageConverter.java rename to src/main/java/com/somemore/notification/event/converter/NotificationMessageConverter.java index ad4ac0048..5253efa74 100644 --- a/src/main/java/com/somemore/notification/converter/NotificationMessageConverter.java +++ b/src/main/java/com/somemore/notification/event/converter/NotificationMessageConverter.java @@ -1,11 +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.InterestCenterCreateRecruitBoardEvent; +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; 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 79% rename from src/main/java/com/somemore/notification/subscriber/RedisNotificationSubscriber.java rename to src/main/java/com/somemore/notification/event/subscriber/RedisNotificationSubscriber.java index 40da6d0ef..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.NotificationMessageConverter; +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; diff --git a/src/test/java/com/somemore/interestcenter/converter/CreateRecruitBoardMessageConverterTest.java b/src/test/java/com/somemore/interestcenter/converter/CreateRecruitBoardMessageConverterTest.java index c79b73538..7e7143b61 100644 --- a/src/test/java/com/somemore/interestcenter/converter/CreateRecruitBoardMessageConverterTest.java +++ b/src/test/java/com/somemore/interestcenter/converter/CreateRecruitBoardMessageConverterTest.java @@ -3,6 +3,7 @@ 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; diff --git a/src/test/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandlerImplTest.java b/src/test/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandlerImplTest.java index e120e04c4..4566f18be 100644 --- a/src/test/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandlerImplTest.java +++ b/src/test/java/com/somemore/interestcenter/handler/CreateRecruitBoardHandlerImplTest.java @@ -2,7 +2,8 @@ import com.somemore.IntegrationTestSupport; import com.somemore.global.common.event.ServerEventPublisher; -import com.somemore.interestcenter.event.InterestCenterCreateRecruitBoardEvent; +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; diff --git a/src/test/java/com/somemore/interestcenter/subscriber/RedisCreateRecruitBoardSubscriberTest.java b/src/test/java/com/somemore/interestcenter/subscriber/RedisCreateRecruitBoardSubscriberTest.java index b35152f83..458345dfa 100644 --- a/src/test/java/com/somemore/interestcenter/subscriber/RedisCreateRecruitBoardSubscriberTest.java +++ b/src/test/java/com/somemore/interestcenter/subscriber/RedisCreateRecruitBoardSubscriberTest.java @@ -1,7 +1,8 @@ package com.somemore.interestcenter.subscriber; -import com.somemore.interestcenter.converter.CreateRecruitBoardMessageConverter; -import com.somemore.interestcenter.handler.CreateRecruitBoardHandler; +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; diff --git a/src/test/java/com/somemore/notification/converter/NotificationMessageConverterTest.java b/src/test/java/com/somemore/notification/converter/NotificationMessageConverterTest.java index f5b021b4b..325970600 100644 --- a/src/test/java/com/somemore/notification/converter/NotificationMessageConverterTest.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; diff --git a/src/test/java/com/somemore/notification/handler/NotificationHandlerTest.java b/src/test/java/com/somemore/notification/handler/NotificationHandlerTest.java index 6803597f5..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.NotificationMessageConverter; +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;