[GitHub] nifi pull request #2745: NIFI-5245: SimpleCSVFileLookupService should take a...

2018-05-30 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/nifi/pull/2745


---


[GitHub] nifi pull request #2745: NIFI-5245: SimpleCSVFileLookupService should take a...

2018-05-29 Thread MikeThomsen
Github user MikeThomsen commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2745#discussion_r191388975
  
--- Diff: 
nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/test/java/org/apache/nifi/lookup/TestSimpleCsvFileLookupService.java
 ---
@@ -64,4 +64,28 @@ public void testSimpleCsvFileLookupService() throws 
InitializationException, IOE
 assertEquals(EMPTY_STRING, property3);
 }
 
+@Test
+public void testSimpleCsvFileLookupServiceWithCharset() throws 
InitializationException, IOException, LookupFailureException {
+final TestRunner runner = 
TestRunners.newTestRunner(TestProcessor.class);
+final SimpleCsvFileLookupService service = new 
SimpleCsvFileLookupService();
+
+runner.addControllerService("csv-file-lookup-service", service);
+runner.setProperty(service, SimpleCsvFileLookupService.CSV_FILE, 
"src/test/resources/test_Windows-31J.csv");
+runner.setProperty(service, SimpleCsvFileLookupService.CSV_FORMAT, 
"RFC4180");
+runner.setProperty(service, SimpleCsvFileLookupService.CHARSET, 
"Windows-31J");
+runner.setProperty(service, 
SimpleCsvFileLookupService.LOOKUP_KEY_COLUMN, "key");
+runner.setProperty(service, 
SimpleCsvFileLookupService.LOOKUP_VALUE_COLUMN, "value");
+runner.enableControllerService(service);
+runner.assertValid(service);
+
+final SimpleCsvFileLookupService lookupService =
--- End diff --

These blocks can be removed.


---


[GitHub] nifi pull request #2745: NIFI-5245: SimpleCSVFileLookupService should take a...

2018-05-29 Thread MikeThomsen
Github user MikeThomsen commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2745#discussion_r191389306
  
--- Diff: 
nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/test/java/org/apache/nifi/lookup/TestSimpleCsvFileLookupService.java
 ---
@@ -64,4 +64,28 @@ public void testSimpleCsvFileLookupService() throws 
InitializationException, IOE
 assertEquals(EMPTY_STRING, property3);
 }
 
+@Test
+public void testSimpleCsvFileLookupServiceWithCharset() throws 
InitializationException, IOException, LookupFailureException {
+final TestRunner runner = 
TestRunners.newTestRunner(TestProcessor.class);
+final SimpleCsvFileLookupService service = new 
SimpleCsvFileLookupService();
+
+runner.addControllerService("csv-file-lookup-service", service);
+runner.setProperty(service, SimpleCsvFileLookupService.CSV_FILE, 
"src/test/resources/test_Windows-31J.csv");
+runner.setProperty(service, SimpleCsvFileLookupService.CSV_FORMAT, 
"RFC4180");
+runner.setProperty(service, SimpleCsvFileLookupService.CHARSET, 
"Windows-31J");
+runner.setProperty(service, 
SimpleCsvFileLookupService.LOOKUP_KEY_COLUMN, "key");
+runner.setProperty(service, 
SimpleCsvFileLookupService.LOOKUP_VALUE_COLUMN, "value");
+runner.enableControllerService(service);
+runner.assertValid(service);
+
+final SimpleCsvFileLookupService lookupService =
+(SimpleCsvFileLookupService) runner.getProcessContext()
+.getControllerServiceLookup()
+.getControllerService("csv-file-lookup-service");
+
+assertThat(lookupService, instanceOf(LookupService.class));
+
+final Optional property1 = 
lookupService.lookup(Collections.singletonMap("key", "property.1"));
+assertEquals(Optional.of("this is property \uff11"), property1);
--- End diff --

Add `assertTrue(property1.isPresent())` so the test will cleanly fail the 
evaluation if it's not present.


---


[GitHub] nifi pull request #2745: NIFI-5245: SimpleCSVFileLookupService should take a...

2018-05-29 Thread MikeThomsen
Github user MikeThomsen commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2745#discussion_r191388864
  
--- Diff: 
nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/test/java/org/apache/nifi/lookup/TestCSVRecordLookupService.java
 ---
@@ -66,4 +66,30 @@ public void testSimpleCsvFileLookupService() throws 
InitializationException, IOE
 assertEquals(EMPTY_RECORD, property3);
 }
 
+@Test
+public void testSimpleCsvFileLookupServiceWithCharset() throws 
InitializationException, IOException, LookupFailureException {
+final TestRunner runner = 
TestRunners.newTestRunner(TestProcessor.class);
+final CSVRecordLookupService service = new 
CSVRecordLookupService();
+
+runner.addControllerService("csv-file-lookup-service", service);
+runner.setProperty(service, CSVRecordLookupService.CSV_FILE, 
"src/test/resources/test_Windows-31J.csv");
+runner.setProperty(service, CSVRecordLookupService.CSV_FORMAT, 
"RFC4180");
+runner.setProperty(service, CSVRecordLookupService.CHARSET, 
"Windows-31J");
+runner.setProperty(service, 
CSVRecordLookupService.LOOKUP_KEY_COLUMN, "key");
+runner.enableControllerService(service);
+runner.assertValid(service);
+
+final CSVRecordLookupService lookupService =
+(CSVRecordLookupService) runner.getProcessContext()
+.getControllerServiceLookup()
+.getControllerService("csv-file-lookup-service");
+
+assertThat(lookupService, instanceOf(LookupService.class));
--- End diff --

Neither is this. If you can successfully add it to the test runner and 
enable it, you're good to go on this.


---


[GitHub] nifi pull request #2745: NIFI-5245: SimpleCSVFileLookupService should take a...

2018-05-29 Thread MikeThomsen
Github user MikeThomsen commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2745#discussion_r191388796
  
--- Diff: 
nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/test/java/org/apache/nifi/lookup/TestCSVRecordLookupService.java
 ---
@@ -66,4 +66,30 @@ public void testSimpleCsvFileLookupService() throws 
InitializationException, IOE
 assertEquals(EMPTY_RECORD, property3);
 }
 
+@Test
+public void testSimpleCsvFileLookupServiceWithCharset() throws 
InitializationException, IOException, LookupFailureException {
+final TestRunner runner = 
TestRunners.newTestRunner(TestProcessor.class);
+final CSVRecordLookupService service = new 
CSVRecordLookupService();
+
+runner.addControllerService("csv-file-lookup-service", service);
+runner.setProperty(service, CSVRecordLookupService.CSV_FILE, 
"src/test/resources/test_Windows-31J.csv");
+runner.setProperty(service, CSVRecordLookupService.CSV_FORMAT, 
"RFC4180");
+runner.setProperty(service, CSVRecordLookupService.CHARSET, 
"Windows-31J");
+runner.setProperty(service, 
CSVRecordLookupService.LOOKUP_KEY_COLUMN, "key");
+runner.enableControllerService(service);
+runner.assertValid(service);
+
+final CSVRecordLookupService lookupService =
--- End diff --

This isn't necessary.


---


[GitHub] nifi pull request #2745: NIFI-5245: SimpleCSVFileLookupService should take a...

2018-05-29 Thread MikeThomsen
Github user MikeThomsen commented on a diff in the pull request:

https://github.com/apache/nifi/pull/2745#discussion_r191389134
  
--- Diff: 
nifi-nar-bundles/nifi-standard-services/nifi-lookup-services-bundle/nifi-lookup-services/src/test/java/org/apache/nifi/lookup/TestCSVRecordLookupService.java
 ---
@@ -66,4 +66,30 @@ public void testSimpleCsvFileLookupService() throws 
InitializationException, IOE
 assertEquals(EMPTY_RECORD, property3);
 }
 
+@Test
+public void testSimpleCsvFileLookupServiceWithCharset() throws 
InitializationException, IOException, LookupFailureException {
+final TestRunner runner = 
TestRunners.newTestRunner(TestProcessor.class);
+final CSVRecordLookupService service = new 
CSVRecordLookupService();
+
+runner.addControllerService("csv-file-lookup-service", service);
+runner.setProperty(service, CSVRecordLookupService.CSV_FILE, 
"src/test/resources/test_Windows-31J.csv");
+runner.setProperty(service, CSVRecordLookupService.CSV_FORMAT, 
"RFC4180");
+runner.setProperty(service, CSVRecordLookupService.CHARSET, 
"Windows-31J");
+runner.setProperty(service, 
CSVRecordLookupService.LOOKUP_KEY_COLUMN, "key");
+runner.enableControllerService(service);
+runner.assertValid(service);
+
+final CSVRecordLookupService lookupService =
+(CSVRecordLookupService) runner.getProcessContext()
+.getControllerServiceLookup()
+.getControllerService("csv-file-lookup-service");
+
+assertThat(lookupService, instanceOf(LookupService.class));
+
+final Optional property1 = 
lookupService.lookup(Collections.singletonMap("key", "property.1"));
+assertEquals("this is property \uff11", 
property1.get().getAsString("value"));
--- End diff --

I would recommend adding `assertTrue(property1.isPresent())`.


---


[GitHub] nifi pull request #2745: NIFI-5245: SimpleCSVFileLookupService should take a...

2018-05-28 Thread ssogabe
GitHub user ssogabe opened a pull request:

https://github.com/apache/nifi/pull/2745

NIFI-5245: SimpleCSVFileLookupService should take account of charset

Thank you for submitting a contribution to Apache NiFi.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

### For all changes:
- [ ] Is there a JIRA ticket associated with this PR? Is it referenced 
 in the commit message?

- [ ] Does your PR title start with NIFI- where  is the JIRA number 
you are trying to resolve? Pay particular attention to the hyphen "-" character.

- [ ] Has your PR been rebased against the latest commit within the target 
branch (typically master)?

- [ ] Is your initial contribution a single, squashed commit?

### For code changes:
- [ ] Have you ensured that the full suite of tests is executed via mvn 
-Pcontrib-check clean install at the root nifi folder?
- [ ] Have you written or updated unit tests to verify your changes?
- [ ] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)? 
- [ ] If applicable, have you updated the LICENSE file, including the main 
LICENSE file under nifi-assembly?
- [ ] If applicable, have you updated the NOTICE file, including the main 
NOTICE file found under nifi-assembly?
- [ ] If adding new Properties, have you added .displayName in addition to 
.name (programmatic access) for each of the new properties?

### For documentation related changes:
- [ ] Have you ensured that format looks appropriate for the output in 
which it is rendered?

### Note:
Please ensure that once the PR is submitted, you check travis-ci for build 
issues and submit an update to your PR as soon as possible.


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/ssogabe/nifi NiFi-5245

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/nifi/pull/2745.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #2745


commit 025eec69d6fa19767077b9bbef2271a66e7969ba
Author: Seiji Sogabe 
Date:   2018-05-29T01:55:51Z

NIFI-5245: SimpleCSVFileLookupService should take account of charset




---