Coverage Report - org.mule.example.loanbroker.DefaultLoanBroker
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultLoanBroker
0%
0/25
0%
0/6
1.375
 
 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.messages.CreditProfile;
 10  
 import org.mule.example.loanbroker.messages.Customer;
 11  
 import org.mule.example.loanbroker.messages.CustomerQuoteRequest;
 12  
 import org.mule.example.loanbroker.messages.LoanBrokerQuoteRequest;
 13  
 import org.mule.example.loanbroker.messages.LoanQuote;
 14  
 
 15  
 import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicInteger;
 16  
 import org.apache.commons.logging.Log;
 17  
 import org.apache.commons.logging.LogFactory;
 18  
 
 19  
 /**
 20  
  * <code>LoanBroker</code> is the Service that starts the loan request process. The
 21  
  * broker also receives the final quote.
 22  
  */
 23  0
 public class DefaultLoanBroker implements LoanBrokerService
 24  
 {
 25  
     /**
 26  
      * logger used by this class
 27  
      */
 28  0
     protected final Log logger = LogFactory.getLog(getClass());
 29  
     
 30  0
     private final AtomicInteger quotes = new AtomicInteger(0);
 31  0
     private final AtomicInteger requests = new AtomicInteger(0);
 32  0
     private final AtomicInteger profiles = new AtomicInteger(0);
 33  
 
 34  
     public Object getLoanQuote(CustomerQuoteRequest request) throws LoanBrokerException
 35  
     {
 36  0
         int requests = incRequests();
 37  0
         if (logger.isInfoEnabled())
 38  
         {
 39  0
             String[] params = new String[] { String.valueOf(requests), 
 40  
                 request.getCustomer().getName(), 
 41  
                 String.valueOf(request.getCustomer().getSsn()), 
 42  
                 String.valueOf(request.getLoanAmount()),
 43  
                 String.valueOf(request.getLoanDuration()) };
 44  
 
 45  0
             logger.info("\n***** " + LocaleMessage.receivedRequest(params));
 46  
         }
 47  0
         return request;
 48  
     }
 49  
 
 50  
     public LoanBrokerQuoteRequest receiveLoanBrokerQuoteRequest(LoanBrokerQuoteRequest request)
 51  
     {
 52  
         // Just pass through
 53  0
         return request;
 54  
     }
 55  
 
 56  
     public Customer receiveCustomer(Customer customer)
 57  
     {
 58  
         // Just pass through
 59  0
         return customer;
 60  
     }
 61  
 
 62  
     public Object receiveCreditProfile(CreditProfile profile)
 63  
     {
 64  0
         int profiles = incProfiles();
 65  0
         if (logger.isInfoEnabled())
 66  
         {
 67  0
             String[] params = new String[] { String.valueOf(profiles), 
 68  
                 String.valueOf(profile.getCreditScore()),
 69  
                 String.valueOf(profile.getCreditHistory()) };
 70  
 
 71  0
             logger.info("\n***** " + LocaleMessage.receivedProfile(params));
 72  
         }
 73  0
         return profile;
 74  
     }
 75  
 
 76  
     public Object receiveQuote(LoanQuote quote)
 77  
     {
 78  0
         int quotes = incQuotes();
 79  0
         if (logger.isInfoEnabled())
 80  
         {
 81  0
             String[] params = new String[] { String.valueOf(quotes), 
 82  
                 quote.toString() };
 83  0
             logger.info("\n***** " + LocaleMessage.receivedQuote(params));
 84  
         }
 85  0
         return quote;
 86  
     }
 87  
 
 88  
     protected int incQuotes()
 89  
     {
 90  0
         return quotes.incrementAndGet();
 91  
     }
 92  
 
 93  
     protected int incRequests()
 94  
     {
 95  0
         return requests.incrementAndGet();
 96  
     }
 97  
 
 98  
     protected int incProfiles()
 99  
     {
 100  0
         return profiles.incrementAndGet();
 101  
     }
 102  
 }