Skip to content

Commit ae470f8

Browse files
Fix deprecation warnings
1 parent 888cb82 commit ae470f8

18 files changed

+79
-61
lines changed

temporal-sdk/src/main/java/io/temporal/client/WorkflowClient.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,7 @@ static WorkflowClient newInstance(WorkflowServiceStubs service, WorkflowClientOp
147147
* @param workflowInterface interface that given workflow implements.
148148
* @param workflowId Workflow id.
149149
* @return Stub that implements workflowInterface and can be used to signal or query it.
150-
* @deprecated Use {@link #newWorkflowStub(Class, WorkflowTargetOptions)} instead.
151150
*/
152-
@Deprecated
153151
<T> T newWorkflowStub(Class<T> workflowInterface, String workflowId);
154152

155153
/**

temporal-sdk/src/main/java/io/temporal/client/WorkflowClientInternalImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ public <T> T newWorkflowStub(
155155
}
156156

157157
@Override
158+
@SuppressWarnings("deprecation")
158159
public <T> T newWorkflowStub(
159160
Class<T> workflowInterface, String workflowId, Optional<String> runId) {
160161
return newWorkflowStub(
@@ -219,6 +220,7 @@ public WorkflowStub newUntypedWorkflowStub(String workflowType, WorkflowOptions
219220
}
220221

221222
@Override
223+
@SuppressWarnings("deprecation")
222224
public WorkflowStub newUntypedWorkflowStub(
223225
String workflowId, Optional<String> runId, Optional<String> workflowType) {
224226
WorkflowExecution execution =
@@ -227,6 +229,7 @@ public WorkflowStub newUntypedWorkflowStub(
227229
}
228230

229231
@Override
232+
@SuppressWarnings("deprecation")
230233
public WorkflowStub newUntypedWorkflowStub(
231234
WorkflowExecution execution, Optional<String> workflowType) {
232235
return newUntypedWorkflowStub(

temporal-sdk/src/test/java/io/temporal/client/functional/StartTest.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import io.temporal.client.WorkflowClient;
1010
import io.temporal.client.WorkflowOptions;
1111
import io.temporal.client.WorkflowStub;
12+
import io.temporal.client.WorkflowTargetOptions;
1213
import io.temporal.common.WorkflowExecutionHistory;
1314
import io.temporal.internal.common.ProtobufTimeUtils;
1415
import io.temporal.testing.internal.SDKTestOptions;
@@ -200,7 +201,9 @@ private void assertResult(String expected, WorkflowExecution execution) {
200201
String result =
201202
testWorkflowRule
202203
.getWorkflowClient()
203-
.newUntypedWorkflowStub(execution, Optional.empty())
204+
.newUntypedWorkflowStub(
205+
Optional.empty(),
206+
WorkflowTargetOptions.newBuilder().setWorkflowExecution(execution).build())
204207
.getResult(String.class);
205208
assertEquals(expected, result);
206209
}
@@ -209,15 +212,19 @@ private void assertResult(int expected, WorkflowExecution execution) {
209212
int result =
210213
testWorkflowRule
211214
.getWorkflowClient()
212-
.newUntypedWorkflowStub(execution, Optional.empty())
215+
.newUntypedWorkflowStub(
216+
Optional.empty(),
217+
WorkflowTargetOptions.newBuilder().setWorkflowExecution(execution).build())
213218
.getResult(int.class);
214219
assertEquals(expected, result);
215220
}
216221

217222
private void waitForProc(WorkflowExecution execution) {
218223
testWorkflowRule
219224
.getWorkflowClient()
220-
.newUntypedWorkflowStub(execution, Optional.empty())
225+
.newUntypedWorkflowStub(
226+
Optional.empty(),
227+
WorkflowTargetOptions.newBuilder().setWorkflowExecution(execution).build())
221228
.getResult(Void.class);
222229
}
223230
}

temporal-sdk/src/test/java/io/temporal/client/functional/WorkflowIdConflictPolicyTest.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ public void policyTerminateExisting() {
5858
testWorkflowRule
5959
.getWorkflowClient()
6060
.newUntypedWorkflowStub(
61-
workflowExecution1,
62-
Optional.of(TestWorkflows.TestSignaledWorkflow.class.toString()))
61+
Optional.of(TestWorkflows.TestSignaledWorkflow.class.toString()),
62+
WorkflowTargetOptions.newBuilder()
63+
.setWorkflowExecution(workflowExecution1)
64+
.build())
6365
.getResult(String.class));
6466
}
6567

temporal-sdk/src/test/java/io/temporal/internal/worker/WorkflowSlotMaxConcurrentTests.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import io.temporal.client.WorkflowClient;
1111
import io.temporal.client.WorkflowOptions;
1212
import io.temporal.client.WorkflowStub;
13+
import io.temporal.client.WorkflowTargetOptions;
1314
import io.temporal.common.RetryOptions;
1415
import io.temporal.common.reporter.TestStatsReporter;
1516
import io.temporal.testing.internal.SDKTestWorkflowRule;
@@ -164,7 +165,10 @@ public void TestSlotsNotExceeded() {
164165

165166
// wait for all of them to finish
166167
for (WorkflowExecution execution : executions) {
167-
WorkflowStub workflowStub = client.newUntypedWorkflowStub(execution, Optional.empty());
168+
WorkflowStub workflowStub =
169+
client.newUntypedWorkflowStub(
170+
Optional.empty(),
171+
WorkflowTargetOptions.newBuilder().setWorkflowExecution(execution).build());
168172
workflowStub.getResult(String.class);
169173
}
170174
}

temporal-sdk/src/test/java/io/temporal/workflow/SyncTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import io.temporal.api.common.v1.WorkflowExecution;
77
import io.temporal.client.WorkflowFailedException;
88
import io.temporal.client.WorkflowStub;
9+
import io.temporal.client.WorkflowTargetOptions;
910
import io.temporal.failure.CanceledFailure;
1011
import io.temporal.failure.TerminatedFailure;
1112
import io.temporal.testing.internal.SDKTestOptions;
@@ -76,7 +77,9 @@ public void testSyncUntypedAndStackTrace() {
7677
workflowStub =
7778
testWorkflowRule
7879
.getWorkflowClient()
79-
.newUntypedWorkflowStub(execution, workflowStub.getWorkflowType());
80+
.newUntypedWorkflowStub(
81+
workflowStub.getWorkflowType(),
82+
WorkflowTargetOptions.newBuilder().setWorkflowExecution(execution).build());
8083
stackTrace = workflowStub.query(QUERY_TYPE_STACK_TRACE, String.class);
8184
assertTrue(stackTrace, stackTrace.contains("TestSyncWorkflowImpl.execute"));
8285
assertTrue(stackTrace, stackTrace.contains("activityWithDelay"));

temporal-sdk/src/test/java/io/temporal/workflow/signalTests/SignalDuringLastWorkflowTaskTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import io.temporal.api.common.v1.WorkflowExecution;
77
import io.temporal.client.WorkflowClient;
8+
import io.temporal.client.WorkflowTargetOptions;
89
import io.temporal.testing.internal.SDKTestWorkflowRule;
910
import io.temporal.worker.WorkerOptions;
1011
import io.temporal.workflow.shared.TestWorkflows.TestSignaledWorkflow;
@@ -56,7 +57,9 @@ public void testSignalDuringLastWorkflowTask() throws ExecutionException, Interr
5657
"Signal Input",
5758
testWorkflowRule
5859
.getWorkflowClient()
59-
.newUntypedWorkflowStub(execution, Optional.empty())
60+
.newUntypedWorkflowStub(
61+
Optional.empty(),
62+
WorkflowTargetOptions.newBuilder().setWorkflowExecution(execution).build())
6063
.getResult(String.class));
6164
assertCompleted.complete(true);
6265
});

temporal-sdk/src/test/java/io/temporal/workflow/signalTests/SignalTest.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ public void testSignal() {
5959
// Test client created using WorkflowExecution
6060
QueryableWorkflow client2 =
6161
workflowClient.newWorkflowStub(
62-
QueryableWorkflow.class, execution.getWorkflowId(), Optional.of(execution.getRunId()));
62+
QueryableWorkflow.class,
63+
WorkflowTargetOptions.newBuilder().setWorkflowExecution(execution).build());
6364
assertEquals("Hello ", client2.getState());
6465

6566
testWorkflowRule.sleep(Duration.ofMillis(500));
@@ -68,7 +69,11 @@ public void testSignal() {
6869
assertEquals("World!", client2.getState());
6970
assertEquals(
7071
"Hello World!",
71-
workflowClient.newUntypedWorkflowStub(execution, Optional.empty()).getResult(String.class));
72+
workflowClient
73+
.newUntypedWorkflowStub(
74+
Optional.empty(),
75+
WorkflowTargetOptions.newBuilder().setWorkflowExecution(execution).build())
76+
.getResult(String.class));
7277
client2.execute();
7378
}
7479

@@ -102,7 +107,11 @@ public void testSignalWithStart() {
102107
assertEquals("World!", client2.getState());
103108
assertEquals(
104109
"Hello World!",
105-
workflowClient.newUntypedWorkflowStub(execution, Optional.empty()).getResult(String.class));
110+
workflowClient
111+
.newUntypedWorkflowStub(
112+
Optional.empty(),
113+
WorkflowTargetOptions.newBuilder().setWorkflowExecution(execution).build())
114+
.getResult(String.class));
106115

107116
// Check if that it starts closed workflow (AllowDuplicate is default IdReusePolicy)
108117
QueryableWorkflow client3 = workflowClient.newWorkflowStub(QueryableWorkflow.class, options);
@@ -160,7 +169,9 @@ public void testSignalUntyped() {
160169
assertEquals(
161170
"Hello World!",
162171
workflowClient
163-
.newUntypedWorkflowStub(execution, Optional.of(workflowType))
172+
.newUntypedWorkflowStub(
173+
Optional.of(workflowType),
174+
WorkflowTargetOptions.newBuilder().setWorkflowExecution(execution).build())
164175
.getResult(String.class));
165176
assertEquals("Hello World!", workflowStub.getResult(String.class));
166177
assertEquals("World!", workflowStub.query("getState", String.class));
@@ -173,7 +184,9 @@ public void testSignalUntyped() {
173184
.setQueryRejectCondition(QueryRejectCondition.QUERY_REJECT_CONDITION_NOT_OPEN)
174185
.build());
175186
WorkflowStub workflowStubNotOptionRejectCondition =
176-
client.newUntypedWorkflowStub(execution, Optional.of(workflowType));
187+
client.newUntypedWorkflowStub(
188+
Optional.of(workflowType),
189+
WorkflowTargetOptions.newBuilder().setWorkflowExecution(execution).build());
177190
try {
178191
workflowStubNotOptionRejectCondition.query("getState", String.class);
179192
fail("unreachable");

temporal-sdk/src/test/java/io/temporal/workflow/updateTest/DynamicUpdateTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ public void dynamicUpdate() throws ExecutionException, InterruptedException {
5959
String result =
6060
testWorkflowRule
6161
.getWorkflowClient()
62-
.newUntypedWorkflowStub(execution, Optional.empty())
62+
.newUntypedWorkflowStub(
63+
Optional.empty(),
64+
WorkflowTargetOptions.newBuilder().setWorkflowExecution(execution).build())
6365
.getResult(String.class);
6466
assertEquals(" update complete", result);
6567
}

temporal-sdk/src/test/java/io/temporal/workflow/updateTest/SpeculativeUpdateTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ public void speculativeUpdateRejected() {
6060
String result =
6161
testWorkflowRule
6262
.getWorkflowClient()
63-
.newUntypedWorkflowStub(execution, Optional.empty())
63+
.newUntypedWorkflowStub(
64+
Optional.empty(),
65+
WorkflowTargetOptions.newBuilder().setWorkflowExecution(execution).build())
6466
.getResult(String.class);
6567
assertEquals("", result);
6668
}

0 commit comments

Comments
 (0)