Take the following sample workflow.
class MyWorkflow {
Activities activities;
int i = 0;
@WorkflowMethod
void workflow() {
activities.activityOne();
i++; // i = 1;
Workflow.sleep(Duration.ofMinutes(1));
activities.activityTwo();
i++; // i = 2;
activities.activityThree();
i++; // i = 3;
}
@QueryMethod
int counter() {
return i;
}
}
I know after initially invoking the workflow, it will reach the sleep call, and I can assert that the result of counter
query is 1. I can then call TestEnv.sleep
, however then the workflow continues and the result of counter
query is 3.
Is there a way to hold up the workflow at the call to activityThree()
and make assertions that the counter
query returns 2? I know this is trivial but gets at my desired to assert against workflow state at various points along its execution. I can do it with timers/sleep calls at the moment, but not other awaitables that the workflow would actually encounter.
(If it’s important, my activites are mocked for this test, I’m just testing workflow logic in isolation here.)