@@ -387,6 +387,64 @@ public void testAnnotationNotAllowedOnInterface() {
387387 e .getMessage ());
388388 }
389389
390+ @ Test
391+ public void testWorkerWithDeploymentOptionsVersioningOffCanRunWorkflows () {
392+ assumeTrue ("Test Server doesn't support versioning" , SDKTestWorkflowRule .useExternalService );
393+
394+ Worker w1 =
395+ testWorkflowRule .newWorker (
396+ (opts ) ->
397+ opts .setDeploymentOptions (
398+ WorkerDeploymentOptions .newBuilder ()
399+ .setVersion (
400+ new WorkerDeploymentVersion (
401+ testWorkflowRule .getDeploymentName (), "my-custom-build-id-1.0" ))
402+ .setUseVersioning (false )
403+ .build ()));
404+ w1 .registerWorkflowImplementationTypes (TestWorkerVersioningMissingAnnotation .class );
405+ w1 .start ();
406+
407+ TestWorkflows .QueryableWorkflow wf =
408+ testWorkflowRule .newWorkflowStubTimeoutOptions (
409+ TestWorkflows .QueryableWorkflow .class , "versioning-off-build-id" );
410+ WorkflowExecution we = WorkflowClient .start (wf ::execute );
411+ wf .mySignal ("done" );
412+ String result =
413+ testWorkflowRule
414+ .getWorkflowClient ()
415+ .newUntypedWorkflowStub (we .getWorkflowId ())
416+ .getResult (String .class );
417+ Assert .assertEquals ("no-annotation" , result );
418+
419+ WorkflowExecutionHistory hist = testWorkflowRule .getExecutionHistory (we .getWorkflowId ());
420+ // The Java SDK sends deployment_options on WFT completion, and the server records the
421+ // deployment name in the worker_deployment_name field of the history event.
422+ Assert .assertTrue (
423+ "Expected deployment name to appear in workflow history" ,
424+ hist .getHistory ().getEventsList ().stream ()
425+ .anyMatch (
426+ e ->
427+ e .getEventType () == EventType .EVENT_TYPE_WORKFLOW_TASK_COMPLETED
428+ && !e .getWorkflowTaskCompletedEventAttributes ()
429+ .getWorkerDeploymentName ()
430+ .isEmpty ()));
431+ }
432+
433+ @ Test
434+ public void testRejectsVersioningBehaviorWhenVersioningOff () {
435+ IllegalStateException e =
436+ Assert .assertThrows (
437+ IllegalStateException .class ,
438+ () ->
439+ WorkerDeploymentOptions .newBuilder ()
440+ .setVersion (
441+ new WorkerDeploymentVersion (testWorkflowRule .getDeploymentName (), "1.0" ))
442+ .setUseVersioning (false )
443+ .setDefaultVersioningBehavior (VersioningBehavior .AUTO_UPGRADE )
444+ .build ());
445+ Assert .assertTrue (e .getMessage ().contains ("defaultVersioningBehavior must be UNSPECIFIED" ));
446+ }
447+
390448 @ SuppressWarnings ("deprecation" )
391449 @ Test
392450 public void testWorkflowsCanUseVersioningOverride () {
0 commit comments