Skip to content

Commit

Permalink
fix: 안부전화는 시니어만 다르면 동시에 여러개 가능하다
Browse files Browse the repository at this point in the history
  • Loading branch information
zzoe2346 committed Nov 6, 2024
1 parent c0f0f86 commit 44203a2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ public interface HelloCallRepository extends JpaRepository<HelloCall, Long> {

boolean existsBySeniorAndStatusIn(Senior senior, List<HelloCall.Status> statuses);

Optional<HelloCall> findByMemberAndStatus(Member member, HelloCall.Status status);
List<HelloCall> findByMemberAndStatus(Member member, HelloCall.Status status);
}
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,9 @@ public List<HelloCallResponse> readOwnHelloCallBySinitto(Long memberId) {
@Transactional
public void cancelAssignedHelloCallIfInProgress(Member member) {

HelloCall helloCall = helloCallRepository.findByMemberAndStatus(member, HelloCall.Status.IN_PROGRESS)
.orElse(null);
List<HelloCall> helloCalls = helloCallRepository.findByMemberAndStatus(member, HelloCall.Status.IN_PROGRESS);

if (helloCall != null) {
for (HelloCall helloCall : helloCalls) {
helloCall.changeStatusToWaiting();
helloCall.setMember(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -872,14 +872,14 @@ void cancelAssignedHelloCallIfInProgressTest1() {
Member member = mock(Member.class);
HelloCall helloCall = mock(HelloCall.class);

when(helloCallRepository.findByMemberAndStatus(member, HelloCall.Status.IN_PROGRESS)).thenReturn(Optional.of(helloCall));
when(helloCallRepository.findByMemberAndStatus(member, HelloCall.Status.IN_PROGRESS)).thenReturn(List.of(helloCall));

// when
helloCallService.cancelAssignedHelloCallIfInProgress(member);

// then
verify(helloCall, atLeastOnce()).changeStatusToWaiting();
verify(helloCall, atLeastOnce()).setMember(null);
verify(helloCall, times(1)).changeStatusToWaiting();
verify(helloCall, times(1)).setMember(null);
}

@Test
Expand All @@ -889,7 +889,7 @@ void cancelAssignedHelloCallIfInProgressTest2() {
Member member = mock(Member.class);
HelloCall helloCall = mock(HelloCall.class);

when(helloCallRepository.findByMemberAndStatus(member, HelloCall.Status.IN_PROGRESS)).thenReturn(Optional.empty());
when(helloCallRepository.findByMemberAndStatus(member, HelloCall.Status.IN_PROGRESS)).thenReturn(List.of());

// when
helloCallService.cancelAssignedHelloCallIfInProgress(member);
Expand Down

0 comments on commit 44203a2

Please sign in to comment.