23
23
import org .apache .nifi .flow .VersionedAsset ;
24
24
import org .apache .nifi .flow .VersionedComponent ;
25
25
import org .apache .nifi .flow .VersionedControllerService ;
26
+ import org .apache .nifi .flow .VersionedFlowCoordinates ;
26
27
import org .apache .nifi .flow .VersionedParameter ;
27
28
import org .apache .nifi .flow .VersionedParameterContext ;
28
29
import org .apache .nifi .flow .VersionedProcessGroup ;
@@ -285,6 +286,63 @@ public void testDeepStrategyWithChildPGs() {
285
286
&& difference .getComponentA ().getComponentType () == ComponentType .CONTROLLER_SERVICE ));
286
287
}
287
288
289
+ @ Test
290
+ public void testScheduledStateChangeDetectedForProcessorInNestedVersionedGroup () {
291
+ final String rootPgIdentifier = "rootPG" ;
292
+ final String nestedPgIdentifier = "nestedPG" ;
293
+ final String procIdentifier = "processorZ" ;
294
+ final VersionedProcessGroup registryRoot = new VersionedProcessGroup ();
295
+ registryRoot .setIdentifier (rootPgIdentifier );
296
+
297
+ final VersionedProcessGroup localRoot = new VersionedProcessGroup ();
298
+ localRoot .setIdentifier (rootPgIdentifier );
299
+
300
+ final VersionedProcessGroup registryNested = new VersionedProcessGroup ();
301
+ registryNested .setIdentifier (nestedPgIdentifier );
302
+ registryNested .setVersionedFlowCoordinates (createVersionedFlowCoordinates ());
303
+ registryRoot .getProcessGroups ().add (registryNested );
304
+
305
+ final VersionedProcessGroup localNested = new VersionedProcessGroup ();
306
+ localNested .setIdentifier (nestedPgIdentifier );
307
+ localNested .setVersionedFlowCoordinates (createVersionedFlowCoordinates ());
308
+ localRoot .getProcessGroups ().add (localNested );
309
+
310
+ final VersionedProcessor registryProcessor = new VersionedProcessor ();
311
+ registryProcessor .setIdentifier (procIdentifier );
312
+ registryProcessor .setScheduledState (ScheduledState .ENABLED );
313
+ registryProcessor .setProperties (Collections .emptyMap ());
314
+ registryProcessor .setPropertyDescriptors (Collections .emptyMap ());
315
+ registryNested .getProcessors ().add (registryProcessor );
316
+
317
+ final VersionedProcessor localProcessor = new VersionedProcessor ();
318
+ localProcessor .setIdentifier (procIdentifier );
319
+ localProcessor .setScheduledState (ScheduledState .DISABLED );
320
+ localProcessor .setProperties (Collections .emptyMap ());
321
+ localProcessor .setPropertyDescriptors (Collections .emptyMap ());
322
+ localNested .getProcessors ().add (localProcessor );
323
+
324
+ final ComparableDataFlow registryFlow = new StandardComparableDataFlow ("registry" , registryRoot );
325
+ final ComparableDataFlow localFlow = new StandardComparableDataFlow ("local" , localRoot );
326
+
327
+ final StandardFlowComparator testComparator = new StandardFlowComparator (
328
+ registryFlow ,
329
+ localFlow ,
330
+ Collections .emptySet (),
331
+ new StaticDifferenceDescriptor (),
332
+ Function .identity (),
333
+ VersionedComponent ::getIdentifier ,
334
+ FlowComparatorVersionedStrategy .SHALLOW );
335
+
336
+ final Set <FlowDifference > differences = testComparator .compare ().getDifferences ();
337
+
338
+ final boolean scheduledStateDiffFound = differences .stream ()
339
+ .anyMatch (diff -> diff .getDifferenceType () == DifferenceType .SCHEDULED_STATE_CHANGED
340
+ && diff .getComponentB () != null
341
+ && procIdentifier .equals (diff .getComponentB ().getIdentifier ()));
342
+
343
+ assertTrue (scheduledStateDiffFound , "Expected scheduled state change for processor inside nested process group to be detected" );
344
+ }
345
+
288
346
private VersionedParameter createParameter (final String name , final String value , final boolean sensitive ) {
289
347
return createParameter (name , value , sensitive , null );
290
348
}
@@ -304,4 +362,13 @@ private VersionedAsset createAsset(final String id, final String name) {
304
362
asset .setName (name );
305
363
return asset ;
306
364
}
365
+
366
+ private VersionedFlowCoordinates createVersionedFlowCoordinates () {
367
+ final VersionedFlowCoordinates coordinates = new VersionedFlowCoordinates ();
368
+ coordinates .setRegistryId ("registry" );
369
+ coordinates .setBucketId ("bucketId" );
370
+ coordinates .setFlowId ("flowId" );
371
+ coordinates .setVersion ("1" );
372
+ return coordinates ;
373
+ }
307
374
}
0 commit comments