2929import io .temporal .activity .*;
3030import io .temporal .api .common .v1 .Payload ;
3131import io .temporal .api .common .v1 .WorkflowExecution ;
32+ import io .temporal .api .enums .v1 .EventType ;
3233import io .temporal .client .*;
33- import io .temporal .client .schedules .*;
3434import io .temporal .common .converter .*;
3535import io .temporal .failure .CanceledFailure ;
3636import io .temporal .payload .codec .PayloadCodec ;
4646import java .io .IOException ;
4747import java .time .Duration ;
4848import java .util .*;
49+ import java .util .concurrent .atomic .AtomicInteger ;
4950import java .util .stream .Collectors ;
5051import javax .annotation .Nonnull ;
5152import javax .annotation .Nullable ;
@@ -71,15 +72,17 @@ public class WorkflowIdSignedPayloadsTest {
7172 private static final DataConverter codecDataConverter =
7273 new CodecDataConverter (
7374 DefaultDataConverter .STANDARD_INSTANCE ,
74- Collections .singletonList (new PayloadEncoderWithWorkflowIdSignature ()));
75+ Collections .singletonList (new PayloadEncoderWithWorkflowIdSignature ()),
76+ true );
7577
7678 @ Rule
7779 public SDKTestWorkflowRule testWorkflowRule =
7880 SDKTestWorkflowRule .newBuilder ()
7981 .setWorkflowTypes (
8082 SimpleWorkflowWithAnActivity .class ,
8183 TestWorkflowWithCronScheduleImpl .class ,
82- DynamicWorkflowImpl .class )
84+ DynamicWorkflowImpl .class ,
85+ WorkflowWithQuery .class )
8386 .setWorkflowClientOptions (
8487 WorkflowClientOptions .newBuilder ().setDataConverter (codecDataConverter ).build ())
8588 .setActivityImplementations (
@@ -173,6 +176,26 @@ public void testDynamicWorkflow() {
173176 assertEquals ("Hello World" , workflow .getResult (String .class ));
174177 }
175178
179+ @ Test
180+ public void testWorkflowWithTaskFailure () {
181+ WorkflowOptions options =
182+ SDKTestOptions .newWorkflowOptionsWithTimeouts (testWorkflowRule .getTaskQueue ());
183+ TestWorkflows .TestWorkflowReturnString workflow =
184+ testWorkflowRule
185+ .getWorkflowClient ()
186+ .newWorkflowStub (TestWorkflows .TestWorkflowReturnString .class , options );
187+ assertEquals ("Hello World" , workflow .execute ());
188+ // Test that the task failure is recorded in the history
189+ // if the serialization fails the workflow task will timeout.
190+ assertEquals (
191+ 1 ,
192+ testWorkflowRule
193+ .getHistoryEvents (
194+ WorkflowStub .fromTyped (workflow ).getExecution ().getWorkflowId (),
195+ EventType .EVENT_TYPE_WORKFLOW_TASK_FAILED )
196+ .size ());
197+ }
198+
176199 @ ActivityInterface
177200 public interface SimpleActivity {
178201 @ ActivityMethod (name = "simple" )
@@ -213,6 +236,18 @@ public String execute(String input) {
213236 }
214237 }
215238
239+ public static class WorkflowWithQuery implements TestWorkflows .TestWorkflowReturnString {
240+ static AtomicInteger taskRetryCount = new AtomicInteger ();
241+
242+ @ Override
243+ public String execute () {
244+ if (taskRetryCount .incrementAndGet () == 1 ) {
245+ throw new RuntimeException ("test" );
246+ }
247+ return "Hello World" ;
248+ }
249+ }
250+
216251 public static class SimpleWorkflowWithAnActivity implements TestWorkflows .TestWorkflow1 {
217252
218253 private final SimpleActivity activity =
0 commit comments