Skip to content

Commit 8a2b3ab

Browse files
committed
fix: revert test changes for operation id
1 parent 75a6da4 commit 8a2b3ab

5 files changed

Lines changed: 43 additions & 49 deletions

File tree

sdk/src/test/java/com/amazonaws/lambda/durable/operation/BaseDurableOperationTest.java

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import static org.junit.jupiter.api.Assertions.assertNull;
88
import static org.junit.jupiter.api.Assertions.assertThrows;
99
import static org.mockito.ArgumentMatchers.any;
10-
import static org.mockito.ArgumentMatchers.eq;
1110
import static org.mockito.Mockito.mock;
1211
import static org.mockito.Mockito.never;
1312
import static org.mockito.Mockito.times;
@@ -45,8 +44,7 @@ class BaseDurableOperationTest {
4544
void getOperation() {
4645
ExecutionManager executionManager = mock(ExecutionManager.class);
4746
Operation operation = mock(Operation.class);
48-
when(executionManager.getOperationAndUpdateReplayState(eq(OPERATION_ID)))
49-
.thenReturn(operation);
47+
when(executionManager.getOperationAndUpdateReplayState(OPERATION_ID)).thenReturn(operation);
5048

5149
BaseDurableOperation<String> op =
5250
new BaseDurableOperation<>(
@@ -72,8 +70,8 @@ void waitForOperationCompletionThrowsIfInStep() {
7270
Phaser phaser = new Phaser();
7371
ExecutionManager executionManager = mock(ExecutionManager.class);
7472
when(executionManager.getCurrentContext()).thenReturn(new OperationContext("context", ThreadType.STEP));
75-
when(executionManager.startPhaser(eq(OPERATION_ID))).thenReturn(phaser);
76-
when(executionManager.getOperationAndUpdateReplayState(eq(OPERATION_ID)))
73+
when(executionManager.startPhaser(OPERATION_ID)).thenReturn(phaser);
74+
when(executionManager.getOperationAndUpdateReplayState(OPERATION_ID))
7775
.thenReturn(Operation.builder().build());
7876

7977
BaseDurableOperation<String> op =
@@ -99,7 +97,7 @@ void waitForOperationCompletionThrowsIfOperationMissing() {
9997
Phaser phaser = new Phaser();
10098
ExecutionManager executionManager = mock(ExecutionManager.class);
10199
when(executionManager.getCurrentContext()).thenReturn(new OperationContext("context", ThreadType.CONTEXT));
102-
when(executionManager.startPhaser(eq(OPERATION_ID))).thenReturn(phaser);
100+
when(executionManager.startPhaser(OPERATION_ID)).thenReturn(phaser);
103101

104102
BaseDurableOperation<String> op =
105103
new BaseDurableOperation<>(
@@ -124,8 +122,8 @@ void waitForOperationCompletionWhenRunningAndReadyToComplete() {
124122
OperationContext context = new OperationContext("step", ThreadType.CONTEXT);
125123
ExecutionManager executionManager = mock(ExecutionManager.class);
126124
when(executionManager.getCurrentContext()).thenReturn(context);
127-
when(executionManager.startPhaser(eq(OPERATION_ID))).thenReturn(phaser);
128-
when(executionManager.getOperationAndUpdateReplayState(eq(OPERATION_ID)))
125+
when(executionManager.startPhaser(OPERATION_ID)).thenReturn(phaser);
126+
when(executionManager.getOperationAndUpdateReplayState(OPERATION_ID))
129127
.thenReturn(Operation.builder().build());
130128

131129
BaseDurableOperation<String> op =
@@ -155,8 +153,8 @@ void waitForOperationCompletionWhenAlreadyCompleted() {
155153
OperationContext context = new OperationContext("step", ThreadType.CONTEXT);
156154
ExecutionManager executionManager = mock(ExecutionManager.class);
157155
when(executionManager.getCurrentContext()).thenReturn(context);
158-
when(executionManager.startPhaser(eq(OPERATION_ID))).thenReturn(phaser);
159-
when(executionManager.getOperationAndUpdateReplayState(eq(OPERATION_ID)))
156+
when(executionManager.startPhaser(OPERATION_ID)).thenReturn(phaser);
157+
when(executionManager.getOperationAndUpdateReplayState(OPERATION_ID))
160158
.thenReturn(Operation.builder().build());
161159

162160
BaseDurableOperation<String> op =
@@ -185,8 +183,8 @@ void markAlreadyCompleted() {
185183
OperationContext context = new OperationContext("step", ThreadType.STEP);
186184
ExecutionManager executionManager = mock(ExecutionManager.class);
187185
when(executionManager.getCurrentContext()).thenReturn(context);
188-
when(executionManager.startPhaser(eq(OPERATION_ID))).thenReturn(phaser);
189-
when(executionManager.getOperationAndUpdateReplayState(eq(OPERATION_ID)))
186+
when(executionManager.startPhaser(OPERATION_ID)).thenReturn(phaser);
187+
when(executionManager.getOperationAndUpdateReplayState(OPERATION_ID))
190188
.thenReturn(Operation.builder().build());
191189

192190
BaseDurableOperation<String> op =
@@ -214,8 +212,8 @@ void validateReplayThrowsWhenTypeMismatch() {
214212
OperationContext context = new OperationContext("step", ThreadType.STEP);
215213
ExecutionManager executionManager = mock(ExecutionManager.class);
216214
when(executionManager.getCurrentContext()).thenReturn(context);
217-
when(executionManager.startPhaser(eq(OPERATION_ID))).thenReturn(phaser);
218-
when(executionManager.getOperationAndUpdateReplayState(eq(OPERATION_ID)))
215+
when(executionManager.startPhaser(OPERATION_ID)).thenReturn(phaser);
216+
when(executionManager.getOperationAndUpdateReplayState(OPERATION_ID))
219217
.thenReturn(
220218
Operation.builder().type(OperationType.CHAINED_INVOKE).build());
221219

@@ -241,8 +239,8 @@ void validateReplayThrowsWhenNameMismatch() {
241239
OperationContext context = new OperationContext("step", ThreadType.STEP);
242240
ExecutionManager executionManager = mock(ExecutionManager.class);
243241
when(executionManager.getCurrentContext()).thenReturn(context);
244-
when(executionManager.startPhaser(eq(OPERATION_ID))).thenReturn(phaser);
245-
when(executionManager.getOperationAndUpdateReplayState(eq(OPERATION_ID)))
242+
when(executionManager.startPhaser(OPERATION_ID)).thenReturn(phaser);
243+
when(executionManager.getOperationAndUpdateReplayState(OPERATION_ID))
246244
.thenReturn(Operation.builder()
247245
.name("another name")
248246
.type(OPERATION_TYPE)
@@ -270,9 +268,8 @@ void validateReplayDoesNotThrowWhenNoOperation() {
270268
OperationContext context = new OperationContext("step", ThreadType.STEP);
271269
ExecutionManager executionManager = mock(ExecutionManager.class);
272270
when(executionManager.getCurrentContext()).thenReturn(context);
273-
when(executionManager.startPhaser(eq(OPERATION_ID))).thenReturn(phaser);
274-
when(executionManager.getOperationAndUpdateReplayState(eq(OPERATION_ID)))
275-
.thenReturn(null);
271+
when(executionManager.startPhaser(OPERATION_ID)).thenReturn(phaser);
272+
when(executionManager.getOperationAndUpdateReplayState(OPERATION_ID)).thenReturn(null);
276273

277274
BaseDurableOperation<String> op =
278275
new BaseDurableOperation<>(
@@ -294,8 +291,8 @@ void validateReplayDoesNotThrowWhenNameAndTypeMatch() {
294291
OperationContext context = new OperationContext("step", ThreadType.STEP);
295292
ExecutionManager executionManager = mock(ExecutionManager.class);
296293
when(executionManager.getCurrentContext()).thenReturn(context);
297-
when(executionManager.startPhaser(eq(OPERATION_ID))).thenReturn(phaser);
298-
when(executionManager.getOperationAndUpdateReplayState(eq(OPERATION_ID)))
294+
when(executionManager.startPhaser(OPERATION_ID)).thenReturn(phaser);
295+
when(executionManager.getOperationAndUpdateReplayState(OPERATION_ID))
299296
.thenReturn(Operation.builder()
300297
.name(OPERATION_NAME)
301298
.type(OPERATION_TYPE)
@@ -321,8 +318,8 @@ void deserializeResult() {
321318
OperationContext context = new OperationContext("step", ThreadType.STEP);
322319
ExecutionManager executionManager = mock(ExecutionManager.class);
323320
when(executionManager.getCurrentContext()).thenReturn(context);
324-
when(executionManager.startPhaser(eq(OPERATION_ID))).thenReturn(phaser);
325-
when(executionManager.getOperationAndUpdateReplayState(eq(OPERATION_ID)))
321+
when(executionManager.startPhaser(OPERATION_ID)).thenReturn(phaser);
322+
when(executionManager.getOperationAndUpdateReplayState(OPERATION_ID))
326323
.thenReturn(Operation.builder()
327324
.name(OPERATION_NAME)
328325
.type(OPERATION_TYPE)
@@ -351,8 +348,8 @@ void deserializeException() {
351348
OperationContext context = new OperationContext("step", ThreadType.STEP);
352349
ExecutionManager executionManager = mock(ExecutionManager.class);
353350
when(executionManager.getCurrentContext()).thenReturn(context);
354-
when(executionManager.startPhaser(eq(OPERATION_ID))).thenReturn(phaser);
355-
when(executionManager.getOperationAndUpdateReplayState(eq(OPERATION_ID)))
351+
when(executionManager.startPhaser(OPERATION_ID)).thenReturn(phaser);
352+
when(executionManager.getOperationAndUpdateReplayState(OPERATION_ID))
356353
.thenReturn(Operation.builder()
357354
.name(OPERATION_NAME)
358355
.type(OPERATION_TYPE)
@@ -386,8 +383,8 @@ void polling() {
386383
OperationContext context = new OperationContext("step", ThreadType.STEP);
387384
ExecutionManager executionManager = mock(ExecutionManager.class);
388385
when(executionManager.getCurrentContext()).thenReturn(context);
389-
when(executionManager.startPhaser(eq(OPERATION_ID))).thenReturn(phaser);
390-
when(executionManager.getOperationAndUpdateReplayState(eq(OPERATION_ID)))
386+
when(executionManager.startPhaser(OPERATION_ID)).thenReturn(phaser);
387+
when(executionManager.getOperationAndUpdateReplayState(OPERATION_ID))
391388
.thenReturn(Operation.builder()
392389
.name(OPERATION_NAME)
393390
.type(OPERATION_TYPE)
@@ -420,8 +417,8 @@ void sendOperationUpdate() {
420417
OperationContext context = new OperationContext("step", ThreadType.STEP);
421418
ExecutionManager executionManager = mock(ExecutionManager.class);
422419
when(executionManager.getCurrentContext()).thenReturn(context);
423-
when(executionManager.startPhaser(eq(OPERATION_ID))).thenReturn(phaser);
424-
when(executionManager.getOperationAndUpdateReplayState(eq(OPERATION_ID)))
420+
when(executionManager.startPhaser(OPERATION_ID)).thenReturn(phaser);
421+
when(executionManager.getOperationAndUpdateReplayState(OPERATION_ID))
425422
.thenReturn(Operation.builder()
426423
.name(OPERATION_NAME)
427424
.type(OPERATION_TYPE)

sdk/src/test/java/com/amazonaws/lambda/durable/operation/ChildContextOperationTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ private ChildContextOperation<String> createOperation(
6565
@Test
6666
void replaySucceededReturnsCachedResult() {
6767
var executionManager = createMockExecutionManager();
68-
when(executionManager.getOperationAndUpdateReplayState(eq("1")))
68+
when(executionManager.getOperationAndUpdateReplayState("1"))
6969
.thenReturn(Operation.builder()
7070
.id("1")
7171
.name("test-context")
@@ -98,7 +98,7 @@ void replayFailedThrowsOriginalException() {
9898
var originalException = new IllegalArgumentException("bad input");
9999
var stackTrace = List.of("com.example.Test|method|Test.java|42");
100100

101-
when(executionManager.getOperationAndUpdateReplayState(eq("1")))
101+
when(executionManager.getOperationAndUpdateReplayState("1"))
102102
.thenReturn(Operation.builder()
103103
.id("1")
104104
.name("test-context")
@@ -132,7 +132,7 @@ void replayFailedThrowsOriginalException() {
132132
void replayFailedFallsBackToChildContextFailedException() {
133133
var executionManager = createMockExecutionManager();
134134

135-
when(executionManager.getOperationAndUpdateReplayState(eq("1")))
135+
when(executionManager.getOperationAndUpdateReplayState("1"))
136136
.thenReturn(Operation.builder()
137137
.id("1")
138138
.name("test-context")
@@ -161,7 +161,7 @@ void replayFailedFallsBackToChildContextFailedException() {
161161
@Test
162162
void replayStartedReExecutesChildContext() throws Exception {
163163
var executionManager = createMockExecutionManager();
164-
when(executionManager.getOperationAndUpdateReplayState(eq("1")))
164+
when(executionManager.getOperationAndUpdateReplayState("1"))
165165
.thenReturn(Operation.builder()
166166
.id("1")
167167
.name("test-context")
@@ -190,7 +190,7 @@ void replayStartedReExecutesChildContext() throws Exception {
190190
@Test
191191
void replayChildrenReExecutesToReconstructResult() throws Exception {
192192
var executionManager = createMockExecutionManager();
193-
when(executionManager.getOperationAndUpdateReplayState(eq("1")))
193+
when(executionManager.getOperationAndUpdateReplayState("1"))
194194
.thenReturn(Operation.builder()
195195
.id("1")
196196
.name("test-context")
@@ -220,7 +220,7 @@ void replayChildrenReExecutesToReconstructResult() throws Exception {
220220
@Test
221221
void replayWithTypeMismatchTerminatesExecution() {
222222
var executionManager = createMockExecutionManager();
223-
when(executionManager.getOperationAndUpdateReplayState(eq("1")))
223+
when(executionManager.getOperationAndUpdateReplayState("1"))
224224
.thenReturn(Operation.builder()
225225
.id("1")
226226
.name("test-context")
@@ -237,7 +237,7 @@ void replayWithTypeMismatchTerminatesExecution() {
237237
@Test
238238
void replayWithNameMismatchTerminatesExecution() {
239239
var executionManager = createMockExecutionManager();
240-
when(executionManager.getOperationAndUpdateReplayState(eq("1")))
240+
when(executionManager.getOperationAndUpdateReplayState("1"))
241241
.thenReturn(Operation.builder()
242242
.id("1")
243243
.name("different-name") // Wrong name

sdk/src/test/java/com/amazonaws/lambda/durable/operation/InvokeOperationTest.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
import static org.junit.jupiter.api.Assertions.assertEquals;
66
import static org.junit.jupiter.api.Assertions.assertThrows;
77
import static org.junit.jupiter.api.Assertions.assertTrue;
8-
import static org.mockito.ArgumentMatchers.any;
9-
import static org.mockito.ArgumentMatchers.eq;
8+
import static org.mockito.Mockito.any;
109
import static org.mockito.Mockito.mock;
1110
import static org.mockito.Mockito.when;
1211

@@ -56,7 +55,7 @@ void getDoesNotThrowWhenCalledFromHandlerContext() {
5655
phaser.arriveAndDeregister(); // Advance to phase 1 to skip blocking
5756
when(executionManager.startPhaser(any())).thenReturn(phaser);
5857
when(executionManager.getCurrentContext()).thenReturn(new OperationContext("handler", ThreadType.CONTEXT));
59-
when(executionManager.getOperationAndUpdateReplayState(eq("1")))
58+
when(executionManager.getOperationAndUpdateReplayState("1"))
6059
.thenReturn(software.amazon.awssdk.services.lambda.model.Operation.builder()
6160
.id("1")
6261
.name("test-invoke")
@@ -87,7 +86,7 @@ void getInvokeFailedExceptionWhenInvocationFailed() {
8786
phaser.arriveAndDeregister(); // Advance to phase 1 to skip blocking
8887
when(executionManager.startPhaser(any())).thenReturn(phaser);
8988
when(executionManager.getCurrentContext()).thenReturn(new OperationContext("handler", ThreadType.CONTEXT));
90-
when(executionManager.getOperationAndUpdateReplayState(eq("1")))
89+
when(executionManager.getOperationAndUpdateReplayState("1"))
9190
.thenReturn(software.amazon.awssdk.services.lambda.model.Operation.builder()
9291
.id("1")
9392
.name("test-invoke")
@@ -124,7 +123,7 @@ void getInvokeTimedOutExceptionWhenInvocationTimedOut() {
124123
phaser.arriveAndDeregister(); // Advance to phase 1 to skip blocking
125124
when(executionManager.startPhaser(any())).thenReturn(phaser);
126125
when(executionManager.getCurrentContext()).thenReturn(new OperationContext("handler", ThreadType.CONTEXT));
127-
when(executionManager.getOperationAndUpdateReplayState(eq("1")))
126+
when(executionManager.getOperationAndUpdateReplayState("1"))
128127
.thenReturn(software.amazon.awssdk.services.lambda.model.Operation.builder()
129128
.id("1")
130129
.name("test-invoke")
@@ -161,7 +160,7 @@ void getInvokeStoppedExceptionWhenInvocationTimedOut() {
161160
phaser.arriveAndDeregister(); // Advance to phase 1 to skip blocking
162161
when(executionManager.startPhaser(any())).thenReturn(phaser);
163162
when(executionManager.getCurrentContext()).thenReturn(new OperationContext("handler", ThreadType.CONTEXT));
164-
when(executionManager.getOperationAndUpdateReplayState(eq("1")))
163+
when(executionManager.getOperationAndUpdateReplayState("1"))
165164
.thenReturn(software.amazon.awssdk.services.lambda.model.Operation.builder()
166165
.id("1")
167166
.name("test-invoke")
@@ -198,7 +197,7 @@ void getInvokeFailedExceptionWhenInvocationEndedUnexpectedly() {
198197
phaser.arriveAndDeregister(); // Advance to phase 1 to skip blocking
199198
when(executionManager.startPhaser(any())).thenReturn(phaser);
200199
when(executionManager.getCurrentContext()).thenReturn(new OperationContext("handler", ThreadType.CONTEXT));
201-
when(executionManager.getOperationAndUpdateReplayState(eq("1")))
200+
when(executionManager.getOperationAndUpdateReplayState("1"))
202201
.thenReturn(software.amazon.awssdk.services.lambda.model.Operation.builder()
203202
.id("1")
204203
.name("test-invoke")

sdk/src/test/java/com/amazonaws/lambda/durable/operation/StepOperationTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
package com.amazonaws.lambda.durable.operation;
44

55
import static org.junit.jupiter.api.Assertions.*;
6-
import static org.mockito.ArgumentMatchers.*;
76
import static org.mockito.Mockito.*;
87

98
import com.amazonaws.lambda.durable.DurableConfig;
@@ -57,7 +56,7 @@ private void mockFailedOperation(
5756
.build())
5857
.build();
5958

60-
when(executionManager.getOperationAndUpdateReplayState(eq("1"))).thenReturn(operation);
59+
when(executionManager.getOperationAndUpdateReplayState("1")).thenReturn(operation);
6160
}
6261

6362
@Test
@@ -91,7 +90,7 @@ void getDoesNotThrowWhenCalledFromHandlerContext() {
9190
phaser.arriveAndDeregister();
9291
when(executionManager.startPhaser(any())).thenReturn(phaser);
9392
when(executionManager.getCurrentContext()).thenReturn(new OperationContext("handler", ThreadType.CONTEXT));
94-
when(executionManager.getOperationAndUpdateReplayState(eq("1")))
93+
when(executionManager.getOperationAndUpdateReplayState("1"))
9594
.thenReturn(Operation.builder()
9695
.id("1")
9796
.name("test-step")

sdk/src/test/java/com/amazonaws/lambda/durable/operation/WaitOperationTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import static org.junit.jupiter.api.Assertions.assertNull;
77
import static org.junit.jupiter.api.Assertions.assertThrows;
88
import static org.mockito.ArgumentMatchers.any;
9-
import static org.mockito.ArgumentMatchers.eq;
109
import static org.mockito.Mockito.mock;
1110
import static org.mockito.Mockito.when;
1211

@@ -43,7 +42,7 @@ void getDoesNotThrowWhenCalledFromHandlerContext() {
4342
phaser.arriveAndDeregister(); // Advance to phase 1 to skip blocking
4443
when(executionManager.startPhaser(any())).thenReturn(phaser);
4544
when(executionManager.getCurrentContext()).thenReturn(new OperationContext("handler", ThreadType.CONTEXT));
46-
when(executionManager.getOperationAndUpdateReplayState(eq("1")))
45+
when(executionManager.getOperationAndUpdateReplayState("1"))
4746
.thenReturn(software.amazon.awssdk.services.lambda.model.Operation.builder()
4847
.id("1")
4948
.name("test-invoke")
@@ -63,7 +62,7 @@ void getSucceededWhenStarted() {
6362
var phaser = new Phaser(0);
6463
when(executionManager.startPhaser(any())).thenReturn(phaser);
6564
when(executionManager.getCurrentContext()).thenReturn(new OperationContext("handler", ThreadType.CONTEXT));
66-
when(executionManager.getOperationAndUpdateReplayState(eq("1")))
65+
when(executionManager.getOperationAndUpdateReplayState("1"))
6766
.thenReturn(software.amazon.awssdk.services.lambda.model.Operation.builder()
6867
.id("1")
6968
.name("test-invoke")

0 commit comments

Comments
 (0)