pvillard31 commented on code in PR #10217:
URL: https://github.com/apache/nifi/pull/10217#discussion_r2303584777


##########
nifi-mock/src/main/java/org/apache/nifi/util/TestRunner.java:
##########
@@ -1069,6 +1069,29 @@ void assertAttributes(
      */
     void setEnvironmentVariableValue(String name, String value);
 
+    /**
+     * Returns the current value of the Context Parameter with the given name
+     *
+     * @param name the name of the Context Parameter whose value should be 
returned.
+     * @return the current value of the Context Parameter with the given name 
or <code>null</code> if no value is currently set
+     *
+     * @throws NullPointerException if the name is null
+     */
+    String getContextParameterValue(String name);
+
+    /**
+     * Sets the value of the Context Parameter with the given name to be the 
given value. This exposes the Context Parameter
+     * for use by the Expression Language (with the #{name} syntax).
+     *
+     * NOTE - this method is only for testing purposes.
+     *
+     * @param name the name of the variable to set
+     * @param value the value of the variable
+     *
+     * @throws NullPointerException if either the name or the value is null
+     */
+    void setContextParameterValue(String name, String value);
+

Review Comment:
   ```suggestion
       /**
        * Sets a parameter with the given name and value into the simulated 
Parameter Context. This makes available the parameter to the properties of the 
component being tested through parameter referencing such as 
<code>#{name}</code>.
        *
        * @param parameterName the name of the parameter to set
        * @param parameterValue the value of the parameter to set
        *
        * @throws NullPointerException if the name is null
        */
       void setParameterContextValue(final String parameterName, final String 
parameterValue);
   
   ```
   
   It is possible to set a value with `null`



##########
nifi-mock/src/main/java/org/apache/nifi/util/TestRunner.java:
##########
@@ -1069,6 +1069,29 @@ void assertAttributes(
      */
     void setEnvironmentVariableValue(String name, String value);
 
+    /**
+     * Returns the current value of the Context Parameter with the given name
+     *
+     * @param name the name of the Context Parameter whose value should be 
returned.
+     * @return the current value of the Context Parameter with the given name 
or <code>null</code> if no value is currently set
+     *
+     * @throws NullPointerException if the name is null
+     */
+    String getContextParameterValue(String name);

Review Comment:
   ```suggestion
       /**
        * Returns the current value for the given parameter name from the 
simulated Parameter Context
        *
        * @param name the name of the parameter from the Parameter Context 
whose value should be returned.
        * @return the current value for the given parameter name from the 
simulated Parameter Context or <code>null</code> if no value is currently set
        *
        * @throws NullPointerException if the name is null
        */
       String getParameterContextValue(String name);
   ```



##########
nifi-mock/src/main/java/org/apache/nifi/util/StandardProcessorTestRunner.java:
##########
@@ -110,6 +110,9 @@ public class StandardProcessorTestRunner implements 
TestRunner {
     // This only for testing purposes as we don't want to set env/sys 
variables in the tests
     private final Map<String, String> environmentVariables = new HashMap<>();
 
+    // This only for testing purposes as we need a way to set context 
parameters normally provided by the nifi environment

Review Comment:
   ```suggestion
       // This is only for testing purposes to simulate parameters coming from 
parameter contexts
   ```



##########
nifi-mock/src/main/java/org/apache/nifi/util/MockParameterLookup.java:
##########
@@ -30,7 +31,7 @@ public class MockParameterLookup implements ParameterLookup {
     private final AtomicLong version = new AtomicLong(1);
 
     public MockParameterLookup(final Map<String, String> parameters) {
-        this.parameters = parameters == null ? new HashMap<>() : new 
HashMap<>(parameters);
+        this.parameters = parameters == null ? new HashMap<>() : 
Collections.unmodifiableMap(parameters);

Review Comment:
   ```suggestion
           this.parameters = parameters == null ? Collections.emptyMap() : 
Collections.unmodifiableMap(parameters);
   ```



-- 
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]

Reply via email to