44import org .junit .jupiter .api .Test ;
55
66import io .javaoperatorsdk .operator .AggregatedOperatorException ;
7+ import io .javaoperatorsdk .operator .api .reconciler .Context ;
78import io .javaoperatorsdk .operator .processing .dependent .workflow .builder .WorkflowBuilder ;
89import io .javaoperatorsdk .operator .sample .simple .TestCustomResource ;
910
1011import static io .javaoperatorsdk .operator .processing .dependent .workflow .ExecutionAssert .assertThat ;
1112import static org .junit .jupiter .api .Assertions .assertThrows ;
13+ import static org .mockito .Mockito .mock ;
1214
1315@ SuppressWarnings ("rawtypes" )
1416class WorkflowReconcileExecutorTest extends AbstractWorkflowExecutorTest {
@@ -21,14 +23,16 @@ class WorkflowReconcileExecutorTest extends AbstractWorkflowExecutorTest {
2123 private final Condition <String , TestCustomResource > notMetReadyCondition =
2224 (primary , secondary , context ) -> false ;
2325
26+ Context <TestCustomResource > mockContext = mock (Context .class );
27+
2428 @ Test
2529 void reconcileTopLevelResources () {
2630 var workflow = new WorkflowBuilder <TestCustomResource >()
2731 .addDependentResource (dr1 )
2832 .addDependentResource (dr2 )
2933 .build ();
3034
31- var res = workflow .reconcile (new TestCustomResource (), null );
35+ var res = workflow .reconcile (new TestCustomResource (), mockContext );
3236
3337 assertThat (executionHistory ).reconciled (dr1 , dr2 );
3438 Assertions .assertThat (res .getErroredDependents ()).isEmpty ();
@@ -42,7 +46,7 @@ void reconciliationWithSimpleDependsOn() {
4246 .addDependentResource (dr2 ).dependsOn (dr1 )
4347 .build ();
4448
45- var res = workflow .reconcile (new TestCustomResource (), null );
49+ var res = workflow .reconcile (new TestCustomResource (), mockContext );
4650
4751 Assertions .assertThat (res .getErroredDependents ()).isEmpty ();
4852 assertThat (executionHistory ).reconciledInOrder (dr1 , dr2 );
@@ -61,7 +65,7 @@ void reconciliationWithTwoTheDependsOns() {
6165 .addDependentResource (dr3 ).dependsOn (dr1 )
6266 .build ();
6367
64- var res = workflow .reconcile (new TestCustomResource (), null );
68+ var res = workflow .reconcile (new TestCustomResource (), mockContext );
6569
6670 Assertions .assertThat (res .getErroredDependents ()).isEmpty ();
6771 assertThat (executionHistory )
@@ -83,7 +87,7 @@ void diamondShareWorkflowReconcile() {
8387 .addDependentResource (dr4 ).dependsOn (dr3 ).dependsOn (dr2 )
8488 .build ();
8589
86- var res = workflow .reconcile (new TestCustomResource (), null );
90+ var res = workflow .reconcile (new TestCustomResource (), mockContext );
8791
8892 Assertions .assertThat (res .getErroredDependents ()).isEmpty ();
8993 assertThat (executionHistory )
@@ -103,7 +107,7 @@ void exceptionHandlingSimpleCases() {
103107 .withThrowExceptionFurther (false )
104108 .build ();
105109
106- var res = workflow .reconcile (new TestCustomResource (), null );
110+ var res = workflow .reconcile (new TestCustomResource (), mockContext );
107111
108112 assertThrows (AggregatedOperatorException .class ,
109113 res ::throwAggregateExceptionIfErrorsPresent );
@@ -123,7 +127,7 @@ void dependentsOnErroredResourceNotReconciled() {
123127 .withThrowExceptionFurther (false )
124128 .build ();
125129
126- var res = workflow .reconcile (new TestCustomResource (), null );
130+ var res = workflow .reconcile (new TestCustomResource (), mockContext );
127131 assertThrows (AggregatedOperatorException .class ,
128132 res ::throwAggregateExceptionIfErrorsPresent );
129133
@@ -145,7 +149,7 @@ void oneBranchErrorsOtherCompletes() {
145149 .withThrowExceptionFurther (false )
146150 .build ();
147151
148- var res = workflow .reconcile (new TestCustomResource (), null );
152+ var res = workflow .reconcile (new TestCustomResource (), mockContext );
149153 assertThrows (AggregatedOperatorException .class ,
150154 res ::throwAggregateExceptionIfErrorsPresent );
151155
@@ -164,7 +168,7 @@ void onlyOneDependsOnErroredResourceNotReconciled() {
164168 .withThrowExceptionFurther (false )
165169 .build ();
166170
167- var res = workflow .reconcile (new TestCustomResource (), null );
171+ var res = workflow .reconcile (new TestCustomResource (), mockContext );
168172 assertThrows (AggregatedOperatorException .class ,
169173 res ::throwAggregateExceptionIfErrorsPresent );
170174
@@ -182,7 +186,7 @@ void simpleReconcileCondition() {
182186 .addDependentResource (drDeleter ).withReconcilePrecondition (not_met_reconcile_condition )
183187 .build ();
184188
185- var res = workflow .reconcile (new TestCustomResource (), null );
189+ var res = workflow .reconcile (new TestCustomResource (), mockContext );
186190
187191 assertThat (executionHistory ).notReconciled (dr1 ).reconciled (dr2 ).deleted (drDeleter );
188192 Assertions .assertThat (res .getErroredDependents ()).isEmpty ();
@@ -200,7 +204,7 @@ void triangleOnceConditionNotMet() {
200204 .dependsOn (dr1 )
201205 .build ();
202206
203- var res = workflow .reconcile (new TestCustomResource (), null );
207+ var res = workflow .reconcile (new TestCustomResource (), mockContext );
204208
205209 assertThat (executionHistory ).reconciledInOrder (dr1 , dr2 ).deleted (drDeleter );
206210 Assertions .assertThat (res .getErroredDependents ()).isEmpty ();
@@ -222,7 +226,7 @@ void reconcileConditionTransitiveDelete() {
222226 .withReconcilePrecondition (met_reconcile_condition )
223227 .build ();
224228
225- var res = workflow .reconcile (new TestCustomResource (), null );
229+ var res = workflow .reconcile (new TestCustomResource (), mockContext );
226230
227231 Assertions .assertThat (res .getErroredDependents ()).isEmpty ();
228232 assertThat (executionHistory ).notReconciled (dr2 );
@@ -246,7 +250,7 @@ void reconcileConditionAlsoErrorDependsOn() {
246250 .withThrowExceptionFurther (false )
247251 .build ();
248252
249- var res = workflow .reconcile (new TestCustomResource (), null );
253+ var res = workflow .reconcile (new TestCustomResource (), mockContext );
250254 assertThrows (AggregatedOperatorException .class ,
251255 res ::throwAggregateExceptionIfErrorsPresent );
252256
@@ -267,7 +271,7 @@ void oneDependsOnConditionNotMet() {
267271 .addDependentResource (drDeleter ).dependsOn (dr1 , dr2 )
268272 .build ();
269273
270- var res = workflow .reconcile (new TestCustomResource (), null );
274+ var res = workflow .reconcile (new TestCustomResource (), mockContext );
271275
272276 Assertions .assertThat (res .getErroredDependents ()).isEmpty ();
273277
@@ -287,7 +291,7 @@ void deletedIfReconcileConditionNotMet() {
287291 .addDependentResource (drDeleter2 ).dependsOn (dr1 , drDeleter )
288292 .build ();
289293
290- var res = workflow .reconcile (new TestCustomResource (), null );
294+ var res = workflow .reconcile (new TestCustomResource (), mockContext );
291295
292296 assertThat (executionHistory )
293297 .reconciledInOrder (dr1 , drDeleter2 , drDeleter )
@@ -313,7 +317,7 @@ void deleteDoneInReverseOrder() {
313317 .addDependentResource (drDeleter4 ).dependsOn (drDeleter3 )
314318 .build ();
315319
316- var res = workflow .reconcile (new TestCustomResource (), null );
320+ var res = workflow .reconcile (new TestCustomResource (), mockContext );
317321
318322 assertThat (executionHistory )
319323 .reconciledInOrder (dr1 , drDeleter4 , drDeleter3 , drDeleter )
@@ -339,7 +343,7 @@ void diamondDeleteWithPostConditionInMiddle() {
339343 .addDependentResource (drDeleter4 ).dependsOn (drDeleter3 , drDeleter2 )
340344 .build ();
341345
342- var res = workflow .reconcile (new TestCustomResource (), null );
346+ var res = workflow .reconcile (new TestCustomResource (), mockContext );
343347
344348 assertThat (executionHistory ).notReconciled (drDeleter )
345349 .reconciledInOrder (drDeleter4 , drDeleter2 )
@@ -363,7 +367,7 @@ void diamondDeleteErrorInMiddle() {
363367 .withThrowExceptionFurther (false )
364368 .build ();
365369
366- var res = workflow .reconcile (new TestCustomResource (), null );
370+ var res = workflow .reconcile (new TestCustomResource (), mockContext );
367371
368372 assertThat (executionHistory )
369373 .notReconciled (drDeleter , drError )
@@ -381,7 +385,7 @@ void readyConditionTrivialCase() {
381385 .addDependentResource (dr2 ).dependsOn (dr1 )
382386 .build ();
383387
384- var res = workflow .reconcile (new TestCustomResource (), null );
388+ var res = workflow .reconcile (new TestCustomResource (), mockContext );
385389
386390 assertThat (executionHistory ).reconciledInOrder (dr1 , dr2 );
387391
@@ -397,7 +401,7 @@ void readyConditionNotMetTrivialCase() {
397401 .addDependentResource (dr2 ).dependsOn (dr1 )
398402 .build ();
399403
400- var res = workflow .reconcile (new TestCustomResource (), null );
404+ var res = workflow .reconcile (new TestCustomResource (), mockContext );
401405
402406
403407 assertThat (executionHistory ).reconciled (dr1 ).notReconciled (dr2 );
@@ -417,7 +421,7 @@ void readyConditionNotMetInOneParent() {
417421 .addDependentResource (dr3 ).dependsOn (dr1 , dr2 )
418422 .build ();
419423
420- var res = workflow .reconcile (new TestCustomResource (), null );
424+ var res = workflow .reconcile (new TestCustomResource (), mockContext );
421425
422426 assertThat (executionHistory ).reconciled (dr1 , dr2 ).notReconciled (dr3 );
423427 Assertions .assertThat (res .getErroredDependents ()).isEmpty ();
@@ -437,7 +441,7 @@ void diamondShareWithReadyCondition() {
437441 .addDependentResource (dr4 ).dependsOn (dr2 , dr3 )
438442 .build ();
439443
440- var res = workflow .reconcile (new TestCustomResource (), null );
444+ var res = workflow .reconcile (new TestCustomResource (), mockContext );
441445
442446 Assertions .assertThat (res .getErroredDependents ()).isEmpty ();
443447 assertThat (executionHistory ).reconciledInOrder (dr1 , dr2 )
0 commit comments