Search in sources :

Example 1 with Referral

use of gov.ca.cwds.data.persistence.cms.Referral 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)

Example 2 with Referral

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

the class ReferralDaoIT method testFind.

@Override
@Test
public void testFind() throws Exception {
    String id = "AbiQCgu0Hj";
    Referral found = referralDao.find(id);
    assertThat(found.getId(), is(id));
}
Also used : Referral(gov.ca.cwds.data.persistence.cms.Referral) Test(org.junit.Test)

Example 3 with Referral

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

the class ReferralDaoIT method testUpdate.

@Override
@Test
public void testUpdate() throws Exception {
    Referral referral = new Referral("AbiQCgu0Hj", " ", "N", "N", "D5YRVOm0Ht", (short) 122, " ", (Date) null, (short) 409, "", "", "L3H7sSC0Ht", "", "N", "N", (short) 1118, " ", "N", "N", (Date) null, "Verification (R3)", " ", (Date) null, (Date) null, (short) 1520, (short) 0, (Date) null, (Date) null, "", "", " ", " ", " ", "", "", "0Ht", "0Ht", "51", "N", "N", "N", "N", (Date) null, "C", (short) 0, (Date) null, "", (Date) null, null, null, null, null);
    Referral updated = referralDao.update(referral);
    assertThat(updated, is(referral));
}
Also used : Referral(gov.ca.cwds.data.persistence.cms.Referral) Test(org.junit.Test)

Example 4 with Referral

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

the class ReferralDaoIT method testDelete.

@Override
@Test
public void testDelete() throws Exception {
    String id = "AbiQCgu0Hj";
    Referral deleted = referralDao.delete(id);
    assertThat(deleted.getId(), is(id));
}
Also used : Referral(gov.ca.cwds.data.persistence.cms.Referral) Test(org.junit.Test)

Example 5 with Referral

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

the class LACountyTriggerTest method createReferralCountyTriggerTest.

/*
   * Test for checking the referral county trigger created with the FKAddress_T
   */
@SuppressWarnings("javadoc")
@Test
public void createReferralCountyTriggerTest() throws JsonParseException, JsonMappingException, IOException {
    when(countyTriggerDao.find(any(String.class))).thenReturn(null);
    gov.ca.cwds.rest.api.domain.cms.Referral validDomainReferral = MAPPER.readValue(fixture("fixtures/legacy/business/rules/laCountyTrigger/validReferral.json"), gov.ca.cwds.rest.api.domain.cms.Referral.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;
        }
    });
    Referral referral = new Referral("ABC1234567", validDomainReferral, "BTr");
    laCountyTrigger.createCountyTrigger(referral);
    assertThat(countyTrigger.getCountyTriggerEmbeddable().getCountyOwnershipT(), is(equalTo("1234567ABC")));
}
Also used : Referral(gov.ca.cwds.data.persistence.cms.Referral) InvocationOnMock(org.mockito.invocation.InvocationOnMock) CountyTrigger(gov.ca.cwds.data.persistence.cms.CountyTrigger) Test(org.junit.Test)

Aggregations

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