generated from hmcts/spring-boot-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DMP-2205 - add pending retention to auto closed cases. (#1403)
- Loading branch information
1 parent
62f0fb0
commit d9deadf
Showing
7 changed files
with
116 additions
and
23 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,13 @@ | ||
package uk.gov.hmcts.darts.cases.service; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.security.core.context.SecurityContextHolder; | ||
import org.springframework.security.oauth2.jwt.Jwt; | ||
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationToken; | ||
import uk.gov.hmcts.darts.common.entity.CaseRetentionEntity; | ||
import uk.gov.hmcts.darts.common.entity.CourtCaseEntity; | ||
import uk.gov.hmcts.darts.common.entity.EventEntity; | ||
import uk.gov.hmcts.darts.common.entity.HearingEntity; | ||
|
@@ -14,6 +19,8 @@ | |
import java.time.LocalDateTime; | ||
import java.time.OffsetDateTime; | ||
import java.time.temporal.ChronoUnit; | ||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
|
@@ -25,17 +32,30 @@ class CloseOldCasesProcessorTest extends IntegrationBase { | |
@Autowired | ||
CloseOldCasesProcessor closeOldCasesProcessor; | ||
|
||
private static final String REQUESTER_EMAIL = "[email protected]"; | ||
|
||
@BeforeEach | ||
void beforeEach() { | ||
Jwt jwt = Jwt.withTokenValue("test") | ||
.header("alg", "RS256") | ||
.claim("sub", UUID.randomUUID().toString()) | ||
.claim("emails", List.of(REQUESTER_EMAIL)) | ||
.build(); | ||
SecurityContextHolder.getContext().setAuthentication(new JwtAuthenticationToken(jwt)); | ||
dartsDatabase.createTestUserAccount(); | ||
} | ||
|
||
@Test | ||
void givenClosedEventsUseDateAsClosedDate() { | ||
HearingEntity hearing = dartsDatabase.createHearing("a_courthouse", "1", "1078", LocalDateTime.now().minusYears(7).plusMonths(3)); | ||
|
||
OffsetDateTime closeDate = OffsetDateTime.now().minusYears(7); | ||
|
||
EventEntity eventEntity1 = dartsDatabase.getEventStub().createEvent(hearing, 8); | ||
EventEntity eventEntity1 = dartsDatabase.getEventStub().createEvent(hearing, 8);//Re-examination | ||
eventEntity1.setCreatedDateTime(OffsetDateTime.now().minusYears(7).plusDays(10)); | ||
EventEntity eventEntity2 = dartsDatabase.getEventStub().createEvent(hearing, 214); | ||
EventEntity eventEntity2 = dartsDatabase.getEventStub().createEvent(hearing, 214);//case closed | ||
eventEntity2.setCreatedDateTime(closeDate); | ||
EventEntity eventEntity3 = dartsDatabase.getEventStub().createEvent(hearing, 23); | ||
EventEntity eventEntity3 = dartsDatabase.getEventStub().createEvent(hearing, 23);//Application: No case to answer | ||
eventEntity3.setCreatedDateTime(OffsetDateTime.now().minusYears(7).plusDays(5)); | ||
dartsDatabase.saveAll(eventEntity1, eventEntity2, eventEntity3); | ||
|
||
|
@@ -51,6 +71,9 @@ void givenClosedEventsUseDateAsClosedDate() { | |
assertTrue(updatedCourtCaseEntity.getClosed()); | ||
assertEquals(closeDate.truncatedTo(ChronoUnit.MINUTES), | ||
updatedCourtCaseEntity.getCaseClosedTimestamp().truncatedTo(ChronoUnit.MINUTES)); | ||
CaseRetentionEntity caseRetentionEntity = dartsDatabase.getCaseRetentionRepository().findAll().get(0); | ||
assertEquals(courtCaseEntity.getId(), caseRetentionEntity.getCourtCase().getId()); | ||
assertEquals(closeDate.plusYears(7).truncatedTo(ChronoUnit.DAYS), caseRetentionEntity.getRetainUntil()); | ||
} | ||
|
||
@Test | ||
|
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
src/main/java/uk/gov/hmcts/darts/retention/api/RetentionApi.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,9 +1,17 @@ | ||
package uk.gov.hmcts.darts.retention.api; | ||
|
||
import uk.gov.hmcts.darts.common.entity.CaseRetentionEntity; | ||
import uk.gov.hmcts.darts.common.entity.CourtCaseEntity; | ||
import uk.gov.hmcts.darts.common.entity.RetentionPolicyTypeEntity; | ||
import uk.gov.hmcts.darts.common.entity.UserAccountEntity; | ||
import uk.gov.hmcts.darts.retention.enums.CaseRetentionStatus; | ||
import uk.gov.hmcts.darts.retentions.model.PostRetentionRequest; | ||
|
||
import java.time.LocalDate; | ||
|
||
public interface RetentionApi { | ||
LocalDate applyPolicyStringToDate(LocalDate dateToAppend, String policyString, RetentionPolicyTypeEntity retentionPolicyType); | ||
|
||
CaseRetentionEntity createRetention(PostRetentionRequest postRetentionRequest, CourtCaseEntity courtCase, LocalDate newRetentionDate, | ||
UserAccountEntity userAccount, CaseRetentionStatus caseRetentionStatus); | ||
} |
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
9 changes: 9 additions & 0 deletions
9
src/main/java/uk/gov/hmcts/darts/retention/service/RetentionPostService.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,9 +1,18 @@ | ||
package uk.gov.hmcts.darts.retention.service; | ||
|
||
import uk.gov.hmcts.darts.common.entity.CaseRetentionEntity; | ||
import uk.gov.hmcts.darts.common.entity.CourtCaseEntity; | ||
import uk.gov.hmcts.darts.common.entity.UserAccountEntity; | ||
import uk.gov.hmcts.darts.retention.enums.CaseRetentionStatus; | ||
import uk.gov.hmcts.darts.retentions.model.PostRetentionRequest; | ||
import uk.gov.hmcts.darts.retentions.model.PostRetentionResponse; | ||
|
||
import java.time.LocalDate; | ||
|
||
public interface RetentionPostService { | ||
|
||
PostRetentionResponse postRetention(Boolean validateOnly, PostRetentionRequest postRetentionRequest); | ||
|
||
CaseRetentionEntity createNewCaseRetention(PostRetentionRequest postRetentionRequest, CourtCaseEntity courtCase, | ||
LocalDate newRetentionDate, UserAccountEntity userAccount, CaseRetentionStatus caseRetentionStatus); | ||
} |
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