Class MapValueFunction
java.lang.Object
org.citrusframework.functions.core.MapValueFunction
- All Implemented Interfaces:
org.citrusframework.common.InitializingPhase,org.citrusframework.functions.Function,org.citrusframework.functions.ParameterizedFunction<StringParameter>,StringFunction
public class MapValueFunction
extends Object
implements StringFunction, org.citrusframework.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="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')" />
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.citrusframework.functions.ParameterizedFunction
org.citrusframework.functions.ParameterizedFunction.FunctionParameters -
Field Summary
Fields inherited from interface org.citrusframework.functions.Function
functions, logger, RESOURCE_PATH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionExecute function with the single String parameter.getMap()Gets the mappings for this function.voidvoidSets the mappings for this function.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.citrusframework.functions.ParameterizedFunction
executeMethods inherited from interface org.citrusframework.functions.StringFunction
execute, getParameters
-
Constructor Details
-
MapValueFunction
public MapValueFunction()
-
-
Method Details
-
execute
Description copied from interface:StringFunctionExecute function with the single String parameter.- Specified by:
executein interfaceStringFunction
-
initialize
public void initialize()- Specified by:
initializein interfaceorg.citrusframework.common.InitializingPhase
-
getMap
Gets the mappings for this function. -
setMap
Sets the mappings for this function.
-