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

uber / cadence-java-client / 2644

07 Nov 2024 09:03PM UTC coverage: 80.295% (-0.001%) from 80.296%
2644

Pull #955

buildkite

fimanishi
Add tests for PollerAutoScalerOptions.java
Pull Request #955: Add tests for PollerAutoScalerOptions.java

15570 of 19391 relevant lines covered (80.29%)

0.8 hits per line

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

64.15
/src/main/java/com/uber/cadence/internal/common/StartWorkflowExecutionParameters.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.common;
19

20
import com.uber.cadence.WorkflowIdReusePolicy;
21
import com.uber.cadence.WorkflowType;
22
import com.uber.cadence.client.WorkflowOptions;
23
import com.uber.cadence.common.RetryOptions;
24
import java.time.Duration;
25
import java.util.ArrayList;
26
import java.util.Arrays;
27
import java.util.List;
28
import java.util.Map;
29
import java.util.Objects;
30

31
public final class StartWorkflowExecutionParameters {
1✔
32

33
  private String workflowId;
34

35
  private WorkflowType workflowType;
36

37
  private String taskList;
38

39
  private byte[] input;
40

41
  private long executionStartToCloseTimeoutSeconds;
42

43
  private long taskStartToCloseTimeoutSeconds;
44

45
  private WorkflowIdReusePolicy workflowIdReusePolicy;
46

47
  private RetryParameters retryParameters;
48

49
  private String cronSchedule;
50

51
  private Map<String, byte[]> memo;
52

53
  private Map<String, byte[]> searchAttributes;
54

55
  private Map<String, byte[]> context;
56

57
  private Duration delayStart;
58

59
  /**
60
   * Returns the value of the WorkflowId property for this object.
61
   *
62
   * <p><b>Constraints:</b><br>
63
   * <b>Length: </b>1 - 64<br>
64
   *
65
   * @return The value of the WorkflowId property for this object.
66
   */
67
  public String getWorkflowId() {
68
    return workflowId;
1✔
69
  }
70

71
  /**
72
   * Sets the value of the WorkflowId property for this object.
73
   *
74
   * <p><b>Constraints:</b><br>
75
   * <b>Length: </b>1 - 64<br>
76
   *
77
   * @param workflowId The new value for the WorkflowId property for this object.
78
   */
79
  public void setWorkflowId(String workflowId) {
80
    this.workflowId = workflowId;
1✔
81
  }
1✔
82

83
  /**
84
   * Sets the value of the WorkflowId property for this object.
85
   *
86
   * <p>Returns a reference to this object so that method calls can be chained together.
87
   *
88
   * <p><b>Constraints:</b><br>
89
   * <b>Length: </b>1 - 64<br>
90
   *
91
   * @param workflowId The new value for the WorkflowId property for this object.
92
   * @return A reference to this updated object so that method calls can be chained together.
93
   */
94
  public StartWorkflowExecutionParameters withWorkflowId(String workflowId) {
95
    this.workflowId = workflowId;
×
96
    return this;
×
97
  }
98

99
  /**
100
   * Returns the value of the WorkflowType property for this object.
101
   *
102
   * @return The value of the WorkflowType property for this object.
103
   */
104
  public WorkflowType getWorkflowType() {
105
    return workflowType;
1✔
106
  }
107

108
  /**
109
   * Sets the value of the WorkflowType property for this object.
110
   *
111
   * @param workflowType The new value for the WorkflowType property for this object.
112
   */
113
  public void setWorkflowType(WorkflowType workflowType) {
114
    this.workflowType = workflowType;
1✔
115
  }
1✔
116

117
  /**
118
   * Sets the value of the WorkflowType property for this object.
119
   *
120
   * <p>Returns a reference to this object so that method calls can be chained together.
121
   *
122
   * @param workflowType The new value for the WorkflowType property for this object.
123
   * @return A reference to this updated object so that method calls can be chained together.
124
   */
125
  public StartWorkflowExecutionParameters withWorkflowType(WorkflowType workflowType) {
126
    this.workflowType = workflowType;
×
127
    return this;
×
128
  }
129

130
  public WorkflowIdReusePolicy getWorkflowIdReusePolicy() {
131
    return workflowIdReusePolicy;
1✔
132
  }
133

134
  public void setWorkflowIdReusePolicy(WorkflowIdReusePolicy workflowIdReusePolicy) {
135
    this.workflowIdReusePolicy = workflowIdReusePolicy;
1✔
136
  }
1✔
137

138
  public StartWorkflowExecutionParameters withWorkflowIdReusePolicy(
139
      WorkflowIdReusePolicy workflowIdReusePolicy) {
140
    this.workflowIdReusePolicy = workflowIdReusePolicy;
×
141
    return this;
×
142
  }
143

144
  /**
145
   * Returns the value of the TaskList property for this object.
146
   *
147
   * @return The value of the TaskList property for this object.
148
   */
149
  public String getTaskList() {
150
    return taskList;
1✔
151
  }
152

153
  /**
154
   * Sets the value of the TaskList property for this object.
155
   *
156
   * @param taskList The new value for the TaskList property for this object.
157
   */
158
  public void setTaskList(String taskList) {
159
    this.taskList = taskList;
1✔
160
  }
1✔
161

162
  /**
163
   * Sets the value of the TaskList property for this object.
164
   *
165
   * <p>Returns a reference to this object so that method calls can be chained together.
166
   *
167
   * @param taskList The new value for the TaskList property for this object.
168
   * @return A reference to this updated object so that method calls can be chained together.
169
   */
170
  public StartWorkflowExecutionParameters withTaskList(String taskList) {
171
    this.taskList = taskList;
×
172
    return this;
×
173
  }
174

175
  /**
176
   * Returns the value of the Input property for this object.
177
   *
178
   * <p><b>Constraints:</b><br>
179
   * <b>Length: </b>0 - 100000<br>
180
   *
181
   * @return The value of the Input property for this object.
182
   */
183
  public byte[] getInput() {
184
    return input;
1✔
185
  }
186

187
  /**
188
   * Sets the value of the Input property for this object.
189
   *
190
   * <p><b>Constraints:</b><br>
191
   * <b>Length: </b>0 - 100000<br>
192
   *
193
   * @param input The new value for the Input property for this object.
194
   */
195
  public void setInput(byte[] input) {
196
    this.input = input;
1✔
197
  }
1✔
198

199
  /**
200
   * Sets the value of the Input property for this object.
201
   *
202
   * <p>Returns a reference to this object so that method calls can be chained together.
203
   *
204
   * <p><b>Constraints:</b><br>
205
   * <b>Length: </b>0 - 100000<br>
206
   *
207
   * @param input The new value for the Input property for this object.
208
   * @return A reference to this updated object so that method calls can be chained together.
209
   */
210
  public StartWorkflowExecutionParameters withInput(byte[] input) {
211
    this.input = input;
×
212
    return this;
×
213
  }
214

215
  /**
216
   * Returns the value of the StartToCloseTimeout property for this object.
217
   *
218
   * <p><b>Constraints:</b><br>
219
   * <b>Length: </b>0 - 64<br>
220
   *
221
   * @return The value of the StartToCloseTimeout property for this object.
222
   */
223
  public long getExecutionStartToCloseTimeoutSeconds() {
224
    return executionStartToCloseTimeoutSeconds;
1✔
225
  }
226

227
  /**
228
   * Sets the value of the StartToCloseTimeout property for this object.
229
   *
230
   * <p><b>Constraints:</b><br>
231
   * <b>Length: </b>0 - 64<br>
232
   *
233
   * @param executionStartToCloseTimeoutSeconds The new value for the StartToCloseTimeout property
234
   *     for this object.
235
   */
236
  public void setExecutionStartToCloseTimeoutSeconds(long executionStartToCloseTimeoutSeconds) {
237
    this.executionStartToCloseTimeoutSeconds = executionStartToCloseTimeoutSeconds;
1✔
238
  }
1✔
239

240
  /**
241
   * Sets the value of the StartToCloseTimeout property for this object.
242
   *
243
   * <p>Returns a reference to this object so that method calls can be chained together.
244
   *
245
   * <p><b>Constraints:</b><br>
246
   * <b>Length: </b>0 - 64<br>
247
   *
248
   * @param executionStartToCloseTimeoutSeconds The new value for the StartToCloseTimeout property
249
   *     for this object.
250
   * @return A reference to this updated object so that method calls can be chained together.
251
   */
252
  public StartWorkflowExecutionParameters withExecutionStartToCloseTimeoutSeconds(
253
      long executionStartToCloseTimeoutSeconds) {
254
    this.executionStartToCloseTimeoutSeconds = executionStartToCloseTimeoutSeconds;
×
255
    return this;
×
256
  }
257

258
  public long getTaskStartToCloseTimeoutSeconds() {
259
    return taskStartToCloseTimeoutSeconds;
1✔
260
  }
261

262
  public void setTaskStartToCloseTimeoutSeconds(long taskStartToCloseTimeoutSeconds) {
263
    this.taskStartToCloseTimeoutSeconds = taskStartToCloseTimeoutSeconds;
1✔
264
  }
1✔
265

266
  public StartWorkflowExecutionParameters withTaskStartToCloseTimeoutSeconds(
267
      int taskStartToCloseTimeoutSeconds) {
268
    this.taskStartToCloseTimeoutSeconds = taskStartToCloseTimeoutSeconds;
×
269
    return this;
×
270
  }
271

272
  public RetryParameters getRetryParameters() {
273
    return retryParameters;
1✔
274
  }
275

276
  public void setRetryParameters(RetryParameters retryParameters) {
277
    this.retryParameters = retryParameters;
1✔
278
  }
1✔
279

280
  public String getCronSchedule() {
281
    return cronSchedule;
1✔
282
  }
283

284
  public void setCronSchedule(String cronSchedule) {
285
    this.cronSchedule = cronSchedule;
1✔
286
  }
1✔
287

288
  public Map<String, byte[]> getMemo() {
289
    return memo;
1✔
290
  }
291

292
  public void setMemo(Map<String, byte[]> memo) {
293
    this.memo = memo;
1✔
294
  }
1✔
295

296
  public Map<String, byte[]> getSearchAttributes() {
297
    return searchAttributes;
1✔
298
  }
299

300
  public void setSearchAttributes(Map<String, byte[]> searchAttributes) {
301
    this.searchAttributes = searchAttributes;
1✔
302
  }
1✔
303

304
  public Map<String, byte[]> getContext() {
305
    return context;
1✔
306
  }
307

308
  public void setContext(Map<String, byte[]> context) {
309
    this.context = context;
1✔
310
  }
1✔
311

312
  public void setDelayStart(Duration delayStart) {
313
    this.delayStart = delayStart;
1✔
314
  }
1✔
315

316
  public Duration getDelayStart() {
317
    return delayStart;
1✔
318
  }
319

320
  public StartWorkflowExecutionParameters withRetryParameters(RetryParameters retryParameters) {
321
    this.retryParameters = retryParameters;
×
322
    return this;
×
323
  }
324

325
  public static StartWorkflowExecutionParameters fromWorkflowOptions(WorkflowOptions options) {
326
    StartWorkflowExecutionParameters parameters = new StartWorkflowExecutionParameters();
1✔
327
    parameters.setExecutionStartToCloseTimeoutSeconds(
1✔
328
        getSeconds(options.getExecutionStartToCloseTimeout()));
1✔
329
    parameters.setTaskStartToCloseTimeoutSeconds(getSeconds(options.getTaskStartToCloseTimeout()));
1✔
330
    parameters.setTaskList(options.getTaskList());
1✔
331
    parameters.setWorkflowIdReusePolicy(options.getWorkflowIdReusePolicy());
1✔
332
    RetryOptions retryOptions = options.getRetryOptions();
1✔
333
    if (retryOptions != null) {
1✔
334
      RetryParameters rp = new RetryParameters();
1✔
335
      rp.setBackoffCoefficient(retryOptions.getBackoffCoefficient());
1✔
336
      rp.setExpirationIntervalInSeconds(getSeconds(retryOptions.getExpiration()));
1✔
337
      rp.setInitialIntervalInSeconds(getSeconds(retryOptions.getInitialInterval()));
1✔
338
      rp.setMaximumIntervalInSeconds(getSeconds(retryOptions.getMaximumInterval()));
1✔
339
      rp.setMaximumAttempts(retryOptions.getMaximumAttempts());
1✔
340
      List<String> reasons = new ArrayList<>();
1✔
341
      // Use exception type name as the reason
342
      List<Class<? extends Throwable>> doNotRetry = retryOptions.getDoNotRetry();
1✔
343
      if (doNotRetry != null) {
1✔
344
        for (Class<? extends Throwable> r : doNotRetry) {
1✔
345
          reasons.add(r.getName());
1✔
346
        }
1✔
347
        rp.setNonRetriableErrorReasons(reasons);
1✔
348
      }
349
      parameters.setRetryParameters(rp);
1✔
350
    }
351

352
    if (options.getCronSchedule() != null) {
1✔
353
      parameters.setCronSchedule(options.getCronSchedule());
1✔
354
    }
355
    return parameters;
1✔
356
  }
357

358
  private static int getSeconds(Duration expiration) {
359
    if (expiration == null) {
1✔
360
      return 0;
1✔
361
    }
362
    return (int) expiration.getSeconds();
1✔
363
  }
364

365
  @Override
366
  public String toString() {
367
    return "StartWorkflowExecutionParameters{"
×
368
        + "workflowId='"
369
        + workflowId
370
        + '\''
371
        + ", workflowType="
372
        + workflowType
373
        + ", taskList='"
374
        + taskList
375
        + '\''
376
        + ", input="
377
        + Arrays.toString(input)
×
378
        + ", executionStartToCloseTimeoutSeconds="
379
        + executionStartToCloseTimeoutSeconds
380
        + ", taskStartToCloseTimeoutSeconds="
381
        + taskStartToCloseTimeoutSeconds
382
        + ", workflowIdReusePolicy="
383
        + workflowIdReusePolicy
384
        + ", retryParameters="
385
        + retryParameters
386
        + ", cronSchedule='"
387
        + cronSchedule
388
        + '\''
389
        + ", memo='"
390
        + memo
391
        + '\''
392
        + ", searchAttributes='"
393
        + searchAttributes
394
        + ", context='"
395
        + context
396
        + ", delayStart='"
397
        + delayStart
398
        + '\''
399
        + '}';
400
  }
401

402
  @Override
403
  public boolean equals(Object o) {
404
    if (this == o) return true;
×
405
    if (o == null || getClass() != o.getClass()) return false;
×
406
    StartWorkflowExecutionParameters that = (StartWorkflowExecutionParameters) o;
×
407
    return executionStartToCloseTimeoutSeconds == that.executionStartToCloseTimeoutSeconds
×
408
        && taskStartToCloseTimeoutSeconds == that.taskStartToCloseTimeoutSeconds
409
        && Objects.equals(workflowId, that.workflowId)
×
410
        && Objects.equals(workflowType, that.workflowType)
×
411
        && Objects.equals(taskList, that.taskList)
×
412
        && Arrays.equals(input, that.input)
×
413
        && workflowIdReusePolicy == that.workflowIdReusePolicy
414
        && Objects.equals(retryParameters, that.retryParameters)
×
415
        && Objects.equals(cronSchedule, that.cronSchedule)
×
416
        && Objects.equals(memo, that.memo)
×
417
        && Objects.equals(searchAttributes, that.searchAttributes)
×
418
        && Objects.equals(context, that.context)
×
419
        && Objects.equals(delayStart, that.delayStart);
×
420
  }
421

422
  @Override
423
  public int hashCode() {
424
    int result =
×
425
        Objects.hash(
×
426
            workflowId,
427
            workflowType,
428
            taskList,
429
            executionStartToCloseTimeoutSeconds,
×
430
            taskStartToCloseTimeoutSeconds,
×
431
            workflowIdReusePolicy,
432
            retryParameters,
433
            cronSchedule,
434
            memo,
435
            searchAttributes,
436
            context,
437
            delayStart);
438
    result = 31 * result + Arrays.hashCode(input);
×
439
    return result;
×
440
  }
441
}
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