I have custom controller service with few properties. Here is sample of one of them:
public static final PropertyDescriptor CONFIG_DELIMITER = new PropertyDescriptor.Builder()
.name("Field delimiter to be used")
.description("Field delimiter used to separate the fields in the cache data file...")
.defaultValue(",")
.expressionLanguageSupported(true)
.required(true)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.build();
I have expressionLanguageSupported set to true for them with the idea of resolving them in onConfigred method of the service.
@OnEnabled
public void onConfigured(final ConfigurationContext context) throws InitializationException {
configDelim = context.getProperty(CONFIG_DELIMITER).evaluateAttributeExpressions().getValue();
..........
}
I have created a custom properties file custom.properties with following content:
nifi.iSOS.MyService.delim=,
I have setup properties in my test as :
@Test
public void testService() throws InitializationException {
final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class);
final MyService service = new MyService();
runner.addControllerService("MyService", service);
runner.setProperty(service, LookupService.CONFIG_DELIMITER , "${nifi.iSOS.MyService.delim}");
..........
}
I need help with 2 things:
- How to pass the custom properties file to the test for MyService?
- Is context.getProperty(CONFIG_DELIMITER).evaluateAttributeExpressions().getValue(); correct way to evaluate the value of the custom property in the controller service?
Big thank you for all the help...