Skip to content

Commit

Permalink
DTSPB-4260 upload document to remove document type (#1042)
Browse files Browse the repository at this point in the history
* DTSPB-4260 upload document to remove document type

* DTSPB-4260 upload document to remove unused import

* DTSPB-4260 fix test case issue

* DTSPB-4261 Document upload notification (#1045)

* DTSPB-4261 Document upload notification

* DTSPB-4261 Fix sonar issue

* DTSPB-4261 Fix sonar issue

---------

Co-authored-by: Feli Tam <[email protected]>

* DTSPB-4261 Removed response code

* DTSPB-4261 Changed the return response type

* DTSPB-4261 Changed the Document field and commons version

* DTSPB-4261 Mapping fields in PA mapper

* DTSPB-4261 Mapping fields in PA mapper

* DTSPB-4261 Changed Date format

* DTSPB-4261 PR Pointing

* Bumping chart version/ fixing aliases

* DTSPB-4260 add DocumentType.CITIZEN_HUB_UPLOAD to DocumentMapper

* DTSPB-4260 fixed style issue with import

* DTSPB-4261 Changed the fields to be inside the object

* DTSPB-4261 Change name of the object

* DTSPB-4261 Fix IT

* add debug log

* DTSPB-4260 adding citizenResponseCheckbox for uploadNotification

* DTSPB-4261 Changed PR no.

* DTSPB-4260 return String for uploadNotification

* DTSPB-4260 fix style issue

* DTSPB-4261 Fix Sonar issue

* DTSPB-4260 change uploadNotification prodices

* DTSPB-4260 fix unused import

* DTSPB-4260 update uploadNotification to return void

* DTSPB-4260 use citizen endpoint

* DTSPB-4260 add informationNeeded and informationNeededByPost

* DTSPB-4261 Changed commons version and changed response date name

* DTSPB-4260 only update ccd when citizenResponseCheckbox is true

* DTSPB-4260 add provideinformation.isSaveAndClose and citizenDocumentsUploaded

* DTSPB-4261 Fix tests

* DTSPB-4260 add isSaveAndClose

* DTSPB-4261 Fix Name of citizenDocuments

* DTSPB-4261 Added log

* DTSPB-4261 Added log

* DTSPB-4260 add condition for send email

* DTSPB-4260 fix style issue

* DTSPB-4260 fix welsh email for Notification

* DTSPB-4260 revert chart, update logging and commons version

* DTSPB-4261 Removed unnecessary log

---------

Co-authored-by: Iswarya Pepakayala <[email protected]>
Co-authored-by: Feli Tam <[email protected]>
Co-authored-by: hmcts-jenkins-j-to-z <61242337+hmcts-jenkins-j-to-z[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Nov 28, 2024
1 parent dda5902 commit 007f737
Show file tree
Hide file tree
Showing 17 changed files with 291 additions and 15 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def versions = [
mapStruct : '1.3.0.Final',
pact_version : '4.1.34',
piTest : '1.17.1',
probateCommonsVersion : '2.0.27',
probateCommonsVersion : '2.0.31',
restAssured : '5.5.0',
serenity : '4.2.9',
serviceAuthProviderClient : '5.2.0',
Expand Down Expand Up @@ -229,7 +229,7 @@ dependencies {
implementation group: 'io.github.openfeign', name: 'feign-jackson', version: versions.feign
implementation group: 'org.apache.httpcomponents.client5', name: 'httpclient5', version: '5.3.1'
implementation group: 'com.github.ben-manes.caffeine', name: 'caffeine', version: '3.1.8'

implementation group: 'com.github.hmcts.java-logging', name: 'logging', version: versions.hmctsJavaLogging
implementation group: 'com.github.hmcts.java-logging', name: 'logging-appinsights', version: versions.hmctsJavaLogging
implementation group: 'com.github.hmcts', name: 'auth-checker-lib', version: versions.authCheckerLib
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public class DocumentsControllerIT {
DocumentsController.DOCUMENTS_BASEURL + DocumentsController.BULK_SCAN_COVERSHEET_ENDPOINT;
private static final String DOCUMENT_UPLOAD_ENDPOINT =
DocumentsController.DOCUMENTS_BASEURL + DocumentsController.DOCUMENT_UPLOAD_ENDPOINT;

private static final String DOCUMENT_UPLOAD_NOTIFICATION_ENDPOINT =
DocumentsController.DOCUMENTS_BASEURL + DocumentsController.DOCUMENT_UPLOAD_NOTIFICATION_ENDPOINT;
private static final String DOCUMENT_DELETE_ENDPOINT =
DocumentsController.DOCUMENTS_BASEURL + DocumentsController.DOCUMENT_DELETE_ENDPOINT;

Expand All @@ -59,6 +62,7 @@ public class DocumentsControllerIT {

@Autowired
private WebApplicationContext webApplicationContext;
private String documentNotificationStr;

@BeforeEach
public void setup() {
Expand Down Expand Up @@ -160,4 +164,17 @@ public void shouldUpload() throws Exception {
ArgumentMatchers.eq(Lists.newArrayList(file)));
}

@Test
public void shouldReturn200ForDocumentUpload() throws Exception {

documentNotificationStr = TestUtils.getJsonFromFile("businessDocuments/documentNotification.json");

mockMvc.perform(post(DOCUMENT_UPLOAD_NOTIFICATION_ENDPOINT + "/12345/true")
.header("Session-Id", "someSessionId")
.content(documentNotificationStr)
.contentType(MediaType.valueOf(MediaType.APPLICATION_JSON_VALUE)))
.andExpect(status().isOk());
verify(businessService, times(1)).documentUploadNotification(eq("12345"), eq("true"));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class InvitationControllerIT {
private ObjectMapper objectMapper;

private String invitationStr;
private String documentNotificationStr;
private Invitation invitation;
private Invitation invitation2;
private List<Invitation> invitationsResult;
Expand All @@ -61,6 +62,7 @@ public void setUp() throws Exception {
mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();

invitationStr = TestUtils.getJsonFromFile("invite/invitation.json");
documentNotificationStr = TestUtils.getJsonFromFile("businessDocuments/documentNotification.json");
this.invitation = objectMapper.readValue(invitationStr, Invitation.class);
this.invitation2 = objectMapper.readValue(invitationStr, Invitation.class);
invitationArrayStr = new StringBuilder("[").append(invitationStr).append("]").toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
import uk.gov.hmcts.reform.probate.model.forms.Equality;
import uk.gov.hmcts.reform.probate.model.forms.InheritanceTax;
import uk.gov.hmcts.reform.probate.model.forms.Language;
import uk.gov.hmcts.reform.probate.model.forms.ProvideInformation;
import uk.gov.hmcts.reform.probate.model.forms.Registry;
import uk.gov.hmcts.reform.probate.model.forms.ReviewResponse;
import uk.gov.hmcts.reform.probate.model.forms.intestacy.IntestacyApplicant;
import uk.gov.hmcts.reform.probate.model.forms.intestacy.IntestacyDeceased;
import uk.gov.hmcts.reform.probate.model.forms.intestacy.IntestacyForm;
Expand Down Expand Up @@ -75,7 +77,7 @@ public void shouldMapNullGrantOfRepresentationToGrantOfIntestacyForm() {
@Test
public void shouldMapEmptyIntestacyFormToGrantOfRepresentation() {
GrantOfRepresentationData expectedGrantOfRepresentation = new GrantOfRepresentationData();
expectedGrantOfRepresentation.setBoDocumentsUploaded(new ArrayList<>());
expectedGrantOfRepresentation.setCitizenDocumentsUploaded(new ArrayList<>());
expectedGrantOfRepresentation.setApplicationSubmittedDate(LocalDate.now());
expectedGrantOfRepresentation.setApplicationType(ApplicationType.PERSONAL);
expectedGrantOfRepresentation.setGrantType(GrantType.INTESTACY);
Expand Down Expand Up @@ -108,6 +110,8 @@ public void shouldMapEmptyGrantOfRepresentationToGrantOfIntestacyForm() {
expectedIntestacyForm.setDeclaration(new Declaration());
expectedIntestacyForm.setLanguage(new Language());
expectedIntestacyForm.setEquality(new Equality());
expectedIntestacyForm.setProvideinformation(new ProvideInformation());
expectedIntestacyForm.setReviewresponse(new ReviewResponse());
IntestacyForm actualIntestacyForm = mapper.fromCaseData(new GrantOfRepresentationData());
assertThat(actualIntestacyForm).isEqualToComparingFieldByFieldRecursively(expectedIntestacyForm);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
import uk.gov.hmcts.reform.probate.model.forms.InheritanceTax;
import uk.gov.hmcts.reform.probate.model.forms.Language;
import uk.gov.hmcts.reform.probate.model.forms.LegalStatement;
import uk.gov.hmcts.reform.probate.model.forms.ProvideInformation;
import uk.gov.hmcts.reform.probate.model.forms.Registry;
import uk.gov.hmcts.reform.probate.model.forms.ReviewResponse;
import uk.gov.hmcts.reform.probate.model.forms.Will;
import uk.gov.hmcts.reform.probate.model.forms.pa.Executors;
import uk.gov.hmcts.reform.probate.model.forms.pa.PaApplicant;
Expand Down Expand Up @@ -111,7 +113,7 @@ public void shouldMapEmptyPaFormToGrantOfRepresentation() {
expectedGrantOfRepresentation.setGrantType(GrantType.GRANT_OF_PROBATE);
expectedGrantOfRepresentation.setApplicationSubmittedDate(LocalDate.now());
expectedGrantOfRepresentation.setNumberOfApplicants(0L);
expectedGrantOfRepresentation.setBoDocumentsUploaded(Lists.newArrayList());
expectedGrantOfRepresentation.setCitizenDocumentsUploaded(Lists.newArrayList());
expectedGrantOfRepresentation.setPrimaryApplicantIsApplying(true);
GrantOfRepresentationData actualGrantOfRepresentation = mapper.toCaseData(new PaForm());
assertThat(actualGrantOfRepresentation)
Expand Down Expand Up @@ -140,6 +142,8 @@ public void shouldMapEmptyGrantOfRepresentationToGrantOfPaForm() {
declaration.setLegalStatement(LegalStatement.builder().build());
expectedPaForm.setDeclaration(declaration);
expectedPaForm.setEquality(new Equality());
expectedPaForm.setProvideinformation(new ProvideInformation());
expectedPaForm.setReviewresponse(new ReviewResponse());
PaForm actualPaForm = mapper.fromCaseData(new GrantOfRepresentationData());
assertThat(actualPaForm).isEqualToComparingFieldByFieldRecursively(expectedPaForm);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
import uk.gov.hmcts.reform.probate.model.forms.Language;
import uk.gov.hmcts.reform.probate.model.forms.LegalStatementHolder;
import uk.gov.hmcts.reform.probate.model.forms.Payment;
import uk.gov.hmcts.reform.probate.model.forms.ProvideInformation;
import uk.gov.hmcts.reform.probate.model.forms.Registry;
import uk.gov.hmcts.reform.probate.model.forms.ReviewResponse;
import uk.gov.hmcts.reform.probate.model.forms.Will;
import uk.gov.hmcts.reform.probate.model.forms.pa.Executor;
import uk.gov.hmcts.reform.probate.model.forms.pa.Executors;
Expand All @@ -56,6 +58,9 @@
import java.util.List;
import java.util.Map;

import static java.lang.Boolean.FALSE;
import static java.lang.Boolean.TRUE;

public final class PaMultipleExecutorTestDataCreator {

public static final String REGISTRY_ADDRESS = "old trafford";
Expand Down Expand Up @@ -202,6 +207,8 @@ public final class PaMultipleExecutorTestDataCreator {

private static String APPLICANT_ADDRESSES = "[{\"formatted_address\":\"102 Petty France London SW1H 9EX\"}]";

private static final String CITIZEN_RESPONSE = "response";

private PaMultipleExecutorTestDataCreator() {

}
Expand Down Expand Up @@ -400,6 +407,10 @@ public static PaForm createPaForm() throws IOException {
.url(SOT_DOCUMENT_URL)
.build()
)
.provideinformation(ProvideInformation.builder()
.citizenResponse(CITIZEN_RESPONSE)
.documentUploadIssue(FALSE).build())
.reviewresponse(ReviewResponse.builder().citizenResponseCheckbox(TRUE).build())
.legalDeclaration(objectMapper.readValue(LEGAL_DECLARATION_JSON, new TypeReference<Map<String, Object>>() {
}))
.checkAnswersSummary(objectMapper.readValue(CHECK_ANSWERS_JSON, new TypeReference<Map<String, Object>>() {
Expand Down Expand Up @@ -557,7 +568,7 @@ public static GrantOfRepresentationData createGrantOfRepresentation() {
.total(FEES_TOTAL.multiply(BigDecimal.valueOf(100)).longValue())
.build()
)
.boDocumentsUploaded(Lists.newArrayList(
.citizenDocumentsUploaded(Lists.newArrayList(
CollectionMember.<UploadDocument>builder()
.value(UploadDocument.builder()
.documentLink(DocumentLink.builder()
Expand All @@ -566,7 +577,7 @@ public static GrantOfRepresentationData createGrantOfRepresentation() {
.documentBinaryUrl(DOCUMENT_URL + "/binary")
.build())
.comment(DOCUMENT_FILENAME)
.documentType(DocumentType.DEATH_CERT)
.documentType(DocumentType.CITIZEN_HUB_UPLOAD)
.build())
.build()

Expand All @@ -576,6 +587,9 @@ public static GrantOfRepresentationData createGrantOfRepresentation() {
.documentUrl(SOT_DOCUMENT_URL)
.documentFilename(SOT_DOCUMENT_FILENAME)
.build())
.citizenResponse(CITIZEN_RESPONSE)
.documentUploadIssue(FALSE)
.citizenResponseCheckbox(TRUE)
.legalDeclarationJson(LEGAL_DECLARATION_JSON)
.checkAnswersSummaryJson(CHECK_ANSWERS_JSON)
.deceasedAddresses(DECEASED_ADDRESSES)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
import uk.gov.hmcts.reform.probate.model.forms.LegalStatementExecutorApplying;
import uk.gov.hmcts.reform.probate.model.forms.LegalStatementHolder;
import uk.gov.hmcts.reform.probate.model.forms.Payment;
import uk.gov.hmcts.reform.probate.model.forms.ProvideInformation;
import uk.gov.hmcts.reform.probate.model.forms.Registry;
import uk.gov.hmcts.reform.probate.model.forms.ReviewResponse;
import uk.gov.hmcts.reform.probate.model.forms.Will;
import uk.gov.hmcts.reform.probate.model.forms.pa.Executor;
import uk.gov.hmcts.reform.probate.model.forms.pa.Executors;
Expand All @@ -58,6 +60,7 @@
import java.util.Map;

import static java.lang.Boolean.TRUE;
import static java.lang.Boolean.FALSE;

public final class PaSingleExecutorTestDataCreator {

Expand Down Expand Up @@ -221,6 +224,8 @@ public final class PaSingleExecutorTestDataCreator {

private static String APPLICANT_ADDRESSES = "[{\"formatted_address\":\"102 Petty France London SW1H 9EX\"}]";

private static String CITIZEN_RESPONSE = "response";

private PaSingleExecutorTestDataCreator() {

}
Expand Down Expand Up @@ -435,6 +440,10 @@ public static PaForm createPaForm() throws IOException {
.url(SOT_DOCUMENT_URL)
.build()
)
.provideinformation(ProvideInformation.builder()
.citizenResponse(CITIZEN_RESPONSE)
.documentUploadIssue(FALSE).build())
.reviewresponse(ReviewResponse.builder().citizenResponseCheckbox(TRUE).build())
.legalDeclaration(objectMapper.readValue(LEGAL_DECLARATION_JSON, new TypeReference<Map<String, Object>>() {
}))
.checkAnswersSummary(objectMapper.readValue(CHECK_ANSWERS_JSON, new TypeReference<Map<String, Object>>() {
Expand Down Expand Up @@ -581,16 +590,17 @@ public static GrantOfRepresentationData createGrantOfRepresentation() {
.total(FEES_TOTAL.multiply(BigDecimal.valueOf(100)).longValue())
.build()
)
.boDocumentsUploaded(Lists.newArrayList(
.citizenDocumentsUploaded(Lists.newArrayList(
CollectionMember.<UploadDocument>builder()
.value(UploadDocument.builder()
.documentLink(DocumentLink.builder()
.documentUrl(DOCUMENT_URL)
.documentFilename(DOCUMENT_FILENAME)

.documentBinaryUrl(DOCUMENT_URL + "/binary")
.build())
.comment(DOCUMENT_FILENAME)
.documentType(DocumentType.DEATH_CERT)
.documentType(DocumentType.CITIZEN_HUB_UPLOAD)
.build())
.build()

Expand Down Expand Up @@ -632,6 +642,9 @@ public static GrantOfRepresentationData createGrantOfRepresentation() {
.codicilsDamageDateKnown(CODICILS_DAMAGE_DATE_KNOWN)
.codicilsDamageDate(CODICILS_DAMAGE_DATE)
.deceasedWrittenWishes(DECEASED_WRITTEN_WISHES)
.citizenResponse(CITIZEN_RESPONSE)
.documentUploadIssue(FALSE)
.citizenResponseCheckbox(TRUE)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.springframework.web.bind.annotation.RequestParam;
import uk.gov.hmcts.reform.probate.model.documents.BulkScanCoverSheet;
import uk.gov.hmcts.reform.probate.model.documents.CheckAnswersSummary;
import uk.gov.hmcts.reform.probate.model.documents.DocumentNotification;
import uk.gov.hmcts.reform.probate.model.documents.LegalDeclaration;
import uk.gov.hmcts.reform.probate.model.multiapplicant.ExecutorNotification;
import uk.gov.hmcts.reform.probate.model.multiapplicant.Invitation;
Expand Down Expand Up @@ -114,6 +115,17 @@ String inviteBilingual(@PathVariable("inviteId") String inviteId,
@PostMapping(path = "/executor-notification/all-bilingual", consumes = MediaType.APPLICATION_JSON_VALUE)
String signedExecAllBilingual(@RequestBody ExecutorNotification executorNotification);

@PostMapping(path = "/document-upload-notification/bilingual", consumes = MediaType.APPLICATION_JSON_VALUE)
String documentUploadBilingual(@RequestBody DocumentNotification executorNotification);

@PostMapping(path = "/document-upload-notification", consumes = MediaType.APPLICATION_JSON_VALUE)
String documentUpload(@RequestBody DocumentNotification executorNotification);

@PostMapping(path = "/document-upload-issue-notification/bilingual", consumes = MediaType.APPLICATION_JSON_VALUE)
String documentUploadIssueBilingual(@RequestBody DocumentNotification executorNotification);

@PostMapping(path = "/document-upload-issue-notification", consumes = MediaType.APPLICATION_JSON_VALUE)
String documentUploadIssue(@RequestBody DocumentNotification executorNotification);

@GetMapping(path = "/pin/bilingual")
String pinNumberBilingual(@RequestParam("phoneNumber") String phoneNumber,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
Expand Down Expand Up @@ -37,6 +38,7 @@ public class DocumentsController {
protected static final String LEGAL_DECLARATION_ENDPOINT = "/generate/legalDeclaration";
protected static final String BULK_SCAN_COVERSHEET_ENDPOINT = "/generate/bulkScanCoversheet";
protected static final String DOCUMENT_UPLOAD_ENDPOINT = "/upload";
protected static final String DOCUMENT_UPLOAD_NOTIFICATION_ENDPOINT = "/notification";
protected static final String DOCUMENT_DELETE_ENDPOINT = "/delete/{documentId}";

private final BusinessService businessService;
Expand Down Expand Up @@ -93,4 +95,11 @@ public ResponseEntity<List<String>> upload(@RequestHeader(value = "Authorization
return new ResponseEntity<>(backOfficeService.uploadDocument(authorizationToken, files), HttpStatus.OK);
}

@PostMapping(path = DOCUMENT_UPLOAD_NOTIFICATION_ENDPOINT + "/{formdataId}/{citizenResponseCheckbox}")
public void uploadNotification(@PathVariable("formdataId") String formdataId,
@PathVariable("citizenResponseCheckbox") String citizenResponseCheckbox) {
log.info("Sending notification for document upload to Business service for case : {}", formdataId);
businessService.documentUploadNotification(formdataId,citizenResponseCheckbox);
}

}
Loading

0 comments on commit 007f737

Please sign in to comment.