use of gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO in project cals-api by ca-cwds.
the class RFA1aApplicantResourceTest method testDuplicatePhoneNumbersButExtension.
@Test
public void testDuplicatePhoneNumbersButExtension() throws Exception {
RFA1aFormDTO form = formAHelper.createRFA1aForm();
ApplicantDTO applicant = getApplicantDTO();
applicant.getPhones().clear();
applicant.getPhones().add(createPhone());
applicant.getPhones().add(createPhoneNoExtension());
assertNoSuchError(() -> applicantHelper.postApplicant(form.getId(), applicant), APPLICANT_PHONE_NUMBERS_DUPLICATION);
}
use of gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO in project cals-api by ca-cwds.
the class RFA1aApplicantResourceTest method moreThenOnePreferredNumberInApplicantValidationTest.
@Test
public void moreThenOnePreferredNumberInApplicantValidationTest() throws Exception {
RFA1aFormDTO form = formAHelper.createRFA1aForm();
ApplicantDTO applicant = getApplicantDTO();
applicant.getPhones().forEach(p -> p.setPreferred(true));
try {
applicant = 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-more-then-one-preferred-number-response.json", parameters);
}
// Update test
applicant.getPhones().forEach(p -> p.setPreferred(false));
applicant = applicantHelper.postApplicant(form.getId(), applicant);
try {
applicant.getPhones().forEach(p -> p.setPreferred(true));
putApplicant(form, 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-more-then-one-preferred-number-response.json", parameters);
}
}
use of gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO in project cals-api by ca-cwds.
the class RFA1bResourceTest method getExternalEntityApiHelper.
@Override
protected BaseExternalEntityApiHelper<RFA1bFormDTO> getExternalEntityApiHelper() {
TestExternalEntityConfiguration<RFA1bFormDTO> configuration = new TestExternalEntityConfiguration<RFA1bFormDTO>(clientTestRule, RFA1bFormDTO.class, API.RFA_1B_FORMS) {
@Override
protected String getFixture() {
return RFA1B_FORM_FIXTURE;
}
@Override
public GenericType<CollectionDTO<RFA1bFormDTO>> getCollectionDTOGenericType() {
return new GenericType<CollectionDTO<RFA1bFormDTO>>() {
};
}
@Override
public void modifyEntity(RFA1bFormDTO rfa1bFormDTO) {
rfa1bFormDTO.setApplicantFirstName("Petya");
}
};
return new BaseExternalEntityApiHelper<RFA1bFormDTO>(clientTestRule, configuration, formAHelper) {
@Override
public RFA1bFormDTO createEntity(RFA1aFormDTO form) throws Exception {
ApplicantDTO applicantDTO = applicantHelper.getFirstExistedOrPostNewApplicant(form.getId(), applicantHelper.getValidApplicant());
WebTarget target = clientTestRule.target(API.RFA_1A_FORMS + "/" + form.getId() + "/" + configuration.getApiPath() + "/" + API.RFA_1A_APPLICANTS + "/" + applicantDTO.getId());
RFA1bFormDTO entity = configuration.createEntity();
return target.request(MediaType.APPLICATION_JSON).post(Entity.entity(entity, MediaType.APPLICATION_JSON_TYPE), configuration.getEntityClass());
}
public void getEntitiesByFormId() throws Exception {
}
};
}
use of gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO in project cals-api by ca-cwds.
the class RFA1bResourceTest method getRFA1bFormApplicantTest.
@Test
public void getRFA1bFormApplicantTest() throws Exception {
RFA1aFormDTO form1a = formAHelper.createRFA1aForm();
RFA1bFormDTO created = getExternalEntityApiHelper().createEntity(form1a);
ApplicantDTO applicantDTO = applicantHelper.getFirstExistedOrPostNewApplicant(form1a.getId(), applicantHelper.getValidApplicant());
WebTarget target = clientTestRule.target(API.RFA_1A_FORMS + "/" + form1a.getId() + "/" + getExternalEntityApiHelper().getConfiguration().getApiPath() + "/" + API.RFA_1A_APPLICANTS + "/" + applicantDTO.getId());
RFA1bFormDTO found = target.request().get(RFA1bFormDTO.class);
assertThat(found).isEqualTo(created);
}
use of gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO in project cals-api by ca-cwds.
the class ApplicantHelper method getFirstApplicant.
public ApplicantDTO getFirstApplicant(long formId) {
Response response = clientTestRule.target(API.RFA_1A_FORMS + "/" + formId + "/" + API.RFA_1A_APPLICANTS).request(MediaType.APPLICATION_JSON).get();
ApplicantDTO applicantDTO = null;
if (response.getStatus() == 200) {
GenericType<CollectionDTO<ApplicantDTO>> genericType = new GenericType<CollectionDTO<ApplicantDTO>>() {
};
CollectionDTO<ApplicantDTO> applicants = response.readEntity(genericType);
if (applicants != null && !applicants.getCollection().isEmpty()) {
applicantDTO = applicants.getCollection().iterator().next();
}
}
return applicantDTO;
}
Aggregations