@Override public ValidationResult setProperty( final ControllerService service, final String propertyName, final String value) { final PropertyDescriptor descriptor = service.getPropertyDescriptor(propertyName); if (descriptor == null) { return new ValidationResult.Builder() .input(propertyName) .explanation(propertyName + " is not a known Property for Controller Service " + service) .subject("Invalid property") .valid(false) .build(); } return setProperty(service, descriptor, value); }
@Override public void addControllerService( final String identifier, final ControllerService service, final Map<String, String> properties) throws InitializationException { // hold off on failing due to deprecated annotation for now... will introduce later. // for ( final Method method : service.getClass().getMethods() ) { // if ( method.isAnnotationPresent(org.apache.nifi.controller.annotation.OnConfigured.class) ) { // Assert.fail("Controller Service " + service + " is using deprecated Annotation " + // org.apache.nifi.controller.annotation.OnConfigured.class + " for method " + method); // } // } final MockComponentLog logger = new MockComponentLog(identifier, service); controllerServiceLoggers.put(identifier, logger); final MockStateManager serviceStateManager = new MockStateManager(service); final MockControllerServiceInitializationContext initContext = new MockControllerServiceInitializationContext( requireNonNull(service), requireNonNull(identifier), logger, serviceStateManager); controllerServiceStateManagers.put(identifier, serviceStateManager); initContext.addControllerServices(context); service.initialize(initContext); final Map<PropertyDescriptor, String> resolvedProps = new HashMap<>(); for (final Map.Entry<String, String> entry : properties.entrySet()) { resolvedProps.put(service.getPropertyDescriptor(entry.getKey()), entry.getValue()); } try { ReflectionUtils.invokeMethodsWithAnnotation(OnAdded.class, service); } catch (final InvocationTargetException | IllegalAccessException | IllegalArgumentException e) { throw new InitializationException(e); } context.addControllerService(identifier, service, resolvedProps, null); }