Class MapValueFunction

  • All Implemented Interfaces:
    com.consol.citrus.common.InitializingPhase, com.consol.citrus.functions.Function

    public class MapValueFunction
    extends Object
    implements com.consol.citrus.functions.Function, com.consol.citrus.common.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="com.consol.citrus.functions.FunctionLibrary">
      <property name="name" value="myCustomFunctionLibrary" />
      <property name="prefix" value="custom:" />
      <property name="members">
        <map>
          <entry key="mapHttpStatusCodeToMessage">
            <bean class="com.consol.citrus.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')" />
     
    Author:
    Dimo Velev ([email protected])
    • Constructor Detail

      • MapValueFunction

        public MapValueFunction()
    • Method Detail

      • execute

        public String execute​(List<String> params,
                              com.consol.citrus.context.TestContext context)
        Specified by:
        execute in interface com.consol.citrus.functions.Function
      • initialize

        public void initialize()
        Specified by:
        initialize in interface com.consol.citrus.common.InitializingPhase
      • getMap

        public Map<String,​String> getMap()
        Gets the mappings for this function.
        Returns:
      • setMap

        public void setMap​(Map<String,​String> map)
        Sets the mappings for this function.
        Parameters:
        map -