Skip to content

Commit

Permalink
Add test for sa
Browse files Browse the repository at this point in the history
  • Loading branch information
longquanzheng committed Jun 2, 2023
1 parent 2a7bc8e commit ba99106
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/test/java/io/iworkflow/integ/RpcTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
16 changes: 16 additions & 0 deletions src/test/java/io/iworkflow/integ/rpc/RpcWorkflow.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit ba99106

Please sign in to comment.