-
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: 콜백 서비스 정책 적용 그리고 이용 내역 조회 기능 (#64)
- Loading branch information
Showing
13 changed files
with
336 additions
and
33 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
11 changes: 11 additions & 0 deletions
11
src/main/java/com/example/sinitto/callback/dto/CallbackUsageHistoryResponse.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,11 @@ | ||
package com.example.sinitto.callback.dto; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
public record CallbackUsageHistoryResponse( | ||
Long callbackId, | ||
String seniorName, | ||
LocalDateTime postTime, | ||
String status | ||
) { | ||
} |
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
8 changes: 8 additions & 0 deletions
8
...ain/java/com/example/sinitto/callback/exception/MemberHasInProgressCallbackException.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,8 @@ | ||
package com.example.sinitto.callback.exception; | ||
|
||
public class MemberHasInProgressCallbackException extends ConflictException { | ||
|
||
public MemberHasInProgressCallbackException(String message) { | ||
super(message); | ||
} | ||
} |
11 changes: 10 additions & 1 deletion
11
src/main/java/com/example/sinitto/callback/repository/CallbackRepository.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 |
---|---|---|
@@ -1,15 +1,24 @@ | ||
package com.example.sinitto.callback.repository; | ||
|
||
import com.example.sinitto.callback.entity.Callback; | ||
import com.example.sinitto.member.entity.Senior; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
import java.time.LocalDateTime; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
public interface CallbackRepository extends JpaRepository<Callback, Long> { | ||
|
||
Page<Callback> findAll(Pageable pageable); | ||
Page<Callback> findAllByStatus(Callback.Status status, Pageable pageable); | ||
|
||
Optional<Callback> findByAssignedMemberIdAndStatus(Long memberId, Callback.Status status); | ||
|
||
boolean existsByAssignedMemberIdAndStatus(Long memberId, Callback.Status status); | ||
|
||
Page<Callback> findAllBySeniorIn(List<Senior> seniors, Pageable pageable); | ||
|
||
List<Callback> findAllByStatusAndPendingCompleteTimeBefore(Callback.Status status, LocalDateTime dateTime); | ||
} |
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 |
---|---|---|
|
@@ -14,6 +14,12 @@ | |
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.data.domain.PageRequest; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.data.domain.Sort; | ||
|
||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
|
@@ -27,14 +33,14 @@ class CallbackTest { | |
@Autowired | ||
private SeniorRepository seniorRepository; | ||
private Callback testCallback; | ||
private Member testMember; | ||
private Senior testSenior; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
Member testMember = new Member("member", "01043214321", "[email protected]", true); | ||
memberRepository.save(testMember); | ||
testMember = memberRepository.save(new Member("member", "01043214321", "[email protected]", true)); | ||
|
||
Senior testSenior = new Senior("senior", "01012341234", testMember); | ||
seniorRepository.save(testSenior); | ||
testSenior = seniorRepository.save(new Senior("senior", "01012341234", testMember)); | ||
|
||
testCallback = callbackRepository.save(new Callback(Callback.Status.WAITING, testSenior)); | ||
} | ||
|
@@ -264,4 +270,23 @@ void changeStatusToComplete_fail2() { | |
assertThrows(AlreadyInProgressException.class, () -> testCallback.changeStatusToComplete()); | ||
} | ||
|
||
@Test | ||
@DisplayName("보호자에 연관된 다수의 시니어 리스트를 얻은후, 다수의 시니어들이 신청한 콜백 요청 기록 조회 테스트(CallbackService 의 getCallbackHistoryOfGuard() 테스트나 마찬가지)") | ||
void getSeniorListAndReadCallbackHistoryOfSeniors() { | ||
//given | ||
Senior testSenior2 = new Senior("senior2", "01099999999", testMember); | ||
seniorRepository.save(testSenior2); | ||
|
||
callbackRepository.save(new Callback(Callback.Status.WAITING, testSenior2)); | ||
callbackRepository.save(new Callback(Callback.Status.COMPLETE, testSenior2)); | ||
Pageable pageable = PageRequest.of(0, 1, Sort.by(Sort.Direction.DESC, "postTime")); | ||
//when | ||
Page<Callback> result = callbackRepository.findAllBySeniorIn(List.of(testSenior, testSenior2), pageable); | ||
|
||
//then | ||
assertEquals(3, result.getTotalPages()); | ||
assertEquals(testSenior2, result.getContent().getFirst().getSenior()); | ||
assertEquals(Callback.Status.COMPLETE.toString(), result.getContent().getFirst().getStatus()); | ||
} | ||
|
||
} |
Oops, something went wrong.