Search in sources :

Example 71 with Client

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

the class DeliveredServiceDaoTest method testFindByChildClientId.

@Test
public void testFindByChildClientId() throws Exception {
    cleanAllAndInsert("/dbunit/Client/update/DeliveredService.xml");
    executeInTransaction(sessionFactory, sessionFactory1 -> {
        Client client = clientDao.find(CLIENT_ID);
        assertNotNull(client);
        assertEquals(CLIENT_ID, client.getIdentifier());
    });
    executeInTransaction(sessionFactory, sessionFactory1 -> {
        List<DeliveredService> deliveredService = deliveredServiceDao.findByClientId(CLIENT_ID);
        assertNotNull(deliveredService);
        assertEquals(1, deliveredService.size());
        assertEquals(CLIENT_ID, deliveredService.get(0).getIndividualId());
    });
}
Also used : DeliveredService(gov.ca.cwds.data.legacy.cms.entity.DeliveredService) Client(gov.ca.cwds.data.legacy.cms.entity.Client) BaseCwsCmsInMemoryPersistenceTest(gov.ca.cwds.data.legacy.cms.persistence.BaseCwsCmsInMemoryPersistenceTest) Test(org.junit.Test)

Example 72 with Client

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

the class DeliveredServiceDaoTest method testFindByWrongChildClientId.

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

Example 73 with Client

use of gov.ca.cwds.data.legacy.cms.entity.Client 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 74 with Client

use of gov.ca.cwds.data.legacy.cms.entity.Client 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)

Example 75 with Client

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

the class ClientAbstractReadAuthorizerTest method clientSameCountySealedTest.

@Test
public void clientSameCountySealedTest() {
    when(clientSensitivityDeterminationService.getClientSensitivityById(CLIENT_ID)).thenReturn(Sensitivity.SEALED);
    when(clientCountyDeterminationService.getClientCountiesById(anyString())).thenReturn(Arrays.asList(new Short[] { 1073, 1126 }));
    final Client client = initClient(Sensitivity.SEALED);
    checkAllCases(client, "1073", "Colusa", false, false, true, false, true);
}
Also used : Client(gov.ca.cwds.data.legacy.cms.entity.Client) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Client (gov.ca.cwds.data.legacy.cms.entity.Client)127 Test (org.junit.Test)105 ChildClientEntityAwareDTO (gov.ca.cwds.cms.data.access.dto.ChildClientEntityAwareDTO)21 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)14 ChildClient (gov.ca.cwds.data.legacy.cms.entity.ChildClient)13 BaseCwsCmsInMemoryPersistenceTest (gov.ca.cwds.data.legacy.cms.persistence.BaseCwsCmsInMemoryPersistenceTest)10 DasHistory (gov.ca.cwds.data.legacy.cms.entity.DasHistory)6 SafetyAlert (gov.ca.cwds.data.legacy.cms.entity.SafetyAlert)6 SchoolOriginHistory (gov.ca.cwds.data.legacy.cms.entity.SchoolOriginHistory)6 ClientOtherEthnicity (gov.ca.cwds.data.legacy.cms.entity.ClientOtherEthnicity)4 NameType (gov.ca.cwds.data.legacy.cms.entity.syscodes.NameType)4 Session (org.hibernate.Session)4 Timestamp (java.sql.Timestamp)3 DeliveredService (gov.ca.cwds.data.legacy.cms.entity.DeliveredService)2 OptimisticLockException (javax.persistence.OptimisticLockException)2 IDataSet (org.dbunit.dataset.IDataSet)2 ITable (org.dbunit.dataset.ITable)2 ClientConditionUtils.toClientCondition (gov.ca.cwds.authorizer.util.ClientConditionUtils.toClientCondition)1 FacilityChildParameterObject (gov.ca.cwds.cals.web.rest.parameter.FacilityChildParameterObject)1 ClientEntityAwareDTO (gov.ca.cwds.cms.data.access.dto.ClientEntityAwareDTO)1