NIFI-10597 Change 'App Config File' property to external resource in Box processors

This closes #6489.

Signed-off-by: Tamas Palfy <tpalfy@apache.org>
This commit is contained in:
krisztina-zsihovszki 2022-10-06 10:38:22 +02:00 committed by Tamas Palfy
parent 2405b0ef71
commit 1ec8c84b6a
2 changed files with 10 additions and 1 deletions

View File

@ -25,6 +25,8 @@ import org.apache.nifi.annotation.lifecycle.OnEnabled;
import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.ValidationContext; import org.apache.nifi.components.ValidationContext;
import org.apache.nifi.components.ValidationResult; import org.apache.nifi.components.ValidationResult;
import org.apache.nifi.components.resource.ResourceCardinality;
import org.apache.nifi.components.resource.ResourceType;
import org.apache.nifi.controller.AbstractControllerService; import org.apache.nifi.controller.AbstractControllerService;
import org.apache.nifi.controller.ConfigurationContext; import org.apache.nifi.controller.ConfigurationContext;
import org.apache.nifi.expression.ExpressionLanguageScope; import org.apache.nifi.expression.ExpressionLanguageScope;
@ -59,7 +61,7 @@ public class JsonConfigBasedBoxClientService extends AbstractControllerService i
.displayName("App Config File") .displayName("App Config File")
.description("Full path of an App config JSON file. See Additional Details for more information.") .description("Full path of an App config JSON file. See Additional Details for more information.")
.required(false) .required(false)
.addValidator(StandardValidators.FILE_EXISTS_VALIDATOR) .identifiesExternalResource(ResourceCardinality.SINGLE, ResourceType.FILE)
.expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY)
.build(); .build();

View File

@ -64,6 +64,13 @@ public class JsonConfigBasedBoxClientServiceTestRunnerTest {
testRunner.assertNotValid(testSubject); testRunner.assertNotValid(testSubject);
} }
@Test
void invalidWhenAppConfigFileDoesNotExist() {
testRunner.setProperty(testSubject, JsonConfigBasedBoxClientService.ACCOUNT_ID, "account_id");
testRunner.setProperty(testSubject, JsonConfigBasedBoxClientService.APP_CONFIG_FILE, "doesnotexist.xml");
testRunner.assertNotValid(testSubject);
}
@Test @Test
void invalidWhenBothAppConfigFileAndAppConfigJsonIsSet() { void invalidWhenBothAppConfigFileAndAppConfigJsonIsSet() {
testRunner.setProperty(testSubject, JsonConfigBasedBoxClientService.ACCOUNT_ID, "account_id"); testRunner.setProperty(testSubject, JsonConfigBasedBoxClientService.ACCOUNT_ID, "account_id");