Search in sources :

Example 11 with CountyTrigger

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

the class CountyTriggerDaoIT method testUpdate.

@Override
@Test
public void testUpdate() throws Exception {
    String timestamp = "2017-05-23 19:53:50.505";
    CountyTriggerEmbeddable countyTriggerEmbeddable = new CountyTriggerEmbeddable(countyOwnershipT, null);
    DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    Date date = formatter.parse(timestamp);
    CountyTrigger countyTrigger = new CountyTrigger(countyOwnershipT, "61", "C", null, "REFR_CLT");
    countyTrigger.getPrimaryKey().setIntegratorTimeStamp(date);
    CountyTrigger updated = countyTriggerDao.update(countyTrigger);
    assertThat(updated, is(countyTrigger));
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) CountyTrigger(gov.ca.cwds.data.persistence.cms.CountyTrigger) CountyTriggerEmbeddable(gov.ca.cwds.data.persistence.cms.CountyTriggerEmbeddable) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test)

Example 12 with CountyTrigger

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

the class CountyTriggerDaoIT method testUpdateEntityNotFoundException.

@Override
@Test
public void testUpdateEntityNotFoundException() throws Exception {
    thrown.expect(EntityNotFoundException.class);
    CountyTrigger countyTrigger = new CountyTrigger("ABC1234569", "61", "C", (Date) null, "REFR_CLT");
    countyTriggerDao.update(countyTrigger);
}
Also used : CountyTrigger(gov.ca.cwds.data.persistence.cms.CountyTrigger) Test(org.junit.Test)

Example 13 with CountyTrigger

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

the class LACountyTriggerTest method createClientAddressCountyTriggerTest.

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

Example 14 with CountyTrigger

use of gov.ca.cwds.data.persistence.cms.CountyTrigger 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 15 with CountyTrigger

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

the class CountyTriggerDaoIT method testCreateExistingEntityException.

@Override
@Test
public void testCreateExistingEntityException() throws Exception {
    thrown.expect(EntityExistsException.class);
    String timestamp = "2017-05-23 19:53:50.597";
    DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    Date date = formatter.parse(timestamp);
    CountyTrigger countyTrigger = new CountyTrigger("Hzfdiu90X5", "62", "C", null, "REFR_CLT");
    countyTrigger.getPrimaryKey().setIntegratorTimeStamp(date);
    countyTriggerDao.create(countyTrigger);
}
Also used : SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) CountyTrigger(gov.ca.cwds.data.persistence.cms.CountyTrigger) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test)

Aggregations

CountyTrigger (gov.ca.cwds.data.persistence.cms.CountyTrigger)17 Test (org.junit.Test)15 InvocationOnMock (org.mockito.invocation.InvocationOnMock)7 CountyTriggerEmbeddable (gov.ca.cwds.data.persistence.cms.CountyTriggerEmbeddable)5 Date (java.util.Date)5 ClientAddress (gov.ca.cwds.data.persistence.cms.ClientAddress)4 DateFormat (java.text.DateFormat)4 SimpleDateFormat (java.text.SimpleDateFormat)4 Referral (gov.ca.cwds.data.persistence.cms.Referral)3 ReferralClient (gov.ca.cwds.data.persistence.cms.ReferralClient)3