Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/contractTest/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,8 @@ document:
doc_send_reply_message_template: FL-PRL-LET-ENG-SEND-REPLY-MESSAGE.docx
doc_send_reply_message_welsh_template: FL-PRL-LET-WEL-SEND-REPLY-MESSAGE.docx
citizen:
prl_citizen_witness_statement_welsh_template: FL-PRL-GOR-WEL-Citizen-Witness-Statement.docx
prl_citizen_witness_statement_template: FL-PRL-GOR-ENG-Citizen-Witness-Statement.docx
prl_citizen_upload_template: FL-PRL-GOR-ENG-Citizen-Uploaded-Statement.docx
prl_citizen_upload_filename: Citizen_Uploaded_Statement.pdf
fl401listonnotice:
Expand Down
2 changes: 2 additions & 0 deletions src/functionalTest/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,8 @@ document:
doc_send_reply_message_template: FL-PRL-LET-ENG-SEND-REPLY-MESSAGE.docx
doc_send_reply_message_welsh_template: FL-PRL-LET-WEL-SEND-REPLY-MESSAGE.docx
citizen:
prl_citizen_witness_statement_welsh_template: FL-PRL-GOR-WEL-Citizen-Witness-Statement.docx
prl_citizen_witness_statement_template: FL-PRL-GOR-ENG-Citizen-Witness-Statement.docx
prl_citizen_upload_template: FL-PRL-GOR-ENG-Citizen-Uploaded-Statement.docx
prl_citizen_upload_filename: Citizen_Uploaded_Statement.pdf
fl401listonnotice:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.bean.override.mockito.MockitoBean;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.web.context.WebApplicationContext;
Expand Down Expand Up @@ -69,34 +69,35 @@ public class CaseDocumentControllerIntegrationTest {
@Autowired
private WebApplicationContext webApplicationContext;

@MockBean
DocumentGenService documentGenService;
@MockitoBean
private DocumentGenService documentGenService;

@MockBean
UploadDocumentService uploadService;
@MockitoBean
private UploadDocumentService uploadService;

@MockBean
AuthorisationService authorisationService;
@MockitoBean
private AuthorisationService authorisationService;

@MockBean
CoreCaseDataApi coreCaseDataApi;
@MockBean
IdamClient idamClient;
@MockitoBean
private CoreCaseDataApi coreCaseDataApi;

@MockBean
CaseService caseService;
@MockitoBean
private IdamClient idamClient;

@MockBean
EmailService emailService;
@MockitoBean
private CaseService caseService;

@MockBean
CitizenDocumentService citizenDocumentService;
@MockitoBean
private EmailService emailService;

@MockBean
UserInfo userInfo;
@MockitoBean
private CitizenDocumentService citizenDocumentService;

@MockitoBean
private UserInfo userInfo;

@Autowired
ObjectMapper objectMapper;
private ObjectMapper objectMapper;

@Before
public void setUp() {
Expand Down Expand Up @@ -139,10 +140,6 @@ public void testDeleteCitizenStatementDocument() throws Exception {
public void testGenerateCitizenStatementDocument() throws Exception {

when(authorisationService.isAuthorized(anyString(), anyString())).thenReturn(true);
Map<String, Object> map = new HashMap<>();
map.put("caseId", "123");
map.put("citizenUploadedDocumentList", List.of(element(UploadedDocuments.builder().build())));
map.put("partyId", "7663081e-778d-4317-b278-7642b740d317");

String caseDetails = ResourceLoader.loadJson("requests/c100-respondent-solicitor-c1adraft-generate.json");

Expand Down Expand Up @@ -243,15 +240,6 @@ public void testUploadCitizenStatementDocument() throws Exception {
"test content".getBytes()
);

String jsonRequest = "{"
+ "\"caseId\": \"123\","
+ "\"documentType\": \"statement\","
+ "\"partyName\": \"John Doe\","
+ "\"partyId\": \"7663081e-778d-4317-b278-7642b740d317\","
+ "\"isApplicant\": \"true\","
+ "\"documentRequestedByCourt\": \"YES\""
+ "}";

mockMvc.perform(
multipart(url)
.file(file)
Expand Down Expand Up @@ -363,7 +351,7 @@ public void testCitizenGenerateDocument() throws Exception {
.document(Document.builder().documentFileName("test.pdf").build())
.build();

when(documentGenService.generateAndUploadDocument(anyString(), any())).thenReturn(documentResponse);
when(documentGenService.generateAndUploadDocument(anyString(), any())).thenReturn(List.of(documentResponse));

String url = "/citizen-generate-document";
String jsonRequest = "{"
Expand Down
2 changes: 2 additions & 0 deletions src/integrationTest/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,8 @@ document:
doc_send_reply_message_template: FL-PRL-LET-ENG-SEND-REPLY-MESSAGE.docx
doc_send_reply_message_welsh_template: FL-PRL-LET-WEL-SEND-REPLY-MESSAGE.docx
citizen:
prl_citizen_witness_statement_welsh_template: FL-PRL-GOR-WEL-Citizen-Witness-Statement.docx
prl_citizen_witness_statement_template: FL-PRL-GOR-ENG-Citizen-Witness-Statement.docx
prl_citizen_upload_template: FL-PRL-GOR-ENG-Citizen-Uploaded-Statement.docx
prl_citizen_upload_filename: Citizen_Uploaded_Statement.pdf
fl401listonnotice:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,12 @@ private void sendEmailToCitizen(CaseData tempCaseData, String name, String email
emailService.send(
email,
EmailTemplateNames.DOCUMENT_UPLOADED,
buildUploadDocuemntEmail(tempCaseData, name, dashboardUrl),
buildUploadDocumentEmail(tempCaseData, name, dashboardUrl),
LanguagePreference.english
);
}

private EmailTemplateVars buildUploadDocuemntEmail(CaseData caseData, String name, String link) {
private EmailTemplateVars buildUploadDocumentEmail(CaseData caseData, String name, String link) {
return UploadDocumentEmail.builder()
.caseReference(String.valueOf(caseData.getId()))
.caseName(caseData.getApplicantCaseName())
Expand All @@ -225,7 +225,7 @@ private EmailTemplateVars buildUploadDocuemntEmail(CaseData caseData, String nam
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Uploaded Successfully"),
@ApiResponse(responseCode = "400", description = "Bad Request while uploading the document"),
@ApiResponse(responseCode = "401", description = "Provided Authroization token is missing or invalid"),
@ApiResponse(responseCode = "401", description = "Provided authorization token is missing or invalid"),
@ApiResponse(responseCode = "500", description = "Internal Server Error")
})
public ResponseEntity<Object> uploadCitizenStatementDocument(@RequestHeader(HttpHeaders.AUTHORIZATION) String authorisation,
Expand Down Expand Up @@ -317,9 +317,9 @@ public String deleteCitizenStatementDocument(@RequestBody DeleteDocumentRequest
CaseData tempCaseData = CaseUtils.getCaseData(caseDetails, objectMapper);
if (deleteDocumentRequest.getValues() != null
&& deleteDocumentRequest.getValues().containsKey("documentId")) {
final String documenIdToBeDeleted = deleteDocumentRequest.getValues().get("documentId");
final String documentIdToBeDeleted = deleteDocumentRequest.getValues().get("documentId");
tempUploadedDocumentsList = tempCaseData.getCitizenUploadedDocumentList();
uploadedDocumentsList = tempUploadedDocumentsList.stream().filter(element -> !documenIdToBeDeleted.equalsIgnoreCase(
uploadedDocumentsList = tempUploadedDocumentsList.stream().filter(element -> !documentIdToBeDeleted.equalsIgnoreCase(
element.getId().toString()))
.toList();
}
Expand All @@ -344,7 +344,7 @@ public String deleteCitizenStatementDocument(@RequestBody DeleteDocumentRequest
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Uploaded Successfully"),
@ApiResponse(responseCode = "400", description = "Bad Request while uploading the document"),
@ApiResponse(responseCode = "401", description = "Provided Authroization token is missing or invalid"),
@ApiResponse(responseCode = "401", description = "Provided Authorization token is missing or invalid"),
@ApiResponse(responseCode = "500", description = "Internal Server Error")
})
public ResponseEntity<Object> uploadCitizenDocument(@RequestHeader(HttpHeaders.AUTHORIZATION) String authorisation,
Expand Down Expand Up @@ -419,16 +419,16 @@ public ResponseEntity<Object> citizenGenerateDocument(@RequestHeader(HttpHeaders
throw (new RuntimeException(INVALID_CLIENT));
}

DocumentResponse documentResponse = null;
List<DocumentResponse> documentResponses;
try {
documentResponse = documentGenService.generateAndUploadDocument(authorisation, documentRequest);
documentResponses = documentGenService.generateAndUploadDocument(authorisation, documentRequest);
} catch (DocumentGenerationException dge) {
log.error("Exception in generating a document {}", dge.getMessage());
return ResponseEntity.internalServerError().body("Error in generating a document");
}

if (isNotEmpty(documentResponse)) {
return ResponseEntity.ok(documentResponse);
if (isNotEmpty(documentResponses)) {
return ResponseEntity.ok(documentResponses);
} else {
return ResponseEntity.internalServerError().body("Error in generating citizen document");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ public static DocumentCategory getValue(String id) {
return DocumentCategory.valueOf(id);
}

public boolean isWitnessStatement() {
return WITNESS_STATEMENTS_APPLICANT.equals(this) || WITNESS_STATEMENTS_RESPONDENT.equals(this);
}

public boolean isApplicantWitnessStatement() {
return WITNESS_STATEMENTS_APPLICANT.equals(this);
}

public boolean isRespondentWitnessStatement() {
return WITNESS_STATEMENTS_RESPONDENT.equals(this);
}

private static class Constants {
public static final String ANY_OTHER_DOC = "anyOtherDoc";
public static final String ANY_OTHER_DOCUMENTS = "Any Other Documents";
Expand Down
Loading