From 1ec8c84b6acf31a45d6a048bca36c68cf74a6019 Mon Sep 17 00:00:00 2001 From: krisztina-zsihovszki Date: Thu, 6 Oct 2022 10:38:22 +0200 Subject: [PATCH] NIFI-10597 Change 'App Config File' property to external resource in Box processors This closes #6489. Signed-off-by: Tamas Palfy --- .../JsonConfigBasedBoxClientService.java | 4 +++- .../JsonConfigBasedBoxClientServiceTestRunnerTest.java | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/nifi-nar-bundles/nifi-box-bundle/nifi-box-services/src/main/java/org/apache/nifi/box/controllerservices/JsonConfigBasedBoxClientService.java b/nifi-nar-bundles/nifi-box-bundle/nifi-box-services/src/main/java/org/apache/nifi/box/controllerservices/JsonConfigBasedBoxClientService.java index 15ef3edc53..f384b015c3 100644 --- a/nifi-nar-bundles/nifi-box-bundle/nifi-box-services/src/main/java/org/apache/nifi/box/controllerservices/JsonConfigBasedBoxClientService.java +++ b/nifi-nar-bundles/nifi-box-bundle/nifi-box-services/src/main/java/org/apache/nifi/box/controllerservices/JsonConfigBasedBoxClientService.java @@ -25,6 +25,8 @@ import org.apache.nifi.annotation.lifecycle.OnEnabled; import org.apache.nifi.components.PropertyDescriptor; import org.apache.nifi.components.ValidationContext; 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.ConfigurationContext; import org.apache.nifi.expression.ExpressionLanguageScope; @@ -59,7 +61,7 @@ public class JsonConfigBasedBoxClientService extends AbstractControllerService i .displayName("App Config File") .description("Full path of an App config JSON file. See Additional Details for more information.") .required(false) - .addValidator(StandardValidators.FILE_EXISTS_VALIDATOR) + .identifiesExternalResource(ResourceCardinality.SINGLE, ResourceType.FILE) .expressionLanguageSupported(ExpressionLanguageScope.VARIABLE_REGISTRY) .build(); diff --git a/nifi-nar-bundles/nifi-box-bundle/nifi-box-services/src/test/java/org/apache/nifi/box/controllerservices/JsonConfigBasedBoxClientServiceTestRunnerTest.java b/nifi-nar-bundles/nifi-box-bundle/nifi-box-services/src/test/java/org/apache/nifi/box/controllerservices/JsonConfigBasedBoxClientServiceTestRunnerTest.java index 55acfbe149..98ecdf168a 100644 --- a/nifi-nar-bundles/nifi-box-bundle/nifi-box-services/src/test/java/org/apache/nifi/box/controllerservices/JsonConfigBasedBoxClientServiceTestRunnerTest.java +++ b/nifi-nar-bundles/nifi-box-bundle/nifi-box-services/src/test/java/org/apache/nifi/box/controllerservices/JsonConfigBasedBoxClientServiceTestRunnerTest.java @@ -64,6 +64,13 @@ public class JsonConfigBasedBoxClientServiceTestRunnerTest { 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 void invalidWhenBothAppConfigFileAndAppConfigJsonIsSet() { testRunner.setProperty(testSubject, JsonConfigBasedBoxClientService.ACCOUNT_ID, "account_id");