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

temporalio / sdk-java / #157

pending completion
#157

push

github-actions

web-flow
Provide SerializationContext for PayloadConverter and PayloadCodec (#1695)

Issue #1694

497 of 497 new or added lines in 32 files covered. (100.0%)

16942 of 20806 relevant lines covered (81.43%)

0.81 hits per line

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

60.0
/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) {
48
    this.response = Objects.requireNonNull(response);
49
    this.namespace = Objects.requireNonNull(namespace);
50
    this.activityTaskQueue = Objects.requireNonNull(activityTaskQueue);
51
    this.local = local;
52
    this.completionHandle = completionHandle;
53
  }
54

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

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

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

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

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

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

85
  @Override
86
  public long getCurrentAttemptScheduledTimestamp() {
87
    return Timestamps.toMillis(response.getCurrentAttemptScheduledTime());
88
  }
89

90
  @Override
91
  public Duration getScheduleToCloseTimeout() {
92
    return ProtobufTimeUtils.toJavaDuration(response.getScheduleToCloseTimeout());
93
  }
94

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

100
  @Nonnull
101
  @Override
102
  public Duration getHeartbeatTimeout() {
103
    return ProtobufTimeUtils.toJavaDuration(response.getHeartbeatTimeout());
104
  }
105

106
  @Override
107
  public Optional<Payloads> getHeartbeatDetails() {
108
    if (response.hasHeartbeatDetails()) {
109
      return Optional.of(response.getHeartbeatDetails());
110
    } else {
111
      return Optional.empty();
112
    }
113
  }
114

115
  @Override
116
  public String getWorkflowType() {
117
    return response.getWorkflowType().getName();
118
  }
119

120
  @Override
121
  @Deprecated
122
  public String getWorkflowNamespace() {
123
    return getNamespace();
124
  }
125

126
  @Override
127
  @Deprecated
128
  public String getActivityNamespace() {
129
    return getNamespace();
130
  }
131

132
  @Override
133
  public String getNamespace() {
134
    return namespace;
135
  }
136

137
  @Override
138
  public String getActivityTaskQueue() {
139
    return activityTaskQueue;
140
  }
141

142
  @Override
143
  public int getAttempt() {
144
    return response.getAttempt();
145
  }
146

147
  @Override
148
  public boolean isLocal() {
149
    return local;
150
  }
151

152
  @Override
153
  public Functions.Proc getCompletionHandle() {
154
    return completionHandle;
155
  }
156

157
  @Override
158
  public Optional<Payloads> getInput() {
159
    if (response.hasInput()) {
160
      return Optional.of(response.getInput());
161
    }
162
    return Optional.empty();
163
  }
164

165
  @Override
166
  public Optional<Header> getHeader() {
167
    if (response.hasHeader()) {
168
      return Optional.of(response.getHeader());
169
    }
170
    return Optional.empty();
171
  }
172

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