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

temporalio / sdk-java / #166

pending completion
#166

push

github-actions

web-flow
Add comment on Workflow#newQueue (#1747)

17109 of 20962 relevant lines covered (81.62%)

0.82 hits per line

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

85.29
/temporal-sdk/src/main/java/io/temporal/internal/replay/BasicWorkflowContext.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 com.google.common.base.Preconditions;
24
import com.google.protobuf.util.Timestamps;
25
import io.temporal.api.common.v1.*;
26
import io.temporal.api.failure.v1.Failure;
27
import io.temporal.api.history.v1.WorkflowExecutionStartedEventAttributes;
28
import io.temporal.internal.common.ProtobufTimeUtils;
29
import java.time.Duration;
30
import java.util.Map;
31
import java.util.Optional;
32
import javax.annotation.Nonnull;
33
import javax.annotation.Nullable;
34

35
/**
36
 * The most basic context with an information about the Workflow and some mutable state that
37
 * collects during its execution. This context is not aware about anything else like state machines.
38
 */
39
final class BasicWorkflowContext {
40
  private final long runStartedTimestampMillis;
41
  private final WorkflowExecutionStartedEventAttributes startedAttributes;
42
  private final String namespace;
43
  @Nonnull private final WorkflowExecution workflowExecution;
44

45
  @Nullable private final Payloads lastCompletionResult;
46

47
  @Nullable private final Failure previousRunFailure;
48

49
  BasicWorkflowContext(
50
      String namespace,
51
      @Nonnull WorkflowExecution workflowExecution,
52
      WorkflowExecutionStartedEventAttributes startedAttributes,
53
      long runStartedTimestampMillis) {
1✔
54
    this.namespace = namespace;
1✔
55
    this.workflowExecution = Preconditions.checkNotNull(workflowExecution);
1✔
56
    this.startedAttributes = startedAttributes;
1✔
57
    this.runStartedTimestampMillis = runStartedTimestampMillis;
1✔
58
    this.lastCompletionResult =
1✔
59
        startedAttributes.hasLastCompletionResult()
1✔
60
            ? startedAttributes.getLastCompletionResult()
1✔
61
            : null;
1✔
62
    this.previousRunFailure =
1✔
63
        startedAttributes.hasContinuedFailure() ? startedAttributes.getContinuedFailure() : null;
1✔
64
  }
1✔
65

66
  @Nonnull
67
  WorkflowExecution getWorkflowExecution() {
68
    return workflowExecution;
1✔
69
  }
70

71
  WorkflowType getWorkflowType() {
72
    return startedAttributes.getWorkflowType();
1✔
73
  }
74

75
  @Nonnull
76
  String getFirstExecutionRunId() {
77
    return startedAttributes.getFirstExecutionRunId();
×
78
  }
79

80
  Optional<String> getContinuedExecutionRunId() {
81
    String runId = startedAttributes.getContinuedExecutionRunId();
1✔
82
    return runId.isEmpty() ? Optional.empty() : Optional.of(runId);
1✔
83
  }
84

85
  @Nonnull
86
  String getOriginalExecutionRunId() {
87
    return startedAttributes.getOriginalExecutionRunId();
×
88
  }
89

90
  WorkflowExecution getParentWorkflowExecution() {
91
    return startedAttributes.hasParentWorkflowExecution()
1✔
92
        ? startedAttributes.getParentWorkflowExecution()
1✔
93
        : null;
1✔
94
  }
95

96
  Duration getWorkflowRunTimeout() {
97
    return ProtobufTimeUtils.toJavaDuration(startedAttributes.getWorkflowRunTimeout());
×
98
  }
99

100
  Duration getWorkflowExecutionTimeout() {
101
    return ProtobufTimeUtils.toJavaDuration(startedAttributes.getWorkflowExecutionTimeout());
×
102
  }
103

104
  long getWorkflowExecutionExpirationTimestampMillis() {
105
    return Timestamps.toMillis(startedAttributes.getWorkflowExecutionExpirationTime());
×
106
  }
107

108
  long getRunStartedTimestampMillis() {
109
    return runStartedTimestampMillis;
1✔
110
  }
111

112
  Duration getWorkflowTaskTimeout() {
113
    return ProtobufTimeUtils.toJavaDuration(startedAttributes.getWorkflowTaskTimeout());
1✔
114
  }
115

116
  String getTaskQueue() {
117
    return startedAttributes.getTaskQueue().getName();
1✔
118
  }
119

120
  String getNamespace() {
121
    return namespace;
1✔
122
  }
123

124
  public Map<String, Payload> getHeader() {
125
    return startedAttributes.getHeader().getFieldsMap();
1✔
126
  }
127

128
  public Payload getMemo(String key) {
129
    return startedAttributes.getMemo().getFieldsMap().get(key);
1✔
130
  }
131

132
  int getAttempt() {
133
    return startedAttributes.getAttempt();
1✔
134
  }
135

136
  public String getCronSchedule() {
137
    return startedAttributes.getCronSchedule();
1✔
138
  }
139

140
  @Nullable
141
  public Payloads getLastCompletionResult() {
142
    return lastCompletionResult;
1✔
143
  }
144

145
  @Nullable
146
  public Failure getPreviousRunFailure() {
147
    return previousRunFailure;
1✔
148
  }
149
}
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