mirror of https://github.com/apache/nifi.git
NIFI-5060 Updated SubstringAfter record processing to support multi-character search trimming
This closes #2623. Signed-off-by: Mark Payne <markap14@hotmail.com>
This commit is contained in:
parent
88c079e447
commit
fdea876ede
|
@ -58,7 +58,7 @@ public class SubstringAfter extends RecordPathSegment {
|
||||||
return new StandardFieldValue("", fv.getField(), fv.getParent().orElse(null));
|
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));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class SubstringAfterLast extends RecordPathSegment {
|
||||||
return new StandardFieldValue("", fv.getField(), fv.getParent().orElse(null));
|
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));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -849,10 +849,12 @@ public class TestRecordPath {
|
||||||
assertEquals("hn Doe", RecordPath.compile("substringAfter(/name, 'o')").evaluate(record).getSelectedFields().findFirst().get().getValue());
|
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, 'XYZ')").evaluate(record).getSelectedFields().findFirst().get().getValue());
|
||||||
assertEquals("John Doe", RecordPath.compile("substringAfter(/name, '')").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("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, 'XYZ')").evaluate(record).getSelectedFields().findFirst().get().getValue());
|
||||||
assertEquals("John Doe", RecordPath.compile("substringAfterLast(/name, '')").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
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue