-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b8ede4
commit 4664734
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
src/test/java/blacktokkies/toquiz/member/application/MemberServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package blacktokkies.toquiz.member.application; | ||
|
||
import blacktokkies.toquiz.domain.member.application.MemberService; | ||
import blacktokkies.toquiz.domain.member.dao.MemberRepository; | ||
import blacktokkies.toquiz.domain.member.domain.Member; | ||
import blacktokkies.toquiz.domain.member.dto.request.UpdateMyInfoRequest; | ||
import blacktokkies.toquiz.domain.member.dto.response.MemberInfoResponse; | ||
import blacktokkies.toquiz.domain.model.Provider; | ||
import org.junit.jupiter.api.DisplayName; | ||
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 static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.Mockito.*; | ||
|
||
@ExtendWith({MockitoExtension.class}) | ||
public class MemberServiceTest { | ||
@InjectMocks | ||
private MemberService memberService; | ||
|
||
@Mock | ||
private MemberRepository memberRepository; | ||
|
||
@Test | ||
@DisplayName("자신의 사용자 정보 가져오기") | ||
void getMyInfo(){} | ||
|
||
@Test | ||
@DisplayName("자신의 사용자 정보 수정하기") | ||
void updateMyInfo(){ | ||
// given | ||
final String updatePassword = "update@311"; | ||
final String updateNickname = "update"; | ||
final UpdateMyInfoRequest updateMyInfoRequest = UpdateMyInfoRequest.builder() | ||
.password(updatePassword) | ||
.nickname(updateNickname) | ||
.build(); | ||
final Member member = Member.builder() | ||
.email("[email protected]") | ||
.password("test@311") | ||
.provider(Provider.LOCAL) | ||
.nickname("TEST") | ||
.activeInfoId("a1c2t3i4v5e6I7n8f9oId") | ||
.build(); | ||
|
||
doReturn(false).when(memberRepository).existsByNickname(any(String.class)); | ||
doReturn(member).when(memberRepository).save(any(Member.class)); | ||
|
||
// when | ||
MemberInfoResponse result = memberService.updateMyInfo(member, updateMyInfoRequest); | ||
|
||
// then | ||
assertThat(result.getEmail()).isEqualTo(member.getEmail()); | ||
assertThat(result.getNickname()).isEqualTo(updateNickname); | ||
|
||
verify(memberRepository, times(1)).existsByNickname(any(String.class)); | ||
verify(memberRepository, times(1)).save(any(Member.class)); | ||
} | ||
} |