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