Class MapValueFunction

java.lang.Object
org.citrusframework.functions.core.MapValueFunction
All Implemented Interfaces:
InitializingPhase, Function

public class MapValueFunction extends Object implements Function, InitializingPhase
Function to map the function's argument to a corresponding value configured using a map.

Example of the function definition and its usage:

 <bean id="myCustomFunctionLibrary" class="org.citrusframework.functions.FunctionLibrary">
  <property name="name" value="myCustomFunctionLibrary" />
  <property name="prefix" value="custom:" />
  <property name="members">
    <map>
      <entry key="mapHttpStatusCodeToMessage">
        <bean class="org.citrusframework.functions.core.MapValueFunction">
          <property name="values">
            <map>
              <entry key="200" value="OK" />
              <entry key="401" value="Unauthorized" />
              <entry key="500" value="Internal Server Error" />
            </map>
          </property>
        </bean>
      </entry>
    </map>
  </property>
 </bean>
 
and the corresponding usage in a test which maps the HTTP status code 500 to its message 'Internal Server Error':
 <variable name="httpStatusCodeMessage" value="custom:mapHttpStatusCodeToMessage('500')" />
 
  • Constructor Details

    • MapValueFunction

      public MapValueFunction()
  • Method Details