Search in sources :

Example 1 with TestExternalEntityConfiguration

use of gov.ca.cwds.cals.web.rest.rfa.configuration.TestExternalEntityConfiguration 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());
        }
    };
}
Also used : GenericType(javax.ws.rs.core.GenericType) LIC198bFormDTO(gov.ca.cwds.cals.service.dto.rfa.lic198b.LIC198bFormDTO) RFA1aFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO) CollectionDTO(gov.ca.cwds.cals.service.dto.rfa.collection.CollectionDTO) ApplicantDTO(gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO) WebTarget(javax.ws.rs.client.WebTarget) TestExternalEntityConfiguration(gov.ca.cwds.cals.web.rest.rfa.configuration.TestExternalEntityConfiguration)

Example 2 with TestExternalEntityConfiguration

use of gov.ca.cwds.cals.web.rest.rfa.configuration.TestExternalEntityConfiguration 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 {
        }
    };
}
Also used : GenericType(javax.ws.rs.core.GenericType) RFA1cFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1cFormDTO) RFA1aFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO) BadRequestException(javax.ws.rs.BadRequestException) CollectionDTO(gov.ca.cwds.cals.service.dto.rfa.collection.CollectionDTO) CountyType(gov.ca.cwds.cals.persistence.model.calsns.dictionaries.CountyType) TestExternalEntityConfiguration(gov.ca.cwds.cals.web.rest.rfa.configuration.TestExternalEntityConfiguration)

Example 3 with TestExternalEntityConfiguration

use of gov.ca.cwds.cals.web.rest.rfa.configuration.TestExternalEntityConfiguration 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 {
        }
    };
}
Also used : GenericType(javax.ws.rs.core.GenericType) RFA1bFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1bFormDTO) RFA1aFormDTO(gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO) CollectionDTO(gov.ca.cwds.cals.service.dto.rfa.collection.CollectionDTO) ApplicantDTO(gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO) WebTarget(javax.ws.rs.client.WebTarget) TestExternalEntityConfiguration(gov.ca.cwds.cals.web.rest.rfa.configuration.TestExternalEntityConfiguration)

Aggregations

RFA1aFormDTO (gov.ca.cwds.cals.service.dto.rfa.RFA1aFormDTO)3 CollectionDTO (gov.ca.cwds.cals.service.dto.rfa.collection.CollectionDTO)3 TestExternalEntityConfiguration (gov.ca.cwds.cals.web.rest.rfa.configuration.TestExternalEntityConfiguration)3 GenericType (javax.ws.rs.core.GenericType)3 ApplicantDTO (gov.ca.cwds.cals.service.dto.rfa.ApplicantDTO)2 WebTarget (javax.ws.rs.client.WebTarget)2 CountyType (gov.ca.cwds.cals.persistence.model.calsns.dictionaries.CountyType)1 RFA1bFormDTO (gov.ca.cwds.cals.service.dto.rfa.RFA1bFormDTO)1 RFA1cFormDTO (gov.ca.cwds.cals.service.dto.rfa.RFA1cFormDTO)1 LIC198bFormDTO (gov.ca.cwds.cals.service.dto.rfa.lic198b.LIC198bFormDTO)1 BadRequestException (javax.ws.rs.BadRequestException)1