[
https://issues.apache.org/jira/browse/NIFI-2369?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15431742#comment-15431742
]
ASF GitHub Bot commented on NIFI-2369:
--------------------------------------
Github user mattyb149 commented on a diff in the pull request:
https://github.com/apache/nifi/pull/709#discussion_r75773057
--- Diff:
nifi-nar-bundles/nifi-kite-bundle/nifi-kite-processors/src/test/java/org/apache/nifi/processors/kite/TestCSVToAvroProcessor.java
---
@@ -191,57 +192,40 @@ public void testEmptyContent() throws IOException {
}
@Test
- public void testCSVProperties() throws IOException {
+ public void testBasicConversionNoErrors() throws IOException {
TestRunner runner =
TestRunners.newTestRunner(ConvertCSVToAvro.class);
- ConvertCSVToAvro processor = new ConvertCSVToAvro();
- ProcessContext context = runner.getProcessContext();
-
- // check defaults
- processor.createCSVProperties(context);
- Assert.assertEquals("Charset should match",
- "utf8", processor.props.charset);
- Assert.assertEquals("Delimiter should match",
- ",", processor.props.delimiter);
- Assert.assertEquals("Quote should match",
- "\"", processor.props.quote);
- Assert.assertEquals("Escape should match",
- "\\", processor.props.escape);
- Assert.assertEquals("Header flag should match",
- false, processor.props.useHeader);
- Assert.assertEquals("Lines to skip should match",
- 0, processor.props.linesToSkip);
+ runner.assertNotValid();
+ runner.setProperty(ConvertCSVToAvro.SCHEMA, SCHEMA.toString());
+ runner.assertValid();
- runner.setProperty(ConvertCSVToAvro.CHARSET, "utf16");
- runner.setProperty(ConvertCSVToAvro.DELIMITER, "|");
- runner.setProperty(ConvertCSVToAvro.QUOTE, "'");
- runner.setProperty(ConvertCSVToAvro.ESCAPE, "\u2603");
- runner.setProperty(ConvertCSVToAvro.HAS_HEADER, "true");
- runner.setProperty(ConvertCSVToAvro.LINES_TO_SKIP, "2");
-
- // check updates
- processor.createCSVProperties(context);
- Assert.assertEquals("Charset should match",
- "utf16", processor.props.charset);
- Assert.assertEquals("Delimiter should match",
- "|", processor.props.delimiter);
- Assert.assertEquals("Quote should match",
- "'", processor.props.quote);
- Assert.assertEquals("Escape should match",
- "\u2603", processor.props.escape);
- Assert.assertEquals("Header flag should match",
- true, processor.props.useHeader);
- Assert.assertEquals("Lines to skip should match",
- 2, processor.props.linesToSkip);
+ runner.enqueue(streamFor("1,green\n2,blue,\n3,grey,12.95"));
+ runner.run();
+
+ long converted = runner.getCounterValue("Converted records");
+ long errors = runner.getCounterValue("Conversion errors");
+ Assert.assertEquals("Should convert 3 rows", 3, converted);
+ Assert.assertEquals("Should reject 0 row", 0, errors);
+
+ runner.assertTransferCount("success", 1);
+ runner.assertTransferCount("failure", 0);
+ runner.assertTransferCount("incompatible", 0);
}
@Test
- public void testBasicConversionNoErrors() throws IOException {
+ public void testExpresionLanguageBasedCSVProperties() throws
IOException {
--- End diff --
Minor typo in test name here
> ConvertCSVtoAvro should allow EL for CSV Properties
> ---------------------------------------------------
>
> Key: NIFI-2369
> URL: https://issues.apache.org/jira/browse/NIFI-2369
> Project: Apache NiFi
> Issue Type: Improvement
> Components: Extensions
> Affects Versions: 0.6.1
> Environment: N/A
> Reporter: Simon Elliston Ball
> Assignee: Joseph Witt
> Priority: Minor
> Labels: starter
> Attachments: ConvertCSVAvro_-_Delimiter_Example.xml
>
>
> When creating a common processing flow, it would be useful to be able to
> parameterise the CSV properties, delimiter, quote and escape characters and
> other processing settings. It should be possible to set these based on
> attributes of the incoming CSV file.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)