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