Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
DefaultLender |
|
| 2.0;2 |
1 | /* | |
2 | * $Id: DefaultLender.java 7963 2007-08-21 08:53:15Z dirk.olmes $ | |
3 | * -------------------------------------------------------------------------------------- | |
4 | * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com | |
5 | * | |
6 | * The software in this package is published under the terms of the CPAL v1.0 | |
7 | * license, a copy of which has been included with this distribution in the | |
8 | * LICENSE.txt file. | |
9 | */ | |
10 | ||
11 | package org.mule.examples.loanbroker.lender; | |
12 | ||
13 | import org.mule.examples.loanbroker.bank.Bank; | |
14 | import org.mule.examples.loanbroker.messages.CreditProfile; | |
15 | import org.mule.examples.loanbroker.messages.LoanBrokerQuoteRequest; | |
16 | ||
17 | /** | |
18 | * <code>DefaultLenderService</code> is responsible for contacting the relivant | |
19 | * banks depending on the amount of the loan | |
20 | */ | |
21 | 0 | public class DefaultLender implements LenderService |
22 | { | |
23 | /** | |
24 | * Sets the list of lenders on the LoanBrokerQuoteRequest and returns it. | |
25 | */ | |
26 | public void setLenderList(LoanBrokerQuoteRequest request) | |
27 | { | |
28 | 0 | Bank[] lenders = getLenders(request.getCreditProfile(), new Double(request.getCustomerRequest() |
29 | .getLoanAmount())); | |
30 | 0 | request.setLenders(lenders); |
31 | 0 | } |
32 | ||
33 | /** | |
34 | * @inheritDocs | |
35 | */ | |
36 | public Bank[] getLenders(CreditProfile creditProfile, Double loanAmount) | |
37 | { | |
38 | // TODO Add creditProfile info. to the logic below. | |
39 | // TODO Look up the existing banks from the config/registry instead of | |
40 | // creating them programatically here. | |
41 | Bank[] lenders; | |
42 | 0 | if ((loanAmount.doubleValue() >= 20000)) |
43 | { | |
44 | 0 | lenders = new Bank[2]; |
45 | 0 | lenders[0] = new Bank("Bank1"); |
46 | 0 | lenders[1] = new Bank("Bank2"); |
47 | } | |
48 | 0 | else if (((loanAmount.doubleValue() >= 10000) && (loanAmount.doubleValue() <= 19999))) |
49 | { | |
50 | 0 | lenders = new Bank[2]; |
51 | 0 | lenders[0] = new Bank("Bank3"); |
52 | 0 | lenders[1] = new Bank("Bank4"); |
53 | } | |
54 | else | |
55 | { | |
56 | 0 | lenders = new Bank[1]; |
57 | 0 | lenders[0] = new Bank("Bank5"); |
58 | } | |
59 | ||
60 | 0 | return lenders; |
61 | } | |
62 | } |