From ba99106604b5eb219b730f93dbd6fc3f8707c860 Mon Sep 17 00:00:00 2001 From: Quanzheng Long Date: Fri, 2 Jun 2023 13:23:16 -0700 Subject: [PATCH] Add test for sa --- src/test/java/io/iworkflow/integ/RpcTest.java | 7 +++++++ .../java/io/iworkflow/integ/rpc/RpcWorkflow.java | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/test/java/io/iworkflow/integ/RpcTest.java b/src/test/java/io/iworkflow/integ/RpcTest.java index b29d86fa..6e70d444 100644 --- a/src/test/java/io/iworkflow/integ/RpcTest.java +++ b/src/test/java/io/iworkflow/integ/RpcTest.java @@ -53,6 +53,13 @@ public void testRPCWorkflowFunc1() throws InterruptedException { value = client.invokeRPC(rpcStub::testRpcGetDataAttribute); Assertions.assertNull(value); + client.invokeRPC(rpcStub::testRpcSetKeyword, "test-value"); + value = client.invokeRPC(rpcStub::testRpcGetKeyword); + Assertions.assertEquals("test-value", value); + client.invokeRPC(rpcStub::testRpcSetKeyword, null); + value = client.invokeRPC(rpcStub::testRpcGetKeyword); + Assertions.assertNull(value); + final Long rpcOutput = client.invokeRPC(rpcStub::testRpcFunc1, RPC_INPUT); Assertions.assertEquals(RPC_OUTPUT, rpcOutput); diff --git a/src/test/java/io/iworkflow/integ/rpc/RpcWorkflow.java b/src/test/java/io/iworkflow/integ/rpc/RpcWorkflow.java index 7b287d9a..2af96767 100644 --- a/src/test/java/io/iworkflow/integ/rpc/RpcWorkflow.java +++ b/src/test/java/io/iworkflow/integ/rpc/RpcWorkflow.java @@ -128,4 +128,20 @@ public String testRpcGetDataAttribute(Context context, Persistence persistence, } return persistence.getDataAttribute(TEST_DATA_OBJECT_KEY, String.class); } + + @RPC + public void testRpcSetKeyword(Context context, String input, Persistence persistence, Communication communication) { + if (context.getWorkflowId().isEmpty() || context.getWorkflowRunId().isEmpty()) { + throw new RuntimeException("invalid context"); + } + persistence.setSearchAttributeKeyword(TEST_SEARCH_ATTRIBUTE_KEYWORD, input); + } + + @RPC + public String testRpcGetKeyword(Context context, Persistence persistence, Communication communication) { + if (context.getWorkflowId().isEmpty() || context.getWorkflowRunId().isEmpty()) { + throw new RuntimeException("invalid context"); + } + return persistence.getSearchAttributeKeyword(TEST_SEARCH_ATTRIBUTE_KEYWORD); + } }