This is an automated email from the ASF dual-hosted git repository.
joewitt 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 b90a6e8 NIFI-7906 This closes #4701. Updated test case to fix a
windows-centric bug. NIFI-7906 Removed unused test code.
b90a6e8 is described below
commit b90a6e893d4920a0e1038ad286b96520d74ab070
Author: Mike Thomsen <[email protected]>
AuthorDate: Wed Dec 2 11:50:26 2020 -0500
NIFI-7906 This closes #4701. Updated test case to fix a windows-centric bug.
NIFI-7906 Removed unused test code.
Signed-off-by: Joe Witt <[email protected]>
---
.../graph/ExecuteGraphQueryRecordTest.java | 28 ++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git
a/nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/test/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecordTest.java
b/nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/test/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecordTest.java
index 8c6cb96..7c260b2 100644
---
a/nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/test/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecordTest.java
+++
b/nifi-nar-bundles/nifi-graph-bundle/nifi-graph-processors/src/test/java/org/apache/nifi/processors/graph/ExecuteGraphQueryRecordTest.java
@@ -16,7 +16,9 @@
*/
package org.apache.nifi.processors.graph;
+import com.fasterxml.jackson.databind.ObjectMapper;
import groovy.json.JsonOutput;
+import org.apache.commons.io.IOUtils;
import org.apache.nifi.processors.graph.util.InMemoryGraphClient;
import org.apache.nifi.reporting.InitializationException;
import org.apache.nifi.util.MockFlowFile;
@@ -28,11 +30,15 @@ import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.HashMap;
import java.util.List;
import java.util.ArrayList;
+import static org.junit.Assert.assertTrue;
+
public class ExecuteGraphQueryRecordTest {
private TestRunner runner;
private JsonTreeReader reader;
@@ -85,7 +91,8 @@ public class ExecuteGraphQueryRecordTest {
runner.assertTransferCount(ExecuteGraphQueryRecord.SUCCESS, 1);
runner.assertTransferCount(ExecuteGraphQueryRecord.FAILURE, 0);
MockFlowFile relGraph =
runner.getFlowFilesForRelationship(ExecuteGraphQueryRecord.GRAPH).get(0);
-
relGraph.assertContentEquals(ExecuteGraphQueryRecordTest.class.getResourceAsStream("/testFlowFileContent.json"));
+
+ assertTrue(contentEqualsWindowsSafe(relGraph,
"/testFlowFileContent.json"));
}
@Test
@@ -115,7 +122,8 @@ public class ExecuteGraphQueryRecordTest {
runner.assertTransferCount(ExecuteGraphQueryRecord.SUCCESS, 1);
runner.assertTransferCount(ExecuteGraphQueryRecord.FAILURE, 0);
MockFlowFile relGraph =
runner.getFlowFilesForRelationship(ExecuteGraphQueryRecord.GRAPH).get(0);
-
relGraph.assertContentEquals(ExecuteGraphQueryRecordTest.class.getResourceAsStream("/testFlowFileList.json"));
+
+ assertTrue(contentEqualsWindowsSafe(relGraph,
"/testFlowFileList.json"));
}
@Test
@@ -146,7 +154,8 @@ public class ExecuteGraphQueryRecordTest {
runner.assertTransferCount(ExecuteGraphQueryRecord.SUCCESS, 1);
runner.assertTransferCount(ExecuteGraphQueryRecord.FAILURE, 0);
MockFlowFile relGraph =
runner.getFlowFilesForRelationship(ExecuteGraphQueryRecord.GRAPH).get(0);
-
relGraph.assertContentEquals(ExecuteGraphQueryRecordTest.class.getResourceAsStream("/testComplexFlowFile.json"));
+
+ assertTrue(contentEqualsWindowsSafe(relGraph,
"/testComplexFlowFile.json"));
}
@Test
@@ -170,7 +179,18 @@ public class ExecuteGraphQueryRecordTest {
runner.assertTransferCount(ExecuteGraphQueryRecord.SUCCESS, 1);
runner.assertTransferCount(ExecuteGraphQueryRecord.FAILURE, 0);
MockFlowFile relGraph =
runner.getFlowFilesForRelationship(ExecuteGraphQueryRecord.GRAPH).get(0);
-
relGraph.assertContentEquals(ExecuteGraphQueryRecordTest.class.getResourceAsStream("/testAttributes.json"));
+
+ assertTrue(contentEqualsWindowsSafe(relGraph, "/testAttributes.json"));
}
+ private boolean contentEqualsWindowsSafe(MockFlowFile flowFile, String
expectedPath) throws IOException {
+ InputStream is =
ExecuteGraphQueryRecordTest.class.getResourceAsStream(expectedPath);
+ String expectedRaw = IOUtils.toString(is, StandardCharsets.UTF_8);
+ String contentRaw = new String(runner.getContentAsByteArray(flowFile));
+ ObjectMapper mapper = new ObjectMapper();
+ List<Map<String, Object>> expected = mapper.readValue(expectedRaw,
List.class);
+ List<Map<String, Object>> content = mapper.readValue(contentRaw,
List.class);
+
+ return expected.equals(content);
+ }
}