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

temporalio / sdk-java / #189

26 Sep 2023 02:27PM CUT coverage: 77.349% (-0.02%) from 77.369%
#189

push

github-actions

web-flow
Fix workflow options equality (#1868)

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

18665 of 24131 relevant lines covered (77.35%)

0.77 hits per line

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

0.0
/temporal-sdk/src/main/java/io/temporal/client/schedules/ScheduleActionStartWorkflow.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.client.schedules;
22

23
import io.temporal.client.WorkflowOptions;
24
import io.temporal.common.converter.EncodedValues;
25
import io.temporal.common.interceptors.Header;
26
import io.temporal.common.metadata.POJOWorkflowInterfaceMetadata;
27

28
/** Schedule action to start a workflow. */
29
public final class ScheduleActionStartWorkflow extends ScheduleAction {
30
  public static ScheduleActionStartWorkflow.Builder newBuilder() {
31
    return new ScheduleActionStartWorkflow.Builder();
×
32
  }
33

34
  public static ScheduleActionStartWorkflow.Builder newBuilder(
35
      ScheduleActionStartWorkflow options) {
36
    return new ScheduleActionStartWorkflow.Builder(options);
×
37
  }
38

39
  public static class Builder {
40
    private String workflowType;
41
    private WorkflowOptions options;
42
    private Header header;
43
    private EncodedValues arguments;
44

45
    private Builder() {}
46

47
    private Builder(ScheduleActionStartWorkflow options) {
×
48
      if (options == null) {
×
49
        return;
×
50
      }
51
      this.workflowType = options.workflowType;
×
52
      this.options = options.options;
×
53
      this.header = options.header;
×
54
      this.arguments = options.arguments;
×
55
    }
×
56

57
    /** Set the name of the workflow type */
58
    public Builder setWorkflowType(String workflowType) {
59
      this.workflowType = workflowType;
×
60
      return this;
×
61
    }
62

63
    /** Set the workflow type. workflowInterface must implement a WorkflowInterface */
64
    public <T> Builder setWorkflowType(Class<T> workflowInterface) {
65
      POJOWorkflowInterfaceMetadata workflowMetadata =
×
66
          POJOWorkflowInterfaceMetadata.newInstance(workflowInterface, true);
×
67
      this.workflowType = workflowMetadata.getWorkflowType().get();
×
68
      return this;
×
69
    }
70

71
    /**
72
     * Set the workflow options to use when starting a workflow action.
73
     *
74
     * @note ID and TaskQueue are required. Some options like ID reuse policy, cron schedule, and
75
     *     start signal cannot be set or an error will occur. Schedules requires the use of typed
76
     *     search attributes and untyped search attributes will be ignored.
77
     */
78
    public Builder setOptions(WorkflowOptions options) {
79
      this.options = options;
×
80
      return this;
×
81
    }
82

83
    /** Set the headers sent with each workflow scheduled. */
84
    public Builder setHeader(Header header) {
85
      this.header = header;
×
86
      return this;
×
87
    }
88

89
    /** Set the workflow arguments to use when starting a workflow action. */
90
    public Builder setRawArguments(EncodedValues values) {
91
      this.arguments = values;
×
92
      return this;
×
93
    }
94

95
    /** Set the workflow arguments to use when starting a workflow action. */
96
    public Builder setArguments(Object... arguments) {
97
      this.arguments = new EncodedValues(arguments);
×
98
      return this;
×
99
    }
100

101
    public ScheduleActionStartWorkflow build() {
102
      return new ScheduleActionStartWorkflow(
×
103
          workflowType,
104
          options,
105
          header == null ? Header.empty() : header,
×
106
          arguments == null ? new EncodedValues() : arguments);
×
107
    }
108
  }
109

110
  private final String workflowType;
111
  private final WorkflowOptions options;
112
  private final Header header;
113
  private final EncodedValues arguments;
114

115
  private ScheduleActionStartWorkflow(
116
      String workflowType, WorkflowOptions options, Header header, EncodedValues arguments) {
×
117
    this.workflowType = workflowType;
×
118
    this.options = options;
×
119
    this.header = header;
×
120
    this.arguments = arguments;
×
121
  }
×
122

123
  /**
124
   * Get the workflow type name.
125
   *
126
   * @return the workflow type name.
127
   */
128
  public String getWorkflowType() {
129
    return workflowType;
×
130
  }
131

132
  /**
133
   * Get the workflow options used. Note {@link WorkflowOptions#getMemo()} every value here is an
134
   * instance of {@link EncodedValues}. To access, call {@link EncodedValues#get} with an index of
135
   * 0.
136
   *
137
   * @return workflow options used for the scheduled workflows.
138
   */
139
  public WorkflowOptions getOptions() {
140
    return options;
×
141
  }
142

143
  /**
144
   * Get the headers that will be sent with each workflow scheduled.
145
   *
146
   * @return headers to be sent
147
   */
148
  public Header getHeader() {
149
    return header;
×
150
  }
151

152
  /**
153
   * Arguments for the workflow.
154
   *
155
   * @return the arguments used for the scheduled workflows.
156
   */
157
  public EncodedValues getArguments() {
158
    return arguments;
×
159
  }
160
}
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