nifi-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvwing <...@git.apache.org>
Subject [GitHub] nifi pull request #929: NIFI-2613 - Apache POI processor to convert Excel do...
Date Thu, 16 Feb 2017 00:15:52 GMT
Github user jvwing commented on a diff in the pull request:

    https://github.com/apache/nifi/pull/929#discussion_r101416358
  
    --- Diff: nifi-nar-bundles/nifi-poi-bundle/nifi-poi-processors/src/test/java/org/apache/nifi/processors/poi/ConvertExcelToCSVProcessorTest.java
---
    @@ -0,0 +1,90 @@
    +/*
    + * 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.poi;
    +
    +import static org.junit.Assert.assertTrue;
    +
    +import java.io.File;
    +
    +import org.apache.nifi.util.MockFlowFile;
    +import org.apache.nifi.util.TestRunner;
    +import org.apache.nifi.util.TestRunners;
    +import org.junit.Before;
    +import org.junit.Test;
    +
    +public class ConvertExcelToCSVProcessorTest {
    +
    +    private TestRunner testRunner;
    +
    +    @Before
    +    public void init() {
    +        testRunner = TestRunners.newTestRunner(ConvertExcelToCSVProcessor.class);
    +    }
    +
    +    @Test
    +    public void testProcessAllSheets() throws Exception {
    +
    +        testRunner.enqueue(new File("src/test/resources/CollegeScorecard.xlsx").toPath());
    +        testRunner.run();
    +
    +        testRunner.assertTransferCount(ConvertExcelToCSVProcessor.SUCCESS, 1);
    +        testRunner.assertTransferCount(ConvertExcelToCSVProcessor.ORIGINAL, 1);
    +        testRunner.assertTransferCount(ConvertExcelToCSVProcessor.FAILURE, 0);
    +
    +        MockFlowFile ff = testRunner.getFlowFilesForRelationship(ConvertExcelToCSVProcessor.SUCCESS).get(0);
    +        Long l = new Long(ff.getAttribute(ConvertExcelToCSVProcessor.ROW_NUM));
    +        assertTrue(l == 7805l);
    +    }
    +
    +    @Test
    +    public void testProcessASpecificSheetThatDoesNotExist() throws Exception {
    +
    +        testRunner.setProperty(ConvertExcelToCSVProcessor.DESIRED_SHEETS, "Scorecard");
    +        testRunner.enqueue(new File("src/test/resources/CollegeScorecard.xlsx").toPath());
    +        testRunner.run();
    +
    +        testRunner.assertTransferCount(ConvertExcelToCSVProcessor.SUCCESS, 1);
    +        testRunner.assertTransferCount(ConvertExcelToCSVProcessor.ORIGINAL, 1);
    +        testRunner.assertTransferCount(ConvertExcelToCSVProcessor.FAILURE, 0);
    +
    +        MockFlowFile ff = testRunner.getFlowFilesForRelationship(ConvertExcelToCSVProcessor.SUCCESS).get(0);
    +        Long l = new Long(ff.getAttribute(ConvertExcelToCSVProcessor.ROW_NUM));
    +        assertTrue(l == 7805l);
    +    }
    +
    +    /**
    +     * We do want to allow this to be a success relationship because if arbitrary Excel
    --- End diff --
    
    Seems like a cliffhanger comment, I would like to read the ending :)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message