Repository: nifi Updated Branches: refs/heads/master 88c079e44 -> fdea876ed
NIFI-5060 Updated SubstringAfter record processing to support multi-character search trimming This closes #2623. Signed-off-by: Mark Payne <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/fdea876e Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/fdea876e Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/fdea876e Branch: refs/heads/master Commit: fdea876ede6b503c703e9a816e9a29137be868f9 Parents: 88c079e Author: greencee <[email protected]> Authored: Mon Apr 9 15:28:54 2018 -0400 Committer: Mark Payne <[email protected]> Committed: Wed Apr 25 15:40:20 2018 -0400 ---------------------------------------------------------------------- .../java/org/apache/nifi/record/path/functions/SubstringAfter.java | 2 +- .../org/apache/nifi/record/path/functions/SubstringAfterLast.java | 2 +- .../src/test/java/org/apache/nifi/record/path/TestRecordPath.java | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/fdea876e/nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/functions/SubstringAfter.java ---------------------------------------------------------------------- diff --git a/nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/functions/SubstringAfter.java b/nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/functions/SubstringAfter.java index 4bdd6b3..d883f2e 100644 --- a/nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/functions/SubstringAfter.java +++ b/nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/functions/SubstringAfter.java @@ -58,7 +58,7 @@ public class SubstringAfter extends RecordPathSegment { return new StandardFieldValue("", fv.getField(), fv.getParent().orElse(null)); } - return new StandardFieldValue(value.substring(index + 1), fv.getField(), fv.getParent().orElse(null)); + return new StandardFieldValue(value.substring(index + searchValue.length()), fv.getField(), fv.getParent().orElse(null)); }); } http://git-wip-us.apache.org/repos/asf/nifi/blob/fdea876e/nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/functions/SubstringAfterLast.java ---------------------------------------------------------------------- diff --git a/nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/functions/SubstringAfterLast.java b/nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/functions/SubstringAfterLast.java index 71af1b9..19e86a1 100644 --- a/nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/functions/SubstringAfterLast.java +++ b/nifi-commons/nifi-record-path/src/main/java/org/apache/nifi/record/path/functions/SubstringAfterLast.java @@ -58,7 +58,7 @@ public class SubstringAfterLast extends RecordPathSegment { return new StandardFieldValue("", fv.getField(), fv.getParent().orElse(null)); } - return new StandardFieldValue(value.substring(index + 1), fv.getField(), fv.getParent().orElse(null)); + return new StandardFieldValue(value.substring(index + searchValue.length()), fv.getField(), fv.getParent().orElse(null)); }); } http://git-wip-us.apache.org/repos/asf/nifi/blob/fdea876e/nifi-commons/nifi-record-path/src/test/java/org/apache/nifi/record/path/TestRecordPath.java ---------------------------------------------------------------------- diff --git a/nifi-commons/nifi-record-path/src/test/java/org/apache/nifi/record/path/TestRecordPath.java b/nifi-commons/nifi-record-path/src/test/java/org/apache/nifi/record/path/TestRecordPath.java index dbf5fba..89b0893 100644 --- a/nifi-commons/nifi-record-path/src/test/java/org/apache/nifi/record/path/TestRecordPath.java +++ b/nifi-commons/nifi-record-path/src/test/java/org/apache/nifi/record/path/TestRecordPath.java @@ -849,10 +849,12 @@ public class TestRecordPath { assertEquals("hn Doe", RecordPath.compile("substringAfter(/name, 'o')").evaluate(record).getSelectedFields().findFirst().get().getValue()); assertEquals("John Doe", RecordPath.compile("substringAfter(/name, 'XYZ')").evaluate(record).getSelectedFields().findFirst().get().getValue()); assertEquals("John Doe", RecordPath.compile("substringAfter(/name, '')").evaluate(record).getSelectedFields().findFirst().get().getValue()); + assertEquals("n Doe", RecordPath.compile("substringAfter(/name, 'oh')").evaluate(record).getSelectedFields().findFirst().get().getValue()); assertEquals("e", RecordPath.compile("substringAfterLast(/name, 'o')").evaluate(record).getSelectedFields().findFirst().get().getValue()); assertEquals("John Doe", RecordPath.compile("substringAfterLast(/name, 'XYZ')").evaluate(record).getSelectedFields().findFirst().get().getValue()); assertEquals("John Doe", RecordPath.compile("substringAfterLast(/name, '')").evaluate(record).getSelectedFields().findFirst().get().getValue()); + assertEquals("n Doe", RecordPath.compile("substringAfterLast(/name, 'oh')").evaluate(record).getSelectedFields().findFirst().get().getValue()); } @Test
