Coverage Report - org.mule.examples.loanbroker.transformers.SetLendersAsRecipients
 
Classes in this File Line Coverage Branch Coverage Complexity
SetLendersAsRecipients
0%
0/12
0%
0/4
2
 
 1  
 /*
 2  
  * $Id: SetLendersAsRecipients.java 7976 2007-08-21 14:26:13Z 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.transformers;
 12  
 
 13  
 import org.mule.examples.loanbroker.bank.Bank;
 14  
 import org.mule.examples.loanbroker.messages.CustomerQuoteRequest;
 15  
 import org.mule.examples.loanbroker.messages.LoanBrokerQuoteRequest;
 16  
 import org.mule.routing.outbound.StaticRecipientList;
 17  
 import org.mule.transformers.AbstractEventAwareTransformer;
 18  
 import org.mule.umo.UMOEventContext;
 19  
 import org.mule.umo.UMOMessage;
 20  
 import org.mule.umo.transformer.TransformerException;
 21  
 
 22  
 /**
 23  
  * Set the Recipient List property on the LoanBrokerQuoteRequest message based on the
 24  
  * list of banks in LoanBrokerQuoteRequest.getLenders()
 25  
  */
 26  
 public class SetLendersAsRecipients extends AbstractEventAwareTransformer
 27  
 {
 28  
 
 29  
     public SetLendersAsRecipients()
 30  0
     {
 31  0
         this.registerSourceType(LoanBrokerQuoteRequest.class);
 32  0
         this.setReturnClass(CustomerQuoteRequest.class);
 33  0
     }
 34  
 
 35  
     public Object transform(Object src, String encoding, UMOEventContext context) throws TransformerException
 36  
     {
 37  0
         Bank[] lenders = ((LoanBrokerQuoteRequest)src).getLenders();
 38  
 
 39  0
         String recipients = "";
 40  0
         for (int i = 0; i < lenders.length; i++)
 41  
         {
 42  0
             if (i > 0) recipients += ",";
 43  0
             recipients += lenders[i].getEndpoint();
 44  
         }
 45  
 
 46  0
         UMOMessage msg = context.getMessage();
 47  0
         context.getMessage().setProperty(StaticRecipientList.RECIPIENTS_PROPERTY, recipients);
 48  0
         return msg;
 49  
     }
 50  
 
 51  
 }