Coverage Report - org.mule.routing.correlation.CorrelationPropertiesExpressionEvaluator
 
Classes in this File Line Coverage Branch Coverage Complexity
CorrelationPropertiesExpressionEvaluator
0%
0/16
0%
0/10
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.routing.correlation;
 8  
 
 9  
 import org.mule.api.MuleMessage;
 10  
 import org.mule.api.config.MuleProperties;
 11  
 import org.mule.expression.MessageHeaderExpressionEvaluator;
 12  
 
 13  
 /**
 14  
  * <code>CorrelationPropertiesExpressionEvaluator</code> is a default implementation used for
 15  
  * getting the Correlation information from a message. This object is only used when
 16  
  * getting a specific property to be set on the message. When reading the property
 17  
  * the getProperty(...) or the direct property accessor will be used i.e.
 18  
  * message.getCorrelationId() or
 19  
  * message.getProperty(MuleProperties.MULE_CORRELATION_ID_PROPERTY)
 20  
  */
 21  0
 public class CorrelationPropertiesExpressionEvaluator extends MessageHeaderExpressionEvaluator
 22  
 {
 23  
     @Override
 24  
     public final Object evaluate(String name, MuleMessage message)
 25  
     {
 26  
         Object result;
 27  0
         if (message != null)
 28  
         {
 29  0
             if (MuleProperties.MULE_CORRELATION_ID_PROPERTY.equals(name))
 30  
             {
 31  0
                 result = getCorrelationId(message);
 32  
             }
 33  0
             else if (MuleProperties.MULE_MESSAGE_ID_PROPERTY.equals(name))
 34  
             {
 35  0
                 result = getMessageId(message);
 36  
             }
 37  
             else
 38  
             {
 39  0
                 throw new IllegalArgumentException("Property name: " + name
 40  
                                                    + " not recognised by the Correlation Property Extractor");
 41  
             }
 42  0
             if (result == null)
 43  
             {
 44  0
                 throw new IllegalArgumentException(
 45  
                     "Property Extractor cannot return a null value. Extractor is: " + getClass().getName());
 46  
             }
 47  
         }
 48  
         else
 49  
         {
 50  0
             return super.evaluate(name, message);
 51  
         }
 52  0
         return result;
 53  
     }
 54  
 
 55  
     public String getMessageId(MuleMessage message)
 56  
     {
 57  0
         return message.getUniqueId();
 58  
     }
 59  
 
 60  
     public String getCorrelationId(MuleMessage message)
 61  
     {
 62  0
         String id = message.getCorrelationId();
 63  0
         if (id == null)
 64  
         {
 65  0
             id = message.getUniqueId();
 66  
         }
 67  0
         return id;
 68  
     }
 69  
 }