Search in sources :

Example 21 with ChildClient

use of gov.ca.cwds.data.legacy.cms.entity.ChildClient in project api-core by ca-cwds.

the class R11126Test method testInValidListOfEligibilities.

@Test
public void testInValidListOfEligibilities() throws Exception {
    ChildClient client = createClient(CLIENT_BIRTH_DAY);
    clientEntityAwareDTO.setEntity(client);
    List<FCEligibility> fcEligibilities = createListOfInvalidChildClientEligibilities();
    clientEntityAwareDTO.getFcEligibilities().addAll(fcEligibilities);
    checkRuleViolatedOnce(RULE_NAME);
}
Also used : FCEligibility(gov.ca.cwds.data.legacy.cms.entity.FCEligibility) ChildClient(gov.ca.cwds.data.legacy.cms.entity.ChildClient) Test(org.junit.Test)

Example 22 with ChildClient

use of gov.ca.cwds.data.legacy.cms.entity.ChildClient in project api-core by ca-cwds.

the class FCEligibilityDaoTest method testFindByWrongChildClientId.

@Test
public void testFindByWrongChildClientId() throws Exception {
    cleanAllAndInsert("/dbunit/Client/update/FCEligibility.xml");
    executeInTransaction(sessionFactory, sessionFactory1 -> {
        ChildClient childClient = (ChildClient) clientDao.find(WRONG_CHILD_CLIENT_ID);
        assertNull(childClient);
    });
    executeInTransaction(sessionFactory, sessionFactory1 -> {
        List<FCEligibility> fcEligibilities = fcEligibilityDao.findByChildClientId(WRONG_CHILD_CLIENT_ID);
        assertNotNull(fcEligibilities);
        assertEquals(0, fcEligibilities.size());
    });
}
Also used : FCEligibility(gov.ca.cwds.data.legacy.cms.entity.FCEligibility) ChildClient(gov.ca.cwds.data.legacy.cms.entity.ChildClient) BaseCwsCmsInMemoryPersistenceTest(gov.ca.cwds.data.legacy.cms.persistence.BaseCwsCmsInMemoryPersistenceTest) Test(org.junit.Test)

Example 23 with ChildClient

use of gov.ca.cwds.data.legacy.cms.entity.ChildClient in project api-core by ca-cwds.

the class FCEligibilityDaoTest method testFindByChildClientId.

@Test
public void testFindByChildClientId() throws Exception {
    cleanAllAndInsert("/dbunit/Client/update/FCEligibility.xml");
    executeInTransaction(sessionFactory, sessionFactory1 -> {
        ChildClient childClient = (ChildClient) clientDao.find(CHILD_CLIENT_ID);
        assertNotNull(childClient);
        assertEquals(true, childClient.getAfdcFcEligibilityIndicatorVar());
        assertEquals(CHILD_CLIENT_ID, childClient.getVictimClientId());
    });
    executeInTransaction(sessionFactory, sessionFactory1 -> {
        List<FCEligibility> fcEligibilities = fcEligibilityDao.findByChildClientId(CHILD_CLIENT_ID);
        assertNotNull(fcEligibilities);
        assertEquals(1, fcEligibilities.size());
        assertEquals(CHILD_CLIENT_ID, fcEligibilities.get(0).getChildClientId());
    });
}
Also used : FCEligibility(gov.ca.cwds.data.legacy.cms.entity.FCEligibility) ChildClient(gov.ca.cwds.data.legacy.cms.entity.ChildClient) BaseCwsCmsInMemoryPersistenceTest(gov.ca.cwds.data.legacy.cms.persistence.BaseCwsCmsInMemoryPersistenceTest) Test(org.junit.Test)

Example 24 with ChildClient

use of gov.ca.cwds.data.legacy.cms.entity.ChildClient in project api-core by ca-cwds.

the class OptimisticLockingTest method testUpdateWithStaleData.

@Test
public void testUpdateWithStaleData() throws Exception {
    cleanAllAndInsert("/dbunit/OptimisticLocking.xml");
    final ChildClientHolder childClientHolder = new ChildClientHolder();
    // read entity from DB
    executeInTransaction(sessionFactory, (sessionFactory) -> {
        Client client = dao.find(ID);
        assertNotNull(client);
        assertTrue(client instanceof ChildClient);
        ChildClient childClient = (ChildClient) client;
        Timestamp lastUpdateTime = childClient.getLastUpdateTime();
        assertNotNull(lastUpdateTime);
        assertEquals(AdoptionStatus.NOT_FREE, childClient.getAdoptionStatus());
        childClientHolder.setChildClient(childClient);
    });
    // update DB in other transaction
    executeInTransaction(sessionFactory, (sessionFactory) -> {
        Client client = dao.find(ID);
        assertNotNull(client);
        assertTrue(client instanceof ChildClient);
        ChildClient childClient = (ChildClient) client;
        childClient.setAdoptionStatus(AdoptionStatus.PARTIALLY_FREE);
        dao.update(childClient);
    });
    // UI edit
    childClientHolder.getChildClient().setAdoptionStatus(AdoptionStatus.TOTALLY_FREE);
    // recreate entity and attempt to persist
    try {
        executeInTransaction(sessionFactory, (sessionFactory) -> {
            dao.update(childClientHolder.getChildClient());
        });
        fail("OptimisticLockException should be thrown");
    } catch (OptimisticLockException e) {
    }
}
Also used : OptimisticLockException(javax.persistence.OptimisticLockException) ChildClient(gov.ca.cwds.data.legacy.cms.entity.ChildClient) Client(gov.ca.cwds.data.legacy.cms.entity.Client) Timestamp(java.sql.Timestamp) ChildClient(gov.ca.cwds.data.legacy.cms.entity.ChildClient) Test(org.junit.Test) BaseCwsCmsInMemoryPersistenceTest(gov.ca.cwds.data.legacy.cms.persistence.BaseCwsCmsInMemoryPersistenceTest)

Example 25 with ChildClient

use of gov.ca.cwds.data.legacy.cms.entity.ChildClient in project api-core by ca-cwds.

the class ClientDaoTest method testFind.

@Test
public void testFind() throws Exception {
    cleanAllAndInsert("/dbunit/Client/find/Clients.xml");
    executeInTransaction(sessionFactory, (sessionFactory) -> {
        Client client_1 = dao.find("AaiU7IW0Rt");
        assertNotNull(client_1);
        assertFalse(client_1.getAdjudicatedDelinquentIndicator());
        assertNull(client_1.getHispanicUnableToDetermineReason());
        assertTrue(client_1.getBirthStateCode() == 0);
        assertTrue(client_1.getBirthCountryCode() == 0);
        assertTrue(client_1.getDriverLicenseStateCode() == 0);
        assertTrue(client_1.getImmigrationCountryCode() == 0);
        assertTrue(client_1.getImmigrationStatusCode() == 0);
        assertTrue(client_1.getReligionCode() == 0);
        assertTrue(client_1.getPrimaryLanguageCode() == 0);
        assertTrue(client_1.getSecondaryLanguageCode() == 0);
        assertTrue(client_1.getMaritalStatusCode() == 0);
        assertTrue(client_1.getPrimaryEthnicityCode() == 0);
        Client client_2 = dao.find("AapJGAU04Z");
        assertNotNull(client_2);
        assertTrue(client_2 instanceof ChildClient);
        assertTrue(client_2.getAdjudicatedDelinquentIndicator());
        Client client_3 = dao.find("AasRx3r0Ha");
        assertNotNull(client_3);
        assertNull(client_3.getAdjudicatedDelinquentIndicator());
        Client client_4 = dao.find("AazXkWY06s");
        assertNotNull(client_4);
        assertNull(client_4.getAdjudicatedDelinquentIndicator());
    });
}
Also used : ChildClient(gov.ca.cwds.data.legacy.cms.entity.ChildClient) Client(gov.ca.cwds.data.legacy.cms.entity.Client) ChildClient(gov.ca.cwds.data.legacy.cms.entity.ChildClient) Test(org.junit.Test) BaseCwsCmsInMemoryPersistenceTest(gov.ca.cwds.data.legacy.cms.persistence.BaseCwsCmsInMemoryPersistenceTest)

Aggregations

ChildClient (gov.ca.cwds.data.legacy.cms.entity.ChildClient)42 Test (org.junit.Test)32 BaseCwsCmsInMemoryPersistenceTest (gov.ca.cwds.data.legacy.cms.persistence.BaseCwsCmsInMemoryPersistenceTest)7 Client (gov.ca.cwds.data.legacy.cms.entity.Client)5 FCEligibility (gov.ca.cwds.data.legacy.cms.entity.FCEligibility)3 Timestamp (java.sql.Timestamp)3 OptimisticLockException (javax.persistence.OptimisticLockException)2 Session (org.hibernate.Session)2 Before (org.junit.Before)2 ClientOtherEthnicity (gov.ca.cwds.data.legacy.cms.entity.ClientOtherEthnicity)1 MedicalEligibilityApplication (gov.ca.cwds.data.legacy.cms.entity.MedicalEligibilityApplication)1