module DeviceApplicationInterfaceAPI_Functions { // JSON import from JSON all; // LibCommon import from LibCommon_BasicTypesAndValues all; import from LibCommon_Time all; import from LibCommon_VerdictControl all; import from LibCommon_Sync all; // LibHttp import from LibItsHttp_TypesAndValues all; import from LibItsHttp_Functions all; import from LibItsHttp_Templates all; import from LibItsHttp_JsonTemplates all; import from LibItsHttp_TestSystem all; // LibMec/DeviceApplicationInterfaceAPI import from DeviceApplicationInterfaceAPI_TypesAndValues all; import from DeviceApplicationInterfaceAPI_Templates all; import from DeviceApplicationInterfaceAPI_Pixits all; // LibMec import from LibMec_Templates all; import from LibMec_Functions all; import from LibMec_Pics all; import from LibMec_Pixits all; function f_create_application_context( out AppContext p_device_info_app_context ) runs on HttpComponent { var Headers v_headers; var HttpMessage v_response; f_init_default_headers_list(-, -, v_headers); httpPort.send( m_http_request( m_http_request_post( PICS_ROOT_API & PX_DEVICE_APP_CTX_URI, v_headers, m_http_message_body_json( m_body_json_device_info_app_context( m_device_app_context( PX_ASSOCIATE_DEV_APPID, m_app_context_info( PX_APPD_ID, PX_UNKNOWN_APP_NAME, PX_APP_PROVIDER, PX_APPD_VERSION ), PX_DEVICE_APP_CALLBACK ) ) ) ) ) ); tc_ac.start; alt { [] httpPort.receive( mw_http_response( mw_http_response_201_created( mw_http_message_body_json( mw_body_json_device_info_app_context( mw_device_app_context( -, PX_ASSOCIATE_DEV_APPID, mw_app_context_info, PX_DEVICE_APP_CALLBACK )))))) -> value v_response { tc_ac.stop; // TODO Check presence of Location HTTP header p_device_info_app_context := v_response.response.body.json_body.appContext_device_info; log("f_create_application_context: INFO: IUT successfully responds with an Application Context: ", p_device_info_app_context); } [] tc_ac.timeout { log("f_create_application_context: INCONC: Expected message not received"); } } // End of 'alt' statement } // End of function f_create_application_context function f_delete_application_context( in AppContext p_device_info_app_context ) runs on HttpComponent { var Headers v_headers; f_init_default_headers_list(-, -, v_headers); httpPort.send( m_http_request( m_http_request_delete( PICS_ROOT_API & PX_DEVICE_APP_CTX_URI & "/" & p_device_info_app_context.contextId, v_headers ) ) ); tc_ac.start; alt { [] httpPort.receive( mw_http_response( mw_http_response_204_no_content )) { tc_ac.stop; log("f_delete_application_context: INFO: IUT successfully deletes the Application Context: ", p_device_info_app_context.contextId); } [] tc_ac.timeout { log("f_delete_application_context: INCONC: Expected message not received"); } } // End of 'alt' statement } // End of function f_delete_application_context } // End of module DeviceApplicationInterfaceAPI_Functions