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