Search in sources :

Example 6 with CountyOwnership

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

the class NonLACountyTriggersTest method testChecksReferralClientCreatedCountyOwnership.

/*
   * Test for checking the referral Client CountyOnwership created or updated through the PUT method
   */
@SuppressWarnings("javadoc")
@Test
public void testChecksReferralClientCreatedCountyOwnership() throws Exception {
    ReferralClient referralClientDomain = MAPPER.readValue(fixture("fixtures/legacy/business/rules/nonLaCountyTrigger/referralClientValid.json"), ReferralClient.class);
    gov.ca.cwds.data.persistence.cms.ReferralClient toCreate = new gov.ca.cwds.data.persistence.cms.ReferralClient(referralClientDomain, "ABC");
    ReferralClient request = new ReferralClient(toCreate);
    when(countyOwnershipDao.find(any(String.class))).thenReturn(null);
    when(countyOwnershipDao.create(any(CountyOwnership.class))).thenAnswer(new Answer<CountyOwnership>() {

        @Override
        public CountyOwnership answer(InvocationOnMock invocation) throws Throwable {
            CountyOwnership report = (CountyOwnership) invocation.getArguments()[0];
            countyOwnership = report;
            return report;
        }
    });
    nonLaCountyTriggers.createAndUpdateReferralClientCoutyOwnership(toCreate);
    Assert.assertNotNull(countyOwnership);
    assertThat(countyOwnership.getEntityCode(), is(equalTo("C")));
}
Also used : CountyOwnership(gov.ca.cwds.data.persistence.cms.CountyOwnership) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ReferralClient(gov.ca.cwds.rest.api.domain.cms.ReferralClient) Test(org.junit.Test)

Example 7 with CountyOwnership

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

the class NonLACountyTriggersTest method testForReferralClientUpdatedCountyOwnership.

/*
   * Test for checking the referral Client CountyOnwership updated
   */
@SuppressWarnings("javadoc")
@Test
public void testForReferralClientUpdatedCountyOwnership() throws Exception {
    ReferralClient referralClientDomain = MAPPER.readValue(fixture("fixtures/legacy/business/rules/nonLaCountyTrigger/referralClientValid.json"), ReferralClient.class);
    gov.ca.cwds.data.persistence.cms.ReferralClient toCreate = new gov.ca.cwds.data.persistence.cms.ReferralClient(referralClientDomain, "ABC");
    ReferralClient request = new ReferralClient(toCreate);
    when(countyOwnershipDao.find(any(String.class))).thenReturn(new CountyOwnership());
    when(countyOwnershipDao.update(any(CountyOwnership.class))).thenAnswer(new Answer<CountyOwnership>() {

        @Override
        public CountyOwnership answer(InvocationOnMock invocation) throws Throwable {
            CountyOwnership report = (CountyOwnership) invocation.getArguments()[0];
            countyOwnership = report;
            return report;
        }
    });
    nonLaCountyTriggers.createAndUpdateReferralClientCoutyOwnership(toCreate);
    Assert.assertNotNull(countyOwnership);
    assertThat(countyOwnership.getCounty62Flag(), is(equalTo("Y")));
}
Also used : CountyOwnership(gov.ca.cwds.data.persistence.cms.CountyOwnership) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ReferralClient(gov.ca.cwds.rest.api.domain.cms.ReferralClient) Test(org.junit.Test)

Example 8 with CountyOwnership

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

the class NonLACountyTriggersTest method testForClientCreatedCountyOwnershipTest.

/*
   * Test for checking the Client CountyOnwership created
   */
@SuppressWarnings("javadoc")
@Test
public void testForClientCreatedCountyOwnershipTest() throws Exception {
    gov.ca.cwds.rest.api.domain.cms.Client ClientDomain = MAPPER.readValue(fixture("fixtures/legacy/business/rules/nonLaCountyTrigger/clientValid.json"), gov.ca.cwds.rest.api.domain.cms.Client.class);
    Client toCreate = new Client("ABC1234567", ClientDomain, "ABC");
    when(countyOwnershipDao.create(any(CountyOwnership.class))).thenAnswer(new Answer<CountyOwnership>() {

        @Override
        public CountyOwnership answer(InvocationOnMock invocation) throws Throwable {
            CountyOwnership report = (CountyOwnership) invocation.getArguments()[0];
            countyOwnership = report;
            return report;
        }
    });
    nonLaCountyTriggers.createClientCountyTrigger(toCreate);
    Assert.assertNotNull(countyOwnership);
    assertThat(countyOwnership.getEntityCode(), is(equalTo("C")));
}
Also used : CountyOwnership(gov.ca.cwds.data.persistence.cms.CountyOwnership) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Client(gov.ca.cwds.data.persistence.cms.Client) ReferralClient(gov.ca.cwds.rest.api.domain.cms.ReferralClient) Test(org.junit.Test)

Example 9 with CountyOwnership

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

the class CountyOwnershipDaoIT method testDeleteEntityNotFoundException.

@Override
@Test
public void testDeleteEntityNotFoundException() throws Exception {
    String id = "ABC1234568";
    CountyOwnership deleted = countyOwnershipDao.delete(id);
    assertThat(deleted, is(nullValue()));
}
Also used : CountyOwnership(gov.ca.cwds.data.persistence.cms.CountyOwnership) Test(org.junit.Test)

Example 10 with CountyOwnership

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

the class CountyOwnershipDaoIT method testCreateExistingEntityException.

@Override
@Test
public void testCreateExistingEntityException() throws Exception {
    thrown.expect(EntityExistsException.class);
    CountyOwnership countyOwnership = new CountyOwnership("AaQshqm0Mb", "C", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", null);
    countyOwnershipDao.create(countyOwnership);
}
Also used : CountyOwnership(gov.ca.cwds.data.persistence.cms.CountyOwnership) Test(org.junit.Test)

Aggregations

CountyOwnership (gov.ca.cwds.data.persistence.cms.CountyOwnership)13 Test (org.junit.Test)10 ReferralClient (gov.ca.cwds.rest.api.domain.cms.ReferralClient)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 Client (gov.ca.cwds.data.persistence.cms.Client)1 TriggerTableException (gov.ca.cwds.data.rules.TriggerTableException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1