Class MapValueFunction
java.lang.Object
org.citrusframework.functions.core.MapValueFunction
- All Implemented Interfaces:
InitializingPhase,Function
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')" />
-
Field Summary
Fields inherited from interface org.citrusframework.functions.Function
functions, logger, RESOURCE_PATH -
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
MapValueFunction
public MapValueFunction()
-
-
Method Details
-
execute
-
initialize
public void initialize()- Specified by:
initializein interfaceInitializingPhase
-
getMap
Gets the mappings for this function.- Returns:
-
setMap
Sets the mappings for this function.- Parameters:
map-
-