use of gov.ca.cwds.data.legacy.cms.entity.ChildClient in project api-core by ca-cwds.
the class R00743Test method testSecondaryLanguagesEmpty.
@Test
public void testSecondaryLanguagesEmpty() throws DroolsException {
ChildClient client = new ChildClient();
client.setPrimaryLanguageCode((short) 12);
client.setSecondaryLanguageCode((short) 0);
checkRuleSatisfied(client, RULE_NAME);
}
use of gov.ca.cwds.data.legacy.cms.entity.ChildClient in project api-core by ca-cwds.
the class R02761Test method createClient.
private static ChildClient createClient() {
ChildClient client = new ChildClient();
client.setBirthDate(DEFAULT_BIRTHDATE);
client.setIdentifier(CLIENT_IDENTIFIER);
return client;
}
use of gov.ca.cwds.data.legacy.cms.entity.ChildClient in project api-core by ca-cwds.
the class R02761Test method initClient.
@Before
public void initClient() {
ChildClient client = createClient();
clientEntityAwareDTO.setEntity(client);
}
use of gov.ca.cwds.data.legacy.cms.entity.ChildClient in project api-core by ca-cwds.
the class OptimisticLockingTest method testClientLastUpdatedTimeUpdatesdAutomatically.
@Test
public void testClientLastUpdatedTimeUpdatesdAutomatically() throws Exception {
cleanAllAndInsert("/dbunit/OptimisticLocking.xml");
final ChildClientHolder childClientHolder = new ChildClientHolder();
executeInTransaction(sessionFactory, (sessionFactory) -> {
Client client = dao.find(ID);
assertNotNull(client);
assertTrue(client instanceof ChildClient);
ChildClient childClient = (ChildClient) client;
childClientHolder.setChildClient(childClient);
Timestamp lastUpdateTime = childClient.getLastUpdateTime();
assertNotNull(lastUpdateTime);
assertEquals(new Short((short) 0), childClient.getAdoptedAge());
// Change child client specific field and assure that Client timestamp changes
childClient.setAdoptedAge((short) 10);
dao.update(client);
Session session = sessionFactory.getCurrentSession();
session.flush();
Timestamp newLastUpdateTime = childClient.getLastUpdateTime();
assertNotNull(newLastUpdateTime);
assertFalse(lastUpdateTime.equals(newLastUpdateTime));
assertTrue((newLastUpdateTime.toLocalDateTime()).isAfter(lastUpdateTime.toLocalDateTime()));
// Check if Client timestamp changes when otherEthnicities collection changes
Set<ClientOtherEthnicity> otherEthnicities = childClient.getOtherEthnicities();
assertEquals(1, otherEthnicities.size());
ClientOtherEthnicity otherEthnicity = otherEthnicities.iterator().next();
assertEquals(5922, otherEthnicity.getEthnicityCode());
// Should increase Client timestamp but does not work
session.lock(childClient, LockMode.OPTIMISTIC_FORCE_INCREMENT);
ClientOtherEthnicity otherEthnicity2 = new ClientOtherEthnicity();
otherEthnicity2.setEthnicityCode((short) 5923);
otherEthnicity2.setId("BaoNM5i00J");
otherEthnicity2.setLastUpdateTime(LocalDateTime.now());
otherEthnicity2.setLastUpdateId("04Z");
childClient.addOtherEthnicity(otherEthnicity2);
dao.update(client);
});
executeInTransaction(sessionFactory, (sessionFactory) -> {
ChildClient oldChildClient = childClientHolder.getChildClient();
Timestamp oldLastUpdateTime = oldChildClient.getLastUpdateTime();
Client client = dao.find(ID);
assertNotNull(client);
assertTrue(client instanceof ChildClient);
ChildClient childClient = (ChildClient) client;
Timestamp lastUpdateTime = childClient.getLastUpdateTime();
assertNotNull(lastUpdateTime);
// changes in otherEthnicities collection DOES NOT change Client timestamp
assertTrue(oldLastUpdateTime.equals(lastUpdateTime));
});
}
use of gov.ca.cwds.data.legacy.cms.entity.ChildClient in project api-core by ca-cwds.
the class OptimisticLockingTest method testUpdateSuccess.
@Test
public void testUpdateSuccess() 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;
assertEquals(AdoptionStatus.NOT_FREE, childClient.getAdoptionStatus());
Timestamp lastUpdateTime = childClient.getLastUpdateTime();
assertNotNull(lastUpdateTime);
childClientHolder.setChildClient(childClient);
});
// UI edit
childClientHolder.getChildClient().setAdoptionStatus(AdoptionStatus.NOT_APPLICABLE);
// persist in new transaction
executeInTransaction(sessionFactory, (sessionFactory) -> {
dao.update(childClientHolder.getChildClient());
});
}
Aggregations