diff --git a/cccm-backend/cccm-api/src/main/java/ca/bc/gov/open/jag/api/form/FormsApiImpl.java b/cccm-backend/cccm-api/src/main/java/ca/bc/gov/open/jag/api/form/FormsApiImpl.java index abb7360d..650f88b1 100644 --- a/cccm-backend/cccm-api/src/main/java/ca/bc/gov/open/jag/api/form/FormsApiImpl.java +++ b/cccm-backend/cccm-api/src/main/java/ca/bc/gov/open/jag/api/form/FormsApiImpl.java @@ -62,7 +62,7 @@ public String getClientFormAnswersUsingGET(BigDecimal clientFormId, String clien logger.info("Client Form Answers Request"); - return clientDataService.getClientFormAnswers(clientNumber, clientFormId); + return clientDataService.getClientFormAnswers(clientNumber, clientFormId, xLocationId); } diff --git a/cccm-backend/cccm-api/src/main/java/ca/bc/gov/open/jag/api/service/ClientDataService.java b/cccm-backend/cccm-api/src/main/java/ca/bc/gov/open/jag/api/service/ClientDataService.java index 94b0f4b7..99be961f 100644 --- a/cccm-backend/cccm-api/src/main/java/ca/bc/gov/open/jag/api/service/ClientDataService.java +++ b/cccm-backend/cccm-api/src/main/java/ca/bc/gov/open/jag/api/service/ClientDataService.java @@ -45,9 +45,10 @@ public interface ClientDataService { * Get client form answers * @param clientNumber * @param clientFormId + * @param location * @return {@link String} JSON answer object */ - String getClientFormAnswers(String clientNumber, BigDecimal clientFormId); + String getClientFormAnswers(String clientNumber, BigDecimal clientFormId, String location); List clientFormSearch(String clientNum, boolean currentPeriod, boolean mostRecent, String formTypeCd, String location); diff --git a/cccm-backend/cccm-api/src/main/java/ca/bc/gov/open/jag/api/service/ClientDataServiceImpl.java b/cccm-backend/cccm-api/src/main/java/ca/bc/gov/open/jag/api/service/ClientDataServiceImpl.java index 2c3e568c..3607977a 100644 --- a/cccm-backend/cccm-api/src/main/java/ca/bc/gov/open/jag/api/service/ClientDataServiceImpl.java +++ b/cccm-backend/cccm-api/src/main/java/ca/bc/gov/open/jag/api/service/ClientDataServiceImpl.java @@ -231,7 +231,7 @@ public List clientFormSearch(String clientNum, boolean curren form.setSupervisionRating(form.getRatings().get(0).getText()); } if (form.getModule().equalsIgnoreCase(OVERALL_FORM_TYPE)) { - formsMerged.add(populateRatings(form, clientNum)); + formsMerged.add(populateRatings(form, clientNum, location)); } else { formsMerged.add(form); } @@ -250,7 +250,7 @@ public List clientFormSearch(String clientNum, boolean curren } else if ((formTypeCd.equalsIgnoreCase(OVERALL_FORM_TYPE) && form.getModule().equalsIgnoreCase(OVERALL_FORM_TYPE)) && hasSMOEarlyAdopter) { logger.info("adding form {}", form.getModule()); - formsMerged.add(populateRatings(form, clientNum)); + formsMerged.add(populateRatings(form, clientNum, location)); } } //Add sorting on update date when implemented @@ -293,9 +293,9 @@ public void deleteInterventionsExcept(String clientNumber, BigDecimal clientForm @Override - public String getClientFormAnswers(String clientNumber,BigDecimal clientFormId) { + public String getClientFormAnswers(String clientNumber,BigDecimal clientFormId, String location) { logger.debug("Getting form answers {}", clientFormId); - return obridgeClientService.getClientFormAnswers(clientNumber,clientFormId); + return obridgeClientService.getClientFormAnswers(clientNumber,clientFormId, new BigDecimal(location)); } @Override @@ -449,10 +449,10 @@ private Boolean hasSMOEarlyAdopter() { * @return the form * NOTE this can be done in a void but is clearer with a return */ - private ClientFormSummary populateRatings(ClientFormSummary form, String clientNumber) { + private ClientFormSummary populateRatings(ClientFormSummary form, String clientNumber, String location) { //Get Answers From CRNA/SARA try { - String answers = getClientFormAnswers(clientNumber, form.getId()); + String answers = getClientFormAnswers(clientNumber, form.getId(), location); String crnaRatingAnswer = FormUtils.findAnswerByKey(answers, OVERALL_CRNA_RATING); String saraRatingAnswer = FormUtils.findAnswerByKey(answers, OVERALL_SARA_RATING); diff --git a/cccm-backend/cccm-api/src/main/java/ca/bc/gov/open/jag/api/service/ClientFormSaveServiceImpl.java b/cccm-backend/cccm-api/src/main/java/ca/bc/gov/open/jag/api/service/ClientFormSaveServiceImpl.java index eabbd91b..ded7ae20 100644 --- a/cccm-backend/cccm-api/src/main/java/ca/bc/gov/open/jag/api/service/ClientFormSaveServiceImpl.java +++ b/cccm-backend/cccm-api/src/main/java/ca/bc/gov/open/jag/api/service/ClientFormSaveServiceImpl.java @@ -147,13 +147,13 @@ public void editForm(UpdateForm updateForm, String location) { if (updateForm.getComplete()) { if (clientFormSummary.getModule().equalsIgnoreCase(CRNA_FORM_TYPE)) { - ValidationResult result = validationService.validateCRNA(obridgeClientService.getClientFormAnswers(updateForm.getUpdateFormInput().getClientNumber(), updateForm.getUpdateFormInput().getClientFormId()), updateForm.getInterventionKeys()); + ValidationResult result = validationService.validateCRNA(obridgeClientService.getClientFormAnswers(updateForm.getUpdateFormInput().getClientNumber(), updateForm.getUpdateFormInput().getClientFormId(), new BigDecimal(location)), updateForm.getInterventionKeys()); if (!result.getErrors().isEmpty()) { throw new CCCMException("CRNA form validation failed:", CCCMErrorCode.VALIDATIONERRORWITHRESULT, result); } if (updateForm.getUpdateFormInput().getLinkedClientFormId() != null) { - ValidationResult saraResult = validationService.validateSARA(obridgeClientService.getClientFormAnswers(updateForm.getUpdateFormInput().getClientNumber(), updateForm.getUpdateFormInput().getLinkedClientFormId())); + ValidationResult saraResult = validationService.validateSARA(obridgeClientService.getClientFormAnswers(updateForm.getUpdateFormInput().getClientNumber(), updateForm.getUpdateFormInput().getLinkedClientFormId(), new BigDecimal(location))); if (!saraResult.getErrors().isEmpty()) { throw new CCCMException("SARA form validation failed:", CCCMErrorCode.VALIDATIONERRORWITHRESULT, saraResult); } @@ -161,13 +161,13 @@ public void editForm(UpdateForm updateForm, String location) { } if (clientFormSummary.getModule().equalsIgnoreCase(SARA_FORM_TYPE)) { - ValidationResult result = validationService.validateSARA(obridgeClientService.getClientFormAnswers(updateForm.getUpdateFormInput().getClientNumber(), updateForm.getUpdateFormInput().getClientFormId())); + ValidationResult result = validationService.validateSARA(obridgeClientService.getClientFormAnswers(updateForm.getUpdateFormInput().getClientNumber(), updateForm.getUpdateFormInput().getClientFormId(), new BigDecimal(location))); if (!result.getErrors().isEmpty()) { throw new CCCMException("SARA form validation failed:", CCCMErrorCode.VALIDATIONERRORWITHRESULT, result); } if (updateForm.getUpdateFormInput().getLinkedClientFormId() != null) { - ValidationResult crnaResult = validationService.validateCRNA(obridgeClientService.getClientFormAnswers(updateForm.getUpdateFormInput().getClientNumber(), updateForm.getUpdateFormInput().getLinkedClientFormId()), updateForm.getInterventionKeys()); + ValidationResult crnaResult = validationService.validateCRNA(obridgeClientService.getClientFormAnswers(updateForm.getUpdateFormInput().getClientNumber(), updateForm.getUpdateFormInput().getLinkedClientFormId(), new BigDecimal(location)), updateForm.getInterventionKeys()); if (!crnaResult.getErrors().isEmpty()) { throw new CCCMException("CRNA form validation failed:", CCCMErrorCode.VALIDATIONERRORWITHRESULT, crnaResult); } @@ -175,7 +175,7 @@ public void editForm(UpdateForm updateForm, String location) { } if (clientFormSummary.getModule().equalsIgnoreCase(ACUTE_FORM_TYPE)) { - ValidationResult result = validationService.validateACUTE(obridgeClientService.getClientFormAnswers(updateForm.getUpdateFormInput().getClientNumber(), updateForm.getUpdateFormInput().getClientFormId())); + ValidationResult result = validationService.validateACUTE(obridgeClientService.getClientFormAnswers(updateForm.getUpdateFormInput().getClientNumber(), updateForm.getUpdateFormInput().getClientFormId(), new BigDecimal(location))); if (!result.getErrors().isEmpty()) { throw new CCCMException("ACUTE form validation failed:", CCCMErrorCode.VALIDATIONERRORWITHRESULT, result); } @@ -183,7 +183,7 @@ public void editForm(UpdateForm updateForm, String location) { } if (clientFormSummary.getModule().equalsIgnoreCase(STATIC99R_FORM_TYPE)) { - ValidationResult result = validationService.validateStatic99r(obridgeClientService.getClientFormAnswers(updateForm.getUpdateFormInput().getClientNumber(), updateForm.getUpdateFormInput().getClientFormId())); + ValidationResult result = validationService.validateStatic99r(obridgeClientService.getClientFormAnswers(updateForm.getUpdateFormInput().getClientNumber(), updateForm.getUpdateFormInput().getClientFormId(), new BigDecimal(location))); if (!result.getErrors().isEmpty()) { throw new CCCMException("Static-99R form validation failed:", CCCMErrorCode.VALIDATIONERRORWITHRESULT, result); } @@ -192,14 +192,14 @@ public void editForm(UpdateForm updateForm, String location) { if (clientFormSummary.getModule().equalsIgnoreCase(STABLE_FORM_TYPE)) { //TODO: Add validation rule to "An Acute and a Static have been completed in the current period of supervision." - ValidationResult result = validationService.validateStable(obridgeClientService.getClientFormAnswers(updateForm.getUpdateFormInput().getClientNumber(), updateForm.getUpdateFormInput().getClientFormId())); + ValidationResult result = validationService.validateStable(obridgeClientService.getClientFormAnswers(updateForm.getUpdateFormInput().getClientNumber(), updateForm.getUpdateFormInput().getClientFormId(), new BigDecimal(location))); if (!result.getErrors().isEmpty()) { throw new CCCMException("Stable form validation failed:", CCCMErrorCode.VALIDATIONERRORWITHRESULT, result); } } if (clientFormSummary.getModule().equalsIgnoreCase(OVERALL_FORM_TYPE)) { - ValidationResult result = validationService.validateSOOverall(obridgeClientService.getClientFormAnswers(updateForm.getUpdateFormInput().getClientNumber(), updateForm.getUpdateFormInput().getClientFormId())); + ValidationResult result = validationService.validateSOOverall(obridgeClientService.getClientFormAnswers(updateForm.getUpdateFormInput().getClientNumber(), updateForm.getUpdateFormInput().getClientFormId(), new BigDecimal(location))); if (!result.getErrors().isEmpty()) { throw new CCCMException("Overall form validation failed:", CCCMErrorCode.VALIDATIONERRORWITHRESULT, result); } @@ -352,7 +352,7 @@ private BigDecimal cloneFormAndAnswers(ClientFormSummary clientFormSummary, Clon BigDecimal clientFormId = obridgeClientService.createForm(formInput); //Get Answers - String answers = obridgeClientService.getClientFormAnswers(cloneFormRequest.getClientNumber(), clientFormSummary.getId()); + String answers = obridgeClientService.getClientFormAnswers(cloneFormRequest.getClientNumber(), clientFormSummary.getId(), new BigDecimal(location)); //Insert Answers Use Clone Config for ignore String strippedAnswers = stripAnswers(answers, cloneConfig.getForms().stream().filter(cloneForm -> cloneForm.getFormType().equalsIgnoreCase(clientFormSummary.getModule())).findFirst().get()); obridgeClientService.saveClientFormAnswers(cloneFormRequest.getClientNumber(), clientFormId, strippedAnswers, false, new BigDecimal(location)); diff --git a/cccm-backend/cccm-api/src/main/java/ca/bc/gov/open/jag/api/service/ObridgeClientService.java b/cccm-backend/cccm-api/src/main/java/ca/bc/gov/open/jag/api/service/ObridgeClientService.java index b5920812..58629281 100644 --- a/cccm-backend/cccm-api/src/main/java/ca/bc/gov/open/jag/api/service/ObridgeClientService.java +++ b/cccm-backend/cccm-api/src/main/java/ca/bc/gov/open/jag/api/service/ObridgeClientService.java @@ -178,7 +178,8 @@ String updateClientFormInterventions(@PathParam("clientNumber") String clientNum @GET @Path("/forms/client/answers/{clientNumber}/{clientFormId}") String getClientFormAnswers(@PathParam("clientNumber") String clientNumber, - @PathParam("clientFormId") BigDecimal clientFormId); + @PathParam("clientFormId") BigDecimal clientFormId, + @QueryParam("location") BigDecimal location); @GET @Path("/forms/client/summary/answers/{clientNumber}/{clientFormId}") diff --git a/cccm-backend/cccm-api/src/test/java/ca/bc/gov/open/jag/api/form/GetClientFormAnswersUsingGETTest.java b/cccm-backend/cccm-api/src/test/java/ca/bc/gov/open/jag/api/form/GetClientFormAnswersUsingGETTest.java index c4eeb599..49c9be00 100644 --- a/cccm-backend/cccm-api/src/test/java/ca/bc/gov/open/jag/api/form/GetClientFormAnswersUsingGETTest.java +++ b/cccm-backend/cccm-api/src/test/java/ca/bc/gov/open/jag/api/form/GetClientFormAnswersUsingGETTest.java @@ -44,7 +44,7 @@ public class GetClientFormAnswersUsingGETTest { @DisplayName("200: should return answers") public void testGetAnswersEndpoint() { - Mockito.when(clientDataService.getClientFormAnswers(Mockito.any(), Mockito.any())).thenReturn("ANSWERS"); + Mockito.when(clientDataService.getClientFormAnswers(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn("ANSWERS"); String result = sut.getClientFormAnswersUsingGET(BigDecimal.ONE,"TEST", null); diff --git a/cccm-backend/cccm-api/src/test/java/ca/bc/gov/open/jag/api/service/dataservice/client/ClientFormSearchTest.java b/cccm-backend/cccm-api/src/test/java/ca/bc/gov/open/jag/api/service/dataservice/client/ClientFormSearchTest.java index 59139794..9530ba3f 100644 --- a/cccm-backend/cccm-api/src/test/java/ca/bc/gov/open/jag/api/service/dataservice/client/ClientFormSearchTest.java +++ b/cccm-backend/cccm-api/src/test/java/ca/bc/gov/open/jag/api/service/dataservice/client/ClientFormSearchTest.java @@ -55,7 +55,7 @@ public class ClientFormSearchTest { public void testGetClientFormsNoMerge() { Mockito.when(obridgeClientService.getClientForms(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(), Mockito.any(BigDecimal.class))).thenReturn(createRelatedList()); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.anyString(), Mockito.any(BigDecimal.class))).thenReturn(answersJson); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.anyString(), Mockito.any(BigDecimal.class), Mockito.any())).thenReturn(answersJson); Mockito.when(jsonWebTokenMock.claim(Mockito.anyString())).thenReturn(Optional.of(getRolesWithSMO())); @@ -71,7 +71,7 @@ public void testGetClientFormsNoMerge() { public void testGetClientFormsAllNoMerge() { Mockito.when(obridgeClientService.getClientForms(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(), Mockito.any(BigDecimal.class))).thenReturn(createNonRelatedList()); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.anyString(), Mockito.any(BigDecimal.class))).thenReturn(answersJson); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.anyString(), Mockito.any(BigDecimal.class), Mockito.any())).thenReturn(answersJson); Mockito.when(jsonWebTokenMock.claim(Mockito.anyString())).thenReturn(Optional.of(getRolesWithSMO())); @@ -87,7 +87,7 @@ public void testGetClientFormsMerge() { Mockito.when(obridgeClientService.getClientForms(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(), Mockito.any(BigDecimal.class))).thenReturn(createRelatedList()); Mockito.when(jsonWebTokenMock.claim(Mockito.anyString())).thenReturn(Optional.of(getRolesWithSMO())); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.anyString(), Mockito.any(BigDecimal.class))).thenReturn(answersJson); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.anyString(), Mockito.any(BigDecimal.class), Mockito.any())).thenReturn(answersJson); List result = sut.clientFormSearch("", false, false,"All", "1"); @@ -181,7 +181,7 @@ public void testGetAllClientFormsOverall() { Mockito.when(obridgeClientService.getClientForms(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(), Mockito.any(BigDecimal.class))).thenReturn(createRelatedList()); Mockito.when(jsonWebTokenMock.claim(Mockito.anyString())).thenReturn(Optional.of(getRolesWithSMO())); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.anyString(), Mockito.any(BigDecimal.class))).thenReturn(answersJson); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.anyString(), Mockito.any(BigDecimal.class), Mockito.any())).thenReturn(answersJson); List result = sut.clientFormSearch("", false, true,"SMO_OVERALL", "1"); diff --git a/cccm-backend/cccm-api/src/test/java/ca/bc/gov/open/jag/api/service/dataservice/clientForm/CloneFormTest.java b/cccm-backend/cccm-api/src/test/java/ca/bc/gov/open/jag/api/service/dataservice/clientForm/CloneFormTest.java index 1cc923d2..74bab66e 100644 --- a/cccm-backend/cccm-api/src/test/java/ca/bc/gov/open/jag/api/service/dataservice/clientForm/CloneFormTest.java +++ b/cccm-backend/cccm-api/src/test/java/ca/bc/gov/open/jag/api/service/dataservice/clientForm/CloneFormTest.java @@ -127,7 +127,7 @@ public void testCloneCrnaForm() throws IOException { Mockito.when(obridgeClientService.getClientFormSummary(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(createClientForm(CRNA_FORM_TYPE, null)); Mockito.when(obridgeClientService.createForm(Mockito.any())).thenReturn(BigDecimal.ONE); Mockito.when(obridgeClientService.getFormTypes(Mockito.any())).thenReturn(Collections.singletonList(createCodeTable(CRNA_FORM_TYPE, BigDecimal.ONE.toPlainString()))); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any())).thenReturn(DATA_ONE); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(DATA_ONE); Mockito.when(obridgeClientService.saveClientFormAnswers(Mockito.anyString(), Mockito.any(), Mockito.anyString(), Mockito.anyBoolean(), Mockito.any())).thenReturn(""); BigDecimal result = sut.cloneClientForm(new CloneFormRequest("TEST", BigDecimal.ONE, BigDecimal.ONE, true), "TEST@idir", "1"); @@ -143,7 +143,7 @@ public void testCloneSaraForm() throws IOException { Mockito.when(obridgeClientService.getClientFormSummary(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(createClientForm(SARA_FORM_TYPE, null)); Mockito.when(obridgeClientService.createForm(Mockito.any())).thenReturn(BigDecimal.ONE); Mockito.when(obridgeClientService.getFormTypes(Mockito.any())).thenReturn(Collections.singletonList(createCodeTable(SARA_FORM_TYPE, BigDecimal.ONE.toPlainString()))); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any())).thenReturn(DATA_ONE); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(DATA_ONE); Mockito.when(obridgeClientService.saveClientFormAnswers(Mockito.anyString(), Mockito.any(), Mockito.anyString(), Mockito.anyBoolean(), Mockito.any())).thenReturn(""); BigDecimal result = sut.cloneClientForm(new CloneFormRequest("TEST", BigDecimal.ONE, BigDecimal.ONE, true), "TEST@idir", "1"); @@ -159,7 +159,7 @@ public void testCloneSaraChildForm() throws IOException { Mockito.when(obridgeClientService.getClientFormSummary(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(createClientForm(SARA_FORM_TYPE, BigDecimal.ONE)); Mockito.when(obridgeClientService.createForm(Mockito.any())).thenReturn(BigDecimal.ONE); Mockito.when(obridgeClientService.getFormTypes(Mockito.any())).thenReturn(Collections.singletonList(createCodeTable(SARA_FORM_TYPE, BigDecimal.ONE.toPlainString()))); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any())).thenReturn(DATA_ONE); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(DATA_ONE); Mockito.when(obridgeClientService.saveClientFormAnswers(Mockito.anyString(), Mockito.any(), Mockito.anyString(), Mockito.anyBoolean(), Mockito.any())).thenReturn(""); BigDecimal result = sut.cloneClientForm(new CloneFormRequest("TEST", BigDecimal.ONE, BigDecimal.ONE, true), "TEST@idir", "1"); @@ -175,7 +175,7 @@ public void testCloneAcuteForm() throws IOException { Mockito.when(obridgeClientService.getClientFormSummary(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(createClientForm(ACUTE_FORM_TYPE, null)); Mockito.when(obridgeClientService.createForm(Mockito.any())).thenReturn(BigDecimal.ONE); Mockito.when(obridgeClientService.getFormTypes(Mockito.any())).thenReturn(Collections.singletonList(createCodeTable(ACUTE_FORM_TYPE, BigDecimal.ONE.toPlainString()))); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any())).thenReturn(DATA_ONE); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(DATA_ONE); Mockito.when(obridgeClientService.saveClientFormAnswers(Mockito.anyString(), Mockito.any(), Mockito.anyString(), Mockito.anyBoolean(), Mockito.any())).thenReturn(""); BigDecimal result = sut.cloneClientForm(new CloneFormRequest("TEST", BigDecimal.ONE, BigDecimal.ONE, true), "TEST@idir", "1"); @@ -192,7 +192,7 @@ public void testCloneStatic99RChildForm() throws IOException { Mockito.when(obridgeClientService.getClientFormSummary(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(createClientForm(STATIC99R_FORM_TYPE, null)); Mockito.when(obridgeClientService.createForm(Mockito.any())).thenReturn(BigDecimal.ONE); Mockito.when(obridgeClientService.getFormTypes(Mockito.any())).thenReturn(Collections.singletonList(createCodeTable(STATIC99R_FORM_TYPE, BigDecimal.ONE.toPlainString()))); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any())).thenReturn(DATA_ONE); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(DATA_ONE); Mockito.when(obridgeClientService.saveClientFormAnswers(Mockito.anyString(), Mockito.any(), Mockito.anyString(), Mockito.anyBoolean(), Mockito.any())).thenReturn(""); BigDecimal result = sut.cloneClientForm(new CloneFormRequest("TEST", BigDecimal.ONE, BigDecimal.ONE, true), "TEST@idir", "1"); @@ -208,7 +208,7 @@ public void testCloneCannotClone() throws IOException { Mockito.when(obridgeClientService.getClientFormSummary(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(createClientForm(SARA_FORM_TYPE, null)); Mockito.when(obridgeClientService.createForm(Mockito.any())).thenReturn(BigDecimal.ONE); Mockito.when(obridgeClientService.getFormTypes(Mockito.any())).thenReturn(Collections.singletonList(createCodeTable(SARA_FORM_TYPE, BigDecimal.TEN.toPlainString()))); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any())).thenReturn(DATA_ONE); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(DATA_ONE); Mockito.when(obridgeClientService.saveClientFormAnswers(Mockito.anyString(), Mockito.any(), Mockito.anyString(), Mockito.anyBoolean(), Mockito.any())).thenReturn(""); Assertions.assertThrows(CCCMException.class, () -> sut.cloneClientForm(new CloneFormRequest("TEST", BigDecimal.ONE, BigDecimal.ONE, false), "NOTTEST@idir", "1")); @@ -223,7 +223,7 @@ public void testCloneFormTypeInvalid() throws IOException { Mockito.when(obridgeClientService.getClientFormSummary(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(createClientForm(SARA_FORM_TYPE, null)); Mockito.when(obridgeClientService.createForm(Mockito.any())).thenReturn(BigDecimal.ONE); Mockito.when(obridgeClientService.getFormTypes(Mockito.any())).thenReturn(Collections.singletonList(createCodeTable(SARA_FORM_TYPE, BigDecimal.TEN.toPlainString()))); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any())).thenReturn(DATA_ONE); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(DATA_ONE); Mockito.when(obridgeClientService.saveClientFormAnswers(Mockito.anyString(), Mockito.any(), Mockito.anyString(), Mockito.anyBoolean(), Mockito.any())).thenReturn(""); Assertions.assertThrows(CCCMException.class, () -> sut.cloneClientForm(new CloneFormRequest("TEST", BigDecimal.ONE, BigDecimal.ONE, true), "TEST@idir", "1")); diff --git a/cccm-backend/cccm-api/src/test/java/ca/bc/gov/open/jag/api/service/dataservice/clientForm/CompleteFormTest.java b/cccm-backend/cccm-api/src/test/java/ca/bc/gov/open/jag/api/service/dataservice/clientForm/CompleteFormTest.java index 3c9eb3f9..dfe715c2 100644 --- a/cccm-backend/cccm-api/src/test/java/ca/bc/gov/open/jag/api/service/dataservice/clientForm/CompleteFormTest.java +++ b/cccm-backend/cccm-api/src/test/java/ca/bc/gov/open/jag/api/service/dataservice/clientForm/CompleteFormTest.java @@ -54,7 +54,7 @@ public void testCompleteFormIsOwner() throws IOException { Mockito.when(obridgeClientService.getClientFormSummary(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(createClientForm(CRNA_FORM_TYPE, null, "TEST", null, null)); Mockito.when(obridgeClientService.getClientFormAnswersObject(Mockito.any(), Mockito.any())).thenReturn(createClientFormAnswers()); Mockito.when(obridgeClientService.createForm(Mockito.any())).thenReturn(BigDecimal.ONE); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any())).thenReturn(""); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(""); Mockito.when(validationService.validateCRNA(Mockito.any(), Mockito.any())).thenReturn(new ValidationResult()); Mockito.when(userDataService.getOracleId(Mockito.any())).thenReturn("TEST"); @@ -73,7 +73,7 @@ public void testCompleteFormIsOwnerHasOverride() throws IOException { Mockito.when(obridgeClientService.getClientFormSummary(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(createClientForm(SARA_FORM_TYPE, null, "TESTER", null, null)); Mockito.when(obridgeClientService.getClientFormAnswersObject(Mockito.any(), Mockito.any())).thenReturn(new ClientFormAnswers()); Mockito.when(obridgeClientService.createForm(Mockito.any())).thenReturn(BigDecimal.ONE); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any())).thenReturn(""); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(""); Mockito.when(validationService.validateSARA(Mockito.any())).thenReturn(new ValidationResult()); Mockito.when(userDataService.getOracleId(Mockito.any())).thenReturn("TEST"); @@ -93,7 +93,7 @@ public void testCompleteWithSARAChild() throws IOException { Mockito.when(obridgeClientService.getClientFormSummary(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(createClientForm(CRNA_FORM_TYPE, BigDecimal.ONE, "TEST", null, null)); Mockito.when(obridgeClientService.createForm(Mockito.any())).thenReturn(BigDecimal.ONE); Mockito.when(obridgeClientService.getClientFormAnswersObject(Mockito.any(), Mockito.any())).thenReturn(createClientFormAnswers()); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any())).thenReturn(""); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(""); Mockito.when(validationService.validateCRNA(Mockito.any(), Mockito.any())).thenReturn(new ValidationResult()); Mockito.when(validationService.validateSARA(Mockito.any())).thenReturn(new ValidationResult()); Mockito.when(userDataService.getOracleId(Mockito.any())).thenReturn("TEST"); @@ -114,7 +114,7 @@ public void testCompleteWithChild() throws IOException { Mockito.when(obridgeClientService.getClientFormSummary(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(createClientForm(SARA_FORM_TYPE, BigDecimal.ONE, "TEST", null, null)); Mockito.when(obridgeClientService.createForm(Mockito.any())).thenReturn(BigDecimal.ONE); Mockito.when(obridgeClientService.getClientFormAnswersObject(Mockito.any(), Mockito.any())).thenReturn(new ClientFormAnswers()); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any())).thenReturn(""); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(""); Mockito.when(validationService.validateCRNA(Mockito.any(), Mockito.any())).thenReturn(new ValidationResult()); Mockito.when(validationService.validateSARA(Mockito.any())).thenReturn(new ValidationResult()); Mockito.when(userDataService.getOracleId(Mockito.any())).thenReturn("TEST"); @@ -138,7 +138,7 @@ public void testSARAWithChildError() throws IOException { Mockito.when(obridgeClientService.getClientFormSummary(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(createClientForm(SARA_FORM_TYPE, BigDecimal.ONE, "TEST", null, null)); Mockito.when(obridgeClientService.createForm(Mockito.any())).thenReturn(BigDecimal.ONE); Mockito.when(obridgeClientService.getClientFormAnswersObject(Mockito.any(), Mockito.any())).thenReturn(new ClientFormAnswers()); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any())).thenReturn(""); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(""); Mockito.when(validationService.validateCRNA(Mockito.any(), Mockito.any())).thenReturn(validationResult); Mockito.when(validationService.validateSARA(Mockito.any())).thenReturn(new ValidationResult()); Mockito.when(userDataService.getOracleId(Mockito.any())).thenReturn("TEST"); @@ -162,7 +162,7 @@ public void testSARAWithValidationError() throws IOException { Mockito.when(obridgeClientService.getClientFormSummary(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(createClientForm(SARA_FORM_TYPE, BigDecimal.ONE, "TEST", null, null)); Mockito.when(obridgeClientService.createForm(Mockito.any())).thenReturn(BigDecimal.ONE); Mockito.when(obridgeClientService.getClientFormAnswersObject(Mockito.any(), Mockito.any())).thenReturn(new ClientFormAnswers()); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any())).thenReturn(""); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(""); Mockito.when(validationService.validateSARA(Mockito.any())).thenReturn(validationResult); Mockito.when(userDataService.getOracleId(Mockito.any())).thenReturn("TEST"); @@ -185,7 +185,7 @@ public void testCRNAWithChildError() throws IOException { Mockito.when(obridgeClientService.getClientFormSummary(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(createClientForm(CRNA_FORM_TYPE, BigDecimal.ONE, "TEST", null, null)); Mockito.when(obridgeClientService.createForm(Mockito.any())).thenReturn(BigDecimal.ONE); Mockito.when(obridgeClientService.getClientFormAnswersObject(Mockito.any(), Mockito.any())).thenReturn(new ClientFormAnswers()); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any())).thenReturn(""); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(""); Mockito.when(validationService.validateSARA(Mockito.any())).thenReturn(validationResult); Mockito.when(validationService.validateCRNA(Mockito.any(), Mockito.any())).thenReturn(new ValidationResult()); Mockito.when(userDataService.getOracleId(Mockito.any())).thenReturn("TEST"); @@ -210,7 +210,7 @@ public void testCRNAWithValidationError() throws IOException { Mockito.when(obridgeClientService.getClientFormSummary(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(createClientForm(CRNA_FORM_TYPE, BigDecimal.ONE, "TEST", null, null)); Mockito.when(obridgeClientService.createForm(Mockito.any())).thenReturn(BigDecimal.ONE); Mockito.when(obridgeClientService.getClientFormAnswersObject(Mockito.any(), Mockito.any())).thenReturn(new ClientFormAnswers()); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any())).thenReturn(""); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(""); Mockito.when(validationService.validateCRNA(Mockito.any(), Mockito.any())).thenReturn(validationResult); Mockito.when(userDataService.getOracleId(Mockito.any())).thenReturn("TEST"); @@ -230,7 +230,7 @@ public void testCompleteFormIsOwnerACUTE() throws IOException { Mockito.when(obridgeClientService.getClientFormSummary(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(createClientForm(ACUTE_FORM_TYPE, null, "TEST", null, null)); Mockito.when(obridgeClientService.createForm(Mockito.any())).thenReturn(BigDecimal.ONE); Mockito.when(obridgeClientService.getClientFormAnswersObject(Mockito.any(), Mockito.any())).thenReturn(new ClientFormAnswers()); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any())).thenReturn(""); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(""); Mockito.when(validationService.validateACUTE(Mockito.any())).thenReturn(new ValidationResult()); Mockito.when(userDataService.getOracleId(Mockito.any())).thenReturn("TEST"); @@ -250,7 +250,7 @@ public void testEditFormIsOwnerACUTERequiresNewForm() { Mockito.when(obridgeClientService.createForm(Mockito.any())).thenReturn(BigDecimal.ONE); Mockito.when(obridgeClientService.getClientFormAnswersObject(Mockito.any(), Mockito.any())).thenReturn(new ClientFormAnswers()); Mockito.when(obridgeClientService.getClientForms(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(), Mockito.any())).thenReturn(Collections.singletonList(createClientForm(ACUTE_FORM_TYPE, null, "TEST", "L", LocalDate.now()))); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any())).thenReturn(""); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(""); Mockito.when(validationService.validateACUTE(Mockito.any())).thenReturn(new ValidationResult()); Mockito.when(obridgeClientService.getFormTypes(Mockito.any())).thenReturn(Collections.singletonList(new CodeTable("123", "TEST"))); Mockito.when(userDataService.getOracleId(Mockito.any())).thenReturn("TEST"); @@ -272,7 +272,7 @@ public void testACUTEWithValidationError() throws IOException { Mockito.when(obridgeClientService.getClientFormSummary(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(createClientForm(ACUTE_FORM_TYPE,null, "TEST", null, null)); Mockito.when(obridgeClientService.createForm(Mockito.any())).thenReturn(BigDecimal.ONE); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any())).thenReturn(""); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(""); Mockito.when(validationService.validateACUTE(Mockito.any())).thenReturn(validationResult); Mockito.when(obridgeClientService.getClientFormAnswersObject(Mockito.any(), Mockito.any())).thenReturn(new ClientFormAnswers()); Mockito.when(userDataService.getOracleId(Mockito.any())).thenReturn("TEST"); @@ -292,7 +292,7 @@ public void testCompleteFormIsOwnerSTAT99R() throws IOException { Mockito.when(obridgeClientService.getClientFormSummary(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(createClientForm(STATIC99R_FORM_TYPE, null, "TEST", null, null)); Mockito.when(obridgeClientService.createForm(Mockito.any())).thenReturn(BigDecimal.ONE); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any())).thenReturn(""); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(""); Mockito.when(validationService.validateStatic99r(Mockito.any())).thenReturn(new ValidationResult()); Mockito.when(obridgeClientService.getClientFormAnswersObject(Mockito.any(), Mockito.any())).thenReturn(new ClientFormAnswers()); Mockito.when(userDataService.getOracleId(Mockito.any())).thenReturn("TEST"); @@ -313,7 +313,7 @@ public void testEditFormIsOwnerSTAT99RRequiresNewForm() { Mockito.when(obridgeClientService.createForm(Mockito.any())).thenReturn(BigDecimal.ONE); Mockito.when(obridgeClientService.getClientFormAnswersObject(Mockito.any(), Mockito.any())).thenReturn(new ClientFormAnswers()); Mockito.when(validationService.validateStatic99r(Mockito.any())).thenReturn(new ValidationResult()); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any())).thenReturn(""); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(""); Mockito.when(obridgeClientService.getFormTypes(Mockito.any())).thenReturn(Collections.singletonList(new CodeTable("123", "TEST"))); Mockito.when(obridgeClientService.getClientForms(Mockito.anyString(), Mockito.anyBoolean(), Mockito.anyString(), Mockito.any())).thenReturn(Collections.singletonList(createClientForm(STATIC99R_FORM_TYPE, null, "TEST", "L", LocalDate.now()))); Mockito.when(userDataService.getOracleId(Mockito.any())).thenReturn("TEST"); @@ -336,7 +336,7 @@ public void testSTABLEWithValidationError() throws IOException { Mockito.when(obridgeClientService.getClientFormSummary(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(createClientForm(STABLE_FORM_TYPE,null, "TEST", null, null)); Mockito.when(obridgeClientService.createForm(Mockito.any())).thenReturn(BigDecimal.ONE); Mockito.when(obridgeClientService.getClientFormAnswersObject(Mockito.any(), Mockito.any())).thenReturn(new ClientFormAnswers()); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any())).thenReturn(""); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(""); Mockito.when(validationService.validateStable(Mockito.any())).thenReturn(validationResult); Mockito.when(userDataService.getOracleId(Mockito.any())).thenReturn("TEST"); @@ -358,7 +358,7 @@ public void testOVERALLWithValidationError() throws IOException { Mockito.when(obridgeClientService.getClientFormSummary(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(createClientForm(OVERALL_FORM_TYPE,null, "TEST", null, null)); Mockito.when(obridgeClientService.createForm(Mockito.any())).thenReturn(BigDecimal.ONE); Mockito.when(obridgeClientService.getClientFormAnswersObject(Mockito.any(), Mockito.any())).thenReturn(new ClientFormAnswers()); - Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any())).thenReturn(""); + Mockito.when(obridgeClientService.getClientFormAnswers(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(""); Mockito.when(validationService.validateSOOverall(Mockito.any())).thenReturn(validationResult); Mockito.when(userDataService.getOracleId(Mockito.any())).thenReturn("TEST");