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

temporalio / sdk-java / #169

pending completion
#169

push

github-actions

web-flow
Remove use of deprecated API (#1758)

4 of 4 new or added lines in 1 file covered. (100.0%)

17345 of 21558 relevant lines covered (80.46%)

0.8 hits per line

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

34.33
/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.replay.ReplayWorkflowContext;
36
import io.temporal.internal.statemachines.ExecuteActivityParameters;
37
import io.temporal.internal.statemachines.ExecuteLocalActivityParameters;
38
import io.temporal.internal.statemachines.LocalActivityCallback;
39
import io.temporal.internal.statemachines.StartChildWorkflowExecutionParameters;
40
import io.temporal.workflow.Functions;
41
import java.time.Duration;
42
import java.util.*;
43
import javax.annotation.Nonnull;
44
import javax.annotation.Nullable;
45

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

309
    @Override
310
    public int getAttempt() {
311
      return 1;
×
312
    }
313

314
    @Override
315
    public String getCronSchedule() {
316
      return "dummy-cron-schedule";
×
317
    }
318

319
    @Nullable
320
    @Override
321
    public Payloads getLastCompletionResult() {
322
      return null;
×
323
    }
324

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

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

337
    @Override
338
    public Map<String, Payload> getHeader() {
339
      return null;
×
340
    }
341

342
    @Override
343
    public long getCurrentWorkflowTaskStartedEventId() {
344
      return 0;
×
345
    }
346
  }
347
}
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