Search in sources :

Example 1 with SCPEntityAwareDTO

use of gov.ca.cwds.cms.data.access.dto.SCPEntityAwareDTO in project api-core by ca-cwds.

the class SubstituteCareProviderServiceImplTest method createValidatePhoneNumberNotPersisted.

@Test
public void createValidatePhoneNumberNotPersisted() throws Exception {
    try {
        SubstituteCareProviderCoreService service = new SubstituteCareProviderCoreService(mock(SubstituteCareProviderDao.class));
        SubstituteCareProvider scp = new SubstituteCareProvider();
        SCPEntityAwareDTO parameterObject = new SCPEntityAwareDTO();
        parameterObject.setEntity(scp);
        List<PhoneContactDetail> phoneNumbers = new ArrayList<>();
        PhoneContactDetail phoneContactDetail = new PhoneContactDetail();
        phoneContactDetail.setThirdId("1");
        phoneNumbers.add(phoneContactDetail);
        parameterObject.setPhoneNumbers(phoneNumbers);
        service.create(parameterObject);
        fail();
    } catch (IllegalStateException e) {
        assertEquals(String.format(ParametersValidator.INSTANCE_MUST_NOT_BE_PERSISTED, PhoneContactDetail.class.getSimpleName()), e.getMessage());
    }
}
Also used : PhoneContactDetail(gov.ca.cwds.data.legacy.cms.entity.PhoneContactDetail) SubstituteCareProviderDao(gov.ca.cwds.cms.data.access.dao.SubstituteCareProviderDao) SubstituteCareProviderCoreService(gov.ca.cwds.cms.data.access.service.impl.SubstituteCareProviderCoreService) ArrayList(java.util.ArrayList) SCPEntityAwareDTO(gov.ca.cwds.cms.data.access.dto.SCPEntityAwareDTO) SubstituteCareProvider(gov.ca.cwds.data.legacy.cms.entity.SubstituteCareProvider) Test(org.junit.Test)

Example 2 with SCPEntityAwareDTO

use of gov.ca.cwds.cms.data.access.dto.SCPEntityAwareDTO in project cals-api by ca-cwds.

the class PlacementHomeEntityAwareDTOBuilder method buildSubstituteCareProviderParameterObject.

private SCPEntityAwareDTO buildSubstituteCareProviderParameterObject(RFA1aFormDTO form, ApplicantDTO applicant) {
    SCPEntityAwareDTO entityAwareDTO = new SCPEntityAwareDTO();
    entityAwareDTO.setPrimaryApplicant(Applicant.isPrimary(form, applicant));
    entityAwareDTO.setPhoneNumbers(mapPhoneContactDetails(applicant));
    entityAwareDTO.setEthnicityList(Arrays.asList(applicant.getEthnicity()));
    entityAwareDTO.setOtherStatesOfLiving(applicant.getRfa1bForm().getOtherStatesOfLiving());
    SubstituteCareProvider substituteCareProvider = mapRFAEntitiesToSCP(applicant);
    entityAwareDTO.setEntity(substituteCareProvider);
    return entityAwareDTO;
}
Also used : SCPEntityAwareDTO(gov.ca.cwds.cms.data.access.dto.SCPEntityAwareDTO)

Example 3 with SCPEntityAwareDTO

use of gov.ca.cwds.cms.data.access.dto.SCPEntityAwareDTO in project api-core by ca-cwds.

the class R07045Test method testRule.

@Test
public void testRule() throws Exception {
    PowerMockito.mockStatic(IdGenerator.class);
    when(IdGenerator.generateId()).thenReturn("1q2w3e4r");
    PowerMockito.mockStatic(PrincipalUtils.class);
    when(PrincipalUtils.getStaffPersonId()).thenReturn("0X5");
    SCPEntityAwareDTO scpEntityAwareDTO = new SCPEntityAwareDTO();
    scpEntityAwareDTO.setEntity(new SubstituteCareProvider());
    // 2 ethnicity was added
    scpEntityAwareDTO.setEthnicityList(Arrays.asList(mock(CWSIdentifier.class), mock(CWSIdentifier.class)));
    SubstituteCareProvider substituteCareProvider = scpService.create(scpEntityAwareDTO);
    // expecting 2 ethnicity to
    verify(mockedEthnicityDao, times(2)).create(any());
}
Also used : SCPEntityAwareDTO(gov.ca.cwds.cms.data.access.dto.SCPEntityAwareDTO) SubstituteCareProvider(gov.ca.cwds.data.legacy.cms.entity.SubstituteCareProvider) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with SCPEntityAwareDTO

use of gov.ca.cwds.cms.data.access.dto.SCPEntityAwareDTO in project api-core by ca-cwds.

the class SubstituteCareProviderServiceImplTest method createValidateScpNotPersistent.

@Test
public void createValidateScpNotPersistent() throws Exception {
    try {
        SubstituteCareProviderCoreService service = new SubstituteCareProviderCoreService(mock(SubstituteCareProviderDao.class));
        SubstituteCareProvider scp = new SubstituteCareProvider();
        scp.setIdentifier("1");
        SCPEntityAwareDTO parameterObject = new SCPEntityAwareDTO();
        parameterObject.setEntity(scp);
        service.create(parameterObject);
        fail();
    } catch (IllegalStateException e) {
        assertEquals(String.format(ParametersValidator.INSTANCE_MUST_NOT_BE_PERSISTED, SubstituteCareProvider.class.getSimpleName()), e.getMessage());
    }
}
Also used : SubstituteCareProviderDao(gov.ca.cwds.cms.data.access.dao.SubstituteCareProviderDao) SubstituteCareProviderCoreService(gov.ca.cwds.cms.data.access.service.impl.SubstituteCareProviderCoreService) SCPEntityAwareDTO(gov.ca.cwds.cms.data.access.dto.SCPEntityAwareDTO) SubstituteCareProvider(gov.ca.cwds.data.legacy.cms.entity.SubstituteCareProvider) Test(org.junit.Test)

Example 5 with SCPEntityAwareDTO

use of gov.ca.cwds.cms.data.access.dto.SCPEntityAwareDTO in project api-core by ca-cwds.

the class BaseDocToolRulesSubstituteCareProviderTest method setUp.

@Before
public void setUp() {
    businessValidationService = new BusinessValidationService(droolsService);
    SCPEntityAwareDTO scpEntityAwareDTO = new SCPEntityAwareDTO();
    entityAwareDTO = new ExtendedSCPEntityAwareDTO(scpEntityAwareDTO);
    PlacementHomeInformation placementHomeInformation = new PlacementHomeInformation();
    entityAwareDTO.setPlacementHomeInformation(placementHomeInformation);
    scpService = new SubstituteCareProviderCoreService(mock(SubstituteCareProviderDao.class));
    entityAwareDTO.setEntity(new SubstituteCareProvider());
}
Also used : SubstituteCareProviderCoreService(gov.ca.cwds.cms.data.access.service.impl.SubstituteCareProviderCoreService) SCPEntityAwareDTO(gov.ca.cwds.cms.data.access.dto.SCPEntityAwareDTO) ExtendedSCPEntityAwareDTO(gov.ca.cwds.cms.data.access.dto.ExtendedSCPEntityAwareDTO) BusinessValidationService(gov.ca.cwds.cms.data.access.service.BusinessValidationService) ExtendedSCPEntityAwareDTO(gov.ca.cwds.cms.data.access.dto.ExtendedSCPEntityAwareDTO) PlacementHomeInformation(gov.ca.cwds.data.legacy.cms.entity.PlacementHomeInformation) SubstituteCareProvider(gov.ca.cwds.data.legacy.cms.entity.SubstituteCareProvider) Before(org.junit.Before)

Aggregations

SCPEntityAwareDTO (gov.ca.cwds.cms.data.access.dto.SCPEntityAwareDTO)7 SubstituteCareProvider (gov.ca.cwds.data.legacy.cms.entity.SubstituteCareProvider)5 SubstituteCareProviderDao (gov.ca.cwds.cms.data.access.dao.SubstituteCareProviderDao)3 SubstituteCareProviderCoreService (gov.ca.cwds.cms.data.access.service.impl.SubstituteCareProviderCoreService)3 Test (org.junit.Test)3 ExtendedSCPEntityAwareDTO (gov.ca.cwds.cms.data.access.dto.ExtendedSCPEntityAwareDTO)2 BusinessValidationService (gov.ca.cwds.cms.data.access.service.BusinessValidationService)2 PhoneContactDetail (gov.ca.cwds.data.legacy.cms.entity.PhoneContactDetail)2 PlacementHomeInformation (gov.ca.cwds.data.legacy.cms.entity.PlacementHomeInformation)2 Inject (com.google.inject.Inject)1 CWSIdentifier (gov.ca.cwds.cms.data.access.CWSIdentifier)1 Constants (gov.ca.cwds.cms.data.access.Constants)1 PhoneticSearchTables (gov.ca.cwds.cms.data.access.Constants.PhoneticSearchTables)1 CountyOwnershipDao (gov.ca.cwds.cms.data.access.dao.CountyOwnershipDao)1 OutOfStateCheckDao (gov.ca.cwds.cms.data.access.dao.OutOfStateCheckDao)1 PhoneContactDetailDao (gov.ca.cwds.cms.data.access.dao.PhoneContactDetailDao)1 PlacementHomeInformationDao (gov.ca.cwds.cms.data.access.dao.PlacementHomeInformationDao)1 ScpOtherEthnicityDao (gov.ca.cwds.cms.data.access.dao.ScpOtherEthnicityDao)1 SsaName3Dao (gov.ca.cwds.cms.data.access.dao.SsaName3Dao)1 SubstituteCareProviderUcDao (gov.ca.cwds.cms.data.access.dao.SubstituteCareProviderUcDao)1