Coverage Report - org.mule.samples.voipservice.routers.PaymentValidationResponseAggregator
 
Classes in this File Line Coverage Branch Coverage Complexity
PaymentValidationResponseAggregator
0%
0/18
0%
0/12
7
 
 1  
 /*
 2  
  * $Id: PaymentValidationResponseAggregator.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.samples.voipservice.routers;
 12  
 
 13  
 import org.mule.config.i18n.MessageFactory;
 14  
 import org.mule.impl.MuleMessage;
 15  
 import org.mule.routing.inbound.EventGroup;
 16  
 import org.mule.routing.response.ResponseCorrelationAggregator;
 17  
 import org.mule.samples.voipservice.to.CreditProfileTO;
 18  
 import org.mule.umo.UMOEvent;
 19  
 import org.mule.umo.UMOMessage;
 20  
 import org.mule.umo.routing.RoutingException;
 21  
 import org.mule.umo.transformer.TransformerException;
 22  
 
 23  
 import java.util.Iterator;
 24  
 import java.util.Map;
 25  
 
 26  0
 public class PaymentValidationResponseAggregator extends ResponseCorrelationAggregator
 27  
 {
 28  
 
 29  
     protected UMOMessage aggregateEvents(EventGroup events) throws RoutingException
 30  
     {
 31  0
         UMOEvent event = null;
 32  0
         boolean one = false;
 33  0
         boolean two = false;
 34  0
         CreditProfileTO creditProfileTO = null;
 35  
 
 36  
         try
 37  
         {
 38  0
             for (Iterator iterator = events.iterator(); iterator.hasNext();)
 39  
             {
 40  0
                 event = (UMOEvent)iterator.next();
 41  0
                 creditProfileTO = (CreditProfileTO)event.getTransformedMessage();
 42  
 
 43  0
                 if (creditProfileTO.getCreditScore() >= CreditProfileTO.CREDIT_LIMIT)
 44  
                 {
 45  0
                     one = true;
 46  
                 }
 47  
 
 48  0
                 if (creditProfileTO.getCreditAuthorisedStatus() == CreditProfileTO.CREDIT_AUTHORISED)
 49  
                 {
 50  0
                     two = true;
 51  
                 }
 52  
             }
 53  
         }
 54  0
         catch (TransformerException e)
 55  
         {
 56  0
             throw new RoutingException(MessageFactory.createStaticMessage("Failed to validate payment service"),
 57  
                 new MuleMessage(events, (Map)null), null, e);
 58  0
         }
 59  
 
 60  0
         if (one && two && creditProfileTO != null)
 61  
         {
 62  0
             creditProfileTO.setValid(true);
 63  
         }
 64  
 
 65  0
         return new MuleMessage(creditProfileTO, event.getMessage());
 66  
     }
 67  
 
 68  
 }