exceptionfactory commented on a change in pull request #5424:
URL: https://github.com/apache/nifi/pull/5424#discussion_r720270104



##########
File path: 
nifi-stateless/nifi-stateless-api/src/test/java/org/apache/nifi/stateless/config/PropertiesFileEngineConfigurationParserTest.java
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.stateless.config;
+
+import org.apache.nifi.stateless.engine.StatelessEngineConfiguration;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Properties;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+public class PropertiesFileEngineConfigurationParserTest {
+    private PropertiesFileEngineConfigurationParser parser;
+
+    private static Path narDirectory;
+
+    private static Path workingDirectory;
+
+    @BeforeAll
+    public static void setDirectories() throws IOException {
+        narDirectory = 
Files.createTempDirectory(PropertiesFileEngineConfigurationParserTest.class.getSimpleName());
+        workingDirectory = 
Files.createTempDirectory(PropertiesFileEngineConfigurationParserTest.class.getSimpleName());
+    }
+
+    @AfterAll
+    public static void deleteDirectories() throws IOException {
+        Files.deleteIfExists(narDirectory);
+        Files.deleteIfExists(workingDirectory);
+    }
+
+    @BeforeEach
+    public void setParser() {
+        parser = new PropertiesFileEngineConfigurationParser();
+    }
+
+    @Test
+    public void testParseEngineConfigurationRequiredProperties() throws 
IOException, StatelessConfigurationException {
+        final Properties properties = getRequiredProperties();
+        final File propertiesFile = getPropertiesFile(properties);
+
+        final StatelessEngineConfiguration configuration = 
parser.parseEngineConfiguration(propertiesFile);
+        assertNotNull(configuration);
+        assertEquals(narDirectory.toFile(), configuration.getNarDirectory());
+        assertEquals(workingDirectory.toFile(), 
configuration.getWorkingDirectory());
+    }
+
+    @Test
+    public void testParseEngineConfigurationRandomSensitivePropsKey() throws 
IOException, StatelessConfigurationException {
+        final Properties properties = getRequiredProperties();
+        final File propertiesFile = getPropertiesFile(properties);
+
+        final StatelessEngineConfiguration configuration = 
parser.parseEngineConfiguration(propertiesFile);
+        assertNotNull(configuration);
+
+        final String sensitivePropsKey = configuration.getSensitivePropsKey();
+        assertNotNull(sensitivePropsKey);
+        assertFalse(sensitivePropsKey.isEmpty());
+
+        final StatelessEngineConfiguration reloadedConfiguration = 
parser.parseEngineConfiguration(propertiesFile);
+        assertEquals(sensitivePropsKey, 
reloadedConfiguration.getSensitivePropsKey());
+    }
+
+    private Properties getRequiredProperties() {
+        final Properties properties = new Properties();
+
+        properties.setProperty("nifi.stateless.nar.directory", 
narDirectory.toString());

Review comment:
       These are the only properties currently required for the stateless 
parser to return a configuration. Several other properties fall back to default 
values, so as long as these two properties are present, and the directories 
exist, the parser returns a working configuration.
   
   I am not aware additional documentation for Stateless properties, so that 
would be great to address in a separate issue.




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