-
Notifications
You must be signed in to change notification settings - Fork 6
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
292c373
commit 043d5a9
Showing
3 changed files
with
64 additions
and
2 deletions.
There are no files selected for viewing
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
57 changes: 57 additions & 0 deletions
57
backend/src/test/java/mouda/backend/auth/business/KakaoAuthServiceTest.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,57 @@ | ||
package mouda.backend.auth.business; | ||
|
||
import static org.assertj.core.api.Assertions.*; | ||
import static org.mockito.Mockito.*; | ||
|
||
import java.util.Optional; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
|
||
import mouda.backend.auth.implement.KakaoUserInfoProvider; | ||
import mouda.backend.auth.presentation.request.KakaoConvertRequest; | ||
import mouda.backend.common.fixture.MemberFixture; | ||
import mouda.backend.member.domain.Member; | ||
import mouda.backend.member.domain.OauthType; | ||
import mouda.backend.member.infrastructure.MemberRepository; | ||
|
||
@SpringBootTest | ||
class KakaoAuthServiceTest { | ||
|
||
@Autowired | ||
private KakaoAuthService kakaoAuthService; | ||
|
||
@Autowired | ||
private MemberRepository memberRepository; | ||
|
||
@MockBean | ||
private KakaoUserInfoProvider userInfoProvider; | ||
|
||
@DisplayName("카카오 회원 정보를 애플 회원으로 변경한다.") | ||
@Test | ||
void convert() { | ||
// given | ||
String kakaoIdentifier = "kakaoIdentifier"; | ||
Member anna = MemberFixture.getAnna(kakaoIdentifier); | ||
memberRepository.save(anna); | ||
|
||
String appleIdentifier = "appleIdentifier"; | ||
Member alternation = MemberFixture.getAnna(OauthType.APPLE, appleIdentifier); | ||
memberRepository.save(alternation); | ||
when(userInfoProvider.getIdentifier(anyString())).thenReturn(kakaoIdentifier); | ||
|
||
// when | ||
kakaoAuthService.convert(alternation, new KakaoConvertRequest("code")); | ||
|
||
// then | ||
Optional<Member> kakaoMember = memberRepository.findByLoginDetail_Identifier(kakaoIdentifier); | ||
assertThat(kakaoMember.isEmpty()).isTrue(); | ||
Optional<Member> appleMember = memberRepository.findByLoginDetail_Identifier(appleIdentifier); | ||
assertThat(appleMember.isPresent()).isTrue(); | ||
assertThat(appleMember.get().getName()).isEqualTo(anna.getName()); | ||
assertThat(appleMember.get().getLoginDetail()).isEqualTo(alternation.getLoginDetail()); | ||
} | ||
} |
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