Coverage Report - org.mule.example.loanbroker.DefaultLoanBroker
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultLoanBroker
0%
0/25
0%
0/6
0
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.example.loanbroker;
 8  
 
 9  
 import org.mule.example.loanbroker.bank.Bank;
 10  
 import org.mule.example.loanbroker.creditagency.CreditAgencyService;
 11  
 import org.mule.example.loanbroker.message.CustomerQuoteRequest;
 12  
 import org.mule.example.loanbroker.message.LoanBrokerQuoteRequest;
 13  
 import org.mule.example.loanbroker.model.CreditProfile;
 14  
 
 15  
 /**
 16  
  * <code>SyncLoanBroker</code> is a synchronous Loan Broker that makes the calls to
 17  
  * various components through the event context synchronously.
 18  
  */
 19  0
 public class DefaultLoanBroker extends AbstractLoanBroker
 20  
 {
 21  
     //A proxy for this object gets injected via the <nested-router> element configured on this service.
 22  
     //The proxy will then call out to an endpoint and return the result.
 23  
     //The transformers configured on the endpoint control how data is marshalled into and out of the call.
 24  
     private CreditAgencyService creditAgency;
 25  
 
 26  
     @Override
 27  
     public Object getLoanQuote(CustomerQuoteRequest request) throws LoanBrokerException
 28  
     {
 29  0
         super.getLoanQuote(request);
 30  0
         LoanBrokerQuoteRequest bqr = new LoanBrokerQuoteRequest();
 31  0
         bqr.setCustomerRequest(request);
 32  
 
 33  
         //This calls out to the CreditAgency service (see above)
 34  0
         CreditProfile cp = creditAgency.getCreditProfile(request.getCustomer());
 35  0
         bqr.setCreditProfile(cp);
 36  
 
 37  0
         setLenderList(bqr);
 38  
 
 39  0
         return bqr;
 40  
     }
 41  
 
 42  
     /**
 43  
      * Sets the list of lenders on the LoanBrokerQuoteRequest and returns it.
 44  
      */
 45  
     public void setLenderList(LoanBrokerQuoteRequest request)
 46  
     {
 47  0
         Bank[] lenders = getLenders(request.getCreditProfile(), request.getCustomerRequest()
 48  
                 .getLoanAmount());
 49  0
         request.setLenders(lenders);
 50  0
     }
 51  
 
 52  
     public Bank[] getLenders(CreditProfile creditProfile, Double loanAmount)
 53  
     {
 54  
         // TODO Add creditProfile info. to the logic below.
 55  
         // TODO Look up the existing banks from the config/registry instead of
 56  
         // creating them programatically here.
 57  
         Bank[] lenders;
 58  0
         if ((loanAmount >= 20000))
 59  
         {
 60  0
             lenders = new Bank[2];
 61  0
             lenders[0] = new Bank("Bank1");
 62  0
             lenders[1] = new Bank("Bank2");
 63  
         }
 64  0
         else if (((loanAmount >= 10000) && (loanAmount <= 19999)))
 65  
         {
 66  0
             lenders = new Bank[2];
 67  0
             lenders[0] = new Bank("Bank3");
 68  0
             lenders[1] = new Bank("Bank4");
 69  
         }
 70  
         else
 71  
         {
 72  0
             lenders = new Bank[1];
 73  0
             lenders[0] = new Bank("Bank5");
 74  
         }
 75  
 
 76  0
         return lenders;
 77  
     }
 78  
 
 79  
     public CreditAgencyService getCreditAgency()
 80  
     {
 81  0
         return creditAgency;
 82  
     }
 83  
 
 84  
     public void setCreditAgency(CreditAgencyService creditAgency)
 85  
     {
 86  0
         this.creditAgency = creditAgency;
 87  0
     }
 88  
 }