Coverage Report - org.mule.example.loanbroker.processor.LowestQuoteProcessor
 
Classes in this File Line Coverage Branch Coverage Complexity
LowestQuoteProcessor
0%
0/12
0%
0/8
0
 
 1  
 /*
 2  
  * $Id: LowestQuoteProcessor.java 19574 2010-09-10 16:42:37Z aperepel $
 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.processor;
 12  
 
 13  
 import org.mule.DefaultMuleEvent;
 14  
 import org.mule.DefaultMuleMessage;
 15  
 import org.mule.api.MuleEvent;
 16  
 import org.mule.api.processor.MessageProcessor;
 17  
 import org.mule.api.transformer.TransformerException;
 18  
 import org.mule.example.loanbroker.model.LoanQuote;
 19  
 
 20  
 import java.util.List;
 21  
 
 22  0
 public class LowestQuoteProcessor implements MessageProcessor
 23  
 {
 24  
 
 25  
     public MuleEvent process(MuleEvent event) throws TransformerException
 26  
     {
 27  
 
 28  0
         Object payload = event.getMessage().getPayload();
 29  0
         LoanQuote lowestQuote = null;
 30  
 
 31  0
         if (payload instanceof LoanQuote)
 32  
         {
 33  0
             lowestQuote = (LoanQuote) payload;
 34  
         }
 35  
         else
 36  
         {
 37  
             @SuppressWarnings("unchecked")
 38  0
             List<LoanQuote> loanQuotes = (List<LoanQuote>) payload;
 39  0
             for (LoanQuote loanQuote : loanQuotes)
 40  
             {
 41  
 
 42  0
                 if (lowestQuote == null)
 43  
                 {
 44  0
                     lowestQuote = loanQuote;
 45  
                 }
 46  
                 else
 47  
                 {
 48  0
                     if (loanQuote.getInterestRate() < lowestQuote.getInterestRate())
 49  
                     {
 50  0
                         lowestQuote = loanQuote;
 51  
                     }
 52  
                 }
 53  
             }
 54  
         }
 55  0
         return new DefaultMuleEvent(new DefaultMuleMessage(lowestQuote, event.getMuleContext()), event);
 56  
     }
 57  
 
 58  
 }