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-2623: Case Document Generation (#1622)
- Loading branch information
1 parent
0e22c6a
commit 0031d72
Showing
63 changed files
with
2,161 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Copy the below annotations from the instance variables to the constructor | ||
# see https://github.com/rzwitserloot/lombok/issues/745 | ||
lombok.copyableAnnotations += org.springframework.beans.factory.annotation.Qualifier | ||
lombok.copyableAnnotations += org.springframework.beans.factory.annotation.Value |
442 changes: 442 additions & 0 deletions
442
...tionTest/java/uk/gov/hmcts/darts/casedocument/service/CourtCaseDocumentMapperIntTest.java
Large diffs are not rendered by default.
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
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
94 changes: 94 additions & 0 deletions
94
...rationTest/java/uk/gov/hmcts/darts/task/service/GenerateCaseDocumentProcessorIntTest.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,94 @@ | ||
package uk.gov.hmcts.darts.task.service; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.mock.mockito.SpyBean; | ||
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.casedocument.service.GenerateCaseDocumentSingleCaseProcessor; | ||
import uk.gov.hmcts.darts.common.entity.CaseDocumentEntity; | ||
import uk.gov.hmcts.darts.common.entity.CourtCaseEntity; | ||
import uk.gov.hmcts.darts.common.entity.ExternalObjectDirectoryEntity; | ||
import uk.gov.hmcts.darts.common.entity.MediaEntity; | ||
import uk.gov.hmcts.darts.common.entity.UserAccountEntity; | ||
import uk.gov.hmcts.darts.common.repository.AnnotationRepository; | ||
import uk.gov.hmcts.darts.common.repository.CaseDocumentRepository; | ||
import uk.gov.hmcts.darts.common.repository.CaseRepository; | ||
import uk.gov.hmcts.darts.common.repository.ExternalObjectDirectoryRepository; | ||
import uk.gov.hmcts.darts.common.repository.HearingRepository; | ||
import uk.gov.hmcts.darts.common.repository.UserAccountRepository; | ||
import uk.gov.hmcts.darts.testutils.IntegrationBase; | ||
|
||
import java.time.OffsetDateTime; | ||
import java.util.List; | ||
|
||
import static java.time.ZoneOffset.UTC; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static uk.gov.hmcts.darts.common.enums.ExternalLocationTypeEnum.ARM; | ||
import static uk.gov.hmcts.darts.common.enums.ObjectRecordStatusEnum.ARM_DROP_ZONE; | ||
|
||
class GenerateCaseDocumentProcessorIntTest extends IntegrationBase { | ||
|
||
private static final OffsetDateTime DT_2025 = OffsetDateTime.of(2025, 1, 1, 1, 0, 0, 0, UTC); | ||
|
||
@SpyBean | ||
CaseRepository caseRepository; | ||
@SpyBean | ||
CaseDocumentRepository caseDocumentRepository; | ||
@SpyBean | ||
ExternalObjectDirectoryRepository eodRepository; | ||
@Autowired | ||
UserAccountRepository userAccountRepository; | ||
@Autowired | ||
AnnotationRepository annotationRepository; | ||
@Autowired | ||
GenerateCaseDocumentSingleCaseProcessor processor; | ||
@Autowired | ||
HearingRepository hearingRepository; | ||
|
||
@Test | ||
void testGenerateCaseDocument() { | ||
// given | ||
givenBearerTokenExists("[email protected]"); | ||
UserAccountEntity testUser = dartsDatabase.getUserAccountStub().getIntegrationTestUserAccountEntity(); | ||
|
||
CourtCaseEntity courtCase = dartsDatabase.getCourtCaseStub().createAndSaveCourtCaseWithHearings(createdCourtCase -> { | ||
createdCourtCase.setRetentionUpdated(true); | ||
createdCourtCase.setRetentionRetries(1); | ||
createdCourtCase.setClosed(true); | ||
}); | ||
|
||
List<MediaEntity> medias = dartsDatabase.getMediaStub().createAndSaveSomeMedias(); | ||
var hearing = courtCase.getHearings().get(0); | ||
hearing.addMedia(medias.get(0)); | ||
|
||
hearingRepository.save(hearing); | ||
dartsDatabase.getCaseRetentionStub().createCaseRetentionObject(courtCase, DT_2025); | ||
|
||
dartsDatabase.getExternalObjectDirectoryStub().createAndSaveEod(medias.get(0), ARM_DROP_ZONE, ARM, eod -> { }); | ||
|
||
var annotation = dartsDatabase.getAnnotationStub().createAndSaveAnnotationEntityWith(testUser, "TestAnnotation", hearing); | ||
annotationRepository.save(annotation); | ||
|
||
// when | ||
processor.processGenerateCaseDocument(courtCase.getId()); | ||
|
||
// then | ||
List<CaseDocumentEntity> caseDocumentEntities = caseDocumentRepository.findByCourtCase(courtCase); | ||
assertThat(caseDocumentEntities.size()).isEqualTo(1); | ||
CaseDocumentEntity caseDocument = caseDocumentEntities.get(0); | ||
assertThat(caseDocument.getCourtCase().getId()).isEqualTo(courtCase.getId()); | ||
|
||
List<ExternalObjectDirectoryEntity> eodCaseDocument = eodRepository.findByCaseDocument(caseDocument); | ||
assertThat(eodCaseDocument.size()).isEqualTo(1); | ||
} | ||
|
||
private static void givenBearerTokenExists(String email) { | ||
Jwt jwt = Jwt.withTokenValue("test") | ||
.header("alg", "RS256") | ||
.claim("emails", List.of(email)) | ||
.build(); | ||
SecurityContextHolder.getContext().setAuthentication(new JwtAuthenticationToken(jwt)); | ||
} | ||
} |
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
Oops, something went wrong.