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