From 29ef824c67d04c435ab9693a532744653d153670 Mon Sep 17 00:00:00 2001 From: thguss Date: Thu, 27 Jun 2024 10:22:01 +0900 Subject: [PATCH] =?UTF-8?q?[ADD]=20import=20=EA=B5=AC=EC=B2=B4=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../routine/service/RoutineService.java | 5 +- .../server/routine/service/vo/RoutineVO.java | 5 +- .../RoutineServiceIntegrationTest.java | 57 ++++++++++--------- 3 files changed, 33 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/soptie/server/routine/service/RoutineService.java b/src/main/java/com/soptie/server/routine/service/RoutineService.java index 82406346..7659b323 100644 --- a/src/main/java/com/soptie/server/routine/service/RoutineService.java +++ b/src/main/java/com/soptie/server/routine/service/RoutineService.java @@ -1,7 +1,5 @@ package com.soptie.server.routine.service; -import static com.soptie.server.routine.entity.RoutineType.*; - import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -13,6 +11,7 @@ import com.soptie.server.member.adapter.MemberFinder; import com.soptie.server.routine.adapter.ChallengeFinder; import com.soptie.server.routine.adapter.RoutineFinder; +import com.soptie.server.routine.entity.RoutineType; import com.soptie.server.routine.service.dto.request.DailyRoutineListByThemeGetServiceRequest; import com.soptie.server.routine.service.dto.request.DailyRoutineListByThemesGetServiceRequest; import com.soptie.server.routine.service.dto.request.HappinessRoutineListGetServiceRequest; @@ -66,7 +65,7 @@ public HappinessSubRoutineListGetServiceResponse getHappinessSubRoutines( public Map> acquireAllInDailyWithThemeId(Set themeIds) { val themeToRoutine = new LinkedHashMap>(); for (val themeId : themeIds) { - val routines = routineFinder.findAllByTypeAndThemeId(DAILY, themeId); + val routines = routineFinder.findAllByTypeAndThemeId(RoutineType.DAILY, themeId); themeToRoutine.put(themeId, routines); } return themeToRoutine; diff --git a/src/main/java/com/soptie/server/routine/service/vo/RoutineVO.java b/src/main/java/com/soptie/server/routine/service/vo/RoutineVO.java index ff191d61..46ed452b 100644 --- a/src/main/java/com/soptie/server/routine/service/vo/RoutineVO.java +++ b/src/main/java/com/soptie/server/routine/service/vo/RoutineVO.java @@ -1,14 +1,13 @@ package com.soptie.server.routine.service.vo; -import static lombok.AccessLevel.*; - import com.soptie.server.routine.entity.Routine; import com.soptie.server.routine.entity.RoutineType; import jakarta.validation.constraints.NotNull; +import lombok.AccessLevel; import lombok.Builder; -@Builder(access = PRIVATE) +@Builder(access = AccessLevel.PRIVATE) public record RoutineVO( long routineId, @NotNull String content, diff --git a/src/test/java/com/soptie/server/routine/service/integration/RoutineServiceIntegrationTest.java b/src/test/java/com/soptie/server/routine/service/integration/RoutineServiceIntegrationTest.java index 487ad0ed..7aa114c5 100644 --- a/src/test/java/com/soptie/server/routine/service/integration/RoutineServiceIntegrationTest.java +++ b/src/test/java/com/soptie/server/routine/service/integration/RoutineServiceIntegrationTest.java @@ -1,13 +1,11 @@ package com.soptie.server.routine.service.integration; -import static com.soptie.server.routine.entity.RoutineType.*; -import static org.assertj.core.api.Assertions.*; - import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; +import org.assertj.core.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; @@ -20,6 +18,7 @@ import com.soptie.server.memberroutine.repository.MemberRoutineRepository; import com.soptie.server.routine.entity.Challenge; import com.soptie.server.routine.entity.Routine; +import com.soptie.server.routine.entity.RoutineType; import com.soptie.server.routine.repository.ChallengeRepository; import com.soptie.server.routine.repository.RoutineRepository; import com.soptie.server.routine.service.RoutineService; @@ -86,11 +85,11 @@ void setUp() { theme3 = themeRepository.save(ThemeFixture.theme().name("새로운 나").build()); routineOfTheme1 = routineRepository.save( - RoutineFixture.routine().type(DAILY).content("관계를 쌓아보자").theme(theme1).build()); + RoutineFixture.routine().type(RoutineType.DAILY).content("관계를 쌓아보자").theme(theme1).build()); routineOfTheme2 = routineRepository.save( - RoutineFixture.routine().type(DAILY).content("성장하자").theme(theme2).build()); + RoutineFixture.routine().type(RoutineType.DAILY).content("성장하자").theme(theme2).build()); routineOfTheme3 = routineRepository.save( - RoutineFixture.routine().type(DAILY).content("보여줄게 완전히 달라진 나").theme(theme3).build()); + RoutineFixture.routine().type(RoutineType.DAILY).content("완전히 달라진 나").theme(theme3).build()); } @Test @@ -105,13 +104,14 @@ void acquireAllByThemeIds() { final DailyRoutineListGetServiceResponse actual = routineService.getRoutinesByThemes(request); // then - assertThat(actual.routines()).hasSize(2); + Assertions.assertThat(actual.routines()).hasSize(2); List routineIds = actual.routines().stream().map(DailyRoutineServiceResponse::routineId).toList(); - assertThat(routineIds).containsExactlyInAnyOrder(routineOfTheme1.getId(), routineOfTheme2.getId()); + Assertions.assertThat(routineIds) + .containsExactlyInAnyOrder(routineOfTheme1.getId(), routineOfTheme2.getId()); } @Test - @DisplayName("[성공] 각 테마(id)별로 데일리 루틴 목록을 조회한다.") + @DisplayName("[성공] 각 테마 id 별로 데일리 루틴 목록을 조회한다.") void acquireAllWithThemeIds() { // given Set themeIds = new LinkedHashSet<>(); @@ -122,13 +122,13 @@ void acquireAllWithThemeIds() { final Map> actual = routineService.acquireAllInDailyWithThemeId(themeIds); // then - assertThat(actual.keySet()).containsExactly(theme2.getId(), theme1.getId()); + Assertions.assertThat(actual.keySet()).containsExactly(theme2.getId(), theme1.getId()); List routineIdsForTheme1 = actual.get(theme1.getId()).stream().map(RoutineVO::routineId).toList(); - assertThat(routineIdsForTheme1).containsExactlyInAnyOrder(routineOfTheme1.getId()); + Assertions.assertThat(routineIdsForTheme1).containsExactlyInAnyOrder(routineOfTheme1.getId()); List routineIdsForTheme2 = actual.get(theme2.getId()).stream().map(RoutineVO::routineId).toList(); - assertThat(routineIdsForTheme2).containsExactlyInAnyOrder(routineOfTheme2.getId()); + Assertions.assertThat(routineIdsForTheme2).containsExactlyInAnyOrder(routineOfTheme2.getId()); } } @@ -151,18 +151,19 @@ void setUp() { theme = themeRepository.save(ThemeFixture.theme().name("관계 쌓기").build()); routine1 = routineRepository.save( - RoutineFixture.routine().type(DAILY).content("관계 쌓자").theme(theme).build()); + RoutineFixture.routine().type(RoutineType.DAILY).content("관계 쌓자").theme(theme).build()); routine2 = routineRepository.save( - RoutineFixture.routine().type(DAILY).content("쌓자 관계").theme(theme).build()); - routineNoTheme = routineRepository.save(RoutineFixture.routine().type(DAILY).content("테마 없음").build()); + RoutineFixture.routine().type(RoutineType.DAILY).content("쌓자 관계").theme(theme).build()); + routineNoTheme = routineRepository.save( + RoutineFixture.routine().type(RoutineType.DAILY).content("테마 없음").build()); routineMemberHas = routineRepository.save( - RoutineFixture.routine().type(DAILY).content("쌓자 관계").theme(theme).build()); + RoutineFixture.routine().type(RoutineType.DAILY).content("쌓자 관계").theme(theme).build()); challengeRoutine = routineRepository.save( - RoutineFixture.routine().type(CHALLENGE).content("관계 도전").theme(theme).build()); + RoutineFixture.routine().type(RoutineType.CHALLENGE).content("관계 도전").theme(theme).build()); memberRoutineRepository.save( MemberRoutineFixture.memberRoutine() - .type(DAILY) + .type(RoutineType.DAILY) .routineId(routineMemberHas.getId()) .member(member) .build()); @@ -180,7 +181,7 @@ void getDailyRoutinesByThemeMemberNotHas() { // then List routineIds = actual.routines().stream().map(DailyRoutineServiceResponse::routineId).toList(); - assertThat(routineIds).containsExactlyInAnyOrder(routine1.getId(), routine2.getId()); + Assertions.assertThat(routineIds).containsExactlyInAnyOrder(routine1.getId(), routine2.getId()); } } @@ -199,11 +200,11 @@ void setUp() { theme2 = themeRepository.save(ThemeFixture.theme().name("한 걸음 성장").color("민트").build()); routine1 = routineRepository.save( - RoutineFixture.routine().type(CHALLENGE).content("관계쌓는").theme(theme1).build()); + RoutineFixture.routine().type(RoutineType.CHALLENGE).content("관계쌓는").theme(theme1).build()); routine2 = routineRepository.save( - RoutineFixture.routine().type(CHALLENGE).content("성장하는").theme(theme1).build()); + RoutineFixture.routine().type(RoutineType.CHALLENGE).content("성장하는").theme(theme1).build()); routine3 = routineRepository.save( - RoutineFixture.routine().type(CHALLENGE).content("보여주는").theme(theme2).build()); + RoutineFixture.routine().type(RoutineType.CHALLENGE).content("보여주는").theme(theme2).build()); } @Test @@ -216,9 +217,9 @@ void getHappinessRoutinesByTheme() { final HappinessRoutineListGetServiceResponse actual = routineService.getHappinessRoutinesByTheme(request); // then - assertThat(actual.routines()).hasSize(2); + Assertions.assertThat(actual.routines()).hasSize(2); List routineIds = actual.routines().stream().map(HappinessRoutineServiceResponse::routineId).toList(); - assertThat(routineIds).containsExactlyInAnyOrder(routine1.getId(), routine2.getId()); + Assertions.assertThat(routineIds).containsExactlyInAnyOrder(routine1.getId(), routine2.getId()); } } @@ -237,9 +238,9 @@ void setUp() { theme = themeRepository.save(ThemeFixture.theme().name("관계 쌓기").color("라일락").build()); routine1 = routineRepository.save( - RoutineFixture.routine().type(CHALLENGE).content("관계쌓는").theme(theme).build()); + RoutineFixture.routine().type(RoutineType.CHALLENGE).content("관계쌓는").theme(theme).build()); routine2 = routineRepository.save( - RoutineFixture.routine().type(CHALLENGE).content("성장하는").theme(theme).build()); + RoutineFixture.routine().type(RoutineType.CHALLENGE).content("성장하는").theme(theme).build()); challenge1 = challengeRepository.save(ChallengeFixture.challenge().routine(routine1).build()); challenge2 = challengeRepository.save(ChallengeFixture.challenge().routine(routine1).build()); @@ -257,11 +258,11 @@ void getHappinessSubRoutinesByRoutine() { final HappinessSubRoutineListGetServiceResponse actual = routineService.getHappinessSubRoutines(request); // then - assertThat(actual.challenges()).hasSize(2); + Assertions.assertThat(actual.challenges()).hasSize(2); List challengeIds = actual.challenges().stream() .map(HappinessSubRoutineServiceResponse::challengeId).toList(); - assertThat(challengeIds).containsExactlyInAnyOrder(challenge1.getId(), challenge2.getId()); + Assertions.assertThat(challengeIds).containsExactlyInAnyOrder(challenge1.getId(), challenge2.getId()); } } }