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

temporalio / sdk-java / #186

30 Aug 2023 04:30PM UTC coverage: 77.6% (-0.04%) from 77.642%
#186

push

github-actions

web-flow
Add new workflow info fields (#1853)

Add new workflow info fields

13 of 13 new or added lines in 5 files covered. (100.0%)

18579 of 23942 relevant lines covered (77.6%)

0.78 hits per line

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

32.86
/temporal-testing/src/main/java/io/temporal/internal/sync/DummySyncWorkflowContext.java
1
/*
2
 * Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved.
3
 *
4
 * Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
5
 *
6
 * Modifications copyright (C) 2017 Uber Technologies, Inc.
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this material except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 *   http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
20

21
package io.temporal.internal.sync;
22

23
import com.uber.m3.tally.NoopScope;
24
import com.uber.m3.tally.Scope;
25
import io.temporal.api.command.v1.ContinueAsNewWorkflowExecutionCommandAttributes;
26
import io.temporal.api.command.v1.SignalExternalWorkflowExecutionCommandAttributes;
27
import io.temporal.api.common.v1.Payload;
28
import io.temporal.api.common.v1.Payloads;
29
import io.temporal.api.common.v1.SearchAttributes;
30
import io.temporal.api.common.v1.WorkflowExecution;
31
import io.temporal.api.common.v1.WorkflowType;
32
import io.temporal.api.failure.v1.Failure;
33
import io.temporal.common.converter.DefaultDataConverter;
34
import io.temporal.failure.CanceledFailure;
35
import io.temporal.internal.common.SdkFlag;
36
import io.temporal.internal.replay.ReplayWorkflowContext;
37
import io.temporal.internal.statemachines.ExecuteActivityParameters;
38
import io.temporal.internal.statemachines.ExecuteLocalActivityParameters;
39
import io.temporal.internal.statemachines.LocalActivityCallback;
40
import io.temporal.internal.statemachines.StartChildWorkflowExecutionParameters;
41
import io.temporal.workflow.Functions;
42
import java.time.Duration;
43
import java.util.*;
44
import javax.annotation.Nonnull;
45
import javax.annotation.Nullable;
46

47
public class DummySyncWorkflowContext {
×
48
  public static SyncWorkflowContext newDummySyncWorkflowContext() {
49
    SyncWorkflowContext context =
1✔
50
        new SyncWorkflowContext(
51
            "dummy",
52
            WorkflowExecution.newBuilder().setWorkflowId("dummy").setRunId("dummy").build(),
1✔
53
            new SignalDispatcher(DefaultDataConverter.STANDARD_INSTANCE),
54
            new QueryDispatcher(DefaultDataConverter.STANDARD_INSTANCE),
55
            new UpdateDispatcher(DefaultDataConverter.STANDARD_INSTANCE),
56
            null,
57
            DefaultDataConverter.STANDARD_INSTANCE,
58
            null);
59
    context.setReplayContext(new DummyReplayWorkflowContext());
1✔
60
    context.initHeadOutboundCallsInterceptor(context);
1✔
61
    context.initHeadInboundCallsInterceptor(
1✔
62
        new BaseRootWorkflowInboundCallsInterceptor(context) {
1✔
63
          @Override
64
          public WorkflowOutput execute(WorkflowInput input) {
65
            throw new UnsupportedOperationException(
×
66
                "#execute is not implemented or needed for low level DeterministicRunner tests");
67
          }
68
        });
69
    return context;
1✔
70
  }
71

72
  private static final class DummyReplayWorkflowContext implements ReplayWorkflowContext {
1✔
73

74
    private final Timer timer = new Timer();
1✔
75

76
    @Override
77
    public WorkflowExecution getWorkflowExecution() {
78
      throw new UnsupportedOperationException("not implemented");
×
79
    }
80

81
    @Override
82
    public WorkflowExecution getParentWorkflowExecution() {
83
      throw new UnsupportedOperationException("not implemented");
×
84
    }
85

86
    @Override
87
    public WorkflowType getWorkflowType() {
88
      return WorkflowType.newBuilder().setName("dummy-workflow").build();
1✔
89
    }
90

91
    @Override
92
    public boolean isCancelRequested() {
93
      throw new UnsupportedOperationException("not implemented");
×
94
    }
95

96
    @Override
97
    public void setCancelRequested() {
98
      throw new UnsupportedOperationException("not implemented");
×
99
    }
100

101
    @Override
102
    public boolean isWorkflowMethodCompleted() {
103
      throw new UnsupportedOperationException("not implemented");
×
104
    }
105

106
    @Override
107
    public void setWorkflowMethodCompleted() {
108
      throw new UnsupportedOperationException("not implemented");
×
109
    }
110

111
    @Override
112
    public ContinueAsNewWorkflowExecutionCommandAttributes getContinueAsNewOnCompletion() {
113
      throw new UnsupportedOperationException("not implemented");
×
114
    }
115

116
    @Override
117
    public String getTaskQueue() {
118
      return "dummy-task-queue";
1✔
119
    }
120

121
    @Override
122
    public String getNamespace() {
123
      return "dummy-namespace";
1✔
124
    }
125

126
    @Override
127
    public String getWorkflowId() {
128
      return "dummy-workflow-id";
1✔
129
    }
130

131
    @Nonnull
132
    @Override
133
    public String getRunId() {
134
      return "dummy-run-id";
1✔
135
    }
136

137
    @Nonnull
138
    @Override
139
    public String getFirstExecutionRunId() {
140
      throw new UnsupportedOperationException("not implemented");
×
141
    }
142

143
    @Override
144
    public Optional<String> getContinuedExecutionRunId() {
145
      throw new UnsupportedOperationException("not implemented");
×
146
    }
147

148
    @Nonnull
149
    @Override
150
    public String getOriginalExecutionRunId() {
151
      throw new UnsupportedOperationException("not implemented");
×
152
    }
153

154
    @Override
155
    public Duration getWorkflowRunTimeout() {
156
      throw new UnsupportedOperationException("not implemented");
×
157
    }
158

159
    @Override
160
    public Duration getWorkflowExecutionTimeout() {
161
      return Duration.ZERO;
×
162
    }
163

164
    @Override
165
    public long getRunStartedTimestampMillis() {
166
      return 0;
×
167
    }
168

169
    @Nonnull
170
    @Override
171
    public Duration getWorkflowTaskTimeout() {
172
      throw new UnsupportedOperationException("not implemented");
×
173
    }
174

175
    @Override
176
    public Payload getMemo(String key) {
177
      throw new UnsupportedOperationException("not implemented");
×
178
    }
179

180
    @Override
181
    @Nullable
182
    public SearchAttributes getSearchAttributes() {
183
      throw new UnsupportedOperationException("not implemented");
×
184
    }
185

186
    @Override
187
    public ScheduleActivityTaskOutput scheduleActivityTask(
188
        ExecuteActivityParameters parameters,
189
        Functions.Proc2<Optional<Payloads>, Failure> callback) {
190
      throw new UnsupportedOperationException("not implemented");
×
191
    }
192

193
    @Override
194
    public Functions.Proc scheduleLocalActivityTask(
195
        ExecuteLocalActivityParameters parameters, LocalActivityCallback callback) {
196
      throw new UnsupportedOperationException("not implemented");
×
197
    }
198

199
    @Override
200
    public Functions.Proc1<Exception> startChildWorkflow(
201
        StartChildWorkflowExecutionParameters parameters,
202
        Functions.Proc2<WorkflowExecution, Exception> executionCallback,
203
        Functions.Proc2<Optional<Payloads>, Exception> callback) {
204
      throw new UnsupportedOperationException("not implemented");
×
205
    }
206

207
    @Override
208
    public Functions.Proc1<Exception> signalExternalWorkflowExecution(
209
        SignalExternalWorkflowExecutionCommandAttributes.Builder attributes,
210
        Functions.Proc2<Void, Failure> callback) {
211
      throw new UnsupportedOperationException("not implemented");
×
212
    }
213

214
    @Override
215
    public void requestCancelExternalWorkflowExecution(
216
        WorkflowExecution execution, Functions.Proc2<Void, RuntimeException> callback) {
217
      throw new UnsupportedOperationException("not implemented");
×
218
    }
219

220
    @Override
221
    public void continueAsNewOnCompletion(
222
        ContinueAsNewWorkflowExecutionCommandAttributes attributes) {
223
      throw new UnsupportedOperationException("not implemented");
×
224
    }
225

226
    @Override
227
    public Throwable getWorkflowTaskFailure() {
228
      throw new UnsupportedOperationException("not implemented");
×
229
    }
230

231
    @Override
232
    public void failWorkflowTask(Throwable failure) {
233
      throw new UnsupportedOperationException("not implemented");
×
234
    }
235

236
    @Override
237
    public long currentTimeMillis() {
238
      return System.currentTimeMillis();
×
239
    }
240

241
    @Override
242
    public Functions.Proc1<RuntimeException> newTimer(
243
        Duration delay, Functions.Proc1<RuntimeException> callback) {
244
      timer.schedule(
1✔
245
          new TimerTask() {
1✔
246
            @Override
247
            public void run() {
248
              callback.apply(null);
1✔
249
            }
1✔
250
          },
251
          delay.toMillis());
1✔
252
      return (e) -> {
1✔
253
        callback.apply(new CanceledFailure(null));
1✔
254
      };
1✔
255
    }
256

257
    @Override
258
    public void sideEffect(
259
        Functions.Func<Optional<Payloads>> func, Functions.Proc1<Optional<Payloads>> callback) {
260
      callback.apply(func.apply());
×
261
    }
×
262

263
    @Override
264
    public void mutableSideEffect(
265
        String id,
266
        Functions.Func1<Optional<Payloads>, Optional<Payloads>> func,
267
        Functions.Proc1<Optional<Payloads>> callback) {
268
      callback.apply(func.apply(Optional.empty()));
×
269
    }
×
270

271
    @Override
272
    public boolean isReplaying() {
273
      return false;
1✔
274
    }
275

276
    @Override
277
    public boolean getVersion(
278
        String changeId,
279
        int minSupported,
280
        int maxSupported,
281
        Functions.Proc2<Integer, RuntimeException> callback) {
282
      throw new UnsupportedOperationException("not implemented");
×
283
    }
284

285
    @Override
286
    public Random newRandom() {
287
      throw new UnsupportedOperationException("not implemented");
×
288
    }
289

290
    @Override
291
    public Scope getMetricsScope() {
292
      return new NoopScope();
×
293
    }
294

295
    @Override
296
    public boolean getEnableLoggingInReplay() {
297
      return false;
×
298
    }
299

300
    @Override
301
    public UUID randomUUID() {
302
      return UUID.randomUUID();
×
303
    }
304

305
    @Override
306
    public void upsertSearchAttributes(@Nonnull SearchAttributes searchAttributes) {
307
      throw new UnsupportedOperationException("not implemented");
×
308
    }
309

310
    @Override
311
    public boolean tryUseSdkFlag(SdkFlag flag) {
312
      return false;
×
313
    }
314

315
    @Override
316
    public int getAttempt() {
317
      return 1;
×
318
    }
319

320
    @Override
321
    public String getCronSchedule() {
322
      return "dummy-cron-schedule";
×
323
    }
324

325
    @Nullable
326
    @Override
327
    public Payloads getLastCompletionResult() {
328
      return null;
×
329
    }
330

331
    @Nullable
332
    @Override
333
    public Failure getPreviousRunFailure() {
334
      return null;
×
335
    }
336

337
    @Nullable
338
    @Override
339
    public String getFullReplayDirectQueryName() {
340
      return null;
×
341
    }
342

343
    @Override
344
    public Map<String, Payload> getHeader() {
345
      return null;
×
346
    }
347

348
    @Override
349
    public long getCurrentWorkflowTaskStartedEventId() {
350
      return 0;
×
351
    }
352

353
    @Override
354
    public long getHistorySize() {
355
      return 0;
×
356
    }
357

358
    @Override
359
    public boolean isContinueAsNewSuggested() {
360
      return false;
×
361
    }
362
  }
363
}
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

© 2025 Coveralls, Inc