use of gov.ca.cwds.cals.service.dto.rfa.collection.CollectionDTO in project cals-api by ca-cwds.
the class LIC198bResourceTest method getExternalEntityApiHelper.
@Override
protected BaseExternalEntityApiHelper<LIC198bFormDTO> getExternalEntityApiHelper() {
TestExternalEntityConfiguration<LIC198bFormDTO> configuration = new TestExternalEntityConfiguration<LIC198bFormDTO>(clientTestRule, LIC198bFormDTO.class, API.LIC_198B_FORMS) {
@Override
protected String getFixture() {
return LIC198B_FORM_FIXTURE;
}
@Override
public GenericType<CollectionDTO<LIC198bFormDTO>> getCollectionDTOGenericType() {
return new GenericType<CollectionDTO<LIC198bFormDTO>>() {
};
}
@Override
public void modifyEntity(LIC198bFormDTO lic198bFormDTO) {
lic198bFormDTO.getIdentifyingData().getPersonName().setFirstName("Petya");
}
};
return new BaseExternalEntityApiHelper<LIC198bFormDTO>(clientTestRule, configuration, formAHelper) {
@Override
public LIC198bFormDTO createEntity(RFA1aFormDTO form) throws IOException {
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());
LIC198bFormDTO entity = configuration.createEntity();
return target.request(MediaType.APPLICATION_JSON).post(Entity.entity(entity, MediaType.APPLICATION_JSON_TYPE), configuration.getEntityClass());
}
};
}
use of gov.ca.cwds.cals.service.dto.rfa.collection.CollectionDTO in project cals-api by ca-cwds.
the class RFA1cResourceTest method getExternalEntityApiHelper.
@Override
protected BaseExternalEntityApiHelper<RFA1cFormDTO> getExternalEntityApiHelper() {
TestExternalEntityConfiguration<RFA1cFormDTO> configuration = new TestExternalEntityConfiguration<RFA1cFormDTO>(clientTestRule, RFA1cFormDTO.class, API.RFA_1C_FORMS) {
@Override
protected String getFixture() {
return FRA1C_FORM_FIXTURE;
}
@Override
public GenericType<CollectionDTO<RFA1cFormDTO>> getCollectionDTOGenericType() {
return new GenericType<CollectionDTO<RFA1cFormDTO>>() {
};
}
@Override
public void modifyEntity(RFA1cFormDTO rfa1cFormDTO) {
CountyType applicationCounty = new CountyType();
applicationCounty.setId(35L);
applicationCounty.setValue("San Benito");
rfa1cFormDTO.setApplicationCounty(applicationCounty);
}
};
return new BaseExternalEntityApiHelper<RFA1cFormDTO>(clientTestRule, configuration, formAHelper) {
@Override
public RFA1cFormDTO createEntity(RFA1aFormDTO form) throws Exception {
RFA1cFormDTO rfa1cFormDTO = super.createEntity(form);
try {
super.createEntity(form);
Assert.fail();
} catch (BadRequestException e) {
// ok
}
return rfa1cFormDTO;
}
@Override
public void getEntitiesByFormId() throws Exception {
}
};
}
use of gov.ca.cwds.cals.service.dto.rfa.collection.CollectionDTO in project cals-api by ca-cwds.
the class RFA1aFormsResourceTest method testApplicationWithParts.
@Test()
public void testApplicationWithParts() throws Exception {
RFA1aFormDTO postFormRequest = clientTestRule.getMapper().readValue(RFA_1A_FIXTURE, RFA1aFormDTO.class);
RFA1aFormDTO postFormResponse = clientTestRule.target(API.RFA_1A_FORMS).request(MediaType.APPLICATION_JSON).post(Entity.entity(postFormRequest, MediaType.APPLICATION_JSON_TYPE), RFA1aFormDTO.class);
Long formId = postFormResponse.getId();
postFormRequest.setId(formId);
assertEqualsResponse(transformDTOtoJSON(postFormRequest), transformDTOtoJSON(postFormResponse));
ApplicantDTO applicantDTO = clientTestRule.target(API.RFA_1A_FORMS + "/" + formId + "/" + API.RFA_1A_APPLICANTS).request(MediaType.APPLICATION_JSON).post(Entity.entity(APPLICANT_FIXTURE, MediaType.APPLICATION_JSON_TYPE), ApplicantDTO.class);
ApplicantDTO applicantDTO2 = clientTestRule.target(API.RFA_1A_FORMS + "/" + formId + "/" + API.RFA_1A_APPLICANTS).request(MediaType.APPLICATION_JSON).post(Entity.entity(APPLICANT_FIXTURE2, MediaType.APPLICATION_JSON_TYPE), ApplicantDTO.class);
ResidenceDTO residenceDTO = clientTestRule.target(API.RFA_1A_FORMS + "/" + formId + "/" + API.RFA_1A_RESIDENCE).request(MediaType.APPLICATION_JSON).put(Entity.entity(RESIDENCE_FIXTURE, MediaType.APPLICATION_JSON_TYPE), ResidenceDTO.class);
ApplicantsRelationshipDTO applicantsRelationshipDTO = clientTestRule.target(API.RFA_1A_FORMS + "/" + formId + "/" + API.RFA_1A_APPLICANTS_RELATIONSHIP).request(MediaType.APPLICATION_JSON).put(Entity.entity(APPLICANTS_RELATIONSHIP_FIXTURE, MediaType.APPLICATION_JSON_TYPE), ApplicantsRelationshipDTO.class);
MinorChildDTO minorChildDTO = clientTestRule.target(API.RFA_1A_FORMS + "/" + formId + "/" + API.RFA_1A_MINOR_CHILDREN).request(MediaType.APPLICATION_JSON).post(Entity.entity(MINOR_CHILDREN_FIXTURE, MediaType.APPLICATION_JSON_TYPE), MinorChildDTO.class);
OtherAdultDTO otherAdultDTO = clientTestRule.target(API.RFA_1A_FORMS + "/" + formId + "/" + API.RFA_1A_OTHER_ADULTS).request(MediaType.APPLICATION_JSON).post(Entity.entity(OTHER_ADULTS_FIXTURE, MediaType.APPLICATION_JSON_TYPE), OtherAdultDTO.class);
ApplicantsHistoryDTO applicantsHistoryDTO = clientTestRule.target(API.RFA_1A_FORMS + "/" + formId + "/" + API.RFA_1A_APPLICANTS_HISTORY).request(MediaType.APPLICATION_JSON).put(Entity.entity(APPLICANTS_HISTORY_FIXTURE, MediaType.APPLICATION_JSON_TYPE), ApplicantsHistoryDTO.class);
ChildDesiredDTO childDesiredDTO = clientTestRule.target(API.RFA_1A_FORMS + "/" + formId + "/" + API.RFA_1A_CHILD_DESIRED).request(MediaType.APPLICATION_JSON).put(Entity.entity(CHILD_DESIRED_FIXTURE, MediaType.APPLICATION_JSON_TYPE), ChildDesiredDTO.class);
AdoptionHistoryDTO adoptionHistoryDTO = clientTestRule.target(API.RFA_1A_FORMS + "/" + formId + "/" + API.RFA_1A_ADOPTION_HISTORY).request(MediaType.APPLICATION_JSON).put(Entity.entity(ADOPTION_HISTORY_FIXTURE, MediaType.APPLICATION_JSON_TYPE), AdoptionHistoryDTO.class);
ReferencesDTO referencesDTO = clientTestRule.target(API.RFA_1A_FORMS + "/" + formId + "/" + API.RFA_1A_REFERENCES).request(MediaType.APPLICATION_JSON).put(Entity.entity(REFERENCES_FIXTURE, MediaType.APPLICATION_JSON_TYPE), ReferencesDTO.class);
ApplicantsDeclarationDTO applicantsDeclarationDTO = clientTestRule.target(API.RFA_1A_FORMS + "/" + formId + "/" + API.RFA_1A_APPLICANTS_DECLARATION).request(MediaType.APPLICATION_JSON).put(Entity.entity(APPLICANTS_DECLARATION_FIXTURE, MediaType.APPLICATION_JSON_TYPE), ApplicantsDeclarationDTO.class);
RFA1aFormDTO getFormResponse = clientTestRule.target(API.RFA_1A_FORMS + "/" + formId).request(MediaType.APPLICATION_JSON).get(RFA1aFormDTO.class);
assertEqualsResponse(transformDTOtoJSON(postFormResponse), transformDTOtoJSON(getFormResponse));
RFA1aFormDTO expectedRfa1aFormDTO = clientTestRule.getMapper().readValue(RFA_1A_FIXTURE, RFA1aFormDTO.class);
expectedRfa1aFormDTO.setId(formId);
List<ApplicantDTO> applicants = new ArrayList<>();
applicants.add(applicantDTO);
applicants.add(applicantDTO2);
expectedRfa1aFormDTO.setApplicants(applicants);
expectedRfa1aFormDTO.setResidence(residenceDTO);
expectedRfa1aFormDTO.setApplicantsRelationship(applicantsRelationshipDTO);
List<MinorChildDTO> minorChildren = new ArrayList<>();
minorChildren.add(minorChildDTO);
expectedRfa1aFormDTO.setMinorChildren(minorChildren);
List<OtherAdultDTO> otherAdults = new ArrayList<>();
otherAdults.add(otherAdultDTO);
expectedRfa1aFormDTO.setOtherAdults(otherAdults);
expectedRfa1aFormDTO.setApplicantsHistory(applicantsHistoryDTO);
expectedRfa1aFormDTO.setChildDesired(childDesiredDTO);
expectedRfa1aFormDTO.setAdoptionHistory(adoptionHistoryDTO);
expectedRfa1aFormDTO.setReferences(referencesDTO);
expectedRfa1aFormDTO.setApplicantsDeclaration(applicantsDeclarationDTO);
RFA1aFormDTO getExpandedFormResponse = clientTestRule.target(API.RFA_1A_FORMS + "/" + formId + "?" + API.QueryParams.EXPANDED + "=true").request(MediaType.APPLICATION_JSON).get(RFA1aFormDTO.class);
assertEqualsResponse(transformDTOtoJSON(expectedRfa1aFormDTO), transformDTOtoJSON(getExpandedFormResponse));
WebTarget getExpandedCollectionTarget = clientTestRule.target(API.RFA_1A_FORMS + "?" + API.QueryParams.EXPANDED + "=true");
CollectionDTO<RFA1aFormDTO> getExpandedCollectionResponseForm = getExpandedCollectionTarget.request(MediaType.APPLICATION_JSON).get(new GenericType<CollectionDTO<RFA1aFormDTO>>() {
});
Collection<RFA1aFormDTO> filtered = getExpandedCollectionResponseForm.getCollection().stream().filter(b -> b.getId().equals(formId)).collect(Collectors.toCollection(ArrayList::new));
getExpandedCollectionResponseForm.getCollection().clear();
getExpandedCollectionResponseForm.getCollection().addAll(filtered);
List<RFA1aFormDTO> items = new ArrayList<>();
items.add(expectedRfa1aFormDTO);
RFA1aFormCollectionDTO expectedExpandedRfa1aFormCollectionResponse = new RFA1aFormCollectionDTO(items);
assertEqualsResponse(transformDTOtoJSON(expectedExpandedRfa1aFormCollectionResponse), transformDTOtoJSON(getExpandedCollectionResponseForm));
}
use of gov.ca.cwds.cals.service.dto.rfa.collection.CollectionDTO 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.collection.CollectionDTO 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