Search in sources :

Example 1 with CountyTrigger

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

Example 2 with CountyTrigger

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

the class LACountyTriggerTest method clientAddressfkAddressIdNullTest.

/*
   * Test for checking clientAddress county trigger not created as FkAddress_T is null
   */
@SuppressWarnings("javadoc")
@Test
public void clientAddressfkAddressIdNullTest() 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/fkAddressTNull.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("ABC1234567", validDomainClientAddress, "BTr");
    laCountyTrigger.createClientAddressCountyTrigger(clientAddress);
    assertThat(countyTrigger, is(equalTo(null)));
}
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 3 with CountyTrigger

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

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

the class LACountyTriggerTest method clientAddressfkclientIdNullTest.

/*
   * Test for checking clientAddress county trigger not created as FkClient_T is null
   */
@SuppressWarnings("javadoc")
@Test
public void clientAddressfkclientIdNullTest() 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/fkClientTNull.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("ABC1234567", validDomainClientAddress, "BTr");
    laCountyTrigger.createClientAddressCountyTrigger(clientAddress);
    assertThat(countyTrigger, is(equalTo(null)));
}
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 5 with CountyTrigger

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

the class LACountyTriggerTest method referralFkAddresssIdNullTest.

/*
   * Test for checking referral county trigger not created as FkAddress_T is null
   */
@SuppressWarnings("javadoc")
@Test
public void referralFkAddresssIdNullTest() 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/allegesAbuseOccurredAtAddressIdNull.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, is(equalTo(null)));
}
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

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