use of gov.ca.cwds.data.legacy.cms.entity.ClientRelationship in project api-core by ca-cwds.
the class ClientRelationshipDaoTest method testFindRelationshipsByClientId.
@Test
public void testFindRelationshipsByClientId() throws Exception {
cleanAllAndInsert("/dbunit/ClientsRelationships.xml");
executeInTransaction(sessionFactory, (sessionFactory) -> {
final LocalDate CURRENT_DATE = LocalDate.of(2018, 1, 18);
List<ClientRelationship> rghtRels = dao.findRelationshipsBySecondaryClientId("AaiU7IW0Rt", CURRENT_DATE);
assertEquals(3, rghtRels.size());
Map<String, ClientRelationship> relMap = rghtRels.stream().collect(Collectors.toMap(clientRelationship -> clientRelationship.getPrimaryClient().getIdentifier(), clientRelationship -> clientRelationship));
assertTrue(relMap.containsKey("AasRx3r0Ha"));
assertTrue(relMap.containsKey("AazXkWY06s"));
assertTrue(relMap.containsKey("AfGN4uS0CR"));
// both dates are NULL
ClientRelationship rel0 = relMap.get("AasRx3r0Ha");
assertEquals("AaiU7IW0Rt", rel0.getSecondaryClient().getIdentifier());
assertEquals("AasRx3r0Ha", rel0.getPrimaryClient().getIdentifier());
assertFalse(rel0.getAbsentParentIndicator());
assertEquals(YesNoUnknown.YES, rel0.getSameHomeStatus());
ClientRelationshipType relType0 = rel0.getType();
assertEquals((short) 276, relType0.getPrimaryKey());
assertEquals("Sister/Brother", relType0.getShortDescription());
// both dates are not null
ClientRelationship rel1 = relMap.get("AazXkWY06s");
assertEquals("AaiU7IW0Rt", rel1.getSecondaryClient().getIdentifier());
assertEquals("AazXkWY06s", rel1.getPrimaryClient().getIdentifier());
assertTrue(rel1.getAbsentParentIndicator());
assertEquals(YesNoUnknown.NO, rel1.getSameHomeStatus());
ClientRelationshipType relType1 = rel1.getType();
assertEquals((short) 190, relType1.getPrimaryKey());
assertEquals("Daughter/Father (Birth)", relType1.getShortDescription());
// start date is null, end date greater than current date
ClientRelationship rel2 = relMap.get("AfGN4uS0CR");
assertEquals("AaiU7IW0Rt", rel2.getSecondaryClient().getIdentifier());
assertEquals("AfGN4uS0CR", rel2.getPrimaryClient().getIdentifier());
assertFalse(rel2.getAbsentParentIndicator());
assertEquals(YesNoUnknown.NO, rel2.getSameHomeStatus());
ClientRelationshipType relType2 = rel2.getType();
assertEquals((short) 301, relType2.getPrimaryKey());
assertEquals("Ward/Guardian", relType2.getShortDescription());
// the same relation is taken from the right side
List<ClientRelationship> leftRels = dao.findRelationshipsByPrimaryClientId("AasRx3r0Ha", CURRENT_DATE);
assertEquals(1, leftRels.size());
ClientRelationship relR0 = leftRels.get(0);
assertEquals(rel0, relR0);
// no relations when take them from left side by right side id
List<ClientRelationship> rightRels2 = dao.findRelationshipsBySecondaryClientId("AasRx3r0Ha", CURRENT_DATE);
assertEquals(0, rightRels2.size());
// relation is not taken into account if its type is inactive
List<ClientRelationship> rightRels3 = dao.findRelationshipsBySecondaryClientId("AapJGAU04Z", CURRENT_DATE);
assertEquals(0, rightRels3.size());
});
}
use of gov.ca.cwds.data.legacy.cms.entity.ClientRelationship in project api-core by ca-cwds.
the class R00755Test method testStartDateNull.
@Test
public void testStartDateNull() throws Exception {
LocalDate date = LocalDate.of(2003, 03, 01);
ClientRelationship entity = getClientRelationship(null, date);
awareDTO.setEntity(entity);
checkRuleSatisfied(RULE_NAME);
}
use of gov.ca.cwds.data.legacy.cms.entity.ClientRelationship in project api-core by ca-cwds.
the class R00755Test method startDateAndDateNull.
@Test
public void startDateAndDateNull() throws Exception {
LocalDate date = LocalDate.of(2003, 03, 01);
ClientRelationship entity = getClientRelationship(null, null);
awareDTO.setEntity(entity);
checkRuleSatisfied(RULE_NAME);
}
use of gov.ca.cwds.data.legacy.cms.entity.ClientRelationship in project api-core by ca-cwds.
the class R00755Test method testStartDateEndDate.
@Test
public void testStartDateEndDate() throws Exception {
LocalDate date = LocalDate.of(2003, 03, 01);
ClientRelationship entity = getClientRelationship(date, date);
awareDTO.setEntity(entity);
checkRuleSatisfied(RULE_NAME);
}
use of gov.ca.cwds.data.legacy.cms.entity.ClientRelationship in project api-core by ca-cwds.
the class R00753Test method overlap2.
/**
* @throws DroolsException
*
* x-------------x
* x------------x
*/
@Test
public void overlap2() throws DroolsException {
LocalDate localDateStartA = LocalDate.of(2001, 11, 11);
LocalDate localDateEndA = LocalDate.of(2020, 11, 11);
ClientRelationship entity = getRelationship(localDateStartA, localDateEndA);
awareDTO.setEntity(entity);
List<ClientRelationship> relationships = new ArrayList<>();
ClientRelationship overlapRelationship1 = getRelationship(localDateStartA.minusYears(1), localDateEndA.minusYears(1));
relationships.add(overlapRelationship1);
relationships.add(getRelationship(localDateStartA.minusYears(3), localDateStartA.minusYears(2)));
relationships.add(getRelationship(localDateEndA.plusYears(3), localDateEndA.plusYears(4)));
awareDTO.getClientRelationshipList().addAll(relationships);
checkRuleViolatedOnce(RULE_NAME);
}
Aggregations