Search in sources :

Example 6 with ClientRelationship

use of gov.ca.cwds.data.legacy.cms.entity.ClientRelationship in project api-core by ca-cwds.

the class R00753Test method overlap3.

/**
 * @throws DroolsException
 *
 *      x-------------x
 *      x-------------x
 */
@Test
public void overlap3() 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, localDateEndA);
    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);
}
Also used : ArrayList(java.util.ArrayList) ClientRelationship(gov.ca.cwds.data.legacy.cms.entity.ClientRelationship) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 7 with ClientRelationship

use of gov.ca.cwds.data.legacy.cms.entity.ClientRelationship in project api-core by ca-cwds.

the class R00753Test method overlap4.

/**
 * @throws DroolsException
 *     <p>x-------------x
 *          x--------x
 */
@Test
public void overlap4() 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(2), localDateEndA.minusYears(2));
    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);
}
Also used : ArrayList(java.util.ArrayList) ClientRelationship(gov.ca.cwds.data.legacy.cms.entity.ClientRelationship) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 8 with ClientRelationship

use of gov.ca.cwds.data.legacy.cms.entity.ClientRelationship in project api-core by ca-cwds.

the class R00753Test method noOverlap2.

/**
 * @throws DroolsException
 *          x-------------x
 *  x-----x
 */
@Test
public void noOverlap2() 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(4), localDateStartA.minusDays(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);
    checkRuleSatisfied(RULE_NAME);
}
Also used : ArrayList(java.util.ArrayList) ClientRelationship(gov.ca.cwds.data.legacy.cms.entity.ClientRelationship) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 9 with ClientRelationship

use of gov.ca.cwds.data.legacy.cms.entity.ClientRelationship in project api-core by ca-cwds.

the class R00753Test method overlap5.

/**
 * @throws DroolsException
 *
 *         x-------------x
 *   x-----x
 */
@Test
public void overlap5() 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(2), localDateStartA);
    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);
}
Also used : ArrayList(java.util.ArrayList) ClientRelationship(gov.ca.cwds.data.legacy.cms.entity.ClientRelationship) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Example 10 with ClientRelationship

use of gov.ca.cwds.data.legacy.cms.entity.ClientRelationship in project api-core by ca-cwds.

the class R00753Test method overlap1.

/**
 * @throws DroolsException
 *
 *      x-------------x
 *        x-------------x
 */
@Test
public void overlap1() 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.plusYears(1), localDateEndA.plusYears(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);
}
Also used : ArrayList(java.util.ArrayList) ClientRelationship(gov.ca.cwds.data.legacy.cms.entity.ClientRelationship) LocalDate(java.time.LocalDate) Test(org.junit.Test)

Aggregations

ClientRelationship (gov.ca.cwds.data.legacy.cms.entity.ClientRelationship)19 Test (org.junit.Test)15 LocalDate (java.time.LocalDate)13 ArrayList (java.util.ArrayList)8 Client (gov.ca.cwds.data.legacy.cms.entity.Client)1 YesNoUnknown (gov.ca.cwds.data.legacy.cms.entity.enums.YesNoUnknown)1 ClientRelationshipType (gov.ca.cwds.data.legacy.cms.entity.syscodes.ClientRelationshipType)1 BaseCwsCmsInMemoryPersistenceTest (gov.ca.cwds.data.legacy.cms.persistence.BaseCwsCmsInMemoryPersistenceTest)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 TestCase.assertTrue (junit.framework.TestCase.assertTrue)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertFalse (org.junit.Assert.assertFalse)1 Before (org.junit.Before)1