From a0f349835309701290bdb0cb9efb6f051b526745 Mon Sep 17 00:00:00 2001 From: kseysh Date: Thu, 31 Oct 2024 16:09:13 +0900 Subject: [PATCH] =?UTF-8?q?[refactor]=20=EC=9C=A0=EC=A0=80=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=B1=85=EC=9E=84=20?= =?UTF-8?q?=EC=9D=B4=EA=B4=80=20(#336)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sopt/app/application/UserServiceTest.java | 10 ---- .../app/application/UserWithdrawTest.java | 50 +++++++++++++++++++ 2 files changed, 50 insertions(+), 10 deletions(-) create mode 100644 src/test/java/org/sopt/app/application/UserWithdrawTest.java diff --git a/src/test/java/org/sopt/app/application/UserServiceTest.java b/src/test/java/org/sopt/app/application/UserServiceTest.java index 61b784a6..ab971d5d 100755 --- a/src/test/java/org/sopt/app/application/UserServiceTest.java +++ b/src/test/java/org/sopt/app/application/UserServiceTest.java @@ -65,16 +65,6 @@ void SUCCESS_upsertRegisteredUser() { Assertions.assertEquals(anyUserId, result); } - @Test - @DisplayName("SUCCESS_유저 삭제") - void SUCCESS_deleteUser() { - //given - User user = new User(); - - //then - Assertions.assertDoesNotThrow(() -> userService.deleteUser(user)); - } - @Test @DisplayName("SUCCESS_플레이그라운드 토큰 조회") void SUCCESS_getPlaygroundToken() { diff --git a/src/test/java/org/sopt/app/application/UserWithdrawTest.java b/src/test/java/org/sopt/app/application/UserWithdrawTest.java new file mode 100644 index 00000000..62454495 --- /dev/null +++ b/src/test/java/org/sopt/app/application/UserWithdrawTest.java @@ -0,0 +1,50 @@ +package org.sopt.app.application; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.verify; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.sopt.app.application.user.UserWithdrawService; +import org.sopt.app.common.event.EventPublisher; +import org.sopt.app.interfaces.postgres.UserRepository; + +@ExtendWith(MockitoExtension.class) +class UserWithdrawTest { + + @Mock + private EventPublisher eventPublisher; + + @Mock + private UserRepository userRepository; + + @InjectMocks + private UserWithdrawService userWithdrawService; + + @Test + void SUCCESS_유저_탈퇴시_유저_삭제() { + //given + final Long userId = 1L; + + // when + userWithdrawService.withdrawUser(userId); + + //then + verify(userRepository).deleteById(userId); + } + + @Test + void SUCCESS_유저_탈퇴시_스탬프_삭제_이벤트_발생() { + //given + final Long userId = 1L; + + // when + userWithdrawService.withdrawUser(userId); + + //then + verify(eventPublisher).raise(any()); + } +}