Repository: nifi
Updated Branches:
  refs/heads/master b4a4cc564 -> c58b02518


NIFI-4916 - ConvertExcelToCSVProcessor inherit parent attributes. This closes 
#2500.

Signed-off-by: Mark Payne <marka...@hotmail.com>


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/c58b0251
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/c58b0251
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/c58b0251

Branch: refs/heads/master
Commit: c58b02518699c68bf73b77c70e563712db3fe12c
Parents: b4a4cc5
Author: Pierre Villard <pierre.villard...@gmail.com>
Authored: Wed Feb 28 18:22:14 2018 +0100
Committer: Mark Payne <marka...@hotmail.com>
Committed: Fri Mar 2 08:47:32 2018 -0500

----------------------------------------------------------------------
 .../nifi/processors/poi/ConvertExcelToCSVProcessor.java     | 2 +-
 .../nifi/processors/poi/ConvertExcelToCSVProcessorTest.java | 9 ++++++++-
 2 files changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/c58b0251/nifi-nar-bundles/nifi-poi-bundle/nifi-poi-processors/src/main/java/org/apache/nifi/processors/poi/ConvertExcelToCSVProcessor.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-poi-bundle/nifi-poi-processors/src/main/java/org/apache/nifi/processors/poi/ConvertExcelToCSVProcessor.java
 
b/nifi-nar-bundles/nifi-poi-bundle/nifi-poi-processors/src/main/java/org/apache/nifi/processors/poi/ConvertExcelToCSVProcessor.java
index 1e0df88..f05312b 100644
--- 
a/nifi-nar-bundles/nifi-poi-bundle/nifi-poi-processors/src/main/java/org/apache/nifi/processors/poi/ConvertExcelToCSVProcessor.java
+++ 
b/nifi-nar-bundles/nifi-poi-bundle/nifi-poi-processors/src/main/java/org/apache/nifi/processors/poi/ConvertExcelToCSVProcessor.java
@@ -292,7 +292,7 @@ public class ConvertExcelToCSVProcessor
     private void handleExcelSheet(ProcessSession session, FlowFile 
originalParentFF, final InputStream sheetInputStream, ExcelSheetReadConfig 
readConfig,
                                   CSVFormat csvFormat) throws IOException {
 
-        FlowFile ff = session.create();
+        FlowFile ff = session.create(originalParentFF);
         try {
             final DataFormatter formatter = new DataFormatter();
             final InputSource sheetSource = new InputSource(sheetInputStream);

http://git-wip-us.apache.org/repos/asf/nifi/blob/c58b0251/nifi-nar-bundles/nifi-poi-bundle/nifi-poi-processors/src/test/java/org/apache/nifi/processors/poi/ConvertExcelToCSVProcessorTest.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-poi-bundle/nifi-poi-processors/src/test/java/org/apache/nifi/processors/poi/ConvertExcelToCSVProcessorTest.java
 
b/nifi-nar-bundles/nifi-poi-bundle/nifi-poi-processors/src/test/java/org/apache/nifi/processors/poi/ConvertExcelToCSVProcessorTest.java
index 9e9131f..193b566 100644
--- 
a/nifi-nar-bundles/nifi-poi-bundle/nifi-poi-processors/src/test/java/org/apache/nifi/processors/poi/ConvertExcelToCSVProcessorTest.java
+++ 
b/nifi-nar-bundles/nifi-poi-bundle/nifi-poi-processors/src/test/java/org/apache/nifi/processors/poi/ConvertExcelToCSVProcessorTest.java
@@ -20,7 +20,9 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.nifi.csv.CSVUtils;
 import org.apache.nifi.flowfile.attributes.CoreAttributes;
@@ -44,7 +46,10 @@ public class ConvertExcelToCSVProcessorTest {
     @Test
     public void testMultipleSheetsGeneratesMultipleFlowFiles() throws 
Exception {
 
-        testRunner.enqueue(new 
File("src/test/resources/TwoSheets.xlsx").toPath());
+        Map<String, String> attributes = new HashMap<String, String>();
+        attributes.put("test", "attribute");
+
+        testRunner.enqueue(new 
File("src/test/resources/TwoSheets.xlsx").toPath(), attributes);
         testRunner.run();
 
         testRunner.assertTransferCount(ConvertExcelToCSVProcessor.SUCCESS, 2);
@@ -59,6 +64,7 @@ public class ConvertExcelToCSVProcessorTest {
 
         //Since TestRunner.run() will create a random filename even if the 
attribute is set in enqueue manually we just check that "_{SHEETNAME}.csv is 
present
         
assertTrue(ffSheetA.getAttribute(CoreAttributes.FILENAME.key()).endsWith("_TestSheetA.csv"));
+        assertTrue(ffSheetA.getAttribute("test").equals("attribute"));
 
         MockFlowFile ffSheetB = 
testRunner.getFlowFilesForRelationship(ConvertExcelToCSVProcessor.SUCCESS).get(1);
         Long rowsSheetB = new 
Long(ffSheetB.getAttribute(ConvertExcelToCSVProcessor.ROW_NUM));
@@ -68,6 +74,7 @@ public class ConvertExcelToCSVProcessorTest {
 
         //Since TestRunner.run() will create a random filename even if the 
attribute is set in enqueue manually we just check that "_{SHEETNAME}.csv is 
present
         
assertTrue(ffSheetB.getAttribute(CoreAttributes.FILENAME.key()).endsWith("_TestSheetB.csv"));
+        assertTrue(ffSheetB.getAttribute("test").equals("attribute"));
 
     }
 

Reply via email to