use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummpyMapEvent in project bender by Nextdoor.
the class FieldSubstitutionTest method testUnknownField.
public void testUnknownField() {
ArrayList<Substitution> substitutions = new ArrayList<Substitution>();
substitutions.add(new FieldSubstitution("bar", Arrays.asList("foo"), false, false, true));
DummpyMapEvent devent = new DummpyMapEvent();
InternalEvent ievent = new InternalEvent("", null, 0);
ievent.setEventObj(devent);
SubstitutionOperation op = new SubstitutionOperation(substitutions);
op.perform(ievent);
}
use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummpyMapEvent in project bender by Nextdoor.
the class FieldSubstitutionTest method testUnknownFieldFail.
@Test(expected = OperationException.class)
public void testUnknownFieldFail() {
ArrayList<Substitution> substitutions = new ArrayList<Substitution>();
substitutions.add(new FieldSubstitution("bar", Arrays.asList("foo"), false, true, true));
DummpyMapEvent devent = new DummpyMapEvent();
InternalEvent ievent = new InternalEvent("", null, 0);
ievent.setEventObj(devent);
SubstitutionOperation op = new SubstitutionOperation(substitutions);
op.perform(ievent);
}
use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummpyMapEvent in project bender by Nextdoor.
the class FieldSubstitutionTest method testRemoveFieldReplace.
@Test
public void testRemoveFieldReplace() throws FieldNotFoundException {
ArrayList<Substitution> substitutions = new ArrayList<Substitution>();
substitutions.add(new FieldSubstitution("foo", Arrays.asList("foo"), true, true, true));
DummpyMapEvent devent = new DummpyMapEvent();
devent.setField("foo", "1234");
InternalEvent ievent = new InternalEvent("", null, 0);
ievent.setEventObj(devent);
SubstitutionOperation op = new SubstitutionOperation(substitutions);
op.perform(ievent);
assertEquals(1, devent.payload.size());
assertEquals("1234", devent.getField("foo"));
}
use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummpyMapEvent in project bender by Nextdoor.
the class RegexSubstitutionTest method testRegexRemoveField.
// TODO: do this somewhere else
// @Test(expected = java.util.regex.PatternSyntaxException.class)
// public void testInvalidRegex() {
// String pattern = "(?q>(expectedstring))";
// new RegexSubSpecConfig(Arrays.asList("foo"), pattern, null, false, true, true);
// }
@Test
public void testRegexRemoveField() throws FieldNotFoundException {
List<RegexSubField> regexSubFields = Arrays.asList(new RegexSubField("q", RegexSubField.RegexSubFieldType.STRING, "q"));
String pattern = "(?<q>(expectedstring))";
ArrayList<Substitution> substitutions = new ArrayList<Substitution>();
substitutions.add(new RegexSubstitution(Arrays.asList("foo"), Pattern.compile(pattern), regexSubFields, true, true, true));
DummpyMapEvent devent = new DummpyMapEvent();
devent.setField("foo", "expectedstring");
InternalEvent ievent = new InternalEvent("", null, 0);
ievent.setEventObj(devent);
SubstitutionOperation op = new SubstitutionOperation(substitutions);
op.perform(ievent);
assertEquals(1, devent.payload.size());
assertEquals("expectedstring", devent.getField("q"));
}
use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummpyMapEvent in project bender by Nextdoor.
the class RegexSubstitutionTest method testRegexFieldCoercionRemove.
@Test
public void testRegexFieldCoercionRemove() throws FieldNotFoundException {
List<RegexSubField> regexSubFields = Arrays.asList(new RegexSubField("q", RegexSubField.RegexSubFieldType.NUMBER, "q"));
String pattern = "(?<q>(expectedstring))";
ArrayList<Substitution> substitutions = new ArrayList<Substitution>();
substitutions.add(new RegexSubstitution(Arrays.asList("foo"), Pattern.compile(pattern), regexSubFields, true, false, true));
DummpyMapEvent devent = new DummpyMapEvent();
devent.setField("foo", "expectedstring");
InternalEvent ievent = new InternalEvent("", null, 0);
ievent.setEventObj(devent);
SubstitutionOperation op = new SubstitutionOperation(substitutions);
op.perform(ievent);
assertEquals(1, devent.payload.size());
assertEquals("expectedstring", devent.getField("foo"));
}
Aggregations