Java Code Examples for org.apache.nifi.controller.ControllerService#getPropertyDescriptor()
The following examples show how to use
org.apache.nifi.controller.ControllerService#getPropertyDescriptor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StandardProcessorTestRunner.java From localization_nifi with Apache License 2.0 | 5 votes |
@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); }
Example 2
Source File: TestStandardProcessorTestRunner.java From localization_nifi with Apache License 2.0 | 5 votes |
@Test public void testControllerServiceUpdateShouldCallOnSetProperty() { // Arrange final ControllerService testService = new SimpleTestService(); final AddAttributeProcessor proc = new AddAttributeProcessor(); final TestRunner runner = TestRunners.newTestRunner(proc); final String serviceIdentifier = "test"; final String pdName = "name"; final String pdValue = "exampleName"; try { runner.addControllerService(serviceIdentifier, testService); } catch (InitializationException e) { fail(e.getMessage()); } assertFalse("onPropertyModified has been called", ((SimpleTestService) testService).isOpmCalled()); // Act ValidationResult vr = runner.setProperty(testService, pdName, pdValue); // Assert assertTrue(vr.isValid()); ControllerServiceConfiguration csConf = ((MockProcessContext) runner.getProcessContext()).getConfiguration(serviceIdentifier); PropertyDescriptor propertyDescriptor = testService.getPropertyDescriptor(pdName); String retrievedPDValue = csConf.getProperties().get(propertyDescriptor); assertEquals(pdValue, retrievedPDValue); assertTrue("onPropertyModified has not been called", ((SimpleTestService) testService).isOpmCalled()); }
Example 3
Source File: StandardProcessorTestRunner.java From nifi with Apache License 2.0 | 5 votes |
@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); }
Example 4
Source File: StandardProcessorTestRunner.java From nifi with Apache License 2.0 | 5 votes |
@Override public boolean removeProperty(ControllerService service, String propertyName) { final PropertyDescriptor descriptor = service.getPropertyDescriptor(propertyName); if (descriptor == null) { return false; } return removeProperty(service, descriptor); }
Example 5
Source File: TestStandardProcessorTestRunner.java From nifi with Apache License 2.0 | 5 votes |
@Test public void testControllerServiceUpdateShouldCallOnSetProperty() { // Arrange final ControllerService testService = new SimpleTestService(); final AddAttributeProcessor proc = new AddAttributeProcessor(); final TestRunner runner = TestRunners.newTestRunner(proc); final String serviceIdentifier = "test"; final String pdName = "name"; final String pdValue = "exampleName"; try { runner.addControllerService(serviceIdentifier, testService); } catch (InitializationException e) { fail(e.getMessage()); } assertFalse("onPropertyModified has been called", ((SimpleTestService) testService).isOpmCalled()); // Act ValidationResult vr = runner.setProperty(testService, pdName, pdValue); // Assert assertTrue(vr.isValid()); ControllerServiceConfiguration csConf = ((MockProcessContext) runner.getProcessContext()).getConfiguration(serviceIdentifier); PropertyDescriptor propertyDescriptor = testService.getPropertyDescriptor(pdName); String retrievedPDValue = csConf.getProperties().get(propertyDescriptor); assertEquals(pdValue, retrievedPDValue); assertTrue("onPropertyModified has not been called", ((SimpleTestService) testService).isOpmCalled()); }