From 3bf0d97a774d34e16fd250ee1641abeee0feed17 Mon Sep 17 00:00:00 2001 From: 13wjdgk <13wjdgk@naver.com> Date: Sun, 15 Oct 2023 02:58:22 +0900 Subject: [PATCH] =?UTF-8?q?refactor=20:=20=20[code=5Fsmell=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0]=20test=20public=20=EC=A0=9C=EA=B1=B0=20for=EB=AC=B8?= =?UTF-8?q?=20{}=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notification/service/NotificationService.java | 12 ++++++------ .../domain/scheduler/service/SchedulerService.java | 6 +++--- .../service/NotificationSearchServiceTest.java | 12 ++++++------ .../scheduler/service/SchedulerServiceTest.java | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/coniverse/dangjang/domain/notification/service/NotificationService.java b/src/main/java/com/coniverse/dangjang/domain/notification/service/NotificationService.java index c19fd616..a287c2f6 100644 --- a/src/main/java/com/coniverse/dangjang/domain/notification/service/NotificationService.java +++ b/src/main/java/com/coniverse/dangjang/domain/notification/service/NotificationService.java @@ -125,18 +125,18 @@ public List makeAccessFcmMessage() { NotificationType notificationType = notificationSearchService.findNotificationType("접속"); List notifications = new ArrayList<>(); - userFcmTokens.forEach(userFcmToken -> { + userFcmTokens.forEach(userFcmToken -> notifications.add( notificationMapper.toEntity(userFcmToken.getUser(), title, content, date, notificationType) - ); - }); + ) + ); notificationRepository.saveAll(notifications); List fcmMessages = new ArrayList<>(); - fcmTokens.stream().forEach(token -> { - fcmMessages.add(new FcmMessage(token, title, content)); - }); + fcmTokens.stream().forEach(token -> + fcmMessages.add(new FcmMessage(token, title, content)) + ); return fcmMessages; } diff --git a/src/main/java/com/coniverse/dangjang/domain/scheduler/service/SchedulerService.java b/src/main/java/com/coniverse/dangjang/domain/scheduler/service/SchedulerService.java index df3b9f56..cd001815 100644 --- a/src/main/java/com/coniverse/dangjang/domain/scheduler/service/SchedulerService.java +++ b/src/main/java/com/coniverse/dangjang/domain/scheduler/service/SchedulerService.java @@ -36,9 +36,9 @@ public class SchedulerService { @Scheduled(cron = "0 0 18 * * *", zone = "Asia/Seoul") public void makeNotification() { List fcmMessage = notificationService.makeAccessFcmMessage(); - fcmMessage.forEach(message -> { - notificationFluentbitService.sendMessageToFluentbit(message); - }); + fcmMessage.forEach(message -> + notificationFluentbitService.sendMessageToFluentbit(message) + ); } } diff --git a/src/test/java/com/coniverse/dangjang/domain/notification/service/NotificationSearchServiceTest.java b/src/test/java/com/coniverse/dangjang/domain/notification/service/NotificationSearchServiceTest.java index ab595ab1..99b267d3 100644 --- a/src/test/java/com/coniverse/dangjang/domain/notification/service/NotificationSearchServiceTest.java +++ b/src/test/java/com/coniverse/dangjang/domain/notification/service/NotificationSearchServiceTest.java @@ -2,7 +2,7 @@ import static com.coniverse.dangjang.fixture.NotificationFixture.*; import static com.coniverse.dangjang.fixture.UserFixture.*; -import static org.assertj.core.api.AssertionsForClassTypes.*; +import static org.assertj.core.api.Assertions.*; import java.time.LocalDate; import java.util.List; @@ -24,7 +24,7 @@ @TestInstance(TestInstance.Lifecycle.PER_CLASS) @SpringBootTest -public class NotificationSearchServiceTest { +class NotificationSearchServiceTest { @Autowired private NotificationSearchService notificationSearchService; @Autowired @@ -37,7 +37,7 @@ public class NotificationSearchServiceTest { private NotificationRepository notificationRepository; @BeforeAll - public void setUp() throws Exception { + void setUp() throws Exception { User 이브 = userRepository.save(유저_이브()); 이브.updateAccessedAt(LocalDate.now().minusDays(1)); userRepository.save(이브); @@ -55,17 +55,17 @@ void tearDown() { } @Test - public void 오늘_접속_안한_유저의_fcmToken을_조회한다() { + void 오늘_접속_안한_유저의_fcmToken을_조회한다() { //given LocalDate date = LocalDate.now(); //when List userFcmTokens = notificationSearchService.findNotAccessUserFcmToken(date); //then - assertThat(userFcmTokens.size()).isEqualTo(1); + assertThat(userFcmTokens).hasSize(1); } @Test - public void notificationType을_조회한다() { + void notificationType을_조회한다() { //given LocalDate date = LocalDate.now(); //when diff --git a/src/test/java/com/coniverse/dangjang/domain/scheduler/service/SchedulerServiceTest.java b/src/test/java/com/coniverse/dangjang/domain/scheduler/service/SchedulerServiceTest.java index 81654315..24e5f8b2 100644 --- a/src/test/java/com/coniverse/dangjang/domain/scheduler/service/SchedulerServiceTest.java +++ b/src/test/java/com/coniverse/dangjang/domain/scheduler/service/SchedulerServiceTest.java @@ -22,7 +22,7 @@ @TestInstance(TestInstance.Lifecycle.PER_CLASS) @SpringBootTest -public class SchedulerServiceTest { +class SchedulerServiceTest { @Autowired private SchedulerService schedulerService; @Autowired @@ -64,7 +64,7 @@ void tearDown() { } @Test - public void 스케줄러를_실행한다() { + void 스케줄러를_실행한다() { //given schedulerService.makeNotification(); //when