You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by ex...@apache.org on 2023/01/25 22:19:46 UTC

[nifi] branch main updated: NIFI-10928 Updated MockFlowFile with LinkedHashMap for attributes

This is an automated email from the ASF dual-hosted git repository.

exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new b3f2d95092 NIFI-10928 Updated MockFlowFile with LinkedHashMap for attributes
b3f2d95092 is described below

commit b3f2d95092f68e0077296a9bc9c7536f615769e1
Author: Priyanka Awatramani <52...@users.noreply.github.com>
AuthorDate: Thu Dec 1 21:27:10 2022 -0600

    NIFI-10928 Updated MockFlowFile with LinkedHashMap for attributes
    
    - Updated TestAttributesToCSV with LinkedHashMap for deterministic test behavior
    - Updated TestHttpFlowFileServerProtocol with adjusted checksums to match expectations from LinkedHashMap changes
    
    This closes #6748
    
    Signed-off-by: David Handermann <ex...@apache.org>
---
 nifi-mock/src/main/java/org/apache/nifi/util/MockFlowFile.java   | 5 +++--
 .../remote/protocol/http/TestHttpFlowFileServerProtocol.java     | 4 ++--
 .../org/apache/nifi/processors/standard/AttributesToCSV.java     | 2 +-
 .../org/apache/nifi/processors/standard/TestAttributesToCSV.java | 9 +++++----
 4 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/nifi-mock/src/main/java/org/apache/nifi/util/MockFlowFile.java b/nifi-mock/src/main/java/org/apache/nifi/util/MockFlowFile.java
index 52c20e08fd..f5702daed1 100644
--- a/nifi-mock/src/main/java/org/apache/nifi/util/MockFlowFile.java
+++ b/nifi-mock/src/main/java/org/apache/nifi/util/MockFlowFile.java
@@ -28,11 +28,12 @@ import java.nio.file.Path;
 import java.nio.file.StandardOpenOption;
 import java.util.Arrays;
 import java.util.Collections;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Set;
 import java.util.UUID;
+
 import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.apache.nifi.controller.repository.FlowFileRecord;
 import org.apache.nifi.controller.repository.claim.ContentClaim;
@@ -42,7 +43,7 @@ import org.junit.jupiter.api.Assertions;
 
 public class MockFlowFile implements FlowFileRecord {
 
-    private final Map<String, String> attributes = new HashMap<>();
+    private final Map<String, String> attributes = new LinkedHashMap<>();
 
     private final long id;
     private final long entryDate;
diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/src/test/java/org/apache/nifi/remote/protocol/http/TestHttpFlowFileServerProtocol.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/src/test/java/org/apache/nifi/remote/protocol/http/TestHttpFlowFileServerProtocol.java
index 7f6b5ee288..1a18507232 100644
--- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/src/test/java/org/apache/nifi/remote/protocol/http/TestHttpFlowFileServerProtocol.java
+++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/src/test/java/org/apache/nifi/remote/protocol/http/TestHttpFlowFileServerProtocol.java
@@ -282,7 +282,7 @@ public class TestHttpFlowFileServerProtocol {
         });
 
         // Commit transaction
-        final int flowFileSent = serverProtocol.commitTransferTransaction(peer, "3229577812");
+        final int flowFileSent = serverProtocol.commitTransferTransaction(peer, "1853411835");
         assertEquals(1, flowFileSent);
 
         // Assert provenance
@@ -378,7 +378,7 @@ public class TestHttpFlowFileServerProtocol {
         );
 
         // Commit transaction
-        final int flowFileSent = serverProtocol.commitTransferTransaction(peer, "3058746557");
+        final int flowFileSent = serverProtocol.commitTransferTransaction(peer, "2295235398");
         assertEquals(2, flowFileSent);
 
         // Assert provenance (SEND and DROP)
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/AttributesToCSV.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/AttributesToCSV.java
index 4859d41c9d..1d93497fb0 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/AttributesToCSV.java
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/AttributesToCSV.java
@@ -271,7 +271,7 @@ public class AttributesToCSV extends AbstractProcessor {
     @OnScheduled
     public void onScheduled(ProcessContext context) {
         includeCoreAttributes = context.getProperty(INCLUDE_CORE_ATTRIBUTES).asBoolean();
-        coreAttributes = Arrays.stream(CoreAttributes.values()).map(CoreAttributes::key).collect(Collectors.toSet());
+        coreAttributes = Arrays.stream(CoreAttributes.values()).map(CoreAttributes::key).collect(Collectors.toCollection(LinkedHashSet::new));
         destinationContent = OUTPUT_OVERWRITE_CONTENT.getValue().equals(context.getProperty(DESTINATION).getValue());
         nullValForEmptyString = context.getProperty(NULL_VALUE_FOR_EMPTY_STRING).asBoolean();
         includeSchema = context.getProperty(INCLUDE_SCHEMA).asBoolean();
diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestAttributesToCSV.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestAttributesToCSV.java
index e98f04a61a..1a02e7e35f 100644
--- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestAttributesToCSV.java
+++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestAttributesToCSV.java
@@ -25,6 +25,7 @@ import org.junit.jupiter.api.Test;
 
 import java.io.IOException;
 import java.util.Arrays;
+import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.HashMap;
 import java.util.Set;
@@ -689,7 +690,7 @@ public class TestAttributesToCSV {
         testRunner.setProperty(AttributesToCSV.INCLUDE_SCHEMA, "true");
         testRunner.setProperty(AttributesToCSV.ATTRIBUTES_REGEX, "beach-.*");
 
-        Map<String, String> attrs = new HashMap<String, String>(){{
+        Map<String, String> attrs = new LinkedHashMap<String, String>(){{
             put("beach-name", "Malibu Beach");
             put("beach-location", "California, US");
             put("attribute-should-be-eliminated", "This should not be in CSVData!");
@@ -721,7 +722,7 @@ public class TestAttributesToCSV {
         testRunner.setProperty(AttributesToCSV.INCLUDE_SCHEMA, "true");
         testRunner.setProperty(AttributesToCSV.ATTRIBUTES_REGEX, "beach-.*");
 
-        Map<String, String> attrs = new HashMap<String, String>(){{
+        Map<String, String> attrs = new LinkedHashMap<String, String>(){{
             put("beach-name", "Malibu Beach");
             put("beach-location", "California, US");
             put("attribute-should-be-eliminated", "This should not be in CSVData!");
@@ -754,7 +755,7 @@ public class TestAttributesToCSV {
         testRunner.setProperty(AttributesToCSV.INCLUDE_SCHEMA, "true");
         testRunner.setProperty(AttributesToCSV.ATTRIBUTES_REGEX, "beach-.*");
 
-        Map<String, String> attrs = new HashMap<String, String>(){{
+        Map<String, String> attrs = new LinkedHashMap<String, String>(){{
             put("beach-name", "Malibu Beach");
             put("beach-location", "California, US");
             put("attribute-should-be-eliminated", "This should not be in CSVData!");
@@ -788,7 +789,7 @@ public class TestAttributesToCSV {
         testRunner.setProperty(AttributesToCSV.INCLUDE_SCHEMA, "true");
         testRunner.setProperty(AttributesToCSV.ATTRIBUTES_REGEX, "beach-.*");
 
-        Map<String, String> attrs = new HashMap<String, String>(){{
+        Map<String, String> attrs = new LinkedHashMap<String, String>(){{
             put("beach-name", "Malibu Beach");
             put("beach-location", "California, US");
             put("attribute-should-be-eliminated", "This should not be in CSVData!");