-
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.
Feat: 시니또 탈퇴시 본인이 할당받은 서비스가 있으면 다시 대기상태로 전환되는 로직 추가, SET_NULL 설정 (#181)
* feat: 콜백 서비스층에 탈퇴시 들어가는 로직 구현 * feat: 안부전화 서비스층에 탈퇴시 들어가는 로직 구현 * feat: 멤버 탈퇴 로직에 콜백, 안부전화 진행중인거 확인하고 진행중인거 있으면 대기상태로 전환하는 로직 추가 * fix: 안부전화는 시니어만 다르면 동시에 여러개 가능하다 * fix: CallbackRepository 잘못된 메서드 제거 후 의존하는 코드 수정 * feat: HelloCall 엔티티에 `@OnDelete(action = OnDeleteAction.SET_NULL)` * feat: 개별 트랜잭션으로 분리 * feat: HelloCallTimeLog의 멤버속성에 ` @onDelete(action = OnDeleteAction.SET_NULL) ` 추가, 시니또이름 분기 추가 * fix: 개별 트랜잭션 적용. 기존에는 개별이 아니라 하나의 트랜잭션에 포함되어 있었다.
- Loading branch information
Showing
9 changed files
with
184 additions
and
7 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
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
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
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
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
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
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
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
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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
package com.example.sinitto.member.service; | ||
|
||
import com.example.sinitto.auth.service.TokenService; | ||
import com.example.sinitto.callback.service.CallbackService; | ||
import com.example.sinitto.common.exception.ConflictException; | ||
import com.example.sinitto.common.exception.NotFoundException; | ||
import com.example.sinitto.helloCall.service.HelloCallService; | ||
import com.example.sinitto.member.dto.RegisterResponse; | ||
import com.example.sinitto.member.entity.Member; | ||
import com.example.sinitto.member.repository.MemberRepository; | ||
|
@@ -34,11 +36,16 @@ public class MemberServiceTest { | |
@Mock | ||
RedisTemplate<String, Object> redisTemplate; | ||
@Mock | ||
private HashOperations<String, Object, Object> hashOperations; | ||
HashOperations<String, Object, Object> hashOperations; | ||
@InjectMocks | ||
MemberService memberService; | ||
@Mock | ||
private ValueOperations<String, String> valueOperations; | ||
ValueOperations<String, String> valueOperations; | ||
@Mock | ||
CallbackService callbackService; | ||
@Mock | ||
HelloCallService helloCallService; | ||
|
||
|
||
@Test | ||
@DisplayName("getMemberIdByToken 메소드 테스트") | ||
|
@@ -143,7 +150,52 @@ void memberLogoutTestWhenMemberIsNull() { | |
|
||
@Test | ||
@DisplayName("deleteMember 메소드 테스트") | ||
void deleteMemberTest(){ | ||
void deleteMemberTest() { | ||
//given | ||
Long memberId = 1L; | ||
String email = "[email protected]"; | ||
Member member = mock(Member.class); | ||
String storedRefreshToken = "testRefreshToken"; | ||
|
||
when(memberRepository.findById(memberId)).thenReturn(Optional.of(member)); | ||
when(member.getEmail()).thenReturn(email); | ||
when(redisTemplate.opsForHash()).thenReturn(hashOperations); | ||
when(redisTemplate.opsForHash().get(member.getEmail(), "refreshToken")).thenReturn(storedRefreshToken); | ||
|
||
//when | ||
memberService.deleteMember(memberId); | ||
|
||
//when | ||
verify(memberRepository, times(1)).deleteById(memberId); | ||
} | ||
|
||
@Test | ||
@DisplayName("deleteMember 메소드 테스트 - 탈퇴 신청한게 시니또인 경우") | ||
void deleteMemberTest2() { | ||
//given | ||
Long memberId = 1L; | ||
String email = "[email protected]"; | ||
Member member = mock(Member.class); | ||
String storedRefreshToken = "testRefreshToken"; | ||
|
||
when(memberRepository.findById(memberId)).thenReturn(Optional.of(member)); | ||
when(member.getEmail()).thenReturn(email); | ||
when(redisTemplate.opsForHash()).thenReturn(hashOperations); | ||
when(redisTemplate.opsForHash().get(member.getEmail(), "refreshToken")).thenReturn(storedRefreshToken); | ||
|
||
when(member.isSinitto()).thenReturn(true); | ||
//when | ||
memberService.deleteMember(memberId); | ||
|
||
//when | ||
verify(memberRepository, times(1)).deleteById(memberId); | ||
verify(callbackService, times(1)).cancelAssignedCallbackIfInProgress(any(Member.class)); | ||
verify(helloCallService, times(1)).cancelAssignedHelloCallIfInProgress(any(Member.class)); | ||
} | ||
|
||
@Test | ||
@DisplayName("deleteMember 메소드 테스트 - 탈퇴 신청한게 보호자인 경우") | ||
void deleteMemberTest3() { | ||
//given | ||
Long memberId = 1L; | ||
String email = "[email protected]"; | ||
|
@@ -155,10 +207,13 @@ void deleteMemberTest(){ | |
when(redisTemplate.opsForHash()).thenReturn(hashOperations); | ||
when(redisTemplate.opsForHash().get(member.getEmail(), "refreshToken")).thenReturn(storedRefreshToken); | ||
|
||
when(member.isSinitto()).thenReturn(false); | ||
//when | ||
memberService.deleteMember(memberId); | ||
|
||
//when | ||
verify(memberRepository, times(1)).deleteById(memberId); | ||
verify(callbackService, times(0)).cancelAssignedCallbackIfInProgress(any(Member.class)); | ||
verify(helloCallService, times(0)).cancelAssignedHelloCallIfInProgress(any(Member.class)); | ||
} | ||
} |