From 85dbab265ee6825d27cecbed2b15e1ee388ae9fc Mon Sep 17 00:00:00 2001 From: choidongkuen Date: Sun, 28 Jan 2024 05:04:13 +0900 Subject: [PATCH 1/8] =?UTF-8?q?refactor:=20=ED=9A=8C=EC=9B=90=20=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=20=EB=93=B1=EB=A1=9D=20API=20=EB=A6=AC=ED=8C=A9?= =?UTF-8?q?=ED=86=A0=EB=A7=81=20(#157)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../net/teumteum/user/controller/UserController.java | 2 +- .../user/domain/request/ReviewRegisterRequest.java | 2 +- src/main/java/net/teumteum/user/service/UserService.java | 9 ++++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/teumteum/user/controller/UserController.java b/src/main/java/net/teumteum/user/controller/UserController.java index 49bbfb8f..d6a28264 100644 --- a/src/main/java/net/teumteum/user/controller/UserController.java +++ b/src/main/java/net/teumteum/user/controller/UserController.java @@ -113,7 +113,7 @@ public void registerReview( @RequestParam Long meetingId, @Valid @RequestBody ReviewRegisterRequest request ) { - userService.registerReview(meetingId, request); + userService.registerReview(meetingId, getCurrentUserId(), request); } @GetMapping("/reviews") diff --git a/src/main/java/net/teumteum/user/domain/request/ReviewRegisterRequest.java b/src/main/java/net/teumteum/user/domain/request/ReviewRegisterRequest.java index 60603575..b5cc4bbb 100644 --- a/src/main/java/net/teumteum/user/domain/request/ReviewRegisterRequest.java +++ b/src/main/java/net/teumteum/user/domain/request/ReviewRegisterRequest.java @@ -8,7 +8,7 @@ public record ReviewRegisterRequest( @Valid - @Size(min = 3, max = 6) + @Size(min = 2, max = 5) List reviews ) { diff --git a/src/main/java/net/teumteum/user/service/UserService.java b/src/main/java/net/teumteum/user/service/UserService.java index f690b304..e036c02a 100644 --- a/src/main/java/net/teumteum/user/service/UserService.java +++ b/src/main/java/net/teumteum/user/service/UserService.java @@ -103,8 +103,9 @@ public void logout(Long userId) { @Transactional - public void registerReview(Long meetingId, ReviewRegisterRequest request) { + public void registerReview(Long meetingId, Long currentUserId, ReviewRegisterRequest request) { checkMeetingExistence(meetingId); + checkCurrentUserIdInRequest(request, currentUserId); request.reviews() .forEach(userReview -> { @@ -152,4 +153,10 @@ private void checkMeetingExistence(Long meetingId) { throw new IllegalArgumentException("meetingId에 해당하는 meeting을 찾을 수 없습니다. \"" + meetingId + "\""); } } + + private void checkCurrentUserIdInRequest(ReviewRegisterRequest request, Long currentUserId) { + if (request.reviews().stream().anyMatch(review -> review.id().equals(currentUserId))) { + throw new IllegalArgumentException("나의 리뷰에 대한 리뷰를 작성할 수 없습니다."); + } + } } From 678210ecfc89dbecb3d3351a3ccfd7c514001ad0 Mon Sep 17 00:00:00 2001 From: choidongkuen Date: Sun, 28 Jan 2024 07:03:08 +0900 Subject: [PATCH 2/8] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9B=90=20=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=20=EB=93=B1=EB=A1=9D=EC=8B=9C,=20=EC=98=A8=EB=8F=84?= =?UTF-8?q?=20=EB=B0=98=EC=98=81=20=EB=B0=8F=20=EB=A6=AC=EB=B7=B0=20?= =?UTF-8?q?=ED=94=BC=EB=93=9C=EB=B0=B1=20=EB=B0=98=EC=98=81=20(#157)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../teumteum/user/service/UserService.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/main/java/net/teumteum/user/service/UserService.java b/src/main/java/net/teumteum/user/service/UserService.java index e036c02a..38f9ca02 100644 --- a/src/main/java/net/teumteum/user/service/UserService.java +++ b/src/main/java/net/teumteum/user/service/UserService.java @@ -105,12 +105,13 @@ public void logout(Long userId) { @Transactional public void registerReview(Long meetingId, Long currentUserId, ReviewRegisterRequest request) { checkMeetingExistence(meetingId); - checkCurrentUserIdInRequest(request, currentUserId); + checkUserNotRegisterSelfReview(request, currentUserId); request.reviews() .forEach(userReview -> { User user = getUser(userReview.id()); - user.addReview(userReview.review()); + user.registerReview(userReview.review()); + user.updateMannerTemperature(userReview.review()); }); } @@ -149,14 +150,18 @@ private void checkUserExistence(Authenticated authenticated, String oauthId) { } private void checkMeetingExistence(Long meetingId) { - if (!meetingConnector.existById(meetingId)) { - throw new IllegalArgumentException("meetingId에 해당하는 meeting을 찾을 수 없습니다. \"" + meetingId + "\""); - } + Assert.isTrue(meetingConnector.existById(meetingId), + () -> { + throw new IllegalArgumentException("meetingId에 해당하는 meeting을 찾을 수 없습니다. \"" + meetingId + "\""); + } + ); } - private void checkCurrentUserIdInRequest(ReviewRegisterRequest request, Long currentUserId) { - if (request.reviews().stream().anyMatch(review -> review.id().equals(currentUserId))) { - throw new IllegalArgumentException("나의 리뷰에 대한 리뷰를 작성할 수 없습니다."); - } + private void checkUserNotRegisterSelfReview(ReviewRegisterRequest request, Long currentUserId) { + Assert.isTrue(request.reviews().stream().noneMatch(review -> review.id().equals(currentUserId)), + () -> { + throw new IllegalArgumentException("나의 리뷰에 대한 리뷰를 작성할 수 없습니다."); + } + ); } } From a3ca588dbdaa532c38adf065797a81bfec2347c5 Mon Sep 17 00:00:00 2001 From: choidongkuen Date: Sun, 28 Jan 2024 07:03:33 +0900 Subject: [PATCH 3/8] =?UTF-8?q?feat:=20User=20=EC=97=94=ED=8B=B0=ED=8B=B0?= =?UTF-8?q?=20=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=B6=94=EA=B0=80=20(#157)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/net/teumteum/user/domain/User.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/teumteum/user/domain/User.java b/src/main/java/net/teumteum/user/domain/User.java index bdec964c..35551ebf 100644 --- a/src/main/java/net/teumteum/user/domain/User.java +++ b/src/main/java/net/teumteum/user/domain/User.java @@ -122,9 +122,13 @@ public void addFriend(User user) { friends.add(user.id); } - public void addReview(Review review) { + public void registerReview(Review review) { List newReviews = new ArrayList<>(reviews); newReviews.add(review); reviews = newReviews; } + + public void updateMannerTemperature(Review review) { + mannerTemperature += review.getScore(); + } } From 4373f53475475e66aa0dc254b33a92e7ebc1b0f1 Mon Sep 17 00:00:00 2001 From: choidongkuen Date: Sun, 28 Jan 2024 07:04:07 +0900 Subject: [PATCH 4/8] =?UTF-8?q?feat:=20Review=20enum=20=ED=95=84=EB=93=9C?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20(#157)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/net/teumteum/user/domain/Review.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/teumteum/user/domain/Review.java b/src/main/java/net/teumteum/user/domain/Review.java index cb01b81e..a04445aa 100644 --- a/src/main/java/net/teumteum/user/domain/Review.java +++ b/src/main/java/net/teumteum/user/domain/Review.java @@ -1,7 +1,14 @@ package net.teumteum.user.domain; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor public enum Review { - 별로에요, - 좋아요, - 최고에요 + 별로에요(-1), + 좋아요(1), + 최고에요(2); + + private final int score; } From b8c10f7b4027c345816723d42c50707115696f2b Mon Sep 17 00:00:00 2001 From: choidongkuen Date: Sun, 28 Jan 2024 07:04:45 +0900 Subject: [PATCH 5/8] =?UTF-8?q?test:=20=EB=A6=AC=EB=B7=B0=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=EC=8B=9C=20=EC=98=A8=EB=8F=84=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8=EC=97=90=20=EB=8C=80=ED=95=9C=20=EB=8B=A8?= =?UTF-8?q?=EC=9C=84=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20(#157)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/controller/UserControllerTest.java | 26 +++++++++++++++++ .../unit/user/service/UserServiceTest.java | 28 +++++++++++++++++-- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/src/test/java/net/teumteum/unit/user/controller/UserControllerTest.java b/src/test/java/net/teumteum/unit/user/controller/UserControllerTest.java index b7b47bd0..ff38eb6c 100644 --- a/src/test/java/net/teumteum/unit/user/controller/UserControllerTest.java +++ b/src/test/java/net/teumteum/unit/user/controller/UserControllerTest.java @@ -7,9 +7,11 @@ import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; +import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.BDDMockito.given; +import static org.mockito.Mockito.doThrow; import static org.springframework.http.HttpHeaders.AUTHORIZATION; import static org.springframework.http.MediaType.APPLICATION_JSON; import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; @@ -163,6 +165,30 @@ void Register_user_review_with_200_ok() throws Exception { .andDo(print()) .andExpect(status().isOk()); } + + @Test + @DisplayName("현재 로그인한 회원의 id 가 리뷰 등록 요청에 포함된다면, 회원 리뷰 등록을 실패하고 400 bad request을 반환한다.") + void Register_reviews_with_400_bad_request() throws Exception { + // given + ReviewRegisterRequest reviewRegisterRequest = RequestFixture.reviewRegisterRequest(); + + String errorMessage = "나의 리뷰에 대한 리뷰를 작성할 수 없습니다."; + + doThrow(new IllegalArgumentException(errorMessage)) + .when(userService) + .registerReview(anyLong(), anyLong(), any(ReviewRegisterRequest.class)); + + // when & then + mockMvc.perform(post("/users/reviews") + .param("meetingId", String.valueOf(1L)) + .contentType(APPLICATION_JSON) + .content(objectMapper.writeValueAsString(reviewRegisterRequest)) + .with(csrf()) + .header(AUTHORIZATION, VALID_ACCESS_TOKEN)) + .andDo(print()) + .andExpect(status().isBadRequest()) + .andExpect(result -> assertEquals(errorMessage, result.getResolvedException().getMessage())); + } } diff --git a/src/test/java/net/teumteum/unit/user/service/UserServiceTest.java b/src/test/java/net/teumteum/unit/user/service/UserServiceTest.java index 5733b2de..7a7525b0 100644 --- a/src/test/java/net/teumteum/unit/user/service/UserServiceTest.java +++ b/src/test/java/net/teumteum/unit/user/service/UserServiceTest.java @@ -148,7 +148,9 @@ void Register_user_review_with_200_ok() { Long meetingId = 1L; - Long userId = 1L; + Long userId = 10L; + + Long currentUserId = 20L; given(meetingConnector.existById(anyLong())) .willReturn(true); @@ -157,13 +159,32 @@ void Register_user_review_with_200_ok() { .willReturn(Optional.of(UserFixture.getUserWithId(userId++))); // when - userService.registerReview(meetingId, reviewRegisterRequest); + userService.registerReview(meetingId, currentUserId, reviewRegisterRequest); // then verify(meetingConnector, times(1)).existById(anyLong()); verify(userRepository, times(3)).findById(anyLong()); } + @Test + @DisplayName("회원 id 가 리뷰 정보 요청에 포함되면, 400 Bad Request 와 함께 리뷰 등록을 실패한다.") + void Return_400_bad_request_if_current_user_id_in_request() { + // given + ReviewRegisterRequest reviewRegisterRequest = RequestFixture.reviewRegisterRequest(); + + Long meetingId = 1L; + + Long currentUserId = reviewRegisterRequest.reviews().get(0).id(); + + given(meetingConnector.existById(anyLong())) + .willReturn(true); + + // when & then + assertThatThrownBy(() -> userService.registerReview(meetingId, currentUserId, reviewRegisterRequest)) + .isInstanceOf(IllegalArgumentException.class) + .hasMessage("나의 리뷰에 대한 리뷰를 작성할 수 없습니다."); + } + @Test @DisplayName("meeting id 에 해당하는 meeting 이 존재하지 않는 경우, 400 Bad Request 와 함께 리뷰 등록을 실패한다.") void Return_400_bad_request_if_meeting_is_not_exist() { @@ -171,11 +192,12 @@ void Return_400_bad_request_if_meeting_is_not_exist() { ReviewRegisterRequest reviewRegisterRequest = RequestFixture.reviewRegisterRequest(); Long meetingId = 1L; + Long currentUserId = 1L; given(meetingConnector.existById(anyLong())) .willReturn(false); // when & then - assertThatThrownBy(() -> userService.registerReview(meetingId, reviewRegisterRequest)) + assertThatThrownBy(() -> userService.registerReview(meetingId, currentUserId, reviewRegisterRequest)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("meetingId에 해당하는 meeting을 찾을 수 없습니다. \"" + meetingId + "\""); } From 6fbca928cef26d1cf1251b179c55bbedf5d47856 Mon Sep 17 00:00:00 2001 From: choidongkuen Date: Sun, 28 Jan 2024 07:05:05 +0900 Subject: [PATCH 6/8] =?UTF-8?q?test:=20=EB=A6=AC=EB=B7=B0=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=20=EA=B8=B0=EB=8A=A5=20=ED=86=B5=ED=95=A9=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20(#157)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/net/teumteum/integration/Api.java | 11 ++++ .../net/teumteum/integration/Repository.java | 8 +++ .../teumteum/integration/RequestFixture.java | 15 +++++ .../integration/UserIntegrationTest.java | 56 ++++++++++++++++++- 4 files changed, 88 insertions(+), 2 deletions(-) diff --git a/src/test/java/net/teumteum/integration/Api.java b/src/test/java/net/teumteum/integration/Api.java index d679e895..225b07de 100644 --- a/src/test/java/net/teumteum/integration/Api.java +++ b/src/test/java/net/teumteum/integration/Api.java @@ -4,6 +4,7 @@ import net.teumteum.meeting.config.PageableHandlerMethodArgumentResolver; import net.teumteum.meeting.domain.Topic; import net.teumteum.teum_teum.domain.request.UserLocationRequest; +import net.teumteum.user.domain.request.ReviewRegisterRequest; import net.teumteum.user.domain.request.UserRegisterRequest; import net.teumteum.user.domain.request.UserUpdateRequest; import net.teumteum.user.domain.request.UserWithdrawRequest; @@ -188,4 +189,14 @@ ResponseSpec getUserReviews(String accessToken) { .header(HttpHeaders.AUTHORIZATION, accessToken) .exchange(); } + + ResponseSpec registerUserReview(String accessToken, Long meetingId, ReviewRegisterRequest request) { + String uri = "/users/reviews?meetingId=" + meetingId; + return webTestClient + .post() + .uri(uri) + .header(HttpHeaders.AUTHORIZATION, accessToken) + .bodyValue(request) + .exchange(); + } } diff --git a/src/test/java/net/teumteum/integration/Repository.java b/src/test/java/net/teumteum/integration/Repository.java index 87f43e8c..7d829ee9 100644 --- a/src/test/java/net/teumteum/integration/Repository.java +++ b/src/test/java/net/teumteum/integration/Repository.java @@ -2,6 +2,7 @@ import java.util.List; +import java.util.stream.IntStream; import java.util.stream.Stream; import lombok.RequiredArgsConstructor; import net.teumteum.core.config.AppConfig; @@ -40,6 +41,13 @@ public User saveAndGetUser(Long id) { return userRepository.saveAndFlush(user); } + public List saveAndGetUsers(int size) { + return Stream.generate(UserFixture::getNullIdUser) + .limit(size) + .map(userRepository::saveAndFlush) + .toList(); + } + List getAllUser() { return userRepository.findAll(); } diff --git a/src/test/java/net/teumteum/integration/RequestFixture.java b/src/test/java/net/teumteum/integration/RequestFixture.java index 442560bd..7c6e5dc7 100644 --- a/src/test/java/net/teumteum/integration/RequestFixture.java +++ b/src/test/java/net/teumteum/integration/RequestFixture.java @@ -5,8 +5,10 @@ import static net.teumteum.user.domain.Review.최고에요; import java.util.List; +import java.util.Random; import java.util.UUID; import net.teumteum.core.security.Authenticated; +import net.teumteum.user.domain.Review; import net.teumteum.user.domain.User; import net.teumteum.user.domain.request.ReviewRegisterRequest; import net.teumteum.user.domain.request.ReviewRegisterRequest.UserReviewRegisterRequest; @@ -62,11 +64,24 @@ public static ReviewRegisterRequest reviewRegisterRequest() { return new ReviewRegisterRequest(userReviewRegisterRequests()); } + public static ReviewRegisterRequest reviewRegisterRequest(List users) { + return new ReviewRegisterRequest(userReviewRegisterRequests(users)); + } + private static List userReviewRegisterRequests() { return List.of(new UserReviewRegisterRequest(1L, 별로에요), new UserReviewRegisterRequest(2L, 최고에요), new UserReviewRegisterRequest(3L, 좋아요)); } + private static List userReviewRegisterRequests(List users) { + Review[] reviews = Review.values(); + int length = reviews.length; + + return users.stream() + .map(user -> new UserReviewRegisterRequest(user.getId(), reviews[new Random().nextInt(length)])) + .toList(); + } + private static Job job(User user) { return new Job(user.getJob().getName(), user.getJob().getJobClass(), diff --git a/src/test/java/net/teumteum/integration/UserIntegrationTest.java b/src/test/java/net/teumteum/integration/UserIntegrationTest.java index 67695200..ec37b960 100644 --- a/src/test/java/net/teumteum/integration/UserIntegrationTest.java +++ b/src/test/java/net/teumteum/integration/UserIntegrationTest.java @@ -4,8 +4,10 @@ import java.util.List; import net.teumteum.core.error.ErrorResponse; +import net.teumteum.meeting.domain.Meeting; import net.teumteum.user.domain.User; import net.teumteum.user.domain.UserFixture; +import net.teumteum.user.domain.request.ReviewRegisterRequest; import net.teumteum.user.domain.response.FriendsResponse; import net.teumteum.user.domain.response.UserGetResponse; import net.teumteum.user.domain.response.UserMeGetResponse; @@ -13,6 +15,7 @@ import net.teumteum.user.domain.response.UserReviewsResponse; import net.teumteum.user.domain.response.UsersGetByIdResponse; import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; @@ -351,11 +354,11 @@ void Logout_user() { @Nested @DisplayName("회원 리뷰 조회 API는") - class Get_user_review_api { + class Get_user_reviews_api { @Test @DisplayName("userId 유저의 리뷰 정보를 가져온다.") - void Get_user_review() { + void Get_user_reviews() { // given var existUser = repository.saveAndGetUser(); @@ -373,4 +376,53 @@ void Get_user_review() { .isNotNull(); } } + + @Nested + @DisplayName("회원 리뷰 등록 API는") + class Register_user_review_api { + + User existUser; + + List users; + + ReviewRegisterRequest request; + + Meeting meeting; + + @BeforeEach + void setUp() { + existUser = repository.saveAndGetUser(); + users = repository.saveAndGetUsers(3); + request = RequestFixture.reviewRegisterRequest(users); + meeting = repository.saveAndGetOpenMeetings(1).get(0); + } + + @Test + @DisplayName("회원 리뷰 등록 요청이 들어오면 리뷰를 등록하고, 200 OK 을 반환한다.") + void Return_200_OK_with_success_register_user_review() { + // given + securityContextSetting.set(existUser.getId()); + + // when + var expected = api.registerUserReview(VALID_TOKEN, meeting.getId(), request); + + // then + Assertions.assertThat(expected.expectStatus().isOk()); + } + + @Test + @DisplayName("현재 로그인한 회원의 id 가 리뷰 등록 요청에 포함된다면, 회원 리뷰 등록을 실패하고 400 bad request 을 반환한다.") + void Return_400_bad_request_if_current_user_id_in_request() { + // given + securityContextSetting.set(users.get(0).getId()); + + // when + var expected = api.registerUserReview(VALID_TOKEN, meeting.getId(), request); + + // then + Assertions.assertThat(expected.expectStatus().isBadRequest() + .expectBody(ErrorResponse.class) + .returnResult().getResponseBody()); + } + } } From d5b0f547c469fc8505bb162edb587174d35824a9 Mon Sep 17 00:00:00 2001 From: choidongkuen Date: Sun, 28 Jan 2024 23:46:42 +0900 Subject: [PATCH 7/8] =?UTF-8?q?refactor:=20=ED=9A=8C=EC=9B=90=20=EB=A6=AC?= =?UTF-8?q?=EB=B7=B0=20=EB=93=B1=EB=A1=9D=20=EB=A9=94=EC=86=8C=EB=93=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20(#157)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/net/teumteum/user/domain/User.java | 4 +--- src/test/java/net/teumteum/user/domain/UserFixture.java | 4 +++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/teumteum/user/domain/User.java b/src/main/java/net/teumteum/user/domain/User.java index 35551ebf..c491a028 100644 --- a/src/main/java/net/teumteum/user/domain/User.java +++ b/src/main/java/net/teumteum/user/domain/User.java @@ -123,9 +123,7 @@ public void addFriend(User user) { } public void registerReview(Review review) { - List newReviews = new ArrayList<>(reviews); - newReviews.add(review); - reviews = newReviews; + reviews.add(review); } public void updateMannerTemperature(Review review) { diff --git a/src/test/java/net/teumteum/user/domain/UserFixture.java b/src/test/java/net/teumteum/user/domain/UserFixture.java index 43616597..2b52ff27 100644 --- a/src/test/java/net/teumteum/user/domain/UserFixture.java +++ b/src/test/java/net/teumteum/user/domain/UserFixture.java @@ -5,6 +5,8 @@ import static net.teumteum.user.domain.Review.좋아요; import static net.teumteum.user.domain.Review.최고에요; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Set; import java.util.UUID; @@ -89,7 +91,7 @@ public static class UserBuilder { @Builder.Default private Terms terms = new Terms(true, true); @Builder.Default - private List reviews = List.of(최고에요, 최고에요, 최고에요, 별로에요, 좋아요, 좋아요); + private List reviews = new ArrayList<>(Arrays.asList(최고에요, 최고에요, 최고에요, 별로에요, 좋아요, 좋아요)); } } From c71a3a2a7f66a07ff47d043548d6c39d0e73ee79 Mon Sep 17 00:00:00 2001 From: choidongkuen Date: Mon, 29 Jan 2024 00:00:57 +0900 Subject: [PATCH 8/8] =?UTF-8?q?test:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=A0=9C=EA=B1=B0=20?= =?UTF-8?q?=EB=B0=8F=20CI=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95=20(#15?= =?UTF-8?q?7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../integration/UserIntegrationTest.java | 22 +++---------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/src/test/java/net/teumteum/integration/UserIntegrationTest.java b/src/test/java/net/teumteum/integration/UserIntegrationTest.java index ec37b960..916bb80d 100644 --- a/src/test/java/net/teumteum/integration/UserIntegrationTest.java +++ b/src/test/java/net/teumteum/integration/UserIntegrationTest.java @@ -256,25 +256,6 @@ void Withdraw_user_info_api() { assertThatCode(() -> api.withdrawUser(VALID_TOKEN, request)) .doesNotThrowAnyException(); } - - @Test - @DisplayName("해당 회원이 존재하지 않으면, 500 에러를 반환한다.") - void Return_500_error_if_user_not_exist() { - // given - repository.clearUserRepository(); - - var request = RequestFixture.userWithdrawRequest(List.of("쓰지 않는 앱이에요", "오류가 생겨서 쓸 수 없어요")); - - // when - var result = api.withdrawUser(VALID_TOKEN, request); - - // then - Assertions.assertThat(result.expectStatus().is5xxServerError() - .expectBody(ErrorResponse.class) - .returnResult() - .getResponseBody()) - .usingRecursiveComparison().isNull(); - } } @Nested @@ -344,6 +325,9 @@ class Logout_user_api { void Logout_user() { // given var existUser = repository.saveAndGetUser(); + + securityContextSetting.set(existUser.getId()); + redisRepository.saveRedisDataWithExpiration(String.valueOf(existUser.getId()), VALID_TOKEN, DURATION); // when & then