/** Test case for 'HouseholdUnits' attribute. Test Class: FamilyOfMissingHouseholdCalculator */
  public void testHouseholdUnit() {
    final long caseParticipantRoleID = 11L;
    final long participantRoleID = 111L;
    final long caseID = 111L;
    final String Name = "Client_Name";

    createPersonRecord(
        participantRoleID,
        Name,
        Date.fromISO8601("20110615"),
        Date.kZeroDate,
        GENDER.FEMALE,
        MARITALSTATUS.SINGLE);
    final CaseParticipantRole caseParticipantRole =
        createCaseParticipantRoleRecord(
            caseID, caseParticipantRoleID, participantRoleID, CASEPARTICIPANTROLETYPE.PRIMARY);
    createConcernRoleRecord(participantRoleID, Name);
    SAHouseholdUnitMember householdUnitMember = createASAHouseholdUnitMember(caseParticipantRole);
    List<SAHouseholdUnitMember> saHouseholdUnitMembers = new ArrayList<SAHouseholdUnitMember>();
    saHouseholdUnitMembers.add(householdUnitMember);

    SAHouseholdUnitCalculator saHouseholdUnit =
        SAHouseholdUnitCalculator_Factory.getFactory().newInstance(getSession());
    saHouseholdUnit.mandatoryMembers().specifyValue(saHouseholdUnitMembers);
  }
  public void testtotalCountableIncomeTimeline1() {
    final Number caseID = 1111L;
    final List<CaseParticipantRole> caseParticipantRoleList = createCaseParticipantRole();
    final List<SAHouseholdUnitMember> saHouseholdUnitMemberList =
        createSAHouseholdUnitMember(caseParticipantRoleList);

    final SAHouseholdUnitCalculator saHouseholdUnitCalculator =
        SAHouseholdUnitCalculator_Factory.getFactory().newInstance(getSession());
    saHouseholdUnitCalculator.mandatoryMembers().specifyValue(saHouseholdUnitMemberList);
    final List<Interval<Number>> amount = new ArrayList<Interval<Number>>();
    amount.add(new Interval<Number>(null, 0));
    amount.add(new Interval<Number>(Date.fromISO8601("20040601"), 3000));
    final Timeline<Number> amountTimeline = new Timeline<Number>(amount);

    final List<Interval<Number>> amount2 = new ArrayList<Interval<Number>>();
    amount2.add(new Interval<Number>(null, 0));
    amount2.add(new Interval<Number>(Date.fromISO8601("20040601"), 4000));
    final Timeline<Number> amount2Timeline = new Timeline<Number>(amount2);

    final List<Interval<Number>> amount3 = new ArrayList<Interval<Number>>();
    amount3.add(new Interval<Number>(null, 0));
    amount3.add(new Interval<Number>(Date.fromISO8601("20040601"), 0));
    final Timeline<Number> amount3Timeline = new Timeline<Number>(amount3);

    final FamilyOfMissingEligibilityUnitCalculator familyOfMissingObj =
        FamilyOfMissingEligibilityUnitCalculator_Factory.getFactory()
            .newInstance(getSession(), caseID, saHouseholdUnitCalculator);
    familyOfMissingObj.caseID().specifyValue(caseID);
    familyOfMissingObj.unearnedIncomeAmount().specifyValue(amountTimeline);
    familyOfMissingObj.totalExpenseAmountTimeline().specifyValue(amount2Timeline);
    CREOLETestHelper.assertEquals(
        amount3Timeline, familyOfMissingObj.totalCountableIncomeTimeline().getValue());
  }
  public void testhasHouseholdPassedIncomeTestTimeline1() {
    final Number caseID = 1111L;
    final List<CaseParticipantRole> caseParticipantRoleList = createCaseParticipantRole();
    final List<SAHouseholdUnitMember> saHouseholdUnitMemberList =
        createSAHouseholdUnitMember(caseParticipantRoleList);

    final SAHouseholdUnitCalculator saHouseholdUnitCalculator =
        SAHouseholdUnitCalculator_Factory.getFactory().newInstance(getSession());
    saHouseholdUnitCalculator.mandatoryMembers().specifyValue(saHouseholdUnitMemberList);

    final List<Interval<Number>> amount = new ArrayList<Interval<Number>>();
    amount.add(new Interval<Number>(null, 1000));
    amount.add(new Interval<Number>(Date.fromISO8601("20040601"), 6000));
    final Timeline<Number> amountTimeline = new Timeline<Number>(amount);

    final List<Interval<Number>> amount2 = new ArrayList<Interval<Number>>();
    amount2.add(new Interval<Number>(null, 0));
    amount2.add(new Interval<Number>(Date.fromISO8601("20040601"), 1000));
    final Timeline<Number> amount2Timeline = new Timeline<Number>(amount2);

    final List<Interval<Boolean>> result = new ArrayList<Interval<Boolean>>();
    result.add(new Interval<Boolean>(null, false));
    result.add(new Interval<Boolean>(Date.fromISO8601("20040601"), false));
    final Timeline<Boolean> resultTimeline = new Timeline<Boolean>(result);

    final FamilyOfMissingEligibilityUnitCalculator familyOfMissingObj =
        FamilyOfMissingEligibilityUnitCalculator_Factory.getFactory()
            .newInstance(getSession(), caseID, saHouseholdUnitCalculator);
    familyOfMissingObj.caseID().specifyValue(caseID);
    familyOfMissingObj.totalCountableIncomeTimeline().specifyValue(amountTimeline);
    familyOfMissingObj.primaryBeneficiaryAmount().specifyValue(amount2Timeline);
    CREOLETestHelper.assertEquals(
        resultTimeline, familyOfMissingObj.hasHouseholdPassedIncomeTestTimeline().getValue());
  }
  public void testisEligibleWifeTimeline1() {
    final Number caseID = 1111L;
    final List<CaseParticipantRole> caseParticipantRoleList = createCaseParticipantRole();
    final List<SAHouseholdUnitMember> saHouseholdUnitMemberList =
        createSAHouseholdUnitMember(caseParticipantRoleList);

    final SAHouseholdUnitCalculator saHouseholdUnitCalculator =
        SAHouseholdUnitCalculator_Factory.getFactory().newInstance(getSession());
    saHouseholdUnitCalculator.mandatoryMembers().specifyValue(saHouseholdUnitMemberList);

    MemberCPRCalculator memberCPRCalculatorobj =
        MemberCPRCalculator_Factory.getFactory()
            .newInstance(getSession(), caseParticipantRoleList.get(0));
    memberCPRCalculatorobj.caseParticipantRoleRecord().specifyValue(caseParticipantRoleList.get(0));
    memberCPRCalculatorobj.hasEarnedIncomeTimeline().specifyValue(Timeline.FALSE_FOREVER);

    final FamilyOfMissingCPRCalculator familyOfMissingCPRCalculatorObj =
        FamilyOfMissingCPRCalculator_Factory.getFactory()
            .newInstance(getSession(), caseParticipantRoleList.get(0));

    familyOfMissingCPRCalculatorObj
        .caseParticipantRoleRecord()
        .specifyValue(caseParticipantRoleList.get(0));
    familyOfMissingCPRCalculatorObj.isFemaleTimeline().specifyValue(Timeline.FALSE_FOREVER);
    familyOfMissingCPRCalculatorObj.isMarriedTimeline().specifyValue(Timeline.TRUE_FOREVER);
    familyOfMissingCPRCalculatorObj.memberCPRCalculator().specifyValue(memberCPRCalculatorobj);

    final List<Interval<CodeTableItem>> test1 = new ArrayList<Interval<CodeTableItem>>();
    test1.add(
        new Interval<CodeTableItem>(
            null, new CodeTableItem(CITIZENSHIPCODE.TABLENAME, CITIZENSHIPCODE.QATARI)));
    final Timeline<CodeTableItem> firstTimeline = new Timeline<CodeTableItem>(test1);

    final List<Interval<CodeTableItem>> test11 = new ArrayList<Interval<CodeTableItem>>();
    test11.add(
        new Interval<CodeTableItem>(null, new CodeTableItem(RESIDENCY.TABLENAME, RESIDENCY.YES)));
    final Timeline<CodeTableItem> first1Timeline = new Timeline<CodeTableItem>(test11);

    HouseholdMember hh = HouseholdMember_Factory.getFactory().newInstance(getSession());
    hh.exists().specifyValue(Timeline.TRUE_FOREVER);
    hh.caseID().specifyValue(caseID);
    hh.citizenship().specifyValue(firstTimeline);
    hh.residency().specifyValue(first1Timeline);
    hh.participant()
        .specifyValue(caseParticipantRoleList.get(0).caseParticipantRoleID().getValue());

    final SANonFinancialCPRCalculator testObj =
        SANonFinancialCPRCalculator_Factory.getFactory()
            .newInstance(getSession(), caseParticipantRoleList.get(0));
    testObj.caseParticipantRoleRecord().specifyValue(caseParticipantRoleList.get(0));
    testObj.hasPassedNonFinancialTestTimeline().specifyValue(Timeline.TRUE_FOREVER);
    testObj.householdMemberRecord().specifyValue(hh);

    CREOLETestHelper.assertEquals(
        Timeline.FALSE_FOREVER,
        familyOfMissingCPRCalculatorObj.isEligibleWifeTimeline().getValue());
  }
  /**
   * Test case for 'totalExpenseAmountTimeline' attribute. Test Data: Expense records Test Class :
   * FamilyOfMissingEligibilityUnitCalculator
   */
  public void testTotalExpenseAmountTimeline() {
    final Number caseID = 1111L;
    final List<CaseParticipantRole> caseParticipantRoleList = createCaseParticipantRole();
    final List<SAHouseholdUnitMember> saHouseholdUnitMemberList =
        createSAHouseholdUnitMember(caseParticipantRoleList);

    final SAHouseholdUnitCalculator saHouseholdUnitCalculator =
        SAHouseholdUnitCalculator_Factory.getFactory().newInstance(getSession());
    saHouseholdUnitCalculator.mandatoryMembers().specifyValue(saHouseholdUnitMemberList);
    final FamilyOfMissingEligibilityUnitCalculator familyOfMissingObj =
        FamilyOfMissingEligibilityUnitCalculator_Factory.getFactory()
            .newInstance(getSession(), caseID, saHouseholdUnitCalculator);

    final List<Interval<Number>> amount = new ArrayList<Interval<Number>>();
    amount.add(new Interval<Number>(null, 0));
    amount.add(new Interval<Number>(Date.fromISO8601("20040601"), 0));
    final Timeline<Number> amountTimeline = new Timeline<Number>(amount);

    final List<Interval<Number>> amount2 = new ArrayList<Interval<Number>>();
    amount2.add(new Interval<Number>(null, 0));
    amount2.add(new Interval<Number>(Date.fromISO8601("20040601"), 1000));
    final Timeline<Number> amount2Timeline = new Timeline<Number>(amount2);

    // When income type is not COMMERCIAL

    Expense expenseObj = Expense_Factory.getFactory().newInstance(getSession());
    expenseObj.rentAmount().specifyValue(amount2Timeline);
    expenseObj.rentType().specifyValue(new CodeTableItem(EXPENSE.TABLENAME, EXPENSE.COMMERCIAL));
    expenseObj
        .frequency()
        .specifyValue(new CodeTableItem(FREQUENCYCODE.TABLENAME, FREQUENCYCODE.MONTHLY));
    expenseObj
        .participant()
        .specifyValue(caseParticipantRoleList.get(0).caseParticipantRoleID().getValue());
    expenseObj.caseID().specifyValue(caseID);

    final List<Expense> expenseList = new ArrayList<Expense>();
    expenseList.add(expenseObj);

    MemberCPRCalculator memberCPRCalculatorobj =
        MemberCPRCalculator_Factory.getFactory()
            .newInstance(getSession(), caseParticipantRoleList.get(0));
    memberCPRCalculatorobj.caseParticipantRoleRecord().specifyValue(caseParticipantRoleList.get(0));
    memberCPRCalculatorobj.expenseRecords().specifyValue(expenseList);

    familyOfMissingObj.caseID().specifyValue(caseParticipantRoleList.get(0).caseID().getValue());

    CREOLETestHelper.assertEquals(
        amountTimeline, familyOfMissingObj.totalExpenseAmountTimeline().getValue());
  }