/**
* Reads all script files in the scriptDirectory and runs them with this borrower's
* information to see if he/she qualifies for each mortgage product.
*/
private static void runQualifications(
ScriptMortgageQualifier mortgageQualifier,
Borrower borrower,
Loan loan,
Property property
) {
for (File scriptFile : getScriptFiles(scriptDirectory)) {
// Print info about the borrower, loan and property.
System.out.println("Processing file: " + scriptFile.getName());
System.out.println(" Borrower: " + borrower.getName());
System.out.println(" Credit score: " + borrower.getCreditScore());
System.out.println(" Sales price: " + property.getSalesPrice());
System.out.println(" Down payment: " + loan.getDownPayment());
MortgageQualificationResult result = null;
try {
// Run the script rules for this borrower on the loan product.
result = mortgageQualifier.qualifyMortgage(
borrower, property, loan, scriptFile
);
} catch (FileNotFoundException fnfe) {
System.out.println(
"Can't read script file: " + fnfe.getMessage()
);
} catch (IllegalArgumentException e) {
System.out.println(
"No script engine available to handle file: " +
scriptFile.getName()
);
} catch (ScriptException e) {
System.out.println(
"Script '" + scriptFile.getName() +
"' encountered an error: " + e.getMessage()
);
}
if (result == null) continue; // Must have hit exception.
// Print results.
System.out.println(
"* Mortgage product: " + result.getProductName() +
", Qualified? " + result.isQualified() +
"\n* Interest rate: " + result.getInterestRate() +
"\n* Message: " + result.getMessage()
);
System.out.println();
}
}
文章来源于领测软件测试网 https://www.ltesting.net/