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