You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/08/22 16:54:29 UTC

[GitHub] [nifi] emiliosetiadarma opened a new pull request, #6321: NIFI-10344: refactored groovy tests in nifi-standard-processor to jav…

emiliosetiadarma opened a new pull request, #6321:
URL: https://github.com/apache/nifi/pull/6321

   …a and JUnit 5
   
   <!-- 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. -->
   
   # Summary
   
   [NIFI-10344](https://issues.apache.org/jira/browse/NIFI-10344)
   
   # Tracking
   
   Please complete the following tracking steps prior to pull request creation.
   
   ### Issue Tracking
   
   - [x] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue created
   
   ### Pull Request Tracking
   
   - [x] Pull Request title starts with Apache NiFi Jira issue number, such as `NIFI-00000`
   - [x] Pull Request commit message starts with Apache NiFi Jira issue number, as such `NIFI-00000`
   
   ### Pull Request Formatting
   
   - [x] Pull Request based on current revision of the `main` branch
   - [x] Pull Request refers to a feature branch with one commit containing changes
   
   # Verification
   
   Please indicate the verification steps performed prior to pull request creation.
   
   ### Build
   
   - [x] Build completed using `mvn clean install -P contrib-check`
     - [x] JDK 8
     - [ ] JDK 11
     - [ ] JDK 17
   
   ### Licensing
   
   - [ ] New dependencies are compatible with the [Apache License 2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License Policy](https://www.apache.org/legal/resolved.html)
   - [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE` files
   
   ### Documentation
   
   - [ ] Documentation formatting appears as expected in rendered files
   


-- 
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-unsubscribe@nifi.apache.org

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


[GitHub] [nifi] emiliosetiadarma commented on a diff in pull request #6321: NIFI-10344: refactored groovy tests in nifi-standard-processor to jav…

Posted by GitBox <gi...@apache.org>.
emiliosetiadarma commented on code in PR #6321:
URL: https://github.com/apache/nifi/pull/6321#discussion_r954353643


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/CryptographicHashContentTest.java:
##########
@@ -0,0 +1,246 @@
+/*
+ * 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.processors.standard;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.nifi.security.util.crypto.HashAlgorithm;
+import org.apache.nifi.security.util.crypto.HashService;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.security.Security;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+
+public class CryptographicHashContentTest {
+    @BeforeAll
+    static void setUpOnce() {
+        Security.addProvider(new BouncyCastleProvider());
+    }
+
+    @Test
+    void testShouldCalculateHashOfPresentContent() throws IOException {
+        final HashAlgorithm[] algorithms = HashAlgorithm.values();
+
+        // Generate some long content (90 KB)
+        final String LONG_CONTENT = StringUtils.repeat("apachenifi ", 8192);
+
+        final TestRunner runner = TestRunners.newTestRunner(new CryptographicHashContent());

Review Comment:
   Made the changes



-- 
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-unsubscribe@nifi.apache.org

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


[GitHub] [nifi] emiliosetiadarma commented on a diff in pull request #6321: NIFI-10344: refactored groovy tests in nifi-standard-processor to jav…

Posted by GitBox <gi...@apache.org>.
emiliosetiadarma commented on code in PR #6321:
URL: https://github.com/apache/nifi/pull/6321#discussion_r954350470


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/CryptographicHashAttributeTest.java:
##########
@@ -0,0 +1,343 @@
+/*
+ * 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.processors.standard;
+
+import org.apache.nifi.security.util.crypto.HashAlgorithm;
+import org.apache.nifi.security.util.crypto.HashService;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.security.Security;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class CryptographicHashAttributeTest {
+    @BeforeAll
+    static void setUpOnce() {
+        Security.addProvider(new BouncyCastleProvider());
+    }
+
+    @Test
+    void testShouldCalculateHashOfPresentAttribute() {
+        final HashAlgorithm[] algorithms = HashAlgorithm.values();
+
+        final TestRunner runner = TestRunners.newTestRunner(new CryptographicHashAttribute());
+
+        // Create attributes for username and date
+
+        final Map<String, String> attributes = new HashMap<>();
+        attributes.put("username", "alopresto");
+        attributes.put("date", ZonedDateTime.now().format(DateTimeFormatter.ofPattern("YYYY-MM-dd HH:mm:ss.SSS Z")));
+
+        final Set<String> attributeKeys = attributes.keySet();
+
+        for (final HashAlgorithm algorithm : algorithms) {

Review Comment:
   Making the changes



-- 
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-unsubscribe@nifi.apache.org

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


[GitHub] [nifi] emiliosetiadarma commented on a diff in pull request #6321: NIFI-10344: refactored groovy tests in nifi-standard-processor to jav…

Posted by GitBox <gi...@apache.org>.
emiliosetiadarma commented on code in PR #6321:
URL: https://github.com/apache/nifi/pull/6321#discussion_r954351431


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/CryptographicHashContentTest.java:
##########
@@ -0,0 +1,246 @@
+/*
+ * 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.processors.standard;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.nifi.security.util.crypto.HashAlgorithm;
+import org.apache.nifi.security.util.crypto.HashService;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.security.Security;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+
+public class CryptographicHashContentTest {
+    @BeforeAll
+    static void setUpOnce() {
+        Security.addProvider(new BouncyCastleProvider());
+    }
+
+    @Test
+    void testShouldCalculateHashOfPresentContent() throws IOException {
+        final HashAlgorithm[] algorithms = HashAlgorithm.values();
+
+        // Generate some long content (90 KB)
+        final String LONG_CONTENT = StringUtils.repeat("apachenifi ", 8192);

Review Comment:
   Lowercased in addition to the other variables defined in the test



-- 
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-unsubscribe@nifi.apache.org

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


[GitHub] [nifi] emiliosetiadarma commented on a diff in pull request #6321: NIFI-10344: refactored groovy tests in nifi-standard-processor to jav…

Posted by GitBox <gi...@apache.org>.
emiliosetiadarma commented on code in PR #6321:
URL: https://github.com/apache/nifi/pull/6321#discussion_r954106685


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/CountTextTest.java:
##########
@@ -0,0 +1,316 @@
+/*
+ * 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.processors.standard;
+
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.util.MockComponentLog;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.Security;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+
+public class CountTextTest {
+    private static final String TLC = "text.line.count";
+    private static final String TLNEC = "text.line.nonempty.count";
+    private static final String TWC = "text.word.count";
+    private static final String TCC = "text.character.count";
+
+    @BeforeAll
+    static void setUpOnce() {
+        Security.addProvider(new BouncyCastleProvider());
+    }
+
+    @Test
+    void testShouldCountAllMetrics() throws IOException {
+        final TestRunner runner = TestRunners.newTestRunner(CountText.class);
+
+        runner.setProperty(CountText.TEXT_LINE_COUNT_PD, "true");
+        runner.setProperty(CountText.TEXT_LINE_NONEMPTY_COUNT_PD, "true");
+        runner.setProperty(CountText.TEXT_WORD_COUNT_PD, "true");
+        runner.setProperty(CountText.TEXT_CHARACTER_COUNT_PD, "true");
+
+        final Path inputPath = Paths.get("src/test/resources/TestCountText/jabberwocky.txt");
+
+        final Map<String, String> expectedValues = new HashMap<>();
+        expectedValues.put(TLC, "34");
+        expectedValues.put(TLNEC, "28");
+        expectedValues.put(TWC, "166");
+        expectedValues.put(TCC, "900");
+
+        runner.enqueue(Files.readAllBytes(inputPath));
+
+        runner.run();
+
+        runner.assertAllFlowFilesTransferred(CountText.REL_SUCCESS, 1);
+        FlowFile flowFile = runner.getFlowFilesForRelationship(CountText.REL_SUCCESS).get(0);
+        for (final Map.Entry<String, String> entry: expectedValues.entrySet()) {
+            final String attribute = entry.getKey();
+            final String expectedValue = entry.getValue();
+
+            assertEquals(expectedValue, flowFile.getAttribute(attribute));
+        }

Review Comment:
   Making the changes



-- 
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-unsubscribe@nifi.apache.org

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


[GitHub] [nifi] emiliosetiadarma commented on a diff in pull request #6321: NIFI-10344: refactored groovy tests in nifi-standard-processor to jav…

Posted by GitBox <gi...@apache.org>.
emiliosetiadarma commented on code in PR #6321:
URL: https://github.com/apache/nifi/pull/6321#discussion_r954105088


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/CountTextTest.java:
##########
@@ -0,0 +1,316 @@
+/*
+ * 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.processors.standard;
+
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.util.MockComponentLog;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.Security;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+
+public class CountTextTest {
+    private static final String TLC = "text.line.count";
+    private static final String TLNEC = "text.line.nonempty.count";
+    private static final String TWC = "text.word.count";
+    private static final String TCC = "text.character.count";
+
+    @BeforeAll
+    static void setUpOnce() {
+        Security.addProvider(new BouncyCastleProvider());
+    }
+
+    @Test
+    void testShouldCountAllMetrics() throws IOException {
+        final TestRunner runner = TestRunners.newTestRunner(CountText.class);

Review Comment:
   Making the changes



-- 
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-unsubscribe@nifi.apache.org

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


[GitHub] [nifi] emiliosetiadarma commented on a diff in pull request #6321: NIFI-10344: refactored groovy tests in nifi-standard-processor to jav…

Posted by GitBox <gi...@apache.org>.
emiliosetiadarma commented on code in PR #6321:
URL: https://github.com/apache/nifi/pull/6321#discussion_r954351134


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/CryptographicHashAttributeTest.java:
##########
@@ -0,0 +1,343 @@
+/*
+ * 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.processors.standard;
+
+import org.apache.nifi.security.util.crypto.HashAlgorithm;
+import org.apache.nifi.security.util.crypto.HashService;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.security.Security;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class CryptographicHashAttributeTest {
+    @BeforeAll
+    static void setUpOnce() {
+        Security.addProvider(new BouncyCastleProvider());
+    }
+
+    @Test
+    void testShouldCalculateHashOfPresentAttribute() {
+        final HashAlgorithm[] algorithms = HashAlgorithm.values();
+
+        final TestRunner runner = TestRunners.newTestRunner(new CryptographicHashAttribute());
+
+        // Create attributes for username and date
+
+        final Map<String, String> attributes = new HashMap<>();
+        attributes.put("username", "alopresto");
+        attributes.put("date", ZonedDateTime.now().format(DateTimeFormatter.ofPattern("YYYY-MM-dd HH:mm:ss.SSS Z")));
+
+        final Set<String> attributeKeys = attributes.keySet();
+
+        for (final HashAlgorithm algorithm : algorithms) {
+            final String EXPECTED_USERNAME_HASH = HashService.hashValue(algorithm, attributes.get("username"));
+            final String EXPECTED_DATE_HASH = HashService.hashValue(algorithm, attributes.get("date"));

Review Comment:
   Made the changes



-- 
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-unsubscribe@nifi.apache.org

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


[GitHub] [nifi] exceptionfactory commented on a diff in pull request #6321: NIFI-10344: refactored groovy tests in nifi-standard-processor to jav…

Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on code in PR #6321:
URL: https://github.com/apache/nifi/pull/6321#discussion_r951756610


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/CountTextTest.java:
##########
@@ -0,0 +1,316 @@
+/*
+ * 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.processors.standard;
+
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.util.MockComponentLog;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.Security;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+
+public class CountTextTest {
+    private static final String TLC = "text.line.count";
+    private static final String TLNEC = "text.line.nonempty.count";
+    private static final String TWC = "text.word.count";
+    private static final String TCC = "text.character.count";
+
+    @BeforeAll
+    static void setUpOnce() {
+        Security.addProvider(new BouncyCastleProvider());
+    }
+
+    @Test
+    void testShouldCountAllMetrics() throws IOException {
+        final TestRunner runner = TestRunners.newTestRunner(CountText.class);

Review Comment:
   This line could be moved to a shared `setRunner` method annotated with `BeforeEach` to create the runner.



##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/CountTextTest.java:
##########
@@ -0,0 +1,316 @@
+/*
+ * 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.processors.standard;
+
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.util.MockComponentLog;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.Security;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+
+public class CountTextTest {
+    private static final String TLC = "text.line.count";
+    private static final String TLNEC = "text.line.nonempty.count";
+    private static final String TWC = "text.word.count";
+    private static final String TCC = "text.character.count";
+
+    @BeforeAll
+    static void setUpOnce() {
+        Security.addProvider(new BouncyCastleProvider());
+    }

Review Comment:
   This Security Provider configuration method is not necessary and should be removed.



##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/CountTextTest.java:
##########
@@ -0,0 +1,316 @@
+/*
+ * 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.processors.standard;
+
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.util.MockComponentLog;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.Security;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+
+public class CountTextTest {
+    private static final String TLC = "text.line.count";
+    private static final String TLNEC = "text.line.nonempty.count";
+    private static final String TWC = "text.word.count";
+    private static final String TCC = "text.character.count";
+
+    @BeforeAll
+    static void setUpOnce() {
+        Security.addProvider(new BouncyCastleProvider());
+    }
+
+    @Test
+    void testShouldCountAllMetrics() throws IOException {
+        final TestRunner runner = TestRunners.newTestRunner(CountText.class);
+
+        runner.setProperty(CountText.TEXT_LINE_COUNT_PD, "true");
+        runner.setProperty(CountText.TEXT_LINE_NONEMPTY_COUNT_PD, "true");
+        runner.setProperty(CountText.TEXT_WORD_COUNT_PD, "true");
+        runner.setProperty(CountText.TEXT_CHARACTER_COUNT_PD, "true");
+
+        final Path inputPath = Paths.get("src/test/resources/TestCountText/jabberwocky.txt");
+
+        final Map<String, String> expectedValues = new HashMap<>();
+        expectedValues.put(TLC, "34");
+        expectedValues.put(TLNEC, "28");
+        expectedValues.put(TWC, "166");
+        expectedValues.put(TCC, "900");
+
+        runner.enqueue(Files.readAllBytes(inputPath));
+
+        runner.run();
+
+        runner.assertAllFlowFilesTransferred(CountText.REL_SUCCESS, 1);
+        FlowFile flowFile = runner.getFlowFilesForRelationship(CountText.REL_SUCCESS).get(0);
+        for (final Map.Entry<String, String> entry: expectedValues.entrySet()) {
+            final String attribute = entry.getKey();
+            final String expectedValue = entry.getValue();
+
+            assertEquals(expectedValue, flowFile.getAttribute(attribute));
+        }

Review Comment:
   This approach should be replaced with `MockFlowFile.assertAttributeEquals()`, which would also remove the need for the `Map` of expected values.



##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/CryptographicHashAttributeTest.java:
##########
@@ -0,0 +1,343 @@
+/*
+ * 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.processors.standard;
+
+import org.apache.nifi.security.util.crypto.HashAlgorithm;
+import org.apache.nifi.security.util.crypto.HashService;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.security.Security;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class CryptographicHashAttributeTest {
+    @BeforeAll
+    static void setUpOnce() {
+        Security.addProvider(new BouncyCastleProvider());
+    }
+
+    @Test
+    void testShouldCalculateHashOfPresentAttribute() {
+        final HashAlgorithm[] algorithms = HashAlgorithm.values();

Review Comment:
   Declaring this local variable is unnecessary.



##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/CryptographicHashContentTest.java:
##########
@@ -0,0 +1,246 @@
+/*
+ * 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.processors.standard;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.nifi.security.util.crypto.HashAlgorithm;
+import org.apache.nifi.security.util.crypto.HashService;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.security.Security;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+
+public class CryptographicHashContentTest {
+    @BeforeAll
+    static void setUpOnce() {
+        Security.addProvider(new BouncyCastleProvider());
+    }
+
+    @Test
+    void testShouldCalculateHashOfPresentContent() throws IOException {
+        final HashAlgorithm[] algorithms = HashAlgorithm.values();
+
+        // Generate some long content (90 KB)
+        final String LONG_CONTENT = StringUtils.repeat("apachenifi ", 8192);

Review Comment:
   This variable should be lowercased to follow standard conventions.



##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/CryptographicHashAttributeTest.java:
##########
@@ -0,0 +1,343 @@
+/*
+ * 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.processors.standard;
+
+import org.apache.nifi.security.util.crypto.HashAlgorithm;
+import org.apache.nifi.security.util.crypto.HashService;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.security.Security;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class CryptographicHashAttributeTest {
+    @BeforeAll
+    static void setUpOnce() {
+        Security.addProvider(new BouncyCastleProvider());
+    }
+
+    @Test
+    void testShouldCalculateHashOfPresentAttribute() {
+        final HashAlgorithm[] algorithms = HashAlgorithm.values();
+
+        final TestRunner runner = TestRunners.newTestRunner(new CryptographicHashAttribute());

Review Comment:
   This should be moved to a `setRunner()` method annotated with `BeforeEach`.



##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/SplitXmlTest.java:
##########
@@ -0,0 +1,50 @@
+/*
+ * 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.processors.standard;
+
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.nio.file.Paths;
+
+public class SplitXmlTest {
+    @Test
+    void testShouldHandleXXEInTemplate() throws IOException {
+        final String XXE_TEMPLATE_FILEPATH = "src/test/resources/xxe_template.xml";
+        final TestRunner runner = TestRunners.newTestRunner(new SplitXml());
+        runner.setProperty(SplitXml.SPLIT_DEPTH, "3");
+        runner.enqueue(Paths.get(XXE_TEMPLATE_FILEPATH));
+
+        runner.run();
+
+        runner.assertAllFlowFilesTransferred(SplitXml.REL_FAILURE);

Review Comment:
   Recommend moving this shared code to a new private method named something like `assertExternalEntitiesFailure()` and changing both test methods to call the shared method.



##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestFlattenJson.java:
##########
@@ -0,0 +1,520 @@
+/*
+ * 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.processors.standard;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class TestFlattenJson {
+    private static final ObjectMapper mapper = new ObjectMapper();
+
+    @Test
+    void testFlatten() throws JsonProcessingException {
+        final TestRunner testRunner = TestRunners.newTestRunner(FlattenJson.class);
+        final String json = "{\n" +
+                "    \"test\": {\n" +
+                "        \"msg\": \"Hello, world\"\n" +
+                "    },\n" +
+                "    \"first\": {\n" +
+                "        \"second\": {\n" +
+                "            \"third\": [\n" +
+                "                \"one\",\n" +
+                "                \"two\",\n" +
+                "                \"three\",\n" +
+                "                \"four\",\n" +
+                "                \"five\"\n" +
+                "            ]\n" +
+                "        }\n" +
+                "    }\n" +
+                "}";
+        final Map parsed = (Map) baseTest(testRunner, json, 2);
+        assertEquals(parsed.get("test.msg"), "Hello, world", "test.msg should exist, but doesn't");
+        assertEquals(parsed.get("first.second.third"),
+                Arrays.asList("one", "two", "three", "four", "five"),
+                "Three level block doesn't exist.");
+    }
+
+    private Object baseTest(TestRunner testRunner, String json, int keyCount) throws JsonProcessingException {
+        return baseTest(testRunner, json, Collections.emptyMap(), keyCount);
+    }
+
+    private Object baseTest(TestRunner testRunner, String json, Map attrs, int keyCount) throws JsonProcessingException {
+        testRunner.enqueue(json, attrs);
+        testRunner.run(1, true);
+        testRunner.assertTransferCount(FlattenJson.REL_FAILURE, 0);
+        testRunner.assertTransferCount(FlattenJson.REL_SUCCESS, 1);
+
+        final List<MockFlowFile> flowFiles = testRunner.getFlowFilesForRelationship(FlattenJson.REL_SUCCESS);
+        final byte[] content = testRunner.getContentAsByteArray(flowFiles.get(0));
+        final String asJson = new String(content);
+        if (asJson.startsWith("[")) {
+            final List parsed;
+            parsed = mapper.readValue(asJson, List.class);
+            assertEquals(keyCount, parsed.size(), "Too many keys");
+            return parsed;
+        } else {
+            final Map parsed;
+            parsed = mapper.readValue(asJson, Map.class);
+            assertEquals(keyCount, parsed.size(), "Too many keys");
+            return parsed;
+        }
+    }

Review Comment:
   All private methods should be moved to the end of the class, following standard conventions.



##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/CryptographicHashAttributeTest.java:
##########
@@ -0,0 +1,343 @@
+/*
+ * 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.processors.standard;
+
+import org.apache.nifi.security.util.crypto.HashAlgorithm;
+import org.apache.nifi.security.util.crypto.HashService;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.security.Security;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class CryptographicHashAttributeTest {
+    @BeforeAll
+    static void setUpOnce() {
+        Security.addProvider(new BouncyCastleProvider());
+    }
+
+    @Test
+    void testShouldCalculateHashOfPresentAttribute() {
+        final HashAlgorithm[] algorithms = HashAlgorithm.values();
+
+        final TestRunner runner = TestRunners.newTestRunner(new CryptographicHashAttribute());
+
+        // Create attributes for username and date
+
+        final Map<String, String> attributes = new HashMap<>();
+        attributes.put("username", "alopresto");
+        attributes.put("date", ZonedDateTime.now().format(DateTimeFormatter.ofPattern("YYYY-MM-dd HH:mm:ss.SSS Z")));
+
+        final Set<String> attributeKeys = attributes.keySet();
+
+        for (final HashAlgorithm algorithm : algorithms) {

Review Comment:
   ```suggestion
           for (final HashAlgorithm algorithm : HashAlgorithm.values()) {
   ```



##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/CryptographicHashContentTest.java:
##########
@@ -0,0 +1,246 @@
+/*
+ * 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.processors.standard;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.nifi.security.util.crypto.HashAlgorithm;
+import org.apache.nifi.security.util.crypto.HashService;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.security.Security;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+
+public class CryptographicHashContentTest {
+    @BeforeAll
+    static void setUpOnce() {
+        Security.addProvider(new BouncyCastleProvider());
+    }
+
+    @Test
+    void testShouldCalculateHashOfPresentContent() throws IOException {
+        final HashAlgorithm[] algorithms = HashAlgorithm.values();
+
+        // Generate some long content (90 KB)
+        final String LONG_CONTENT = StringUtils.repeat("apachenifi ", 8192);
+
+        final TestRunner runner = TestRunners.newTestRunner(new CryptographicHashContent());

Review Comment:
   Should be moved to a standard `BeforeEach` annotated method.



##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/CryptographicHashAttributeTest.java:
##########
@@ -0,0 +1,343 @@
+/*
+ * 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.processors.standard;
+
+import org.apache.nifi.security.util.crypto.HashAlgorithm;
+import org.apache.nifi.security.util.crypto.HashService;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.security.Security;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class CryptographicHashAttributeTest {
+    @BeforeAll
+    static void setUpOnce() {
+        Security.addProvider(new BouncyCastleProvider());
+    }
+
+    @Test
+    void testShouldCalculateHashOfPresentAttribute() {
+        final HashAlgorithm[] algorithms = HashAlgorithm.values();
+
+        final TestRunner runner = TestRunners.newTestRunner(new CryptographicHashAttribute());
+
+        // Create attributes for username and date
+
+        final Map<String, String> attributes = new HashMap<>();
+        attributes.put("username", "alopresto");
+        attributes.put("date", ZonedDateTime.now().format(DateTimeFormatter.ofPattern("YYYY-MM-dd HH:mm:ss.SSS Z")));
+
+        final Set<String> attributeKeys = attributes.keySet();
+
+        for (final HashAlgorithm algorithm : algorithms) {
+            final String EXPECTED_USERNAME_HASH = HashService.hashValue(algorithm, attributes.get("username"));
+            final String EXPECTED_DATE_HASH = HashService.hashValue(algorithm, attributes.get("date"));

Review Comment:
   These variable names should be lowercased following standard conventions for local variables.



-- 
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-unsubscribe@nifi.apache.org

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


[GitHub] [nifi] exceptionfactory commented on a diff in pull request #6321: NIFI-10344: refactored groovy tests in nifi-standard-processor to jav…

Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on code in PR #6321:
URL: https://github.com/apache/nifi/pull/6321#discussion_r951755408


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/CountTextTest.java:
##########
@@ -0,0 +1,316 @@
+/*
+ * 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.processors.standard;
+
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.util.MockComponentLog;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.Security;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+
+public class CountTextTest {
+    private static final String TLC = "text.line.count";
+    private static final String TLNEC = "text.line.nonempty.count";
+    private static final String TWC = "text.word.count";
+    private static final String TCC = "text.character.count";
+
+    @BeforeAll
+    static void setUpOnce() {
+        Security.addProvider(new BouncyCastleProvider());
+    }

Review Comment:
   This Security Provider configuration method is not necessary and should be removed from this particular test class.



-- 
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-unsubscribe@nifi.apache.org

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


[GitHub] [nifi] emiliosetiadarma commented on a diff in pull request #6321: NIFI-10344: refactored groovy tests in nifi-standard-processor to jav…

Posted by GitBox <gi...@apache.org>.
emiliosetiadarma commented on code in PR #6321:
URL: https://github.com/apache/nifi/pull/6321#discussion_r954327325


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/CryptographicHashAttributeTest.java:
##########
@@ -0,0 +1,343 @@
+/*
+ * 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.processors.standard;
+
+import org.apache.nifi.security.util.crypto.HashAlgorithm;
+import org.apache.nifi.security.util.crypto.HashService;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.security.Security;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class CryptographicHashAttributeTest {
+    @BeforeAll
+    static void setUpOnce() {
+        Security.addProvider(new BouncyCastleProvider());
+    }
+
+    @Test
+    void testShouldCalculateHashOfPresentAttribute() {
+        final HashAlgorithm[] algorithms = HashAlgorithm.values();
+
+        final TestRunner runner = TestRunners.newTestRunner(new CryptographicHashAttribute());

Review Comment:
   Making the changes



-- 
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-unsubscribe@nifi.apache.org

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


[GitHub] [nifi] emiliosetiadarma commented on a diff in pull request #6321: NIFI-10344: refactored groovy tests in nifi-standard-processor to jav…

Posted by GitBox <gi...@apache.org>.
emiliosetiadarma commented on code in PR #6321:
URL: https://github.com/apache/nifi/pull/6321#discussion_r954099159


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/CountTextTest.java:
##########
@@ -0,0 +1,316 @@
+/*
+ * 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.processors.standard;
+
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.util.MockComponentLog;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.security.Security;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.spy;
+
+public class CountTextTest {
+    private static final String TLC = "text.line.count";
+    private static final String TLNEC = "text.line.nonempty.count";
+    private static final String TWC = "text.word.count";
+    private static final String TCC = "text.character.count";
+
+    @BeforeAll
+    static void setUpOnce() {
+        Security.addProvider(new BouncyCastleProvider());
+    }

Review Comment:
   Removing it!



-- 
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-unsubscribe@nifi.apache.org

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


[GitHub] [nifi] exceptionfactory closed pull request #6321: NIFI-10344: refactored groovy tests in nifi-standard-processor to jav…

Posted by GitBox <gi...@apache.org>.
exceptionfactory closed pull request #6321: NIFI-10344: refactored groovy tests in nifi-standard-processor to jav…
URL: https://github.com/apache/nifi/pull/6321


-- 
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-unsubscribe@nifi.apache.org

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


[GitHub] [nifi] emiliosetiadarma commented on a diff in pull request #6321: NIFI-10344: refactored groovy tests in nifi-standard-processor to jav…

Posted by GitBox <gi...@apache.org>.
emiliosetiadarma commented on code in PR #6321:
URL: https://github.com/apache/nifi/pull/6321#discussion_r954348546


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/CryptographicHashAttributeTest.java:
##########
@@ -0,0 +1,343 @@
+/*
+ * 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.processors.standard;
+
+import org.apache.nifi.security.util.crypto.HashAlgorithm;
+import org.apache.nifi.security.util.crypto.HashService;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.bouncycastle.jce.provider.BouncyCastleProvider;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.security.Security;
+import java.time.ZonedDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class CryptographicHashAttributeTest {
+    @BeforeAll
+    static void setUpOnce() {
+        Security.addProvider(new BouncyCastleProvider());
+    }
+
+    @Test
+    void testShouldCalculateHashOfPresentAttribute() {
+        final HashAlgorithm[] algorithms = HashAlgorithm.values();

Review Comment:
   Making the changes



-- 
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-unsubscribe@nifi.apache.org

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


[GitHub] [nifi] emiliosetiadarma commented on a diff in pull request #6321: NIFI-10344: refactored groovy tests in nifi-standard-processor to jav…

Posted by GitBox <gi...@apache.org>.
emiliosetiadarma commented on code in PR #6321:
URL: https://github.com/apache/nifi/pull/6321#discussion_r954356927


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestFlattenJson.java:
##########
@@ -0,0 +1,520 @@
+/*
+ * 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.processors.standard;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.nifi.util.MockFlowFile;
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.jupiter.api.Test;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class TestFlattenJson {
+    private static final ObjectMapper mapper = new ObjectMapper();
+
+    @Test
+    void testFlatten() throws JsonProcessingException {
+        final TestRunner testRunner = TestRunners.newTestRunner(FlattenJson.class);
+        final String json = "{\n" +
+                "    \"test\": {\n" +
+                "        \"msg\": \"Hello, world\"\n" +
+                "    },\n" +
+                "    \"first\": {\n" +
+                "        \"second\": {\n" +
+                "            \"third\": [\n" +
+                "                \"one\",\n" +
+                "                \"two\",\n" +
+                "                \"three\",\n" +
+                "                \"four\",\n" +
+                "                \"five\"\n" +
+                "            ]\n" +
+                "        }\n" +
+                "    }\n" +
+                "}";
+        final Map parsed = (Map) baseTest(testRunner, json, 2);
+        assertEquals(parsed.get("test.msg"), "Hello, world", "test.msg should exist, but doesn't");
+        assertEquals(parsed.get("first.second.third"),
+                Arrays.asList("one", "two", "three", "four", "five"),
+                "Three level block doesn't exist.");
+    }
+
+    private Object baseTest(TestRunner testRunner, String json, int keyCount) throws JsonProcessingException {
+        return baseTest(testRunner, json, Collections.emptyMap(), keyCount);
+    }
+
+    private Object baseTest(TestRunner testRunner, String json, Map attrs, int keyCount) throws JsonProcessingException {
+        testRunner.enqueue(json, attrs);
+        testRunner.run(1, true);
+        testRunner.assertTransferCount(FlattenJson.REL_FAILURE, 0);
+        testRunner.assertTransferCount(FlattenJson.REL_SUCCESS, 1);
+
+        final List<MockFlowFile> flowFiles = testRunner.getFlowFilesForRelationship(FlattenJson.REL_SUCCESS);
+        final byte[] content = testRunner.getContentAsByteArray(flowFiles.get(0));
+        final String asJson = new String(content);
+        if (asJson.startsWith("[")) {
+            final List parsed;
+            parsed = mapper.readValue(asJson, List.class);
+            assertEquals(keyCount, parsed.size(), "Too many keys");
+            return parsed;
+        } else {
+            final Map parsed;
+            parsed = mapper.readValue(asJson, Map.class);
+            assertEquals(keyCount, parsed.size(), "Too many keys");
+            return parsed;
+        }
+    }

Review Comment:
   Moved it!



-- 
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-unsubscribe@nifi.apache.org

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


[GitHub] [nifi] emiliosetiadarma commented on a diff in pull request #6321: NIFI-10344: refactored groovy tests in nifi-standard-processor to jav…

Posted by GitBox <gi...@apache.org>.
emiliosetiadarma commented on code in PR #6321:
URL: https://github.com/apache/nifi/pull/6321#discussion_r954355634


##########
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/SplitXmlTest.java:
##########
@@ -0,0 +1,50 @@
+/*
+ * 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.processors.standard;
+
+import org.apache.nifi.util.TestRunner;
+import org.apache.nifi.util.TestRunners;
+import org.junit.jupiter.api.Test;
+
+import java.io.IOException;
+import java.nio.file.Paths;
+
+public class SplitXmlTest {
+    @Test
+    void testShouldHandleXXEInTemplate() throws IOException {
+        final String XXE_TEMPLATE_FILEPATH = "src/test/resources/xxe_template.xml";
+        final TestRunner runner = TestRunners.newTestRunner(new SplitXml());
+        runner.setProperty(SplitXml.SPLIT_DEPTH, "3");
+        runner.enqueue(Paths.get(XXE_TEMPLATE_FILEPATH));
+
+        runner.run();
+
+        runner.assertAllFlowFilesTransferred(SplitXml.REL_FAILURE);

Review Comment:
   Made the changes



-- 
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-unsubscribe@nifi.apache.org

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