Hi! I’m using SDKTestWorkflowRule for workflow unit testing. I want to query the workflows by using the ListWorkflowExecutionsRequest/ListOpenWorkflowExecutionsResponse. I encounter this exception that says WorkflowService/ListWorkflowExecutions is unimplemented.
I tried using ListOpenWorkflowExecutionsRequest and I’m able to get all running/open workflows. The problem of using ListOpenWorkflowExecutionsRequest is I can’t query specific workflow (setQuery method).
What is the cause of the unimplemented method? Any help is much appreciated. Thanks!
Oh, I see. Reason I came up trying to use SDKTestWorkflowRule because I want to check if an event exists in workflow history (i.e., signal event) by using the assertHistoryEvent(WorkflowExecution execution, EventType eventType) method.
Is there an equivalent of that functionality in the TestWorkflowRule/TestWorkflowExtension?
You can implement this method yourself (and extend it if needed) pretty easily with TestWorkflowRule, for example:
public void assertHistoryEvent(
TestWorkflowRule testWorkflowRule, WorkflowExecution execution, EventType eventType) {
History history =
testWorkflowRule
.getTestEnvironment()
.getWorkflowExecutionHistory(
WorkflowExecution.newBuilder().setWorkflowId("testId").build())
.getHistory();
for (HistoryEvent event : history.getEventsList()) {
if (eventType == event.getEventType()) {
return;
}
}
fail("No event of " + eventType + " found in the history");
}
and can call it from within your tests given workflow id (and runid if you have it):