use of gov.ca.cwds.rest.exception.BaseExceptionResponse in project cals-api by ca-cwds.
the class RFA1aApplicantResourceTest method testEmptyLastNameValidation.
@Test
public void testEmptyLastNameValidation() throws Exception {
RFA1aFormDTO form = formAHelper.createRFA1aForm();
ApplicantDTO applicant = getApplicantDTO();
applicant.setFirstName("setFirstName");
applicant.setLastName(" ");
try {
applicantHelper.postApplicant(form.getId(), applicant);
fail();
} catch (ClientErrorException e) {
assertEquals(422, e.getResponse().getStatus());
String entity = e.getResponse().readEntity(String.class);
Map<String, Object> parameters = new HashMap<>();
BaseExceptionResponse exceptionResponse = e.getResponse().readEntity(BaseExceptionResponse.class);
Set<IssueDetails> issueDetails = exceptionResponse.getIssueDetails();
IssueDetails detail = issueDetails.iterator().next();
parameters.put("incident_id", detail.getIncidentId());
assertResponseByFixtureTemplate(entity, "fixtures/rfa/validation/applicant-empty-last-name-response.json", parameters);
}
}
use of gov.ca.cwds.rest.exception.BaseExceptionResponse in project cals-api by ca-cwds.
the class RFA1aApplicantResourceTest method testDuplicatePhoneNumbersWithExtension.
@Test
public void testDuplicatePhoneNumbersWithExtension() throws Exception {
RFA1aFormDTO form = formAHelper.createRFA1aForm();
ApplicantDTO applicant = getApplicantDTO();
applicant.getPhones().clear();
applicant.getPhones().add(createPhone());
applicant.getPhones().add(createPhone());
try {
applicantHelper.postApplicant(form.getId(), applicant);
fail();
} catch (ClientErrorException e) {
assertEquals(422, e.getResponse().getStatus());
String entity = e.getResponse().readEntity(String.class);
Map<String, Object> parameters = new HashMap<>();
BaseExceptionResponse exceptionResponse = e.getResponse().readEntity(BaseExceptionResponse.class);
Set<IssueDetails> issueDetails = exceptionResponse.getIssueDetails();
IssueDetails detail = issueDetails.iterator().next();
parameters.put("incident_id", detail.getIncidentId());
assertResponseByFixtureTemplate(entity, "fixtures/rfa/validation/applicant-duplicate-phone-numbers-with-extensions-response.json", parameters);
}
}
use of gov.ca.cwds.rest.exception.BaseExceptionResponse in project cals-api by ca-cwds.
the class RFA1aApplicantResourceTest method checkMaxFirstNameSizeTest.
@Test
public void checkMaxFirstNameSizeTest() throws Exception {
try {
ApplicantDTO applicantDTO = getApplicantDTO();
applicantDTO.setFirstName("12345678901234567890x");
RFA1aFormDTO form = formAHelper.createRFA1aForm();
applicantHelper.postApplicant(form.getId(), applicantDTO);
fail();
} catch (ClientErrorException e) {
Map<String, Object> parameters = new HashMap<>();
BaseExceptionResponse exceptionResponse = e.getResponse().readEntity(BaseExceptionResponse.class);
Set<IssueDetails> issueDetails = exceptionResponse.getIssueDetails();
IssueDetails detail = issueDetails.iterator().next();
parameters.put("incident_id", detail.getIncidentId());
parameters.put("property", "firstName");
parameters.put("invalid_value", "12345678901234567890x");
parameters.put("user_message", "12345678901234567890x exceeds maximum length of 20");
checkValidationResponse(e, parameters);
}
}
use of gov.ca.cwds.rest.exception.BaseExceptionResponse in project cals-api by ca-cwds.
the class RFA1aApplicantResourceTest method checkMaxLastNameSizeTest.
@Test
public void checkMaxLastNameSizeTest() throws Exception {
try {
ApplicantDTO applicantDTO = getApplicantDTO();
applicantDTO.setLastName("1234567890123456789012345X");
RFA1aFormDTO form = formAHelper.createRFA1aForm();
applicantHelper.postApplicant(form.getId(), applicantDTO);
fail();
} catch (ClientErrorException e) {
Map<String, Object> parameters = new HashMap<>();
BaseExceptionResponse exceptionResponse = e.getResponse().readEntity(BaseExceptionResponse.class);
Set<IssueDetails> issueDetails = exceptionResponse.getIssueDetails();
IssueDetails detail = issueDetails.iterator().next();
parameters.put("incident_id", detail.getIncidentId());
parameters.put("property", "lastName");
parameters.put("invalid_value", "1234567890123456789012345X");
parameters.put("user_message", "1234567890123456789012345X exceeds maximum length of 25");
checkValidationResponse(e, parameters);
}
}
use of gov.ca.cwds.rest.exception.BaseExceptionResponse in project cals-api by ca-cwds.
the class RFA1aApplicantResourceTest method postDuplicateApplicantFirstNameValidationTest.
@Test
public void postDuplicateApplicantFirstNameValidationTest() throws Exception {
try {
RFA1aFormDTO form = formAHelper.createRFA1aForm();
ApplicantDTO firstApplicant = applicantHelper.postApplicant(form.getId(), getApplicantDTO());
ApplicantDTO secondApplicant = getApplicantDTO();
secondApplicant.setFirstName("differentName");
secondApplicant = applicantHelper.postApplicant(form.getId(), secondApplicant);
secondApplicant.setFirstName(firstApplicant.getFirstName());
putApplicant(form, secondApplicant);
fail();
} catch (ClientErrorException e) {
assertEquals(422, e.getResponse().getStatus());
String entity = e.getResponse().readEntity(String.class);
Map<String, Object> parameters = new HashMap<>();
BaseExceptionResponse exceptionResponse = e.getResponse().readEntity(BaseExceptionResponse.class);
Set<IssueDetails> issueDetails = exceptionResponse.getIssueDetails();
IssueDetails detail = issueDetails.iterator().next();
parameters.put("incident_id", detail.getIncidentId());
assertResponseByFixtureTemplate(entity, "fixtures/rfa/validation/applicant-duplicate-name-violation-response.json", parameters);
}
}
Aggregations