From 7d59e92bb8eb394b839eb936fadcf2edac41b0b2 Mon Sep 17 00:00:00 2001 From: wellbeing-dough Date: Thu, 7 Dec 2023 01:08:16 +0900 Subject: [PATCH] =?UTF-8?q?[Test]=20:=20UserEntityFixture=20pk=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/repository/UserRepositoryTest.java | 12 ++++++------ .../user/service/StudyPostServiceTest.java | 5 +---- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/test/java/kr/co/studyhubinu/studyhubserver/user/repository/UserRepositoryTest.java b/src/test/java/kr/co/studyhubinu/studyhubserver/user/repository/UserRepositoryTest.java index 0ac7beda..049da945 100644 --- a/src/test/java/kr/co/studyhubinu/studyhubserver/user/repository/UserRepositoryTest.java +++ b/src/test/java/kr/co/studyhubinu/studyhubserver/user/repository/UserRepositoryTest.java @@ -22,7 +22,7 @@ class UserRepositoryTest { @Test void 유저가_회원가입한다() { // given - UserEntity user = UserEntityFixture.YEONGJAE.UserEntity_생성(1L); + UserEntity user = UserEntityFixture.YEONGJAE.UserEntity_생성(); // when UserEntity saveUser = userRepository.save(user); @@ -36,11 +36,11 @@ class UserRepositoryTest { @Test void 식별자값으로_유저를_조회한다() { // given - UserEntity user = UserEntityFixture.YEONGJAE.UserEntity_생성(1L); + UserEntity user = UserEntityFixture.YEONGJAE.UserEntity_생성(); userRepository.save(user); // when - UserEntity findUserById = userRepository.findById(1L).orElseThrow(UserNotFoundException::new); + UserEntity findUserById = userRepository.findById(user.getId()).orElseThrow(UserNotFoundException::new); // then assertAll( @@ -51,7 +51,7 @@ class UserRepositoryTest { @Test void 이메일로_유저를_조회한다() { // given - UserEntity user = UserEntityFixture.YEONGJAE.UserEntity_생성(1L); + UserEntity user = UserEntityFixture.YEONGJAE.UserEntity_생성(); userRepository.save(user); // when @@ -66,7 +66,7 @@ class UserRepositoryTest { @Test void 닉네임으로_유저를_조회한다() { // given - UserEntity user = UserEntityFixture.YEONGJAE.UserEntity_생성(1L); + UserEntity user = UserEntityFixture.YEONGJAE.UserEntity_생성(); userRepository.save(user); // when @@ -81,7 +81,7 @@ class UserRepositoryTest { @Test void 이메일로_유저_존재여부를_확인한다() { // given - UserEntity user = UserEntityFixture.YEONGJAE.UserEntity_생성(1L); + UserEntity user = UserEntityFixture.YEONGJAE.UserEntity_생성(); userRepository.save(user); // when diff --git a/src/test/java/kr/co/studyhubinu/studyhubserver/user/service/StudyPostServiceTest.java b/src/test/java/kr/co/studyhubinu/studyhubserver/user/service/StudyPostServiceTest.java index 642984cd..cc3e43e5 100644 --- a/src/test/java/kr/co/studyhubinu/studyhubserver/user/service/StudyPostServiceTest.java +++ b/src/test/java/kr/co/studyhubinu/studyhubserver/user/service/StudyPostServiceTest.java @@ -66,15 +66,12 @@ void createPost_success() { ArgumentCaptor captor = ArgumentCaptor.forClass(StudyPostEntity.class); // when - Long createdPostId = studyPostService.createPost(info); + studyPostService.createPost(info); // then verify(studyPostRepository, times(1)) .save(captor.capture()); StudyPostEntity capturedStudyPost = captor.getValue(); assertEquals("정보처리기사", capturedStudyPost.getTitle()); - - assertNotNull(createdPostId); - } }