• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

uber / cadence-java-client / 2263

19 Apr 2024 03:59PM UTC coverage: 60.13% (-0.2%) from 60.328%
2263

push

buildkite

web-flow
Update idls (#882)

Implement required methods for new IDL types

0 of 51 new or added lines in 7 files covered. (0.0%)

16 existing lines in 7 files now uncovered.

11456 of 19052 relevant lines covered (60.13%)

0.6 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

69.71
/src/main/java/com/uber/cadence/internal/testservice/TestWorkflowService.java
1
/*
2
 *  Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
 *
4
 *  Modifications copyright (C) 2017 Uber Technologies, Inc.
5
 *
6
 *  Licensed under the Apache License, Version 2.0 (the "License"). You may not
7
 *  use this file except in compliance with the License. A copy of the License is
8
 *  located at
9
 *
10
 *  http://aws.amazon.com/apache2.0
11
 *
12
 *  or in the "license" file accompanying this file. This file is distributed on
13
 *  an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
14
 *  express or implied. See the License for the specific language governing
15
 *  permissions and limitations under the License.
16
 */
17

18
package com.uber.cadence.internal.testservice;
19

20
import com.uber.cadence.BadRequestError;
21
import com.uber.cadence.ClientVersionNotSupportedError;
22
import com.uber.cadence.ClusterInfo;
23
import com.uber.cadence.CountWorkflowExecutionsRequest;
24
import com.uber.cadence.CountWorkflowExecutionsResponse;
25
import com.uber.cadence.DeprecateDomainRequest;
26
import com.uber.cadence.DescribeDomainRequest;
27
import com.uber.cadence.DescribeDomainResponse;
28
import com.uber.cadence.DescribeTaskListRequest;
29
import com.uber.cadence.DescribeTaskListResponse;
30
import com.uber.cadence.DescribeWorkflowExecutionRequest;
31
import com.uber.cadence.DescribeWorkflowExecutionResponse;
32
import com.uber.cadence.DomainAlreadyExistsError;
33
import com.uber.cadence.DomainNotActiveError;
34
import com.uber.cadence.EntityNotExistsError;
35
import com.uber.cadence.GetSearchAttributesResponse;
36
import com.uber.cadence.GetTaskListsByDomainRequest;
37
import com.uber.cadence.GetTaskListsByDomainResponse;
38
import com.uber.cadence.GetWorkflowExecutionHistoryRequest;
39
import com.uber.cadence.GetWorkflowExecutionHistoryResponse;
40
import com.uber.cadence.InternalServiceError;
41
import com.uber.cadence.LimitExceededError;
42
import com.uber.cadence.ListArchivedWorkflowExecutionsRequest;
43
import com.uber.cadence.ListArchivedWorkflowExecutionsResponse;
44
import com.uber.cadence.ListClosedWorkflowExecutionsRequest;
45
import com.uber.cadence.ListClosedWorkflowExecutionsResponse;
46
import com.uber.cadence.ListDomainsRequest;
47
import com.uber.cadence.ListDomainsResponse;
48
import com.uber.cadence.ListOpenWorkflowExecutionsRequest;
49
import com.uber.cadence.ListOpenWorkflowExecutionsResponse;
50
import com.uber.cadence.ListTaskListPartitionsRequest;
51
import com.uber.cadence.ListTaskListPartitionsResponse;
52
import com.uber.cadence.ListWorkflowExecutionsRequest;
53
import com.uber.cadence.ListWorkflowExecutionsResponse;
54
import com.uber.cadence.PollForActivityTaskRequest;
55
import com.uber.cadence.PollForActivityTaskResponse;
56
import com.uber.cadence.PollForDecisionTaskRequest;
57
import com.uber.cadence.PollForDecisionTaskResponse;
58
import com.uber.cadence.QueryFailedError;
59
import com.uber.cadence.QueryWorkflowRequest;
60
import com.uber.cadence.QueryWorkflowResponse;
61
import com.uber.cadence.RecordActivityTaskHeartbeatByIDRequest;
62
import com.uber.cadence.RecordActivityTaskHeartbeatRequest;
63
import com.uber.cadence.RecordActivityTaskHeartbeatResponse;
64
import com.uber.cadence.RefreshWorkflowTasksRequest;
65
import com.uber.cadence.RegisterDomainRequest;
66
import com.uber.cadence.RequestCancelWorkflowExecutionRequest;
67
import com.uber.cadence.ResetStickyTaskListRequest;
68
import com.uber.cadence.ResetStickyTaskListResponse;
69
import com.uber.cadence.ResetWorkflowExecutionRequest;
70
import com.uber.cadence.ResetWorkflowExecutionResponse;
71
import com.uber.cadence.RespondActivityTaskCanceledByIDRequest;
72
import com.uber.cadence.RespondActivityTaskCanceledRequest;
73
import com.uber.cadence.RespondActivityTaskCompletedByIDRequest;
74
import com.uber.cadence.RespondActivityTaskCompletedRequest;
75
import com.uber.cadence.RespondActivityTaskFailedByIDRequest;
76
import com.uber.cadence.RespondActivityTaskFailedRequest;
77
import com.uber.cadence.RespondDecisionTaskCompletedRequest;
78
import com.uber.cadence.RespondDecisionTaskCompletedResponse;
79
import com.uber.cadence.RespondDecisionTaskFailedRequest;
80
import com.uber.cadence.RespondQueryTaskCompletedRequest;
81
import com.uber.cadence.RestartWorkflowExecutionRequest;
82
import com.uber.cadence.RestartWorkflowExecutionResponse;
83
import com.uber.cadence.RetryPolicy;
84
import com.uber.cadence.ServiceBusyError;
85
import com.uber.cadence.SignalExternalWorkflowExecutionDecisionAttributes;
86
import com.uber.cadence.SignalExternalWorkflowExecutionFailedCause;
87
import com.uber.cadence.SignalWithStartWorkflowExecutionAsyncRequest;
88
import com.uber.cadence.SignalWithStartWorkflowExecutionAsyncResponse;
89
import com.uber.cadence.SignalWithStartWorkflowExecutionRequest;
90
import com.uber.cadence.SignalWorkflowExecutionRequest;
91
import com.uber.cadence.StartWorkflowExecutionAsyncRequest;
92
import com.uber.cadence.StartWorkflowExecutionAsyncResponse;
93
import com.uber.cadence.StartWorkflowExecutionRequest;
94
import com.uber.cadence.StartWorkflowExecutionResponse;
95
import com.uber.cadence.TerminateWorkflowExecutionRequest;
96
import com.uber.cadence.UpdateDomainRequest;
97
import com.uber.cadence.UpdateDomainResponse;
98
import com.uber.cadence.WorkflowExecution;
99
import com.uber.cadence.WorkflowExecutionAlreadyCompletedError;
100
import com.uber.cadence.WorkflowExecutionAlreadyStartedError;
101
import com.uber.cadence.WorkflowExecutionCloseStatus;
102
import com.uber.cadence.WorkflowExecutionContinuedAsNewEventAttributes;
103
import com.uber.cadence.WorkflowExecutionFilter;
104
import com.uber.cadence.WorkflowExecutionInfo;
105
import com.uber.cadence.WorkflowIdReusePolicy;
106
import com.uber.cadence.internal.testservice.TestWorkflowMutableStateImpl.QueryId;
107
import com.uber.cadence.internal.testservice.TestWorkflowStore.WorkflowState;
108
import com.uber.cadence.serviceclient.IWorkflowService;
109
import java.time.Duration;
110
import java.util.HashMap;
111
import java.util.List;
112
import java.util.Map;
113
import java.util.Optional;
114
import java.util.OptionalLong;
115
import java.util.concurrent.CompletableFuture;
116
import java.util.concurrent.ExecutionException;
117
import java.util.concurrent.ForkJoinPool;
118
import java.util.concurrent.TimeUnit;
119
import java.util.concurrent.locks.Lock;
120
import java.util.concurrent.locks.ReentrantLock;
121
import org.apache.thrift.TException;
122
import org.apache.thrift.async.AsyncMethodCallback;
123
import org.slf4j.Logger;
124
import org.slf4j.LoggerFactory;
125

126
/**
127
 * In memory implementation of the Cadence service. To be used for testing purposes only. Do not use
128
 * directly. Instead use {@link com.uber.cadence.testing.TestWorkflowEnvironment}.
129
 */
130
public final class TestWorkflowService implements IWorkflowService {
1✔
131

132
  private static final Logger log = LoggerFactory.getLogger(TestWorkflowService.class);
1✔
133

134
  private final Lock lock = new ReentrantLock();
1✔
135

136
  private final TestWorkflowStore store = new TestWorkflowStoreImpl();
1✔
137

138
  private final Map<ExecutionId, TestWorkflowMutableState> executions = new HashMap<>();
1✔
139

140
  // key->WorkflowId
141
  private final Map<WorkflowId, TestWorkflowMutableState> executionsByWorkflowId = new HashMap<>();
1✔
142

143
  private final ForkJoinPool forkJoinPool = new ForkJoinPool(4);
1✔
144

145
  @Override
146
  public void close() {
147
    store.close();
1✔
148
  }
1✔
149

150
  private TestWorkflowMutableState getMutableState(ExecutionId executionId)
151
      throws InternalServiceError, EntityNotExistsError {
152
    return getMutableState(executionId, true);
1✔
153
  }
154

155
  private TestWorkflowMutableState getMutableState(ExecutionId executionId, boolean failNotExists)
156
      throws InternalServiceError, EntityNotExistsError {
157
    lock.lock();
1✔
158
    try {
159
      if (executionId.getExecution().getRunId() == null) {
1✔
160
        return getMutableState(executionId.getWorkflowId(), failNotExists);
1✔
161
      }
162
      TestWorkflowMutableState mutableState = executions.get(executionId);
1✔
163
      if (mutableState == null && failNotExists) {
1✔
164
        throw new InternalServiceError("Execution not found in mutable state: " + executionId);
1✔
165
      }
166
      return mutableState;
1✔
167
    } finally {
168
      lock.unlock();
1✔
169
    }
170
  }
171

172
  private TestWorkflowMutableState getMutableState(WorkflowId workflowId)
173
      throws EntityNotExistsError {
174
    return getMutableState(workflowId, true);
1✔
175
  }
176

177
  private TestWorkflowMutableState getMutableState(WorkflowId workflowId, boolean failNotExists)
178
      throws EntityNotExistsError {
179
    lock.lock();
1✔
180
    try {
181
      TestWorkflowMutableState mutableState = executionsByWorkflowId.get(workflowId);
1✔
182
      if (mutableState == null && failNotExists) {
1✔
183
        throw new EntityNotExistsError("Execution not found in mutable state: " + workflowId);
1✔
184
      }
185
      return mutableState;
1✔
186
    } finally {
187
      lock.unlock();
1✔
188
    }
189
  }
190

191
  @Override
192
  public void RegisterDomain(RegisterDomainRequest registerRequest)
193
      throws BadRequestError, InternalServiceError, DomainAlreadyExistsError, TException {
194
    throw new UnsupportedOperationException("not implemented");
×
195
  }
196

197
  @Override
198
  public DescribeDomainResponse DescribeDomain(DescribeDomainRequest describeRequest)
199
      throws BadRequestError, InternalServiceError, EntityNotExistsError, TException {
200
    throw new UnsupportedOperationException("not implemented");
×
201
  }
202

203
  @Override
204
  public ListDomainsResponse ListDomains(ListDomainsRequest listRequest)
205
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
206
          TException {
207
    throw new UnsupportedOperationException("not implemented");
×
208
  }
209

210
  @Override
211
  public UpdateDomainResponse UpdateDomain(UpdateDomainRequest updateRequest)
212
      throws BadRequestError, InternalServiceError, EntityNotExistsError, TException {
213
    throw new UnsupportedOperationException("not implemented");
×
214
  }
215

216
  @Override
217
  public void DeprecateDomain(DeprecateDomainRequest deprecateRequest)
218
      throws BadRequestError, InternalServiceError, EntityNotExistsError, TException {
219
    throw new UnsupportedOperationException("not implemented");
×
220
  }
221

222
  @Override
223
  public RestartWorkflowExecutionResponse RestartWorkflowExecution(
224
      RestartWorkflowExecutionRequest restartRequest)
225
      throws BadRequestError, ServiceBusyError, DomainNotActiveError, LimitExceededError,
226
          EntityNotExistsError, ClientVersionNotSupportedError, TException {
NEW
227
    throw new UnsupportedOperationException("not implemented");
×
228
  }
229

230
  @Override
231
  public GetTaskListsByDomainResponse GetTaskListsByDomain(GetTaskListsByDomainRequest request)
232
      throws BadRequestError, EntityNotExistsError, LimitExceededError, ServiceBusyError,
233
          ClientVersionNotSupportedError, TException {
234
    throw new UnsupportedOperationException("not implemented");
×
235
  }
236

237
  @Override
238
  public StartWorkflowExecutionResponse StartWorkflowExecution(
239
      StartWorkflowExecutionRequest startRequest) throws TException {
240
    return startWorkflowExecutionImpl(
1✔
241
        startRequest, 0, Optional.empty(), OptionalLong.empty(), Optional.empty());
1✔
242
  }
243

244
  @Override
245
  public StartWorkflowExecutionAsyncResponse StartWorkflowExecutionAsync(
246
      StartWorkflowExecutionAsyncRequest startRequest)
247
      throws BadRequestError, WorkflowExecutionAlreadyStartedError, ServiceBusyError,
248
          DomainNotActiveError, LimitExceededError, EntityNotExistsError,
249
          ClientVersionNotSupportedError, TException {
NEW
250
    throw new UnsupportedOperationException("not implemented");
×
251
  }
252

253
  StartWorkflowExecutionResponse startWorkflowExecutionImpl(
254
      StartWorkflowExecutionRequest startRequest,
255
      int backoffStartIntervalInSeconds,
256
      Optional<TestWorkflowMutableState> parent,
257
      OptionalLong parentChildInitiatedEventId,
258
      Optional<SignalWorkflowExecutionRequest> signalWithStartSignal)
259
      throws BadRequestError, WorkflowExecutionAlreadyStartedError, InternalServiceError {
260
    String requestWorkflowId = requireNotNull("WorkflowId", startRequest.getWorkflowId());
1✔
261
    String domain = requireNotNull("Domain", startRequest.getDomain());
1✔
262
    WorkflowId workflowId = new WorkflowId(domain, requestWorkflowId);
1✔
263
    TestWorkflowMutableState existing;
264
    lock.lock();
1✔
265
    try {
266
      existing = executionsByWorkflowId.get(workflowId);
1✔
267
      if (existing != null) {
1✔
268
        Optional<WorkflowExecutionCloseStatus> statusOptional = existing.getCloseStatus();
1✔
269
        WorkflowIdReusePolicy policy =
270
            startRequest.isSetWorkflowIdReusePolicy()
1✔
271
                ? startRequest.getWorkflowIdReusePolicy()
1✔
272
                : WorkflowIdReusePolicy.AllowDuplicateFailedOnly;
1✔
273
        if (!statusOptional.isPresent() || policy == WorkflowIdReusePolicy.RejectDuplicate) {
1✔
274
          return throwDuplicatedWorkflow(startRequest, existing);
×
275
        }
276
        WorkflowExecutionCloseStatus status = statusOptional.get();
1✔
277
        if (policy == WorkflowIdReusePolicy.AllowDuplicateFailedOnly
1✔
278
            && (status == WorkflowExecutionCloseStatus.COMPLETED
279
                || status == WorkflowExecutionCloseStatus.CONTINUED_AS_NEW)) {
280
          return throwDuplicatedWorkflow(startRequest, existing);
×
281
        }
282
      }
283
      RetryPolicy retryPolicy = startRequest.getRetryPolicy();
1✔
284
      Optional<RetryState> retryState = newRetryStateLocked(retryPolicy);
1✔
285
      return startWorkflowExecutionNoRunningCheckLocked(
1✔
286
          startRequest,
287
          Optional.empty(),
1✔
288
          retryState,
289
          backoffStartIntervalInSeconds,
290
          null,
291
          parent,
292
          parentChildInitiatedEventId,
293
          signalWithStartSignal,
294
          workflowId);
295
    } finally {
296
      lock.unlock();
1✔
297
    }
298
  }
299

300
  private Optional<RetryState> newRetryStateLocked(RetryPolicy retryPolicy) throws BadRequestError {
301
    if (retryPolicy == null) {
1✔
302
      return Optional.empty();
1✔
303
    }
304
    long expirationInterval =
1✔
305
        TimeUnit.SECONDS.toMillis(retryPolicy.getExpirationIntervalInSeconds());
1✔
306
    long expirationTime = store.currentTimeMillis() + expirationInterval;
1✔
307
    return Optional.of(new RetryState(retryPolicy, expirationTime));
1✔
308
  }
309

310
  private StartWorkflowExecutionResponse throwDuplicatedWorkflow(
311
      StartWorkflowExecutionRequest startRequest, TestWorkflowMutableState existing)
312
      throws WorkflowExecutionAlreadyStartedError {
313
    WorkflowExecutionAlreadyStartedError error = new WorkflowExecutionAlreadyStartedError();
1✔
314
    WorkflowExecution execution = existing.getExecutionId().getExecution();
1✔
315
    error.setMessage(
1✔
316
        String.format(
1✔
317
            "WorkflowId: %s, " + "RunId: %s", execution.getWorkflowId(), execution.getRunId()));
1✔
318
    error.setRunId(execution.getRunId());
1✔
319
    error.setStartRequestId(startRequest.getRequestId());
1✔
320
    throw error;
1✔
321
  }
322

323
  private StartWorkflowExecutionResponse startWorkflowExecutionNoRunningCheckLocked(
324
      StartWorkflowExecutionRequest startRequest,
325
      Optional<String> continuedExecutionRunId,
326
      Optional<RetryState> retryState,
327
      int backoffStartIntervalInSeconds,
328
      byte[] lastCompletionResult,
329
      Optional<TestWorkflowMutableState> parent,
330
      OptionalLong parentChildInitiatedEventId,
331
      Optional<SignalWorkflowExecutionRequest> signalWithStartSignal,
332
      WorkflowId workflowId)
333
      throws InternalServiceError, BadRequestError {
334
    String domain = startRequest.getDomain();
1✔
335
    TestWorkflowMutableState mutableState =
1✔
336
        new TestWorkflowMutableStateImpl(
337
            startRequest,
338
            retryState,
339
            backoffStartIntervalInSeconds,
340
            lastCompletionResult,
341
            parent,
342
            parentChildInitiatedEventId,
343
            continuedExecutionRunId,
344
            this,
345
            store);
346
    WorkflowExecution execution = mutableState.getExecutionId().getExecution();
1✔
347
    ExecutionId executionId = new ExecutionId(domain, execution);
1✔
348
    executionsByWorkflowId.put(workflowId, mutableState);
1✔
349
    executions.put(executionId, mutableState);
1✔
350
    mutableState.startWorkflow(continuedExecutionRunId.isPresent(), signalWithStartSignal);
1✔
351
    return new StartWorkflowExecutionResponse().setRunId(execution.getRunId());
1✔
352
  }
353

354
  @Override
355
  public GetWorkflowExecutionHistoryResponse GetWorkflowExecutionHistory(
356
      GetWorkflowExecutionHistoryRequest getRequest)
357
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
358
          TException {
359
    ExecutionId executionId = new ExecutionId(getRequest.getDomain(), getRequest.getExecution());
1✔
360
    TestWorkflowMutableState mutableState = getMutableState(executionId);
1✔
361

362
    return store.getWorkflowExecutionHistory(mutableState.getExecutionId(), getRequest);
1✔
363
  }
364

365
  @Override
366
  public GetWorkflowExecutionHistoryResponse GetWorkflowExecutionHistoryWithTimeout(
367
      GetWorkflowExecutionHistoryRequest getRequest, Long timeoutInMillis)
368
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
369
          TException {
370

371
    return GetWorkflowExecutionHistory(getRequest);
1✔
372
  }
373

374
  @Override
375
  public PollForDecisionTaskResponse PollForDecisionTask(PollForDecisionTaskRequest pollRequest)
376
      throws BadRequestError, InternalServiceError, ServiceBusyError, TException {
377
    PollForDecisionTaskResponse task;
378
    try {
379
      task = store.pollForDecisionTask(pollRequest);
1✔
380
    } catch (InterruptedException e) {
1✔
381
      return new PollForDecisionTaskResponse();
1✔
382
    }
1✔
383
    ExecutionId executionId = new ExecutionId(pollRequest.getDomain(), task.getWorkflowExecution());
1✔
384
    TestWorkflowMutableState mutableState = getMutableState(executionId);
1✔
385
    try {
386
      mutableState.startDecisionTask(task, pollRequest);
1✔
387
      // The task always has the original tasklist is was created on as part of the response. This
388
      // may different
389
      // then the task list it was scheduled on as in the case of sticky execution.
390
      task.setWorkflowExecutionTaskList(mutableState.getStartRequest().taskList);
1✔
391
      return task;
1✔
392
    } catch (EntityNotExistsError e) {
×
393
      if (log.isDebugEnabled()) {
×
394
        log.debug("Skipping outdated decision task for " + executionId, e);
×
395
      }
396
      // skip the task
397
    }
398
    task.setWorkflowExecutionTaskList(mutableState.getStartRequest().taskList);
×
399
    return task;
×
400
  }
401

402
  @Override
403
  public RespondDecisionTaskCompletedResponse RespondDecisionTaskCompleted(
404
      RespondDecisionTaskCompletedRequest request)
405
      throws BadRequestError, InternalServiceError, EntityNotExistsError, TException {
406
    DecisionTaskToken taskToken = DecisionTaskToken.fromBytes(request.getTaskToken());
1✔
407
    TestWorkflowMutableState mutableState = getMutableState(taskToken.getExecutionId());
1✔
408
    mutableState.completeDecisionTask(taskToken.getHistorySize(), request);
1✔
409
    return new RespondDecisionTaskCompletedResponse();
1✔
410
  }
411

412
  @Override
413
  public void RespondDecisionTaskFailed(RespondDecisionTaskFailedRequest failedRequest)
414
      throws BadRequestError, InternalServiceError, EntityNotExistsError, TException {
415
    DecisionTaskToken taskToken = DecisionTaskToken.fromBytes(failedRequest.getTaskToken());
1✔
416
    TestWorkflowMutableState mutableState = getMutableState(taskToken.getExecutionId());
1✔
417
    mutableState.failDecisionTask(failedRequest);
1✔
418
  }
1✔
419

420
  @Override
421
  public PollForActivityTaskResponse PollForActivityTask(PollForActivityTaskRequest pollRequest)
422
      throws BadRequestError, InternalServiceError, ServiceBusyError, TException {
423
    PollForActivityTaskResponse task;
424
    while (true) {
425
      try {
426
        task = store.pollForActivityTask(pollRequest);
1✔
427
      } catch (InterruptedException e) {
1✔
428
        return new PollForActivityTaskResponse();
1✔
429
      }
1✔
430
      ExecutionId executionId =
1✔
431
          new ExecutionId(pollRequest.getDomain(), task.getWorkflowExecution());
1✔
432
      TestWorkflowMutableState mutableState = getMutableState(executionId);
1✔
433
      try {
434
        mutableState.startActivityTask(task, pollRequest);
1✔
435
        return task;
1✔
436
      } catch (EntityNotExistsError e) {
×
437
        if (log.isDebugEnabled()) {
×
438
          log.debug("Skipping outdated activity task for " + executionId, e);
×
439
        }
440
      }
441
    }
×
442
  }
443

444
  @Override
445
  public RecordActivityTaskHeartbeatResponse RecordActivityTaskHeartbeat(
446
      RecordActivityTaskHeartbeatRequest heartbeatRequest)
447
      throws BadRequestError, InternalServiceError, EntityNotExistsError, TException {
448
    ActivityId activityId = ActivityId.fromBytes(heartbeatRequest.getTaskToken());
1✔
449
    TestWorkflowMutableState mutableState = getMutableState(activityId.getExecutionId());
1✔
450
    return mutableState.heartbeatActivityTask(activityId.getId(), heartbeatRequest.getDetails());
1✔
451
  }
452

453
  @Override
454
  public RecordActivityTaskHeartbeatResponse RecordActivityTaskHeartbeatByID(
455
      RecordActivityTaskHeartbeatByIDRequest heartbeatRequest)
456
      throws BadRequestError, InternalServiceError, EntityNotExistsError, DomainNotActiveError,
457
          LimitExceededError, ServiceBusyError, TException {
458
    ExecutionId execution =
×
459
        new ExecutionId(
460
            heartbeatRequest.getDomain(),
×
461
            heartbeatRequest.getWorkflowID(),
×
462
            heartbeatRequest.getRunID());
×
463
    TestWorkflowMutableState mutableState = getMutableState(execution);
×
464
    return mutableState.heartbeatActivityTask(
×
465
        heartbeatRequest.getActivityID(), heartbeatRequest.getDetails());
×
466
  }
467

468
  @Override
469
  public void RespondActivityTaskCompleted(RespondActivityTaskCompletedRequest completeRequest)
470
      throws BadRequestError, InternalServiceError, EntityNotExistsError, TException {
471
    ActivityId activityId = ActivityId.fromBytes(completeRequest.getTaskToken());
1✔
472
    TestWorkflowMutableState mutableState = getMutableState(activityId.getExecutionId());
1✔
473
    mutableState.completeActivityTask(activityId.getId(), completeRequest);
1✔
474
  }
1✔
475

476
  @Override
477
  public void RespondActivityTaskCompletedByID(
478
      RespondActivityTaskCompletedByIDRequest completeRequest)
479
      throws BadRequestError, InternalServiceError, EntityNotExistsError, TException {
480
    ActivityId activityId =
1✔
481
        new ActivityId(
482
            completeRequest.getDomain(),
1✔
483
            completeRequest.getWorkflowID(),
1✔
484
            completeRequest.getRunID(),
1✔
485
            completeRequest.getActivityID());
1✔
486
    TestWorkflowMutableState mutableState = getMutableState(activityId.getWorkflowId());
1✔
487
    mutableState.completeActivityTaskById(activityId.getId(), completeRequest);
1✔
488
  }
1✔
489

490
  @Override
491
  public void RespondActivityTaskFailed(RespondActivityTaskFailedRequest failRequest)
492
      throws BadRequestError, InternalServiceError, EntityNotExistsError, TException {
493
    ActivityId activityId = ActivityId.fromBytes(failRequest.getTaskToken());
1✔
494
    TestWorkflowMutableState mutableState = getMutableState(activityId.getExecutionId());
1✔
495
    mutableState.failActivityTask(activityId.getId(), failRequest);
1✔
496
  }
1✔
497

498
  @Override
499
  public void RespondActivityTaskFailedByID(RespondActivityTaskFailedByIDRequest failRequest)
500
      throws BadRequestError, InternalServiceError, EntityNotExistsError, TException {
501
    ActivityId activityId =
×
502
        new ActivityId(
503
            failRequest.getDomain(),
×
504
            failRequest.getWorkflowID(),
×
505
            failRequest.getRunID(),
×
506
            failRequest.getActivityID());
×
507
    TestWorkflowMutableState mutableState = getMutableState(activityId.getWorkflowId());
×
508
    mutableState.failActivityTaskById(activityId.getId(), failRequest);
×
509
  }
×
510

511
  @Override
512
  public void RespondActivityTaskCanceled(RespondActivityTaskCanceledRequest canceledRequest)
513
      throws BadRequestError, InternalServiceError, EntityNotExistsError, TException {
514
    ActivityId activityId = ActivityId.fromBytes(canceledRequest.getTaskToken());
1✔
515
    TestWorkflowMutableState mutableState = getMutableState(activityId.getExecutionId());
1✔
516
    mutableState.cancelActivityTask(activityId.getId(), canceledRequest);
1✔
517
  }
1✔
518

519
  @Override
520
  public void RespondActivityTaskCanceledByID(
521
      RespondActivityTaskCanceledByIDRequest canceledRequest)
522
      throws BadRequestError, InternalServiceError, EntityNotExistsError, TException {
523
    ActivityId activityId =
×
524
        new ActivityId(
525
            canceledRequest.getDomain(),
×
526
            canceledRequest.getWorkflowID(),
×
527
            canceledRequest.getRunID(),
×
528
            canceledRequest.getActivityID());
×
529
    TestWorkflowMutableState mutableState = getMutableState(activityId.getWorkflowId());
×
530
    mutableState.cancelActivityTaskById(activityId.getId(), canceledRequest);
×
531
  }
×
532

533
  @Override
534
  public void RequestCancelWorkflowExecution(RequestCancelWorkflowExecutionRequest cancelRequest)
535
      throws TException {
536
    ExecutionId executionId =
1✔
537
        new ExecutionId(cancelRequest.getDomain(), cancelRequest.getWorkflowExecution());
1✔
538
    TestWorkflowMutableState mutableState = getMutableState(executionId);
1✔
539
    mutableState.requestCancelWorkflowExecution(cancelRequest);
1✔
540
  }
1✔
541

542
  @Override
543
  public void SignalWorkflowExecution(SignalWorkflowExecutionRequest signalRequest)
544
      throws TException {
545
    ExecutionId executionId =
1✔
546
        new ExecutionId(signalRequest.getDomain(), signalRequest.getWorkflowExecution());
1✔
547
    TestWorkflowMutableState mutableState = getMutableState(executionId);
1✔
548
    mutableState.signal(signalRequest);
1✔
549
  }
1✔
550

551
  @Override
552
  public StartWorkflowExecutionResponse SignalWithStartWorkflowExecution(
553
      SignalWithStartWorkflowExecutionRequest r)
554
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
555
          DomainNotActiveError, LimitExceededError, WorkflowExecutionAlreadyStartedError,
556
          TException {
557
    ExecutionId executionId = new ExecutionId(r.getDomain(), r.getWorkflowId(), null);
1✔
558
    TestWorkflowMutableState mutableState = getMutableState(executionId, false);
1✔
559
    SignalWorkflowExecutionRequest signalRequest =
1✔
560
        new SignalWorkflowExecutionRequest()
561
            .setInput(r.getSignalInput())
1✔
562
            .setSignalName(r.getSignalName())
1✔
563
            .setControl(r.getControl())
1✔
564
            .setDomain(r.getDomain())
1✔
565
            .setWorkflowExecution(executionId.getExecution())
1✔
566
            .setRequestId(r.getRequestId())
1✔
567
            .setIdentity(r.getIdentity());
1✔
568
    if (mutableState != null) {
1✔
569
      mutableState.signal(signalRequest);
1✔
570
      return new StartWorkflowExecutionResponse()
1✔
571
          .setRunId(mutableState.getExecutionId().getExecution().getRunId());
1✔
572
    }
573
    StartWorkflowExecutionRequest startRequest =
1✔
574
        new StartWorkflowExecutionRequest()
575
            .setInput(r.getInput())
1✔
576
            .setExecutionStartToCloseTimeoutSeconds(r.getExecutionStartToCloseTimeoutSeconds())
1✔
577
            .setTaskStartToCloseTimeoutSeconds(r.getTaskStartToCloseTimeoutSeconds())
1✔
578
            .setDomain(r.getDomain())
1✔
579
            .setRetryPolicy(r.getRetryPolicy())
1✔
580
            .setTaskList(r.getTaskList())
1✔
581
            .setWorkflowId(r.getWorkflowId())
1✔
582
            .setWorkflowIdReusePolicy(r.getWorkflowIdReusePolicy())
1✔
583
            .setWorkflowType(r.getWorkflowType())
1✔
584
            .setCronSchedule(r.getCronSchedule())
1✔
585
            .setRequestId(r.getRequestId())
1✔
586
            .setIdentity(r.getIdentity());
1✔
587
    return startWorkflowExecutionImpl(
1✔
588
        startRequest, 0, Optional.empty(), OptionalLong.empty(), Optional.of(signalRequest));
1✔
589
  }
590

591
  @Override
592
  public SignalWithStartWorkflowExecutionAsyncResponse SignalWithStartWorkflowExecutionAsync(
593
      SignalWithStartWorkflowExecutionAsyncRequest signalWithStartRequest)
594
      throws BadRequestError, WorkflowExecutionAlreadyStartedError, ServiceBusyError,
595
          DomainNotActiveError, LimitExceededError, EntityNotExistsError,
596
          ClientVersionNotSupportedError, TException {
NEW
597
    throw new UnsupportedOperationException("not implemented");
×
598
  }
599

600
  // TODO: https://github.com/uber/cadence-java-client/issues/359
601
  @Override
602
  public ResetWorkflowExecutionResponse ResetWorkflowExecution(
603
      ResetWorkflowExecutionRequest resetRequest)
604
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
605
          DomainNotActiveError, LimitExceededError, ClientVersionNotSupportedError, TException {
606
    return null;
×
607
  }
608

609
  public void signalExternalWorkflowExecution(
610
      String signalId,
611
      SignalExternalWorkflowExecutionDecisionAttributes a,
612
      TestWorkflowMutableState source)
613
      throws InternalServiceError, EntityNotExistsError, WorkflowExecutionAlreadyCompletedError,
614
          BadRequestError {
615
    ExecutionId executionId = new ExecutionId(a.getDomain(), a.getExecution());
1✔
616
    TestWorkflowMutableState mutableState = null;
1✔
617
    try {
618
      mutableState = getMutableState(executionId);
1✔
619
      mutableState.signalFromWorkflow(a);
1✔
620
      source.completeSignalExternalWorkflowExecution(
1✔
621
          signalId, mutableState.getExecutionId().getExecution().getRunId());
1✔
622
    } catch (EntityNotExistsError entityNotExistsError) {
1✔
623
      source.failSignalExternalWorkflowExecution(
1✔
624
          signalId, SignalExternalWorkflowExecutionFailedCause.UNKNOWN_EXTERNAL_WORKFLOW_EXECUTION);
625
    }
1✔
626
  }
1✔
627

628
  @Override
629
  public void TerminateWorkflowExecution(TerminateWorkflowExecutionRequest terminateRequest)
630
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
631
          TException {
632
    throw new UnsupportedOperationException("not implemented");
×
633
  }
634

635
  /**
636
   * Creates next run of a workflow execution
637
   *
638
   * @return RunId
639
   */
640
  public String continueAsNew(
641
      StartWorkflowExecutionRequest previousRunStartRequest,
642
      WorkflowExecutionContinuedAsNewEventAttributes a,
643
      Optional<RetryState> retryState,
644
      String identity,
645
      ExecutionId executionId,
646
      Optional<TestWorkflowMutableState> parent,
647
      OptionalLong parentChildInitiatedEventId)
648
      throws InternalServiceError, BadRequestError {
649
    StartWorkflowExecutionRequest startRequest =
1✔
650
        new StartWorkflowExecutionRequest()
651
            .setWorkflowType(a.getWorkflowType())
1✔
652
            .setExecutionStartToCloseTimeoutSeconds(a.getExecutionStartToCloseTimeoutSeconds())
1✔
653
            .setTaskStartToCloseTimeoutSeconds(a.getTaskStartToCloseTimeoutSeconds())
1✔
654
            .setDomain(executionId.getDomain())
1✔
655
            .setTaskList(a.getTaskList())
1✔
656
            .setWorkflowId(executionId.getWorkflowId().getWorkflowId())
1✔
657
            .setWorkflowIdReusePolicy(previousRunStartRequest.getWorkflowIdReusePolicy())
1✔
658
            .setIdentity(identity)
1✔
659
            .setRetryPolicy(previousRunStartRequest.getRetryPolicy())
1✔
660
            .setCronSchedule(previousRunStartRequest.getCronSchedule());
1✔
661
    if (a.isSetInput()) {
1✔
662
      startRequest.setInput(a.getInput());
1✔
663
    }
664
    lock.lock();
1✔
665
    try {
666
      StartWorkflowExecutionResponse response =
1✔
667
          startWorkflowExecutionNoRunningCheckLocked(
1✔
668
              startRequest,
669
              Optional.of(executionId.getExecution().getRunId()),
1✔
670
              retryState,
671
              a.getBackoffStartIntervalInSeconds(),
1✔
672
              a.getLastCompletionResult(),
1✔
673
              parent,
674
              parentChildInitiatedEventId,
675
              Optional.empty(),
1✔
676
              executionId.getWorkflowId());
1✔
677
      return response.getRunId();
1✔
678
    } finally {
679
      lock.unlock();
1✔
680
    }
681
  }
682

683
  @Override
684
  public ListOpenWorkflowExecutionsResponse ListOpenWorkflowExecutions(
685
      ListOpenWorkflowExecutionsRequest listRequest)
686
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
687
          TException {
688
    Optional<String> workflowIdFilter;
689
    WorkflowExecutionFilter executionFilter = listRequest.getExecutionFilter();
1✔
690
    if (executionFilter != null
1✔
691
        && executionFilter.isSetWorkflowId()
×
692
        && !executionFilter.getWorkflowId().isEmpty()) {
×
693
      workflowIdFilter = Optional.of(executionFilter.getWorkflowId());
×
694
    } else {
695
      workflowIdFilter = Optional.empty();
1✔
696
    }
697
    List<WorkflowExecutionInfo> result = store.listWorkflows(WorkflowState.OPEN, workflowIdFilter);
1✔
698
    return new ListOpenWorkflowExecutionsResponse().setExecutions(result);
1✔
699
  }
700

701
  @Override
702
  public ListClosedWorkflowExecutionsResponse ListClosedWorkflowExecutions(
703
      ListClosedWorkflowExecutionsRequest listRequest)
704
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
705
          TException {
706
    Optional<String> workflowIdFilter;
707
    WorkflowExecutionFilter executionFilter = listRequest.getExecutionFilter();
1✔
708
    if (executionFilter != null
1✔
709
        && executionFilter.isSetWorkflowId()
1✔
710
        && !executionFilter.getWorkflowId().isEmpty()) {
1✔
711
      workflowIdFilter = Optional.of(executionFilter.getWorkflowId());
1✔
712
    } else {
713
      workflowIdFilter = Optional.empty();
1✔
714
    }
715
    List<WorkflowExecutionInfo> result =
1✔
716
        store.listWorkflows(WorkflowState.CLOSED, workflowIdFilter);
1✔
717
    return new ListClosedWorkflowExecutionsResponse().setExecutions(result);
1✔
718
  }
719

720
  @Override
721
  public ListWorkflowExecutionsResponse ListWorkflowExecutions(
722
      ListWorkflowExecutionsRequest listRequest)
723
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
724
          ClientVersionNotSupportedError, TException {
725
    throw new UnsupportedOperationException("not implemented");
×
726
  }
727

728
  @Override
729
  public ListArchivedWorkflowExecutionsResponse ListArchivedWorkflowExecutions(
730
      ListArchivedWorkflowExecutionsRequest listRequest)
731
      throws BadRequestError, EntityNotExistsError, ServiceBusyError,
732
          ClientVersionNotSupportedError, TException {
733
    throw new UnsupportedOperationException("not implemented");
×
734
  }
735

736
  @Override
737
  public ListWorkflowExecutionsResponse ScanWorkflowExecutions(
738
      ListWorkflowExecutionsRequest listRequest)
739
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
740
          ClientVersionNotSupportedError, TException {
741
    throw new UnsupportedOperationException("not implemented");
×
742
  }
743

744
  @Override
745
  public CountWorkflowExecutionsResponse CountWorkflowExecutions(
746
      CountWorkflowExecutionsRequest countRequest)
747
      throws BadRequestError, InternalServiceError, EntityNotExistsError, ServiceBusyError,
748
          ClientVersionNotSupportedError, TException {
749
    throw new UnsupportedOperationException("not implemented");
×
750
  }
751

752
  @Override
753
  public GetSearchAttributesResponse GetSearchAttributes()
754
      throws InternalServiceError, ServiceBusyError, ClientVersionNotSupportedError, TException {
755
    throw new UnsupportedOperationException("not implemented");
×
756
  }
757

758
  @Override
759
  public void RespondQueryTaskCompleted(RespondQueryTaskCompletedRequest completeRequest)
760
      throws BadRequestError, InternalServiceError, EntityNotExistsError, TException {
761
    QueryId queryId = QueryId.fromBytes(completeRequest.getTaskToken());
1✔
762
    TestWorkflowMutableState mutableState = getMutableState(queryId.getExecutionId());
1✔
763
    mutableState.completeQuery(queryId, completeRequest);
1✔
764
  }
1✔
765

766
  @Override
767
  public ResetStickyTaskListResponse ResetStickyTaskList(ResetStickyTaskListRequest resetRequest)
768
      throws BadRequestError, InternalServiceError, EntityNotExistsError, LimitExceededError,
769
          ServiceBusyError, DomainNotActiveError, TException {
770
    throw new UnsupportedOperationException("not implemented");
×
771
  }
772

773
  @Override
774
  public QueryWorkflowResponse QueryWorkflow(QueryWorkflowRequest queryRequest)
775
      throws BadRequestError, InternalServiceError, EntityNotExistsError, QueryFailedError,
776
          TException {
777
    ExecutionId executionId =
1✔
778
        new ExecutionId(queryRequest.getDomain(), queryRequest.getExecution());
1✔
779
    TestWorkflowMutableState mutableState = getMutableState(executionId);
1✔
780
    return mutableState.query(queryRequest);
1✔
781
  }
782

783
  @Override
784
  public DescribeWorkflowExecutionResponse DescribeWorkflowExecution(
785
      DescribeWorkflowExecutionRequest describeRequest)
786
      throws BadRequestError, InternalServiceError, EntityNotExistsError, TException {
787
    throw new UnsupportedOperationException("not implemented");
×
788
  }
789

790
  @Override
791
  public DescribeTaskListResponse DescribeTaskList(DescribeTaskListRequest request)
792
      throws BadRequestError, InternalServiceError, EntityNotExistsError, TException {
793
    throw new UnsupportedOperationException("not implemented");
×
794
  }
795

796
  @Override
797
  public ClusterInfo GetClusterInfo() throws InternalServiceError, ServiceBusyError, TException {
798
    throw new UnsupportedOperationException("not implemented");
×
799
  }
800

801
  @Override
802
  public ListTaskListPartitionsResponse ListTaskListPartitions(
803
      ListTaskListPartitionsRequest request)
804
      throws BadRequestError, EntityNotExistsError, LimitExceededError, ServiceBusyError,
805
          TException {
806
    throw new UnsupportedOperationException("not implemented");
×
807
  }
808

809
  @Override
810
  public void RefreshWorkflowTasks(RefreshWorkflowTasksRequest request)
811
      throws BadRequestError, DomainNotActiveError, ServiceBusyError, EntityNotExistsError,
812
          TException {
813
    throw new UnsupportedOperationException("not implemented");
×
814
  }
815

816
  @Override
817
  public void RegisterDomain(
818
      RegisterDomainRequest registerRequest, AsyncMethodCallback resultHandler) throws TException {
819
    throw new UnsupportedOperationException("not implemented");
×
820
  }
821

822
  @Override
823
  public void DescribeDomain(
824
      DescribeDomainRequest describeRequest, AsyncMethodCallback resultHandler) throws TException {
825
    throw new UnsupportedOperationException("not implemented");
×
826
  }
827

828
  @Override
829
  public void ListDomains(ListDomainsRequest listRequest, AsyncMethodCallback resultHandler)
830
      throws TException {
831
    throw new UnsupportedOperationException("not implemented");
×
832
  }
833

834
  @Override
835
  public void UpdateDomain(UpdateDomainRequest updateRequest, AsyncMethodCallback resultHandler)
836
      throws TException {
837
    throw new UnsupportedOperationException("not implemented");
×
838
  }
839

840
  @Override
841
  public void DeprecateDomain(
842
      DeprecateDomainRequest deprecateRequest, AsyncMethodCallback resultHandler)
843
      throws TException {
844
    throw new UnsupportedOperationException("not implemented");
×
845
  }
846

847
  @Override
848
  public void RestartWorkflowExecution(
849
      RestartWorkflowExecutionRequest restartRequest, AsyncMethodCallback resultHandler)
850
      throws TException {
NEW
851
    throw new UnsupportedOperationException("not implemented");
×
852
  }
853

854
  @Override
855
  public void GetTaskListsByDomain(
856
      GetTaskListsByDomainRequest request, AsyncMethodCallback resultHandler)
857
      throws org.apache.thrift.TException {
858
    throw new UnsupportedOperationException("not implemented");
×
859
  }
860

861
  @Override
862
  public void StartWorkflowExecution(
863
      StartWorkflowExecutionRequest startRequest, AsyncMethodCallback resultHandler)
864
      throws TException {
865
    StartWorkflowExecutionWithTimeout(startRequest, resultHandler, null);
×
866
  }
×
867

868
  @Override
869
  public void StartWorkflowExecutionAsync(
870
      StartWorkflowExecutionAsyncRequest startRequest, AsyncMethodCallback resultHandler)
871
      throws TException {
NEW
872
    throw new UnsupportedOperationException("not implemented");
×
873
  }
874

875
  @Override
876
  public void StartWorkflowExecutionWithTimeout(
877
      StartWorkflowExecutionRequest startRequest,
878
      AsyncMethodCallback resultHandler,
879
      Long timeoutInMillis)
880
      throws TException {
881
    forkJoinPool.execute(
1✔
882
        () -> {
883
          try {
884
            StartWorkflowExecutionResponse result = StartWorkflowExecution(startRequest);
1✔
885
            resultHandler.onComplete(result);
1✔
886
          } catch (TException e) {
1✔
887
            resultHandler.onError(e);
1✔
888
          }
1✔
889
        });
1✔
890
  }
1✔
891

892
  @SuppressWarnings("unchecked") // Generator ignores that AsyncMethodCallback is generic
893
  @Override
894
  public void GetWorkflowExecutionHistory(
895
      GetWorkflowExecutionHistoryRequest getRequest, AsyncMethodCallback resultHandler)
896
      throws TException {
897
    forkJoinPool.execute(
1✔
898
        () -> {
899
          try {
900
            GetWorkflowExecutionHistoryResponse result = GetWorkflowExecutionHistory(getRequest);
1✔
901
            resultHandler.onComplete(result);
1✔
902
          } catch (TException e) {
×
903
            resultHandler.onError(e);
×
904
          }
1✔
905
        });
1✔
906
  }
1✔
907

908
  @SuppressWarnings("unchecked") // Generator ignores that AsyncMethodCallback is generic
909
  @Override
910
  public void GetWorkflowExecutionHistoryWithTimeout(
911
      GetWorkflowExecutionHistoryRequest getRequest,
912
      AsyncMethodCallback resultHandler,
913
      Long timeoutInMillis)
914
      throws TException {
915
    GetWorkflowExecutionHistory(getRequest, resultHandler);
1✔
916
  }
1✔
917

918
  @Override
919
  public CompletableFuture<Boolean> isHealthy() {
920
    CompletableFuture<Boolean> rval = new CompletableFuture<>();
×
921
    rval.complete(Boolean.TRUE);
×
922
    return rval;
×
923
  }
924

925
  @Override
926
  public void PollForDecisionTask(
927
      PollForDecisionTaskRequest pollRequest, AsyncMethodCallback resultHandler) throws TException {
928
    throw new UnsupportedOperationException("not implemented");
×
929
  }
930

931
  @Override
932
  public void RespondDecisionTaskCompleted(
933
      RespondDecisionTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler)
934
      throws TException {
935
    throw new UnsupportedOperationException("not implemented");
×
936
  }
937

938
  @Override
939
  public void RespondDecisionTaskFailed(
940
      RespondDecisionTaskFailedRequest failedRequest, AsyncMethodCallback resultHandler)
941
      throws TException {
942
    throw new UnsupportedOperationException("not implemented");
×
943
  }
944

945
  @Override
946
  public void PollForActivityTask(
947
      PollForActivityTaskRequest pollRequest, AsyncMethodCallback resultHandler) throws TException {
948
    throw new UnsupportedOperationException("not implemented");
×
949
  }
950

951
  @Override
952
  public void RecordActivityTaskHeartbeat(
953
      RecordActivityTaskHeartbeatRequest heartbeatRequest, AsyncMethodCallback resultHandler)
954
      throws TException {
955
    throw new UnsupportedOperationException("not implemented");
×
956
  }
957

958
  @Override
959
  public void RecordActivityTaskHeartbeatByID(
960
      RecordActivityTaskHeartbeatByIDRequest heartbeatRequest, AsyncMethodCallback resultHandler)
961
      throws TException {
962
    throw new UnsupportedOperationException("not implemented");
×
963
  }
964

965
  @Override
966
  public void RespondActivityTaskCompleted(
967
      RespondActivityTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler)
968
      throws TException {
969
    throw new UnsupportedOperationException("not implemented");
×
970
  }
971

972
  @Override
973
  public void RespondActivityTaskCompletedByID(
974
      RespondActivityTaskCompletedByIDRequest completeRequest, AsyncMethodCallback resultHandler)
975
      throws TException {
976
    throw new UnsupportedOperationException("not implemented");
×
977
  }
978

979
  @Override
980
  public void RespondActivityTaskFailed(
981
      RespondActivityTaskFailedRequest failRequest, AsyncMethodCallback resultHandler)
982
      throws TException {
983
    throw new UnsupportedOperationException("not implemented");
×
984
  }
985

986
  @Override
987
  public void RespondActivityTaskFailedByID(
988
      RespondActivityTaskFailedByIDRequest failRequest, AsyncMethodCallback resultHandler)
989
      throws TException {
990
    throw new UnsupportedOperationException("not implemented");
×
991
  }
992

993
  @Override
994
  public void RespondActivityTaskCanceled(
995
      RespondActivityTaskCanceledRequest canceledRequest, AsyncMethodCallback resultHandler)
996
      throws TException {
997
    throw new UnsupportedOperationException("not implemented");
×
998
  }
999

1000
  @Override
1001
  public void RespondActivityTaskCanceledByID(
1002
      RespondActivityTaskCanceledByIDRequest canceledRequest, AsyncMethodCallback resultHandler)
1003
      throws TException {
1004
    throw new UnsupportedOperationException("not implemented");
×
1005
  }
1006

1007
  @Override
1008
  public void RequestCancelWorkflowExecution(
1009
      RequestCancelWorkflowExecutionRequest cancelRequest, AsyncMethodCallback resultHandler)
1010
      throws TException {
1011
    throw new UnsupportedOperationException("not implemented");
×
1012
  }
1013

1014
  @Override
1015
  public void SignalWorkflowExecution(
1016
      SignalWorkflowExecutionRequest signalRequest, AsyncMethodCallback resultHandler)
1017
      throws TException {
1018
    SignalWorkflowExecutionWithTimeout(signalRequest, resultHandler, null);
1✔
1019
  }
1✔
1020

1021
  @Override
1022
  public void SignalWorkflowExecutionWithTimeout(
1023
      SignalWorkflowExecutionRequest signalRequest,
1024
      AsyncMethodCallback resultHandler,
1025
      Long timeoutInMillis)
1026
      throws TException {
1027
    forkJoinPool.execute(
1✔
1028
        () -> {
1029
          try {
1030
            SignalWorkflowExecution(signalRequest);
1✔
1031
            resultHandler.onComplete(null);
1✔
1032
          } catch (TException e) {
×
1033
            resultHandler.onError(e);
×
1034
          }
1✔
1035
        });
1✔
1036
  }
1✔
1037

1038
  @Override
1039
  public void SignalWithStartWorkflowExecution(
1040
      SignalWithStartWorkflowExecutionRequest signalWithStartRequest,
1041
      AsyncMethodCallback resultHandler)
1042
      throws TException {
1043
    throw new UnsupportedOperationException("not implemented");
×
1044
  }
1045

1046
  @Override
1047
  public void SignalWithStartWorkflowExecutionAsync(
1048
      SignalWithStartWorkflowExecutionAsyncRequest signalWithStartRequest,
1049
      AsyncMethodCallback resultHandler)
1050
      throws TException {
NEW
1051
    throw new UnsupportedOperationException("not implemented");
×
1052
  }
1053

1054
  @Override
1055
  public void ResetWorkflowExecution(
1056
      ResetWorkflowExecutionRequest resetRequest, AsyncMethodCallback resultHandler)
1057
      throws TException {}
×
1058

1059
  @Override
1060
  public void TerminateWorkflowExecution(
1061
      TerminateWorkflowExecutionRequest terminateRequest, AsyncMethodCallback resultHandler)
1062
      throws TException {
1063
    throw new UnsupportedOperationException("not implemented");
×
1064
  }
1065

1066
  @Override
1067
  public void ListOpenWorkflowExecutions(
1068
      ListOpenWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
1069
      throws TException {
1070
    throw new UnsupportedOperationException("not implemented");
×
1071
  }
1072

1073
  @Override
1074
  public void ListClosedWorkflowExecutions(
1075
      ListClosedWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
1076
      throws TException {
1077
    throw new UnsupportedOperationException("not implemented");
×
1078
  }
1079

1080
  @Override
1081
  public void ListWorkflowExecutions(
1082
      ListWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
1083
      throws TException {
1084
    throw new UnsupportedOperationException("not implemented");
×
1085
  }
1086

1087
  @Override
1088
  public void ListArchivedWorkflowExecutions(
1089
      ListArchivedWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
1090
      throws TException {}
×
1091

1092
  @Override
1093
  public void ScanWorkflowExecutions(
1094
      ListWorkflowExecutionsRequest listRequest, AsyncMethodCallback resultHandler)
1095
      throws TException {
1096
    throw new UnsupportedOperationException("not implemented");
×
1097
  }
1098

1099
  @Override
1100
  public void CountWorkflowExecutions(
1101
      CountWorkflowExecutionsRequest countRequest, AsyncMethodCallback resultHandler)
1102
      throws TException {
1103
    throw new UnsupportedOperationException("not implemented");
×
1104
  }
1105

1106
  @Override
1107
  public void GetSearchAttributes(AsyncMethodCallback resultHandler) throws TException {
1108
    throw new UnsupportedOperationException("not implemented");
×
1109
  }
1110

1111
  @Override
1112
  public void RespondQueryTaskCompleted(
1113
      RespondQueryTaskCompletedRequest completeRequest, AsyncMethodCallback resultHandler)
1114
      throws TException {
1115
    throw new UnsupportedOperationException("not implemented");
×
1116
  }
1117

1118
  @Override
1119
  public void ResetStickyTaskList(
1120
      ResetStickyTaskListRequest resetRequest, AsyncMethodCallback resultHandler)
1121
      throws TException {
1122
    throw new UnsupportedOperationException("not implemented");
×
1123
  }
1124

1125
  @Override
1126
  public void QueryWorkflow(QueryWorkflowRequest queryRequest, AsyncMethodCallback resultHandler)
1127
      throws TException {
1128
    throw new UnsupportedOperationException("not implemented");
×
1129
  }
1130

1131
  @Override
1132
  public void DescribeWorkflowExecution(
1133
      DescribeWorkflowExecutionRequest describeRequest, AsyncMethodCallback resultHandler)
1134
      throws TException {
1135
    throw new UnsupportedOperationException("not implemented");
×
1136
  }
1137

1138
  @Override
1139
  public void DescribeTaskList(DescribeTaskListRequest request, AsyncMethodCallback resultHandler)
1140
      throws TException {
1141
    throw new UnsupportedOperationException("not implemented");
×
1142
  }
1143

1144
  @Override
1145
  public void GetClusterInfo(AsyncMethodCallback resultHandler) throws TException {}
×
1146

1147
  @Override
1148
  public void ListTaskListPartitions(
1149
      ListTaskListPartitionsRequest request, AsyncMethodCallback resultHandler) throws TException {}
×
1150

1151
  @Override
1152
  public void RefreshWorkflowTasks(
1153
      RefreshWorkflowTasksRequest request, AsyncMethodCallback resultHandler) throws TException {}
×
1154

1155
  private <R> R requireNotNull(String fieldName, R value) throws BadRequestError {
1156
    if (value == null) {
1✔
1157
      throw new BadRequestError("Missing requried field \"" + fieldName + "\".");
×
1158
    }
1159
    return value;
1✔
1160
  }
1161

1162
  /**
1163
   * Adds diagnostic data about internal service state to the provided {@link StringBuilder}.
1164
   * Currently includes histories of all workflow instances stored in the service.
1165
   */
1166
  public void getDiagnostics(StringBuilder result) {
1167
    store.getDiagnostics(result);
1✔
1168
  }
1✔
1169

1170
  public long currentTimeMillis() {
1171
    return store.getTimer().getClock().getAsLong();
1✔
1172
  }
1173

1174
  /** Invokes callback after the specified delay according to internal service clock. */
1175
  public void registerDelayedCallback(Duration delay, Runnable r) {
1176
    store.registerDelayedCallback(delay, r);
1✔
1177
  }
1✔
1178

1179
  /**
1180
   * Disables time skipping. To enable back call {@link #unlockTimeSkipping(String)}. These calls
1181
   * are counted, so calling unlock does not guarantee that time is going to be skipped immediately
1182
   * as another lock can be holding it.
1183
   */
1184
  public void lockTimeSkipping(String caller) {
1185
    store.getTimer().lockTimeSkipping(caller);
1✔
1186
  }
1✔
1187

1188
  public void unlockTimeSkipping(String caller) {
1189
    store.getTimer().unlockTimeSkipping(caller);
1✔
1190
  }
1✔
1191

1192
  /**
1193
   * Blocks calling thread until internal clock doesn't pass the current + duration time. Might not
1194
   * block at all due to time skipping.
1195
   */
1196
  public void sleep(Duration duration) {
1197
    CompletableFuture<Void> result = new CompletableFuture<>();
1✔
1198
    store
1✔
1199
        .getTimer()
1✔
1200
        .schedule(
1✔
1201
            duration,
1202
            () -> {
1203
              store.getTimer().lockTimeSkipping("TestWorkflowService sleep");
1✔
1204
              result.complete(null);
1✔
1205
            },
1✔
1206
            "workflow sleep");
1207
    store.getTimer().unlockTimeSkipping("TestWorkflowService sleep");
1✔
1208
    try {
1209
      result.get();
1✔
1210
    } catch (InterruptedException e) {
×
1211
      throw new RuntimeException(e);
×
1212
    } catch (ExecutionException e) {
×
1213
      throw new RuntimeException(e);
×
1214
    }
1✔
1215
  }
1✔
1216
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc