exceptionfactory commented on code in PR #11792:
URL: https://github.com/apache/nifi/pull/11792#discussion_r4587630599
##########
nifi-framework-bundle/nifi-framework/nifi-framework-components/src/test/java/org/apache/nifi/migration/TestStandardPropertyConfiguration.java:
##########
@@ -57,7 +58,28 @@ public ControllerServiceNode create(final
ControllerServiceCreationDetails creat
config = new StandardPropertyConfiguration(originalProperties,
originalProperties, raw -> raw, "Test Component", controllerServiceFactory);
}
- // TODO: Test Raw vs. Effective values
+ @Test
+ public void testParameterReferenceWithoutValueIsRawValueOnly() {
+ final Map<String, String> rawProperties = new HashMap<>();
+ rawProperties.put("service", "#{service-parameter}");
+ rawProperties.put("a", "A");
+
+ final Map<String, String> effectiveProperties = new HashMap<>();
+ effectiveProperties.put("service", null);
+ effectiveProperties.put("a", "A");
+
+ final StandardPropertyConfiguration parameterConfig = new
StandardPropertyConfiguration(
+ effectiveProperties, rawProperties, raw ->
raw.startsWith("#{") ? null : raw, "Test Component", controllerServiceFactory);
+
+ assertTrue(parameterConfig.hasProperty("service"));
+ assertFalse(parameterConfig.isPropertySet("service"));
+ assertEquals(Optional.empty(),
parameterConfig.getPropertyValue("service"));
+ assertEquals(Optional.of("#{service-parameter}"),
parameterConfig.getRawPropertyValue("service"));
+
+ assertTrue(parameterConfig.isPropertySet("a"));
+ assertEquals(Optional.of("A"), parameterConfig.getPropertyValue("a"));
+ assertEquals(Optional.of("A"),
parameterConfig.getRawPropertyValue("a"));
Review Comment:
The repeated literal string values in this test should be declared once and
reused
##########
nifi-extension-bundles/nifi-snowflake-bundle/nifi-snowflake-services/src/test/java/org/apache/nifi/snowflake/service/TestStandardSnowflakeIngestManagerProviderService.java:
##########
@@ -229,4 +230,32 @@ private static SnowpipeIngestClient createClient(final
MockWebServer mockWebServ
final RSAKeyAuthorizationProvider authProvider = new
RSAKeyAuthorizationProvider(ACCOUNT, USER, privateKey);
return new SnowpipeIngestClient(baseUri, PIPE_NAME, authProvider,
webClientService);
}
+
+ @Test
+ void
testMigratePropertiesRetainsWebClientServiceProviderParameterReferenceWithoutValue()
{
+ final String webClientServiceProviderName =
StandardSnowflakeIngestManagerProviderService.WEB_CLIENT_SERVICE_PROVIDER.getName();
+ final MockPropertyConfiguration configuration = new
UnresolvedParameterPropertyConfiguration(Map.of(webClientServiceProviderName,
"#{web-client-service}"));
+
+ new
StandardSnowflakeIngestManagerProviderService().migrateProperties(configuration);
+
+ assertEquals(Optional.of("#{web-client-service}"),
configuration.getRawPropertyValue(webClientServiceProviderName));
+
assertTrue(configuration.toPropertyMigrationResult().getCreatedControllerServices().isEmpty());
+ }
+
+ private static class UnresolvedParameterPropertyConfiguration extends
MockPropertyConfiguration {
+
+ private UnresolvedParameterPropertyConfiguration(final Map<String,
String> rawProperties) {
+ super(rawProperties);
+ }
+
+ @Override
+ public boolean isPropertySet(final String propertyName) {
+ return getPropertyValue(propertyName).isPresent();
+ }
+
+ @Override
+ public Optional<String> getPropertyValue(final String propertyName) {
+ return getRawPropertyValue(propertyName).filter(value ->
!value.startsWith("#{"));
+ }
+ }
Review Comment:
Since the change is minor, introducing the complete test method and class do
not seem necessary, recommend removing
##########
nifi-extension-bundles/nifi-aws-bundle/nifi-aws-processors/src/test/java/org/apache/nifi/processors/aws/s3/TestFetchS3Object.java:
##########
@@ -378,4 +382,31 @@ private AwsServiceException buildS3Exception(int
statusCode, String errorCode, S
}
+ @Test
+ void
testMigrationRetainsCredentialsServiceParameterReferenceWithoutValue() {
+ final String credentialsServiceName =
AbstractAwsProcessor.AWS_CREDENTIALS_PROVIDER_SERVICE.getName();
+ final MockPropertyConfiguration configuration = new
UnresolvedParameterPropertyConfiguration(Map.of(credentialsServiceName,
"#{credentials-service}"));
+
+ new FetchS3Object().migrateProperties(configuration);
+
+ assertEquals(Optional.of("#{credentials-service}"),
configuration.getRawPropertyValue(credentialsServiceName));
+
assertTrue(configuration.toPropertyMigrationResult().getCreatedControllerServices().isEmpty());
Review Comment:
The repeated parameter reference string should be declared once and reused
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]