Coverage Report - org.mule.tck.property.SessionPropertiesValidatorComponent
 
Classes in this File Line Coverage Branch Coverage Complexity
SessionPropertiesValidatorComponent
0%
0/9
0%
0/4
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.tck.property;
 8  
 
 9  
 import org.mule.api.MuleEventContext;
 10  
 import org.mule.api.lifecycle.Callable;
 11  
 
 12  
 import java.util.HashMap;
 13  
 import java.util.Map;
 14  
 
 15  
 import static org.hamcrest.core.Is.is;
 16  
 import static org.junit.Assert.assertThat;
 17  
 
 18  0
 public class SessionPropertiesValidatorComponent implements Callable
 19  
 {
 20  
 
 21  0
     private Map<String,String> expectedProperties = new HashMap<String,String>();
 22  
 
 23  
     public void setExpectedProperties(Map<String, String> expectedProperties)
 24  
     {
 25  0
         this.expectedProperties = expectedProperties;
 26  0
     }
 27  
 
 28  
     public Object onCall(MuleEventContext eventContext) throws Exception
 29  
     {
 30  0
         if (expectedProperties.isEmpty())
 31  
         {
 32  0
             throw new IllegalStateException("you must set at least one expected property");
 33  
         }
 34  0
         for (String propertyName : expectedProperties.keySet())
 35  
         {
 36  0
             assertThat((String) eventContext.getMessage().getSessionProperty(propertyName), is(expectedProperties.get(propertyName)));
 37  
         }
 38  0
         return eventContext.getMessage();
 39  
     }
 40  
 }