use of gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO 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.RFA1aFormDTO 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.RFA1aFormDTO in project cals-api by ca-cwds.
the class BaseExternalEntityApiHelper method getEntitiesByFormId.
public void getEntitiesByFormId() throws Exception {
RFA1aFormDTO form = helper.createRFA1aForm();
createEntity(form);
createEntity(form);
createEntity(form);
WebTarget target = clientTestRule.target(API.RFA_1A_FORMS + "/" + form.getId() + "/" + configuration.getApiPath());
CollectionDTO<T> entityCollectionDTO = target.request(MediaType.APPLICATION_JSON).get(configuration.getCollectionDTOGenericType());
assertThat(entityCollectionDTO.getCollection().size()).isEqualTo(3);
}
use of gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO in project cals-api by ca-cwds.
the class BaseExternalEntityApiHelper method deleteEntity.
public void deleteEntity() throws Exception {
RFA1aFormDTO form = helper.createRFA1aForm();
T created = createEntity(form);
Long createdEntityId = created.getId();
T found = findEntity(form, createdEntityId);
Long foundId = found.getId();
assertThat(found).isEqualTo(created);
WebTarget target = clientTestRule.target(API.RFA_1A_FORMS + "/" + form.getId() + "/" + configuration.getApiPath() + "/" + foundId);
Response response = target.request(MediaType.APPLICATION_JSON).delete();
assertThat(response.getStatus()).isEqualTo(200);
response = target.request(MediaType.APPLICATION_JSON).delete();
assertThat(response.getStatus()).isEqualTo(404);
}
use of gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO in project cals-api by ca-cwds.
the class BaseExternalEntityApiHelper method updateEntity.
public void updateEntity() throws Exception {
RFA1aFormDTO form = helper.createRFA1aForm();
T created = createEntity(form);
Long createdEntityId = created.getId();
T found = findEntity(form, createdEntityId);
configuration.modifyEntity(found);
WebTarget target = clientTestRule.target(API.RFA_1A_FORMS + "/" + form.getId() + "/" + configuration.getApiPath() + "/" + createdEntityId);
T updated = target.request(MediaType.APPLICATION_JSON).put(Entity.entity(found, MediaType.APPLICATION_JSON_TYPE), configuration.getEntityClass());
found = findEntity(form, createdEntityId);
assertThat(found).isEqualTo(updated);
assertThat(found).isNotEqualTo(created);
}
Aggregations