StandardFDExtensionManager implements FDExtensionManager { @Override public PropertyDescriptor createDynamicControllerServicePropertyDescriptor(final String type, final Bundle bundle, final String propertyName) { final ControllerServiceDefinition serviceDefinition = locateManifestControllerService(type, bundle); if (!serviceDefinition.getSupportsDynamicProperties()) { throw new IllegalStateException("Service does not support dynamic properties"); } final PropertyDescriptor propertyDescriptor = new PropertyDescriptor(); propertyDescriptor.setName(propertyName); propertyDescriptor.setDisplayName(propertyName); propertyDescriptor.setExpressionLanguageScope(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES); propertyDescriptor.setDescription("Dynamic property"); propertyDescriptor.setRequired(false); propertyDescriptor.setDynamic(true); return propertyDescriptor; } StandardFDExtensionManager(final AgentManifest agentManifest); @Override Set<FDComponentType> getProcessorTypes(); @Override ProcessorDefinition getProcessorDefinition(final String type, final Bundle bundle); @Override FDProcessor createProcessor(final String type, final Bundle bundle); @Override Optional<PropertyDescriptor> getProcessorPropertyDescriptor(final String type, final Bundle bundle, final String propertyName); @Override PropertyDescriptor createDynamicProcessorPropertyDescriptor(final String type, final Bundle bundle, final String propertyName); @Override Set<FDComponentType> getControllerServiceTypes(); @Override ControllerServiceDefinition getControllerServiceDefinition(final String type, final Bundle bundle); @Override FDControllerService createControllerService(final String type, final Bundle bundle); @Override Optional<PropertyDescriptor> getControllerServicePropertyDescriptor(final String type, final Bundle bundle, final String propertyName); @Override PropertyDescriptor createDynamicControllerServicePropertyDescriptor(final String type, final Bundle bundle, final String propertyName);  }
@Test public void testCreateDynamicControllerServicePropertyWhenSupported() { final String propertyName = "FOO"; final org.apache.nifi.registry.flow.Bundle bundle = getRequestBundle(systemBundle); final PropertyDescriptor dynamicProperty = extensionManager.createDynamicControllerServicePropertyDescriptor( dynamicPropsService.getType(), bundle, propertyName); assertNotNull(dynamicProperty); assertEquals(propertyName, dynamicProperty.getName()); assertEquals(propertyName, dynamicProperty.getDisplayName()); }
@Test(expected = IllegalStateException.class) public void testCreateDynamicControllerServicePropertyWhenNotSupported() { final String propertyName = "FOO"; final org.apache.nifi.registry.flow.Bundle bundle = getRequestBundle(systemBundle); extensionManager.createDynamicControllerServicePropertyDescriptor(sslContextService.getType(), bundle, propertyName); }