ComponentUtils { public static Set<VersionedControllerService> getAncestorControllerServices(final String targetGroupId, final VersionedProcessGroup parentGroup) { final Set<VersionedControllerService> controllerServices = new LinkedHashSet<>(); final boolean partOfDescendantChain = getAncestorControllerServices(targetGroupId, parentGroup, controllerServices); if (!partOfDescendantChain) { throw new IllegalStateException("The target process group is not a child of the starting group or any of its children"); } return controllerServices; }  static VersionedProcessGroup getProcessGroupOrNotFound(final String processGroupId, final VersionedProcessGroup startingGroup); static VersionedProcessGroup getProcessGroupOrIllegalArgument(final String processGroupId, final VersionedProcessGroup startingGroup); static V getComponentOrNotFound(
            final String componentId,
            final VersionedProcessGroup startingGroup,
            final Function<VersionedProcessGroup, Set<V>> getComponentsFunction); static V getComponentOrIllegalArgument(
            final String componentId,
            final VersionedProcessGroup startingGroup,
            final Function<VersionedProcessGroup, Set<V>> getComponentsFunction); static Optional<V> locateComponent(
            final String componentId,
            final VersionedProcessGroup startingGroup,
            final Function<VersionedProcessGroup, Set<V>> getComponentsFunction); static Optional<VersionedProcessGroup> locateProcessGroup(final String processGroupId, final VersionedProcessGroup startingGroup); static Set<VersionedControllerService> getAncestorControllerServices(final String targetGroupId, final VersionedProcessGroup parentGroup); static Set<PropertyDescriptor> getControllerServicePropertyDescriptors(final ConfigurableComponentDefinition componentDefinition); static void populateControllerServicePropertyDescriptors(final FDFlow flow, final String componentGroupId,
                                                                    final ConfigurableComponentDefinition componentDefinition); static void populateControllerServicePropertyDescriptors(final ConfigurableComponentDefinition componentDefinition,
                                                                    final Set<VersionedControllerService> ancestorControllerServices); static void populateControllerServicePropertyDescriptors(final Set<PropertyDescriptor> controllerServiceProperties,
                                                                    final Set<VersionedControllerService> ancestorControllerServices); static void updatePropertyValues(final ConfigurableComponentDefinition componentDefinition,
                                            final Map<String,String> properties); static V removeComponent(
            final String componentId,
            final VersionedProcessGroup flowContent,
            final Function<VersionedProcessGroup, Set<V>> getComponentsFunction); static V removeComponent(
            final V componentConfig,
            final VersionedProcessGroup flowContent,
            final Function<VersionedProcessGroup, Set<V>> getComponentsFunction); static void removeComponentConnections(final String componentId, final VersionedProcessGroup processGroup); static void removeComponentConnections(final String componentId, final VersionedProcessGroup processGroup, final boolean recursive); static ConnectableComponent createConnectableComponent(final VersionedComponent component); static String getComponentName(final VersionedComponent requestComponent, final String requestType); static void configureComponent(final V requestComponent, final V resultComponent); static void configureConfigurableComponent(final V requestComponent, final V resultComponent); static boolean isNotNull(T object); static void validateTimePeriodValue(final String value); static String validateDataUnitValue(final String value); static void publishComponentAddedEvent(final FDFlowManager flowManager, final String flowId,
                                                  final String componentId, final VersionedProcessGroup flowContent); static void publishComponentModifiedEvent(final FDFlowManager flowManager, final String flowId,
                                                     final String componentId, final VersionedProcessGroup flowContent); static void publishComponentRemovedEvent(final FDFlowManager flowManager, final String flowId,
                                                    final String componentId, final VersionedProcessGroup flowContent); static void publishComponentEvent(final FDFlowManager flowManager, final String flowId,
                                             final String componentId, final FDFlowEventType eventType,
                                             final String eventDescription, final VersionedProcessGroup flowContent);  }
@Test public void testGetAncestorControllerServicesFromLeafBackToRoot() { final Set<VersionedControllerService> services = ComponentUtils.getAncestorControllerServices(groupLevel2Child4.getIdentifier(), rootGroup); Assert.assertEquals(3, services.size()); Assert.assertTrue(services.contains(rootService)); Assert.assertTrue(services.contains(serviceLevel1Child2)); Assert.assertTrue(services.contains(serviceLevel2Child4)); }
@Test public void testGetAncestorControllerServicesFromRootToRoot() { final Set<VersionedControllerService> services = ComponentUtils.getAncestorControllerServices(rootGroup.getIdentifier(), rootGroup); Assert.assertEquals(1, services.size()); Assert.assertTrue(services.contains(rootService)); }
@Test public void testGetAncestorControllerServicesFromLeafToLeaf() { final Set<VersionedControllerService> services = ComponentUtils.getAncestorControllerServices(groupLevel2Child4.getIdentifier(), groupLevel2Child4); Assert.assertEquals(1, services.size()); Assert.assertTrue(services.contains(serviceLevel2Child4)); }