Search in sources :

Example 6 with ReferralClient

use of gov.ca.cwds.data.persistence.cms.ReferralClient in project API by ca-cwds.

the class LACountyTriggerTest method createReferralClientCountyTriggerTest.

/*
   * Test for checking the referralClient county trigger created with the FKClient_T
   */
@SuppressWarnings("javadoc")
@Test
public void createReferralClientCountyTriggerTest() throws JsonParseException, JsonMappingException, IOException {
    when(countyTriggerDao.find(any(String.class))).thenReturn(null);
    gov.ca.cwds.rest.api.domain.cms.ReferralClient validDomainReferralClient = MAPPER.readValue(fixture("fixtures/legacy/business/rules/laCountyTrigger/validReferralClient.json"), gov.ca.cwds.rest.api.domain.cms.ReferralClient.class);
    when(countyTriggerDao.create(any(CountyTrigger.class))).thenAnswer(new Answer<CountyTrigger>() {

        @Override
        public CountyTrigger answer(InvocationOnMock invocation) throws Throwable {
            CountyTrigger report = (CountyTrigger) invocation.getArguments()[0];
            countyTrigger = report;
            return report;
        }
    });
    ReferralClient referralClient = new ReferralClient(validDomainReferralClient, "BTr");
    laCountyTrigger.createCountyTrigger(referralClient);
    assertThat(countyTrigger.getCountyTriggerEmbeddable().getCountyOwnershipT(), is(equalTo("ABC1234567")));
}
Also used : InvocationOnMock(org.mockito.invocation.InvocationOnMock) CountyTrigger(gov.ca.cwds.data.persistence.cms.CountyTrigger) ReferralClient(gov.ca.cwds.data.persistence.cms.ReferralClient) Test(org.junit.Test)

Example 7 with ReferralClient

use of gov.ca.cwds.data.persistence.cms.ReferralClient in project API by ca-cwds.

the class ReferralClientService method create.

@Override
public gov.ca.cwds.rest.api.domain.cms.ReferralClient create(Request request) {
    assert request instanceof gov.ca.cwds.rest.api.domain.cms.ReferralClient;
    gov.ca.cwds.rest.api.domain.cms.ReferralClient referralClient = (gov.ca.cwds.rest.api.domain.cms.ReferralClient) request;
    try {
        String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
        ReferralClient managed = new ReferralClient(referralClient, lastUpdatedId);
        managed = referralClientDao.create(managed);
        // checking the staffPerson county code
        StaffPerson staffperson = staffpersonDao.find(managed.getLastUpdatedId());
        if (staffperson != null && (triggerTablesDao.getLaCountySpecificCode().equals(staffperson.getCountyCode()))) {
            laCountyTrigger.createCountyTrigger(managed);
        } else {
            nonLaTriggers.createAndUpdateReferralClientCoutyOwnership(managed);
        }
        return new gov.ca.cwds.rest.api.domain.cms.ReferralClient(managed);
    } catch (EntityExistsException e) {
        LOGGER.info("Referral Client already exists : {}", referralClient);
        throw new ServiceException(e);
    }
}
Also used : StaffPerson(gov.ca.cwds.data.persistence.cms.StaffPerson) EntityExistsException(javax.persistence.EntityExistsException) ServiceException(gov.ca.cwds.rest.services.ServiceException) ReferralClient(gov.ca.cwds.data.persistence.cms.ReferralClient)

Example 8 with ReferralClient

use of gov.ca.cwds.data.persistence.cms.ReferralClient in project API by ca-cwds.

the class ReferralClientDaoIT method testUpdateEntityNotFoundException.

@Override
@Test
public void testUpdateEntityNotFoundException() throws Exception {
    thrown.expect(EntityNotFoundException.class);
    ReferralClient referralClient = new ReferralClient("ZZuzMKw06s", "AazXkWY06s", "", (short) 122, (short) 681, "S", null, "N", "N", "", (short) 2, "", "", "Y", "N", "N");
    referralClientDao.update(referralClient);
}
Also used : ReferralClient(gov.ca.cwds.data.persistence.cms.ReferralClient) Test(org.junit.Test)

Example 9 with ReferralClient

use of gov.ca.cwds.data.persistence.cms.ReferralClient in project API by ca-cwds.

the class ReferralClientDaoIT method testFindEntityNotFoundException.

@Override
@Test
public void testFindEntityNotFoundException() throws Exception {
    ReferralClient found = referralClientDao.find(new PrimaryKey("ZZZZZZZ999", "XXXXXXX000"));
    assertThat(found, is(nullValue()));
}
Also used : PrimaryKey(gov.ca.cwds.data.persistence.cms.ReferralClient.PrimaryKey) ReferralClient(gov.ca.cwds.data.persistence.cms.ReferralClient) Test(org.junit.Test)

Example 10 with ReferralClient

use of gov.ca.cwds.data.persistence.cms.ReferralClient in project API by ca-cwds.

the class ReferralClientDaoIT method testDelete.

@Override
@Test
public void testDelete() throws Exception {
    ReferralClient delete = referralClientDao.delete(new PrimaryKey("LNuzMKw06s", "AazXkWY06s"));
    assertThat(delete.getClientId(), is("AazXkWY06s"));
    assertThat(delete.getReferralId(), is("LNuzMKw06s"));
}
Also used : PrimaryKey(gov.ca.cwds.data.persistence.cms.ReferralClient.PrimaryKey) ReferralClient(gov.ca.cwds.data.persistence.cms.ReferralClient) Test(org.junit.Test)

Aggregations

ReferralClient (gov.ca.cwds.data.persistence.cms.ReferralClient)13 Test (org.junit.Test)10 PrimaryKey (gov.ca.cwds.data.persistence.cms.ReferralClient.PrimaryKey)4 CountyTrigger (gov.ca.cwds.data.persistence.cms.CountyTrigger)3 StaffPerson (gov.ca.cwds.data.persistence.cms.StaffPerson)2 ServiceException (gov.ca.cwds.rest.services.ServiceException)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Referral (gov.ca.cwds.data.persistence.cms.Referral)1 EntityExistsException (javax.persistence.EntityExistsException)1 EntityNotFoundException (javax.persistence.EntityNotFoundException)1