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