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

temporalio / sdk-java / #157

pending completion
#157

push

github-actions

web-flow
Provide SerializationContext for PayloadConverter and PayloadCodec (#1695)

Issue #1694

497 of 497 new or added lines in 32 files covered. (100.0%)

16942 of 20806 relevant lines covered (81.43%)

0.81 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
            null,
55
            DefaultDataConverter.STANDARD_INSTANCE,
56
            null);
57
    context.setReplayContext(new DummyReplayWorkflowContext());
1✔
58
    context.initHeadOutboundCallsInterceptor(context);
1✔
59
    context.initHeadInboundCallsInterceptor(
1✔
60
        new BaseRootWorkflowInboundCallsInterceptor(context) {
1✔
61
          @Override
62
          public WorkflowOutput execute(WorkflowInput input) {
63
            throw new UnsupportedOperationException(
×
64
                "#execute is not implemented or needed for low level DeterministicRunner tests");
65
          }
66
        });
67
    return context;
1✔
68
  }
69

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

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

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

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

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

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

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

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

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

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

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

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

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

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

134
    @Override
135
    public String getFirstExecutionRunId() {
136
      return null;
×
137
    }
138

139
    @Override
140
    public Optional<String> getContinuedExecutionRunId() {
141
      throw new UnsupportedOperationException("not implemented");
×
142
    }
143

144
    @Override
145
    public Optional<String> getOriginalExecutionRunId() {
146
      return Optional.empty();
×
147
    }
148

149
    @Override
150
    public Duration getWorkflowRunTimeout() {
151
      throw new UnsupportedOperationException("not implemented");
×
152
    }
153

154
    @Override
155
    public Duration getWorkflowExecutionTimeout() {
156
      return Duration.ZERO;
×
157
    }
158

159
    @Override
160
    public long getRunStartedTimestampMillis() {
161
      return 0;
×
162
    }
163

164
    @Nonnull
165
    @Override
166
    public Duration getWorkflowTaskTimeout() {
167
      throw new UnsupportedOperationException("not implemented");
×
168
    }
169

170
    @Override
171
    public Payload getMemo(String key) {
172
      throw new UnsupportedOperationException("not implemented");
×
173
    }
174

175
    @Override
176
    @Nullable
177
    public SearchAttributes getSearchAttributes() {
178
      throw new UnsupportedOperationException("not implemented");
×
179
    }
180

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

188
    @Override
189
    public Functions.Proc scheduleLocalActivityTask(
190
        ExecuteLocalActivityParameters parameters, LocalActivityCallback callback) {
191
      throw new UnsupportedOperationException("not implemented");
×
192
    }
193

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

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

209
    @Override
210
    public void requestCancelExternalWorkflowExecution(
211
        WorkflowExecution execution, Functions.Proc2<Void, RuntimeException> callback) {
212
      throw new UnsupportedOperationException("not implemented");
×
213
    }
214

215
    @Override
216
    public void continueAsNewOnCompletion(
217
        ContinueAsNewWorkflowExecutionCommandAttributes attributes) {
218
      throw new UnsupportedOperationException("not implemented");
×
219
    }
220

221
    @Override
222
    public Throwable getWorkflowTaskFailure() {
223
      throw new UnsupportedOperationException("not implemented");
×
224
    }
225

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

231
    @Override
232
    public long currentTimeMillis() {
233
      return System.currentTimeMillis();
×
234
    }
235

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

252
    @Override
253
    public void sideEffect(
254
        Functions.Func<Optional<Payloads>> func, Functions.Proc1<Optional<Payloads>> callback) {
255
      callback.apply(func.apply());
×
256
    }
×
257

258
    @Override
259
    public void mutableSideEffect(
260
        String id,
261
        Functions.Func1<Optional<Payloads>, Optional<Payloads>> func,
262
        Functions.Proc1<Optional<Payloads>> callback) {
263
      callback.apply(func.apply(Optional.empty()));
×
264
    }
×
265

266
    @Override
267
    public boolean isReplaying() {
268
      return false;
1✔
269
    }
270

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

280
    @Override
281
    public Random newRandom() {
282
      throw new UnsupportedOperationException("not implemented");
×
283
    }
284

285
    @Override
286
    public Scope getMetricsScope() {
287
      return new NoopScope();
×
288
    }
289

290
    @Override
291
    public boolean getEnableLoggingInReplay() {
292
      return false;
×
293
    }
294

295
    @Override
296
    public UUID randomUUID() {
297
      return UUID.randomUUID();
×
298
    }
299

300
    @Override
301
    public void upsertSearchAttributes(@Nonnull SearchAttributes searchAttributes) {
302
      throw new UnsupportedOperationException("not implemented");
×
303
    }
304

305
    @Override
306
    public int getAttempt() {
307
      return 1;
×
308
    }
309

310
    @Override
311
    public String getCronSchedule() {
312
      return "dummy-cron-schedule";
×
313
    }
314

315
    @Nullable
316
    @Override
317
    public Payloads getLastCompletionResult() {
318
      return null;
×
319
    }
320

321
    @Nullable
322
    @Override
323
    public Failure getPreviousRunFailure() {
324
      return null;
×
325
    }
326

327
    @Nullable
328
    @Override
329
    public String getFullReplayDirectQueryName() {
330
      return null;
×
331
    }
332

333
    @Override
334
    public Map<String, Payload> getHeader() {
335
      return null;
×
336
    }
337

338
    @Override
339
    public long getCurrentWorkflowTaskStartedEventId() {
340
      return 0;
×
341
    }
342
  }
343
}
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