Search in sources :

Example 1 with ReferralClient

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

the class ReferralClientService method update.

@Override
public gov.ca.cwds.rest.api.domain.cms.ReferralClient update(Serializable primaryKeyObject, 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 {
        ReferralClient managed = new ReferralClient(referralClient, "BTr");
        // 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 (EntityNotFoundException e) {
        LOGGER.info("Referral not found : {}", referralClient);
        LOGGER.error(e.getMessage(), e);
        throw new ServiceException(e);
    }
}
Also used : StaffPerson(gov.ca.cwds.data.persistence.cms.StaffPerson) ServiceException(gov.ca.cwds.rest.services.ServiceException) EntityNotFoundException(javax.persistence.EntityNotFoundException) ReferralClient(gov.ca.cwds.data.persistence.cms.ReferralClient)

Example 2 with ReferralClient

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

the class ReferralClientDaoIT method testCreateExistingEntityException.

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

Example 3 with ReferralClient

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

the class ReferralClientDaoIT method testUpdate.

@Override
@Test
public void testUpdate() throws Exception {
    ReferralClient referralClient = new ReferralClient("LNuzMKw06s", "AazXkWY06s", "", (short) 122, (short) 681, "S", null, "N", "N", "", (short) 2, "", "", "Y", "N", "N");
    ReferralClient updated = referralClientDao.update(referralClient);
    assertThat(updated, is(referralClient));
}
Also used : ReferralClient(gov.ca.cwds.data.persistence.cms.ReferralClient) Test(org.junit.Test)

Example 4 with ReferralClient

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

the class LACountyTriggerTest method referralClientFkClientIdNullTest.

/*
   * Test for checking referralClient county trigger not created as FkClient_T is null
   */
@SuppressWarnings("javadoc")
@Test
public void referralClientFkClientIdNullTest() 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/referralClientFkClientTIdNull.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, is(equalTo(null)));
}
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 5 with ReferralClient

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

the class LACountyTrigger method createCountyTrigger.

/**
   * @param object The object creates the county Trigger for the Referral and referralClient
   * @return the countyTrigger created
   */
public boolean createCountyTrigger(Object object) {
    Referral referral;
    ReferralClient referralClient;
    if (object instanceof Referral) {
        referral = (Referral) object;
        if (referral.getAllegesAbuseOccurredAtAddressId() != "" && referral.getAllegesAbuseOccurredAtAddressId() != null) {
            CountyTrigger countyTrigger = new CountyTrigger(referral.getAllegesAbuseOccurredAtAddressId(), referral.getCountySpecificCode(), ADDRESS_COUNTYOWNERSHIP, null, Referral.class.getDeclaredAnnotation(Table.class).name());
            countyTriggerDao.create(countyTrigger);
            LOGGER.info("LA county referral address triggered");
        }
    }
    if (object instanceof ReferralClient) {
        referralClient = (ReferralClient) object;
        if (referralClient.getClientId() != "" && referralClient.getClientId() != null) {
            CountyTrigger countyTrigger = new CountyTrigger(referralClient.getClientId(), referralClient.getCountySpecificCode(), CLIENT_COUNTYOWNERSHIP, null, ReferralClient.class.getDeclaredAnnotation(Table.class).name());
            countyTriggerDao.create(countyTrigger);
            LOGGER.info("LA county referralClient triggered");
        }
    }
    return true;
}
Also used : Referral(gov.ca.cwds.data.persistence.cms.Referral) CountyTrigger(gov.ca.cwds.data.persistence.cms.CountyTrigger) ReferralClient(gov.ca.cwds.data.persistence.cms.ReferralClient)

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