Coverage Report - org.mule.examples.loanbroker.routers.BankQuotesAggregationLogic
 
Classes in this File Line Coverage Branch Coverage Complexity
BankQuotesAggregationLogic
0%
0/15
0%
0/6
4
 
 1  
 /*
 2  
  * $Id: BankQuotesAggregationLogic.java 7963 2007-08-21 08:53:15Z dirk.olmes $
 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.examples.loanbroker.routers;
 12  
 
 13  
 import org.mule.examples.loanbroker.LocaleMessage;
 14  
 import org.mule.examples.loanbroker.messages.LoanQuote;
 15  
 import org.mule.impl.MuleMessage;
 16  
 import org.mule.routing.inbound.EventGroup;
 17  
 import org.mule.umo.UMOEvent;
 18  
 import org.mule.umo.UMOMessage;
 19  
 
 20  
 import java.util.Iterator;
 21  
 
 22  
 import org.apache.commons.logging.Log;
 23  
 import org.apache.commons.logging.LogFactory;
 24  
 
 25  0
 public class BankQuotesAggregationLogic
 26  
 {
 27  
     /**
 28  
      * logger used by this class
 29  
      */
 30  0
     protected static final Log logger = LogFactory.getLog(BankQuotesAggregationLogic.class);
 31  
     
 32  
     public static UMOMessage aggregateEvents(EventGroup events) throws Exception
 33  
     {
 34  0
         LoanQuote lowestQuote = null;
 35  0
         LoanQuote quote = null;
 36  0
         UMOEvent event = null;
 37  
 
 38  0
         for (Iterator iterator = events.iterator(); iterator.hasNext();)
 39  
         {
 40  0
             event = (UMOEvent)iterator.next();
 41  0
             quote = (LoanQuote)event.getTransformedMessage();
 42  0
             logger.info(LocaleMessage.processingQuote(quote));
 43  
 
 44  0
             if (lowestQuote == null)
 45  
             {
 46  0
                 lowestQuote = quote;
 47  
             }
 48  
             else
 49  
             {
 50  0
                 if (quote.getInterestRate() < lowestQuote.getInterestRate())
 51  
                 {
 52  0
                     lowestQuote = quote;
 53  
                 }
 54  
             }
 55  
         }
 56  
 
 57  0
         logger.info(LocaleMessage.lowestQuote(lowestQuote));
 58  0
         return new MuleMessage(lowestQuote, event.getMessage());
 59  
     }
 60  
 }