use of gov.ca.cwds.data.legacy.cms.entity.ClientOtherEthnicity in project api-core by ca-cwds.
the class R00742Test method createListOfDifferentClientOtherEthnicities.
private static List<ClientOtherEthnicity> createListOfDifferentClientOtherEthnicities(Client client) {
List<ClientOtherEthnicity> clientScpEthnicityList = new ArrayList<>();
ClientOtherEthnicity clientScpEthnicity1 = createClientOtherEthnicity(client, (short) 3162);
ClientOtherEthnicity clientScpEthnicity2 = createClientOtherEthnicity(client, (short) 3163);
ClientOtherEthnicity clientScpEthnicity3 = createClientOtherEthnicity(client, (short) 0);
clientScpEthnicityList.addAll(Arrays.asList(clientScpEthnicity1, clientScpEthnicity2, clientScpEthnicity3));
return clientScpEthnicityList;
}
use of gov.ca.cwds.data.legacy.cms.entity.ClientOtherEthnicity in project api-core by ca-cwds.
the class R00742Test method testValidListofEthnicities.
@Test
public void testValidListofEthnicities() throws Exception {
Client client = new Client();
client.setIdentifier(CLIENT_IDENTIFIER);
client.setPrimaryEthnicityCode((short) 1);
clientEntityAwareDTO.setEntity(client);
List<ClientOtherEthnicity> clientScpEthnicityList = createListOfDifferentClientOtherEthnicities(client);
clientEntityAwareDTO.getOtherEthnicities().addAll(clientScpEthnicityList);
checkRuleSatisfied(RULE_NAME);
}
use of gov.ca.cwds.data.legacy.cms.entity.ClientOtherEthnicity 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.ClientOtherEthnicity in project api-core by ca-cwds.
the class ClientOtherEthnicitiesTest method testFindEthnicitiesByClient.
@Test
public void testFindEthnicitiesByClient() throws Exception {
cleanAllAndInsert("/dbunit/ClientOtherEthnicities.xml");
executeInTransaction(sessionFactory, (sessionFactory) -> {
Session session = sessionFactory.getCurrentSession();
Client client1 = session.load(Client.class, "05gLqgG10R");
Set<ClientOtherEthnicity> result1 = client1.getOtherEthnicities();
assertNotNull(result1);
assertTrue(result1.size() == 2);
Client client2 = session.load(Client.class, "fG5y8Sdg3F");
Set<ClientOtherEthnicity> result2 = client2.getOtherEthnicities();
assertNotNull(result2);
assertTrue(result2.size() == 0);
});
}
use of gov.ca.cwds.data.legacy.cms.entity.ClientOtherEthnicity in project api-core by ca-cwds.
the class R00742Test method testOtherEthnicityPresentWhenNoPrimary.
@Test
public void testOtherEthnicityPresentWhenNoPrimary() throws Exception {
Client client = new Client();
client.setIdentifier(CLIENT_IDENTIFIER);
client.setPrimaryEthnicityCode((short) 0);
clientEntityAwareDTO.setEntity(client);
List<ClientOtherEthnicity> clientScpEthnicityList = createListOfDifferentClientOtherEthnicities(client);
clientEntityAwareDTO.getOtherEthnicities().addAll(clientScpEthnicityList);
checkRuleViolatedOnce(RULE_NAME);
}
Aggregations