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

temporalio / sdk-java / #181

pending completion
#181

push

github-actions

web-flow
Properly wrap exceptions from schedule client (#1827)

Wrap schedule exception

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

18557 of 23894 relevant lines covered (77.66%)

0.78 hits per line

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

97.44
/temporal-sdk/src/main/java/io/temporal/internal/replay/WorkflowTaskResult.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.replay;
22

23
import io.temporal.api.command.v1.Command;
24
import io.temporal.api.protocol.v1.Message;
25
import io.temporal.api.query.v1.WorkflowQueryResult;
26
import java.util.Collections;
27
import java.util.List;
28
import java.util.Map;
29

30
public final class WorkflowTaskResult {
31

32
  public static Builder newBuilder() {
33
    return new Builder();
1✔
34
  }
35

36
  public static final class Builder {
1✔
37
    private List<Command> commands;
38
    private List<Message> messages;
39
    private boolean finalCommand;
40
    private Map<String, WorkflowQueryResult> queryResults;
41
    private boolean forceWorkflowTask;
42
    private int nonfirstLocalActivityAttempts;
43
    private List<Integer> sdkFlags;
44

45
    public Builder setCommands(List<Command> commands) {
46
      this.commands = commands;
1✔
47
      return this;
1✔
48
    }
49

50
    public Builder setMessages(List<Message> messages) {
51
      this.messages = messages;
1✔
52
      return this;
1✔
53
    }
54

55
    public Builder setFinalCommand(boolean finalCommand) {
56
      this.finalCommand = finalCommand;
1✔
57
      return this;
1✔
58
    }
59

60
    public Builder setQueryResults(Map<String, WorkflowQueryResult> queryResults) {
61
      this.queryResults = queryResults;
1✔
62
      return this;
1✔
63
    }
64

65
    public Builder setForceWorkflowTask(boolean forceWorkflowTask) {
66
      this.forceWorkflowTask = forceWorkflowTask;
1✔
67
      return this;
1✔
68
    }
69

70
    public Builder setNonfirstLocalActivityAttempts(int nonfirstLocalActivityAttempts) {
71
      this.nonfirstLocalActivityAttempts = nonfirstLocalActivityAttempts;
1✔
72
      return this;
1✔
73
    }
74

75
    public Builder setSdkFlags(List<Integer> sdkFlags) {
76
      this.sdkFlags = sdkFlags;
1✔
77
      return this;
1✔
78
    }
79

80
    public WorkflowTaskResult build() {
81
      return new WorkflowTaskResult(
1✔
82
          commands == null ? Collections.emptyList() : commands,
1✔
83
          messages == null ? Collections.emptyList() : messages,
1✔
84
          queryResults == null ? Collections.emptyMap() : queryResults,
1✔
85
          finalCommand,
86
          forceWorkflowTask,
87
          nonfirstLocalActivityAttempts,
88
          sdkFlags == null ? Collections.emptyList() : sdkFlags);
1✔
89
    }
90
  }
91

92
  private final List<Command> commands;
93
  private final List<Message> messages;
94
  private final boolean finalCommand;
95
  private final Map<String, WorkflowQueryResult> queryResults;
96
  private final boolean forceWorkflowTask;
97
  private final int nonfirstLocalActivityAttempts;
98
  private final List<Integer> sdkFlags;
99

100
  private WorkflowTaskResult(
101
      List<Command> commands,
102
      List<Message> messages,
103
      Map<String, WorkflowQueryResult> queryResults,
104
      boolean finalCommand,
105
      boolean forceWorkflowTask,
106
      int nonfirstLocalActivityAttempts,
107
      List<Integer> sdkFlags) {
1✔
108
    this.commands = commands;
1✔
109
    this.messages = messages;
1✔
110
    this.nonfirstLocalActivityAttempts = nonfirstLocalActivityAttempts;
1✔
111
    if (forceWorkflowTask && finalCommand) {
1✔
112
      throw new IllegalArgumentException("both forceWorkflowTask and finalCommand are true");
×
113
    }
114
    this.queryResults = queryResults;
1✔
115
    this.finalCommand = finalCommand;
1✔
116
    this.forceWorkflowTask = forceWorkflowTask;
1✔
117
    this.sdkFlags = sdkFlags;
1✔
118
  }
1✔
119

120
  public List<Command> getCommands() {
121
    return commands;
1✔
122
  }
123

124
  public List<Message> getMessages() {
125
    return messages;
1✔
126
  }
127

128
  public Map<String, WorkflowQueryResult> getQueryResults() {
129
    return queryResults;
1✔
130
  }
131

132
  /** Is this result contain a workflow completion command */
133
  public boolean isFinalCommand() {
134
    return finalCommand;
1✔
135
  }
136

137
  public boolean isForceWorkflowTask() {
138
    return forceWorkflowTask;
1✔
139
  }
140

141
  public int getNonfirstLocalActivityAttempts() {
142
    return nonfirstLocalActivityAttempts;
1✔
143
  }
144

145
  public List<Integer> getSdkFlags() {
146
    return sdkFlags;
1✔
147
  }
148
}
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