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

temporalio / sdk-java / #180

pending completion
#180

push

github-actions

web-flow
Add support for SDK metadata to test server (#1800)

13 of 13 new or added lines in 2 files covered. (100.0%)

18358 of 23713 relevant lines covered (77.42%)

0.77 hits per line

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

57.69
/temporal-sdk/src/main/java/io/temporal/internal/activity/ActivityInfoImpl.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.activity;
22

23
import com.google.protobuf.util.Timestamps;
24
import io.temporal.api.common.v1.Header;
25
import io.temporal.api.common.v1.Payloads;
26
import io.temporal.api.workflowservice.v1.PollActivityTaskQueueResponseOrBuilder;
27
import io.temporal.internal.common.ProtobufTimeUtils;
28
import io.temporal.workflow.Functions;
29
import java.time.Duration;
30
import java.util.Base64;
31
import java.util.Objects;
32
import java.util.Optional;
33
import javax.annotation.Nonnull;
34

35
final class ActivityInfoImpl implements ActivityInfoInternal {
36
  private final String namespace;
37
  private final String activityTaskQueue;
38
  private final PollActivityTaskQueueResponseOrBuilder response;
39
  private final boolean local;
40
  private final Functions.Proc completionHandle;
41

42
  ActivityInfoImpl(
43
      PollActivityTaskQueueResponseOrBuilder response,
44
      @Nonnull String namespace,
45
      @Nonnull String activityTaskQueue,
46
      boolean local,
47
      Functions.Proc completionHandle) {
1✔
48
    this.response = Objects.requireNonNull(response);
1✔
49
    this.namespace = Objects.requireNonNull(namespace);
1✔
50
    this.activityTaskQueue = Objects.requireNonNull(activityTaskQueue);
1✔
51
    this.local = local;
1✔
52
    this.completionHandle = completionHandle;
1✔
53
  }
1✔
54

55
  @Override
56
  public byte[] getTaskToken() {
57
    return response.getTaskToken().toByteArray();
1✔
58
  }
59

60
  @Override
61
  public String getWorkflowId() {
62
    return response.getWorkflowExecution().getWorkflowId();
1✔
63
  }
64

65
  @Override
66
  public String getRunId() {
67
    return response.getWorkflowExecution().getRunId();
1✔
68
  }
69

70
  @Override
71
  public String getActivityId() {
72
    return response.getActivityId();
1✔
73
  }
74

75
  @Override
76
  public String getActivityType() {
77
    return response.getActivityType().getName();
1✔
78
  }
79

80
  @Override
81
  public long getScheduledTimestamp() {
82
    return Timestamps.toMillis(response.getScheduledTime());
×
83
  }
84

85
  @Override
86
  public long getStartedTimestamp() {
87
    return Timestamps.toMillis(response.getStartedTime());
×
88
  }
89

90
  @Override
91
  public long getCurrentAttemptScheduledTimestamp() {
92
    return Timestamps.toMillis(response.getCurrentAttemptScheduledTime());
×
93
  }
94

95
  @Override
96
  public Duration getScheduleToCloseTimeout() {
97
    return ProtobufTimeUtils.toJavaDuration(response.getScheduleToCloseTimeout());
1✔
98
  }
99

100
  @Override
101
  public Duration getStartToCloseTimeout() {
102
    return ProtobufTimeUtils.toJavaDuration(response.getStartToCloseTimeout());
1✔
103
  }
104

105
  @Nonnull
106
  @Override
107
  public Duration getHeartbeatTimeout() {
108
    return ProtobufTimeUtils.toJavaDuration(response.getHeartbeatTimeout());
1✔
109
  }
110

111
  @Override
112
  public Optional<Payloads> getHeartbeatDetails() {
113
    if (response.hasHeartbeatDetails()) {
1✔
114
      return Optional.of(response.getHeartbeatDetails());
1✔
115
    } else {
116
      return Optional.empty();
1✔
117
    }
118
  }
119

120
  @Override
121
  public String getWorkflowType() {
122
    return response.getWorkflowType().getName();
1✔
123
  }
124

125
  @Override
126
  @Deprecated
127
  public String getWorkflowNamespace() {
128
    return getNamespace();
×
129
  }
130

131
  @Override
132
  @Deprecated
133
  public String getActivityNamespace() {
134
    return getNamespace();
×
135
  }
136

137
  @Override
138
  public String getNamespace() {
139
    return namespace;
1✔
140
  }
141

142
  @Override
143
  public String getActivityTaskQueue() {
144
    return activityTaskQueue;
1✔
145
  }
146

147
  @Override
148
  public int getAttempt() {
149
    return response.getAttempt();
1✔
150
  }
151

152
  @Override
153
  public boolean isLocal() {
154
    return local;
1✔
155
  }
156

157
  @Override
158
  public Functions.Proc getCompletionHandle() {
159
    return completionHandle;
1✔
160
  }
161

162
  @Override
163
  public Optional<Payloads> getInput() {
164
    if (response.hasInput()) {
1✔
165
      return Optional.of(response.getInput());
1✔
166
    }
167
    return Optional.empty();
1✔
168
  }
169

170
  @Override
171
  public Optional<Header> getHeader() {
172
    if (response.hasHeader()) {
1✔
173
      return Optional.of(response.getHeader());
1✔
174
    }
175
    return Optional.empty();
1✔
176
  }
177

178
  @Override
179
  public String toString() {
180
    return "WorkflowInfo{"
×
181
        + ", workflowId="
182
        + getWorkflowId()
×
183
        + ", runId="
184
        + getRunId()
×
185
        + ", activityId="
186
        + getActivityId()
×
187
        + ", activityType="
188
        + getActivityType()
×
189
        + ", scheduledTimestamp="
190
        + getScheduledTimestamp()
×
191
        + ", startedTimestamp="
192
        + getStartedTimestamp()
×
193
        + ", currentAttemptScheduledTimestamp="
194
        + getCurrentAttemptScheduledTimestamp()
×
195
        + ", scheduleToCloseTimeout="
196
        + getScheduleToCloseTimeout()
×
197
        + ", startToCloseTimeout="
198
        + getStartToCloseTimeout()
×
199
        + ", heartbeatTimeout="
200
        + getHeartbeatTimeout()
×
201
        + ", heartbeatDetails="
202
        + getHeartbeatDetails()
×
203
        + ", workflowType="
204
        + getWorkflowType()
×
205
        + ", namespace="
206
        + getNamespace()
×
207
        + ", attempt="
208
        + getAttempt()
×
209
        + ", isLocal="
210
        + isLocal()
×
211
        + "taskToken="
212
        + Base64.getEncoder().encodeToString(getTaskToken())
×
213
        + '}';
214
  }
215
}
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