Unknow exception in Junit5 unittest

Hello,

I write a unittest case for our temporal workflow but got exception like below. not sure what is the issue and how to solve it.

I:\jdk-11.0.13\bin\java.exe -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:57523,suspend=y,server=n -ea -Djacoco-agent.
Connected to the target VM, address: ‘127.0.0.1:57523’, transport: ‘socket’
13:13:32.794 [main] INFO i.t.s.WorkflowServiceStubsImpl - Created GRPC client for channel: ManagedChannelOrphanWrapper{delegate=ManagedChannelImpl{logId=1, target=directaddress:///2be973e9-c9cc-4362-b253-0470b709ee88}}
13:13:32.815 [main] INFO i.t.s.WorkflowServiceStubsImpl - Created GRPC client for channel: ManagedChannelOrphanWrapper{delegate=ManagedChannelImpl{logId=5, target=directaddress:///dfb878c3-0016-417d-afcb-5a16a7642c11}}
13:13:32.902 [main] INFO io.temporal.internal.worker.Poller - start: Poller{name=Workflow Poller taskQueue=“WorkflowTest-testWorkflow(UMCWorkflow)-[engine:junit-jupiter]/[class:HelloActivityTestExtension]/[method:testWorkflow(net.jpmchase.umc.workflow.UMCWorkflow)]”, namespace=“UnitTest”, identity=14200@chcd1191c8n1}
13:13:32.906 [main] INFO io.temporal.internal.worker.Poller - start: Poller{name=Local Activity Poller taskQueue=“WorkflowTest-testWorkflow(UMCWorkflow)-[engine:junit-jupiter]/[class:HelloActivityTestExtension]/[method:testWorkflow(net.jpmchase.umc.workflow.UMCWorkflow)]”, namespace=“UnitTest”, identity=14200@chcd1191c8n1}
13:13:32.909 [main] INFO io.temporal.internal.worker.Poller - start: Poller{name=Activity Poller taskQueue=“UnitTest”, namespace=“WorkflowTest-testWorkflow(UMCWorkflow)-[engine:junit-jupiter]/[class:HelloActivityTestExtension]/[method:testWorkflow(net.jpmchase.umc.workflow.UMCWorkflow)]”, identity=14200@chcd1191c8n1}
13:13:32.910 [main] INFO io.temporal.internal.worker.Poller - start: Poller{name=Host Local Workflow Poller, identity=2186414d-0463-4498-815e-6c35e303d967}
Apr 07, 2022 1:13:33 PM io.grpc.internal.SerializeReentrantCallsDirectExecutor execute
SEVERE: Exception while executing runnable io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1HalfClosed@c1fca2a
java.lang.NoSuchMethodError: io.temporal.internal.common.WorkflowExecutionUtils.isWorkflowExecutionCompletedEvent(Lio/temporal/api/history/v1/HistoryEventOrBuilder;)Z
at io.temporal.internal.testservice.RequestContext.addEvent(RequestContext.java:180)
at io.temporal.internal.testservice.StateMachines.startWorkflow(StateMachines.java:875)
at io.temporal.internal.testservice.StateMachine$FixedTransitionDestination.apply(StateMachine.java:133)
at io.temporal.internal.testservice.StateMachine.action(StateMachine.java:229)


at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

13:13:33.180 [main] WARN i.t.internal.retryer.GrpcSyncRetryer - Retrying after failure
io.grpc.StatusRuntimeException: UNKNOWN
at io.grpc.stub.ClientCalls.toStatusRuntimeException(ClientCalls.java:262)
at io.grpc.stub.ClientCalls.getUnchecked(ClientCalls.java:243)
at io.grpc.stub.ClientCalls.blockingUnaryCall(ClientCalls.java:156)
at io.temporal.api.workflowservice.v1.WorkflowServiceGrpc$WorkflowServiceBlockingStub.startWorkflowExecution(WorkflowServiceGrpc.java:2631)
at …

......

Disconnected from the target VM, address: ‘127.0.0.1:57523’, transport: ‘socket’

Process finished with exit code -1

code:

public class HelloActivityTestExtension {
private static final Logger log = LoggerFactory.getLogger(HelloActivityTestExtension.class);
private static final String TASK_QUEUE = “test-workflow”;

@RegisterExtension
public static final TestWorkflowExtension testWorkflowExtension =
        TestWorkflowExtension.newBuilder()
                .setWorkflowTypes(PartialRepoToClusterWorkflowImpl.class)
                .setActivityImplementations(new PartialRepoToClusterActivitiesImpl())
                .build();

@Test
public void testWorkflow(UMCWorkflow workflow) {
    // Execute a workflow waiting for it to complete.
    workflow.execute("NATGQ03", "natgq02");
}

}

Hi @fromdw

java.lang.NoSuchMethodError: io.temporal.internal.common.WorkflowExecutionUtils.isWorkflowExecutionCompletedEvent

This method was renamed in Java SDK release 1.5.0, specifically this PR

Which SDK version are you using? Might be a misalignment in your depends.

the dependency like below:

jdk 11

<dependency>
  <groupId>io.temporal</groupId>
  <artifactId>temporal-sdk</artifactId>
  <version>1.7.1</version>
</dependency>

<dependency>
  <groupId>io.temporal</groupId>
  <artifactId>temporal-testing-junit5</artifactId>
  <version>1.1.0</version>
  <scope>test</scope>
</dependency>

For Maven you should use the same version for sdk and testing depends, for example:

<dependency>
	<groupId>io.temporal</groupId>
	<artifactId>temporal-sdk</artifactId>
	<version>${version.temporal}</version>
</dependency>
<dependency>
	<groupId>io.temporal</groupId>
	<artifactId>temporal-testing</artifactId>
	<scope>test</scope>
	<version>${version.temporal}</version>
</dependency>

where version.temporal can be in your pom properties section:

<properties>
   <version.temporal>1.8.1</version.temporal>
</properties>

temporal-testing depends will pull in support for both JUnit 4 and 5

thanks so much