フローを使用したテスト接続動作の実装
この手順では、フローを使用して接続のテスト機能を実装する方法について説明します。
- べき等テストAPIへのGETコールを使用して、単純なフローを定義します。サンプル・コードは次のとおりです:
"flows": { "testConnectionFlow" :{ "id": "testConnectionFlow", "description": "testConnectionFlow", "specVersion": "0.8", "version": "0.1", "start": "startState", "functions": [ { "name": "generalRestFunc", "type": "custom", "operation": "connectivity::rest" } ], "states": [ { "name": "startState", "type": "operation", "actions": [ { "functionRef": { "refName": "generalRestFunc", "arguments": { "uri": "${.connectionProperties.baseURL + \"/customers\"}", "method": "GET" } }, } ], "end": true } ] } } - 条件をアサートし、
.output.successをtrueに設定してステータス・コードをアサートするactionDataFilterアクションを追加します。サンプル・コードは次のとおりです:"actionDataFilter": { "results": "${ { success: (.status==200), message: .body.origin } }", "toStateData": "${ .output }" }次に、テスト・エンドポイントへのアウトバウンドGETコールを行い、状態ブール出力値を使用して結果を示す完全なサンプル・コードを示します:"flows": { "testConnectionFlow" :{ "id": "testConnectionFlow", "description": "testConnectionFlow", "specVersion": "0.8", "version": "0.1", "start": "startState", "functions": [ { "name": "generalRestFunc", "type": "custom", "operation": "connectivity::rest" } ], "states": [ { "name": "startState", "type": "operation", "actions": [ { "functionRef": { "refName": "generalRestFunc", "arguments": { "uri": "${.connectionProperties.baseURL + \"/customers\"}", "method": "GET" } }, "actionDataFilter": { "results": "${ { success: (.status==200), message: .body.origin } }", "toStateData": "${ .output }" } } ], "end": true } ] } } - 接続定義でフローをコールします。サンプル・コードを次に示します。
"connectionDefinition": { "connectionProperties": [ ], "securityPolicies": [ { "type": "managed", "policy": "BASIC_AUTH", "description": "Account credentials", "displayName": "Account credentials", "scope": "ACTION", "securityProperties": [ { "name": "username", "hidden" : true, "default": "oracle" } ] } ], "test": "flow:testConnectionFlow"