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());
});
}
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());
});
}
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) {
}
}
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());
});
}
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);
}
Aggregations