/*
* @SecondTest.java 1.2 Apr 23, 2006
*
* Copyright (c) 2006 FirstPartner
* All rights reserved.
*
* SecondTest.java has few changes compared to FirstTest.java
* 1. loanSought = 80000
* 2. valuationValueOrPurchasePrice = 50000
* 3. First Application is PAYE
* 4. Both are married
* 5. Actual Basic income of first applicant = 70000
*/
package net.fp.rp.drools;
import org.apache.log4j.Logger;
import junit.framework.TestCase;
import net.fp.rp.common.exception.RpException;
import net.fp.rp.drools.SpringDecisionTableLoader;
import net.fp.rp.drools.Constants;
/**
* Test of Medium value loan applicaiton
* This class depends on Excel.properties
* @version 1.2 Apr 23, 2006
*
*/
public class MediumValueTest extends TestCase {
/** Logger for this class and subclasses */
protected final Logger log = Logger.getLogger(getClass());
private final int termSought = 3; // K13
private final int mortgageType = Constants.HOUSEPURCHASEVAL; // C15
private final int statusFirstApplicant = Constants.MARRIEDVAL; // C20
private final int statusSecondApplicant = Constants.MARRIEDVAL; // I20
private final double loanSought = 80000d; // K5
private final double valuationValueOrPurchasePrice = 50000d; // K9
private final double actualBasicIncomeFirstApplicant = 70000d; // C31
private final double actualBasicIncomeSecondApplicant = 20000d; // I31
private final double actualOvertimeFirstApplicant = 3000d; // C33
private final double actualOvertimeSecondApplicant = 2000d; // I33
private final double actualBonusFirstApplicant = 100d; // C35
private final double actualBonusSecondApplicant = 0d; // I35
private final double actualCommissionFirstApplicant = 0d; // C37
private final double actualCommissionSecondApplicant = 0d; // I37
private final double actualOtherIncomeFirstApplicant = 0d; // C39
private final double actualOtherIncomeSecondApplicant = 0d; // I39
private final int occupationTypeFirstApplicant = Constants.ACCOUNTANTVAL; // C24
private final int occupationTypeSecondApplicant = Constants.ACCOUNTANTVAL; // I24
private final int rateType = Constants.STANDARDVARIABLEVAL;
private final int employmentTypeFirstApplicant = Constants.PAYEVAL; // C22
private final int employmentTypeSecondApplicant = Constants.SELFEMPLOYEDVAL; // I22
private final double rateTypeVal = 3.95;
// Handle to the bean we use to load the decision table
SpringDecisionTableLoader dtLoader =null;
public void setUp(){
log.debug("Creating Decision Loader Bean");
dtLoader = new SpringDecisionTableLoader();
dtLoader.setExcelFileLocation("red-financial-calculator/war/WEB-INF/file/ExcelDecisionTables.xls");
}
// default constructor
public MediumValueTest() {
}
/**
*
* testCalcLoanToValue
*
*/
public void testCalcLoanToValue() throws RpException {
CalculatorBean cal = setValueToCalculator();
// Print the output
printOutput(cal);
// ensure that cal is not null
assertTrue(cal != null);
// Run the rules on it
dtLoader.executeDecisionTable(cal,true);
assertTrue(cal.getLoanToValue() == 160.0);// K11
assertTrue(cal.getApplicant1().getAllowableBasicIncome() == 70000);// E31
assertTrue(cal.getApplicant2().getAllowableBasicIncome() == 20000);// K31
assertTrue(cal.getApplicant1().getAllowableOvertime() == 3000);// E33
assertTrue(cal.getApplicant2().getAllowableOvertime() == 2000);// I33
assertTrue(cal.getApplicant1().getAllowableBonus() == 100);// E35
assertTrue(cal.getApplicant2().getAllowableBonus() == 0);// I35
assertTrue(cal.getApplicant1().getAllowableCommission() == 0);// E37
assertTrue(cal.getApplicant2().getAllowableCommission() == 0);// I37
assertTrue(cal.getApplicant1().getAllowableOtherIncome() == 0);// E39
assertTrue(cal.getApplicant2().getAllowableOtherIncome() == 0);// I39
assertTrue(cal.getApplicant1().getPreTaxAnnualIncome() == 73100);// E41
assertTrue(cal.getApplicant2().getPreTaxAnnualIncome() == 22000);// I41
assertTrue(cal.getCombinedPreTaxAnnualIncome() == 95100); // K43
assertTrue(cal.getCombinedNetAnnualIncome() == 70266.16); // K45
assertTrue(cal.getCombinedNetMonthlyIncome() == 5855.513333333333); // K47
// assertTrue(cal.getTotalAdditionalCommitment() == 600); //K59
assertTrue(cal.getNetDisposableIncome() == 5255.513333333333);
assertTrue(cal.getMaxAllowableLendingPolicyReq() == 46.274128670744865);
// assertTrue(cal.getMaxAllowableLendingPolicyMax() == 44.0);
assertTrue(cal.getMaxAllowablePercentMortgageRepaymentMax() == 0.26607623985678297);
assertTrue(cal.getMaxAllowableMortgageRepaymentReq() == 2431.943002174819);
assertTrue(cal.getMaxAllowableMortgageRepaymentMax() == 1398.367226250521);
// assertTrue(cal.getRoomRentalAllowance() == 0);
assertTrue(cal.getLoanSought() == 80000);
assertTrue(cal.getMaxLoadAmountMinRen() == 46000);
assertTrue(cal.getMaxLoanAmountMultipleIncomeReq() == 0.9101251422070534);
assertTrue(cal.getMaxLoanAmountMultipleIncomeMax() == 0.5233219567690558);
assertTrue(cal.getLoanAmountWithinCriteria() == -34000.0);
}
/**
*
* setValueToCalculator
*
* @return
*/
public CalculatorBean setValueToCalculator() throws RpException {
CalculatorBean cal = new CalculatorBean();
cal.setLoanSought(loanSought);
cal.setValuationValueOrPurchasePrice(valuationValueOrPurchasePrice);
cal.setMortgageType(mortgageType);
cal.setTermSought(termSought);
// cal.setNoRooms(noRooms);
cal.getApplicant1().setOccupationType(occupationTypeFirstApplicant);
cal.getApplicant2().setOccupationType(occupationTypeSecondApplicant);
cal.getApplicant1().setActualBasicIncome(
actualBasicIncomeFirstApplicant);
cal.getApplicant2().setActualBasicIncome(
actualBasicIncomeSecondApplicant);
cal.getApplicant1().setActualOvertime(actualOvertimeFirstApplicant);
cal.getApplicant2().setActualOvertime(actualOvertimeSecondApplicant);
cal.getApplicant1().setActualBonus(actualBonusFirstApplicant);
cal.getApplicant2().setActualBonus(actualBonusSecondApplicant);
cal.getApplicant1().setActualCommission(actualCommissionFirstApplicant);
cal.getApplicant2()
.setActualCommission(actualCommissionSecondApplicant);
cal.getApplicant1().setActualOtherIncome(
actualOtherIncomeFirstApplicant);
cal.getApplicant2().setActualOtherIncome(
actualOtherIncomeSecondApplicant);
// cal.getApplicant1().setDependentChild(dependentChildFirstApplicant);
// cal.getApplicant2().setDependentChild(dependentChildSecondApplicant);
cal.setRateType(rateType);
cal.getApplicant1().setStatus(statusFirstApplicant);
cal.getApplicant2().setStatus(statusSecondApplicant);
cal.getApplicant1().setEmploymentType(employmentTypeFirstApplicant);
cal.getApplicant2().setEmploymentType(employmentTypeSecondApplicant);
// cal.setMonthlyMaintenancePayment(monthlyMaintenancePayment);
// cal.setMonthlyLoanRepayment1(monthlyLoanRepayment1);
// cal.setMonthlyLoanRepayment2(monthlyLoanRepayment2);
// cal.setMonthlyLoanRepayment3(monthlyLoanRepayment3);
// cal.setMonthlyLoanRepayment4(monthlyLoanRepayment4);
// cal.setMonthlyLoanRepayment5(monthlyLoanRepayment5);
cal.setRateTypeValue(rateTypeVal);
// default to false
cal.setJoint(false);
return cal;
}
/**
*
* printOutput
*
* @param cal
*/
public void printOutput(CalculatorBean cal) {
try {
log.debug("\nOUTPUT");
log.debug("------");
log.debug("Loan to Value = " + cal.getLoanToValue());
log.debug("First Applicant's Allowable Basic Income = "
+ cal.getApplicant1().getAllowableBasicIncome());
log.debug("Second Applicant's Allowable Basic Income = "
+ cal.getApplicant2().getAllowableBasicIncome());
log.debug("First Applicant's Allowable Overtime = "
+ cal.getApplicant1().getAllowableOvertime());
log.debug("Second Applicant's Allowable Overtime = "
+ cal.getApplicant2().getAllowableOvertime());
log.debug("First Applicant's Allowable Bonus = "
+ cal.getApplicant1().getAllowableBonus());
log.debug("Second Applicant's Allowable Bonus = "
+ cal.getApplicant2().getAllowableBonus());
log.debug("First Applicant's Allowable Commission = "
+ cal.getApplicant1().getAllowableCommission());
log.debug("Second Applicant's Allowable Commission = "
+ cal.getApplicant2().getAllowableCommission());
log.debug("First Applicant's Allowable Other Income = "
+ cal.getApplicant1().getAllowableOtherIncome());
log.debug("Second Applicant's Allowable Other Income = "
+ cal.getApplicant2().getAllowableOtherIncome());
log.debug("");
log.debug("First Applicant's Pre Tax Annual Income = "
+ cal.getApplicant1().getPreTaxAnnualIncome());
log.debug("Second Applicant's Pre Tax Annual Income = "
+ cal.getApplicant2().getPreTaxAnnualIncome());
log.debug("");
log.debug("Combined Pre Tax Annual Income = "
+ cal.getCombinedPreTaxAnnualIncome());
log.debug("Combined Net Annual Income = "
+ cal.getCombinedNetAnnualIncome());
log.debug("Combined Net Monthly Annual Income = "
+ cal.getCombinedNetMonthlyIncome());
log
.debug("Net Disposable Income : "
+ cal.getNetDisposableIncome());
log.debug("Maximum Allowable NDI Lending Policy (Required) : "
+ cal.getMaxAllowableLendingPolicyReq());
log.debug("Maximum Allowable NDI Percentage Mortgage Repayment : "
+ cal.getMaxAllowablePercentMortgageRepaymentMax());
log.debug("Maximum Allowable NDI Mortgage Repayment (Required) : "
+ cal.getMaxAllowableMortgageRepaymentReq());
log.debug("Maximum Allowable NDI Mortgage Repayment (Maximum) : "
+ cal.getMaxAllowableMortgageRepaymentMax());
log.debug("Maximum Loan Amount Allowed (Required) : "
+ cal.getLoanSought());
log.debug("Maximum Loan Amount Allowed (Maximum) : "
+ cal.getMaxLoadAmountMinRen());
log
.debug("Maximum loan amount allowable expressed as a multiple of allowable income (Required) : "
+ cal.getMaxLoanAmountMultipleIncomeReq());
log
.debug("Maximum loan amount allowable expressed as a multiple of allowable income (Maximum) : "
+ cal.getMaxLoanAmountMultipleIncomeMax());
log
.debug("Loan Amount is within criteria with additional capacity borrowing of : "
+ cal.getLoanAmountWithinCriteria());
} catch (Exception e) {
e.printStackTrace();
}
}
}