briansolo1985 commented on code in PR #7997:
URL: https://github.com/apache/nifi/pull/7997#discussion_r1386758472


##########
minifi/minifi-commons/minifi-utils/src/main/java/org/apache/nifi/minifi/commons/status/util/PropertyUtil.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.minifi.commons.status.util;
+
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Stream;
+
+public class PropertyUtil {

Review Comment:
   Minor but if this is a util class, we could add abstract, so nobody could 
instantiate this class - even with reflection



##########
minifi/minifi-commons/minifi-utils/src/test/java/org/apache/nifi/minifi/commons/status/util/PropertyUtilTest.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.nifi.minifi.commons.status.util;
+
+import static 
org.apache.nifi.minifi.commons.status.util.PropertyUtil.resolvePropertyValue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+import java.util.Map;
+import org.junit.jupiter.api.Test;
+
+class PropertyUtilTest {
+
+    private static final String PROPERTY_KEY_WITH_DOTS = "property.foo.bar";
+    private static final String PROPERTY_KEY_WITH_HYPHENS = "property-foo-bar";
+    private static final String PROPERTY_KEY_WITH_DOTS_AND_HYPHENS = 
"property.foo-bar";
+    private static final String PROPERTY_KEY_WITH_UNDERSCORE = 
"property_foo_bar";
+    private static final String VALUE = "value";
+
+    @Test
+    void 
testResolveParameterValueReturnsNullWhenPropertiesDoesNotContainTheKey() {
+        assertNull(resolvePropertyValue(PROPERTY_KEY_WITH_DOTS, Map.of()));
+    }
+
+    @Test

Review Comment:
   These tests would be a good for for a parameterized test. Or is this 
intentional because the of the descriptive test case name?



##########
minifi/minifi-nar-bundles/minifi-framework-bundle/minifi-framework/minifi-runtime/src/main/java/org/apache/nifi/minifi/util/MiNiFiProperties.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.minifi.util;
+
+import static 
org.apache.nifi.minifi.commons.status.util.PropertyUtil.resolvePropertyValue;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Optional;
+import java.util.Properties;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import org.apache.nifi.util.NiFiProperties;
+
+/**
+ * Extends NiFi properties functionality with System and Environment property 
override possibility. The property resolution also works with
+ * dots and hyphens that are not supported in some shells.
+ */
+public class MiNiFiProperties extends NiFiProperties {
+
+    private final Properties properties = new Properties();

Review Comment:
   Maybe I misunderstand something, but if we create and use a different 
properties object here, than the superclass', all the methods on NiFiProperties 
will give back false results (hurt of the Liskov-Substitution principle)
   Can't we use the superclass' property member?
   Or if it is not necessary to extend NiFiProperties, then we could remove the 
extend relationship



##########
minifi/minifi-bootstrap/src/main/java/org/apache/nifi/minifi/bootstrap/service/BootstrapProperties.java:
##########
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.nifi.minifi.bootstrap.service;
+
+import static 
org.apache.nifi.minifi.commons.status.util.PropertyUtil.resolvePropertyValue;
+
+import java.util.Optional;
+import java.util.Properties;
+
+/**
+ * Extends Properties functionality with System and Environment property 
override possibility. The property resolution also works with
+ * dots and hyphens that are not supported in some shells.
+ */
+public class BootstrapProperties extends Properties {
+
+    public BootstrapProperties() {

Review Comment:
   Can we add a getInstance factory method here as well to make it consistent 
with MiNiFiProperties?



-- 
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: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to