/AWS1/IF_SFN=>TESTSTATE()¶
About TestState¶
Accepts the definition of a single state and executes it. You can test a state without creating a state machine or updating an existing state machine. Using this API, you can test the following:
-
A state's input and output processing data flow
-
An Amazon Web Services service integration request and response
-
An HTTP Task request and response
You can call this API on only one state at a time. The states that you can test include the following:
The TestState API assumes an IAM role which must contain the required IAM permissions for the resources your state is accessing. For information about the permissions a state might need, see IAM permissions to test a state.
The TestState API can run for up to five minutes. If the execution of a state exceeds this duration, it fails with the States.Timeout error.
TestState only supports the following when a mock is specified: Activity tasks, .sync or .waitForTaskToken
service integration patterns, Parallel, or Map states.
Method Signature¶
METHODS /AWS1/IF_SFN~TESTSTATE
IMPORTING
!IV_DEFINITION TYPE /AWS1/SFNDEFINITION OPTIONAL
!IV_ROLEARN TYPE /AWS1/SFNARN OPTIONAL
!IV_INPUT TYPE /AWS1/SFNSENSITIVEDATA OPTIONAL
!IV_INSPECTIONLEVEL TYPE /AWS1/SFNINSPECTIONLEVEL OPTIONAL
!IV_REVEALSECRETS TYPE /AWS1/SFNREVEALSECRETS OPTIONAL
!IV_VARIABLES TYPE /AWS1/SFNSENSITIVEDATA OPTIONAL
!IV_STATENAME TYPE /AWS1/SFNTESTSTATESTATENAME OPTIONAL
!IO_MOCK TYPE REF TO /AWS1/CL_SFNMOCKINPUT OPTIONAL
!IV_CONTEXT TYPE /AWS1/SFNSENSITIVEDATA OPTIONAL
!IO_STATECONFIGURATION TYPE REF TO /AWS1/CL_SFNTESTSTATECONF OPTIONAL
RETURNING
VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_sfnteststateoutput
RAISING
/AWS1/CX_SFNINVALIDARN
/AWS1/CX_SFNINVALIDDEFINITION
/AWS1/CX_SFNINVALIDEXECINPUT
/AWS1/CX_SFNVALIDATIONEX
/AWS1/CX_SFNCLIENTEXC
/AWS1/CX_SFNSERVEREXC
/AWS1/CX_RT_TECHNICAL_GENERIC
/AWS1/CX_RT_SERVICE_GENERIC.
IMPORTING¶
Required arguments:¶
iv_definition TYPE /AWS1/SFNDEFINITION /AWS1/SFNDEFINITION¶
The Amazon States Language (ASL) definition of the state or state machine.
Optional arguments:¶
iv_rolearn TYPE /AWS1/SFNARN /AWS1/SFNARN¶
The Amazon Resource Name (ARN) of the execution role with the required IAM permissions for the state.
iv_input TYPE /AWS1/SFNSENSITIVEDATA /AWS1/SFNSENSITIVEDATA¶
A string that contains the JSON input data for the state.
iv_inspectionlevel TYPE /AWS1/SFNINSPECTIONLEVEL /AWS1/SFNINSPECTIONLEVEL¶
Determines the values to return when a state is tested. You can specify one of the following types:
INFO: Shows the final state output. By default, Step Functions setsinspectionLeveltoINFOif you don't specify a level.
DEBUG: Shows the final state output along with the input and output data processing result.
TRACE: Shows the HTTP request and response for an HTTP Task. This level also shows the final state output along with the input and output data processing result.Each of these levels also provide information about the status of the state execution and the next state to transition to.
iv_revealsecrets TYPE /AWS1/SFNREVEALSECRETS /AWS1/SFNREVEALSECRETS¶
Specifies whether or not to include secret information in the test result. For HTTP Tasks, a secret includes the data that an EventBridge connection adds to modify the HTTP request headers, query parameters, and body. Step Functions doesn't omit any information included in the state definition or the HTTP response.
If you set
revealSecretstotrue, you must make sure that the IAM user that calls theTestStateAPI has permission for thestates:RevealSecretsaction. For an example of IAM policy that sets thestates:RevealSecretspermission, see IAM permissions to test a state. Without this permission, Step Functions throws an access denied error.By default,
revealSecretsis set tofalse.
iv_variables TYPE /AWS1/SFNSENSITIVEDATA /AWS1/SFNSENSITIVEDATA¶
JSON object literal that sets variables used in the state under test. Object keys are the variable names and values are the variable values.
iv_statename TYPE /AWS1/SFNTESTSTATESTATENAME /AWS1/SFNTESTSTATESTATENAME¶
Denotes the particular state within a state machine definition to be tested. If this field is specified, the
definitionmust contain a fully-formed state machine definition.
io_mock TYPE REF TO /AWS1/CL_SFNMOCKINPUT /AWS1/CL_SFNMOCKINPUT¶
Defines a mocked result or error for the state under test.
A mock can only be specified for Task, Map, or Parallel states. If it is specified for another state type, an exception will be thrown.
iv_context TYPE /AWS1/SFNSENSITIVEDATA /AWS1/SFNSENSITIVEDATA¶
A JSON string representing a valid Context object for the state under test. This field may only be specified if a mock is specified in the same request.
io_stateconfiguration TYPE REF TO /AWS1/CL_SFNTESTSTATECONF /AWS1/CL_SFNTESTSTATECONF¶
Contains configurations for the state under test.
RETURNING¶
oo_output TYPE REF TO /aws1/cl_sfnteststateoutput /AWS1/CL_SFNTESTSTATEOUTPUT¶
Domain /AWS1/RT_ACCOUNT_ID Primitive Type NUMC
Examples¶
Syntax Example¶
This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.
DATA(lo_result) = lo_client->teststate(
io_mock = new /aws1/cl_sfnmockinput(
io_erroroutput = new /aws1/cl_sfnmockerroroutput(
iv_cause = |string|
iv_error = |string|
)
iv_fieldvalidationmode = |string|
iv_result = |string|
)
io_stateconfiguration = new /aws1/cl_sfnteststateconf(
iv_errorcausedbystate = |string|
iv_mapitemreaderdata = |string|
iv_mapiterationfailurecount = 123
iv_retrierretrycount = 123
)
iv_context = |string|
iv_definition = |string|
iv_input = |string|
iv_inspectionlevel = |string|
iv_revealsecrets = ABAP_TRUE
iv_rolearn = |string|
iv_statename = |string|
iv_variables = |string|
).
This is an example of reading all possible response values
lo_result = lo_result.
IF lo_result IS NOT INITIAL.
lv_sensitivedata = lo_result->get_output( ).
lv_sensitiveerror = lo_result->get_error( ).
lv_sensitivecause = lo_result->get_cause( ).
lo_inspectiondata = lo_result->get_inspectiondata( ).
IF lo_inspectiondata IS NOT INITIAL.
lv_sensitivedata = lo_inspectiondata->get_input( ).
lv_sensitivedata = lo_inspectiondata->get_afterarguments( ).
lv_sensitivedata = lo_inspectiondata->get_afterinputpath( ).
lv_sensitivedata = lo_inspectiondata->get_afterparameters( ).
lv_sensitivedata = lo_inspectiondata->get_result( ).
lv_sensitivedata = lo_inspectiondata->get_afterresultselector( ).
lv_sensitivedata = lo_inspectiondata->get_afterresultpath( ).
lo_inspectiondatarequest = lo_inspectiondata->get_request( ).
IF lo_inspectiondatarequest IS NOT INITIAL.
lv_httpprotocol = lo_inspectiondatarequest->get_protocol( ).
lv_httpmethod = lo_inspectiondatarequest->get_method( ).
lv_url = lo_inspectiondatarequest->get_url( ).
lv_httpheaders = lo_inspectiondatarequest->get_headers( ).
lv_httpbody = lo_inspectiondatarequest->get_body( ).
ENDIF.
lo_inspectiondataresponse = lo_inspectiondata->get_response( ).
IF lo_inspectiondataresponse IS NOT INITIAL.
lv_httpprotocol = lo_inspectiondataresponse->get_protocol( ).
lv_httpstatuscode = lo_inspectiondataresponse->get_statuscode( ).
lv_httpstatusmessage = lo_inspectiondataresponse->get_statusmessage( ).
lv_httpheaders = lo_inspectiondataresponse->get_headers( ).
lv_httpbody = lo_inspectiondataresponse->get_body( ).
ENDIF.
lv_sensitivedata = lo_inspectiondata->get_variables( ).
lo_inspectionerrordetails = lo_inspectiondata->get_errordetails( ).
IF lo_inspectionerrordetails IS NOT INITIAL.
lv_exceptionhandlerindex = lo_inspectionerrordetails->get_catchindex( ).
lv_exceptionhandlerindex = lo_inspectionerrordetails->get_retryindex( ).
lv_retrybackoffintervalsec = lo_inspectionerrordetails->get_retrybackoffintervalsecs( ).
ENDIF.
lv_sensitivedata = lo_inspectiondata->get_afteritemspath( ).
lv_sensitivedata = lo_inspectiondata->get_afteritemselector( ).
lv_sensitivedata = lo_inspectiondata->get_afteritembatcher( ).
lv_sensitivedata = lo_inspectiondata->get_afteritemspointer( ).
lv_inspectiontoleratedfail = lo_inspectiondata->get_toleratedfailurecount( ).
lv_inspectiontoleratedfail_1 = lo_inspectiondata->get_toleratedfailurepercen00( ).
lv_inspectionmaxconcurrenc = lo_inspectiondata->get_maxconcurrency( ).
ENDIF.
lv_statename = lo_result->get_nextstate( ).
lv_testexecutionstatus = lo_result->get_status( ).
ENDIF.