Mock untyped activity - Java SDK

Hi,
We write temporal unit tests in our java springboot application using the @RegisterExtension annotation and instantiating a TestWorkflowExtension.
We have a workflow with multiple activities. However ONE of these is an untyped activity as we wanted this to be executed by another application(another code base and deployment). In the test case how do we mock this untyped activity.

In the workflowImpl we have
private final ActivityStub activity = Workflow.newUntypedActivityStub(TemporalWorkFlowUtil.getActivityOptionByTaskQueue(Constants.TemporalConstants.SOME_QUEUE));

and activity is executed using
activity.execute(“generateExcel”, Void.class, someRequest);

how do i mock the activity and the activity.execute method

You only need the activity interface in test, so something like

  @ActivityInterface
  public interface MyActivities {
    void generateExcel(Request someRequest);
  }

and mock it and register mock with test worker, assume you want to test this void method throw exception so could be

    MyActivities activities =
        mock(MyActivities.class, withSettings().withoutAnnotations());
    Mockito.doThrow(new MyRequestException()).when(activities).generateExcel(any());