We have activity, that is using "Asynchronous Activity Completion" and we want to test it. In our case, we just want to test, that activity will send proper kafka message, but still, we need to set up test environment, to obtain activity token, etc.
In shortest form, our test looks like this:
var testActivityEnvironment = TestActivityEnvironment.newInstance(TestEnvironmentOptions.getDefaultInstance());
testActivityEnvironment.registerActivitiesImplementations(activityImpl);
var testActivity = testActivityEnvironment.newActivityStub(SomeActivities.class);
testActivity.execute();
Inside of activityImpl we use context.doNotCompleteOnReturn();
Problem is, that TestActivityEnvironmentInternal expects either cancelled, failed or completed activity.
In case of not async activity, all fields of ActivityTaskHandler.Result are null and we get NullPointerException
We have activity, that is using "Asynchronous Activity Completion" and we want to test it. In our case, we just want to test, that activity will send proper kafka message, but still, we need to set up test environment, to obtain activity token, etc.
In shortest form, our test looks like this:
Inside of
activityImpl
we usecontext.doNotCompleteOnReturn();
Problem is, that
TestActivityEnvironmentInternal
expects either cancelled, failed or completed activity. In case of not async activity, all fields ofActivityTaskHandler.Result
are null and we getNullPointerException
Problematic block of code: https://github.com/temporalio/sdk-java/blob/master/temporal-testing/src/main/java/io/temporal/testing/TestActivityEnvironmentInternal.java#L489-L496
Expected Behavior
Calling mehod of async activity will do nothing.
Actual Behavior
NullPointerException at https://github.com/temporalio/sdk-java/blob/master/temporal-testing/src/main/java/io/temporal/testing/TestActivityEnvironmentInternal.java#L496 (response.getTaskFailed() is null)
Specifications