Hi There.
I developing a workflow with a similar approach to this example:
https://github.com/temporalio/samples-java/blob/main/src/main/java/io/temporal/samples/hello/HelloSignal.java (GreetingWorkflowImpl)
The main differences are that I’m requesting the execution of a process to another microservice and this microservice will be sending signals to the workflow as it goes.
If a failure signal arrive, I have to request the execution up to 3 times.
When testing this workflow, I’m mocking the activity using mockito.
The mock for activityMock.retrieveExecutionTimeout() works fine,
but when the flow executes activityMock.retrieveCounter(anyInt()) it throws the exception described in the subject for this topic.
Any idea about why the activityMock works in the first call but throws and exception in the second call?
I’m providing you with much information as possible, but I have limitations to share the real stuff, sorry for that.
By the way, I’m using the java sdk plus temporal-testing version 1.6 as well as the temporal-testing-junit5 version 1.5.
see the code below:
@RegisterExtension
public static final TestWorkflowExtension testWorkflowExtension = TestWorkflowExtension.newBuilder()
.setWorkflowTypes(MyWorkflowImpl.class)
.setDoNotStart(true)
.build();@Test
void createCustomDomain_FailedTest(TestWorkflowEnvironment testEnv, Worker worker, CustomDomainWorkflow workflow) {
MyActivity activityMock = Mockito.mock(CustomDomainActivity.class);
RequestDTO request = buildRequest();
SomeDTO response = buildDTOFromResultCode(SomeDTO.ResultCode.SUCCESS);when(activityMock.createSomething(any(RequestDTO.class), anyString())).thenReturn(response); when(activityMock.retrieveExecutionTimeout()).thenReturn(2L); when(activityMock.retrieveCounter(anyInt())).thenReturn(2) .thenReturn(3); //Execute worker.registerActivitiesImplementations(activityMock); testEnv.registerDelayedCallback(Duration.ofSeconds(4L), () -> { workflow.updateStatus(Constants.FAILURE); }); testEnv.registerDelayedCallback(Duration.ofSeconds(4L), () -> { workflow.updateStatus(Constants.FAILURE); }); testEnv.registerDelayedCallback(Duration.ofSeconds(4L), () -> { workflow.updateStatus(Constants.FAILURE); }); testEnv.start(); String result = workflow.createStack(request, "ABC-123"); //Assertions after this.
}