NIFI-6172 Fixed a bug that caused ElasticSearchStringLookupService to always return a value even when it should return Optional.empty().

NIFI-6172 Fixed broken integration test.

Signed-off-by: Matthew Burgess <mattyb149@apache.org>

This closes #3399
This commit is contained in:
Mike Thomsen 2019-04-02 10:32:36 -04:00 committed by Matthew Burgess
parent d372318d47
commit 4810f6d32e
2 changed files with 6 additions and 2 deletions

View File

@ -88,7 +88,11 @@ public class ElasticSearchStringLookupService extends AbstractControllerService
try {
final String id = (String) coordinates.get(ID);
final Map<String, Object> enums = esClient.get(index, type, id);
return Optional.of(mapper.writeValueAsString(enums));
if (enums == null) {
return Optional.empty();
} else {
return Optional.ofNullable(mapper.writeValueAsString(enums));
}
} catch (IOException e) {
throw new LookupFailureException(e);
}

View File

@ -203,7 +203,7 @@ class ElasticSearchLookupService_IT {
def result = lookupService.lookup(coordinates)
Assert.assertTrue(result.isPresent())
def rec = result.get()
["dateField": "2018-08-14T10:08:00Z", "longField": 150000L].each { field ->
["dateField2": "2018-08-14T10:08:00Z", "longField2": 150000L].each { field ->
def value = rec.getValue(field.key)
Assert.assertEquals(field.value, value)
}