No response needed. Just noting here for completeness.
When constructing unit-tests with JUnit, it’s useful to use Mockito.Spy, e.g. to track call counts into activity methods. However, in constructing Spy instances, I’ve noticed that Spy strips the @ActivityInterface annotations, thus causing a Temporal runtime error attempting to use the activity.
I’ve tried with 3.12.4 and 3.11.2, but it won’t work.
In the sample above, you’re using the interface. In my JUnit test, I create an instance of the activity impl, and wrap that with the spy. Then add the impl to the worker. So I’m wondering if your sample isn’t valid in this case. Whatever Spy is doing to insert hooks, it’s not re-attaching the annotations.
Also, your example is fetching the annotation from the interface. If you’re on the impl class, you’d have to navigate up the class hierarchy to find the annotation, e.g.
“Note that the spy won’t have any annotations of the spied type, because CGLIB won’t rewrite them. It may troublesome for code that rely on the spy to have these annotations.”