use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummpyMapEvent in project bender by Nextdoor.
the class NestedSubstitutionTest method testBasicNested.
@Test
public void testBasicNested() throws FieldNotFoundException {
/*
* Substitutions in nest
*/
FieldSubstitutionConfig fieldSubConfig = new FieldSubstitutionConfig("bar", Arrays.asList("foo0", "foo1", "foo2"), false, true, true);
StaticSubstitutionConfig staticSubConfig = new StaticSubstitutionConfig("static", "value", true);
/*
* Nested substitution
*/
List<SubstitutionConfig> nsc = Arrays.asList(fieldSubConfig, staticSubConfig);
NestedSubstitutionFactory nsf = new NestedSubstitutionFactory();
nsf.setConf(new NestedSubstitutionConfig("a", nsc, true));
DummpyMapEvent devent = new DummpyMapEvent();
devent.setField("foo2", "1234");
InternalEvent ievent = new InternalEvent("", null, 0);
ievent.setEventObj(devent);
SubstitutionOperation op = new SubstitutionOperation(Arrays.asList(nsf.newInstance()));
op.perform(ievent);
Map<String, Object> expectedNested = new HashMap<String, Object>() {
{
put("bar", "1234");
put("static", "value");
}
};
assertEquals(expectedNested, devent.getField("a"));
assertEquals("1234", devent.getField("foo2"));
}
use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummpyMapEvent in project bender by Nextdoor.
the class URLDecodeOperationTest method testDecodeOnce.
@Test
public void testDecodeOnce() throws FieldNotFoundException {
DummpyMapEvent devent = new DummpyMapEvent();
devent.setField("foo", "%3Ffoo%3Dbar%26baz%3Dqux");
URLDecodeOperation op = new URLDecodeOperation(Arrays.asList("foo"), 1);
InternalEvent ievent = new InternalEvent("", null, 0);
ievent.setEventObj(devent);
op.perform(ievent);
assertEquals(1, devent.payload.size());
assertEquals("?foo=bar&baz=qux", devent.getFieldAsString("foo"));
}
use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummpyMapEvent in project bender by Nextdoor.
the class URLDecodeOperationTest method testDecodeTwoThingsEmpty.
@Test
public void testDecodeTwoThingsEmpty() throws FieldNotFoundException {
DummpyMapEvent devent = new DummpyMapEvent();
devent.setField("foo", "%3Ffoo%3Dbar%26baz%3Dqux");
URLDecodeOperation op = new URLDecodeOperation(Arrays.asList("foo", "bar"), 1);
InternalEvent ievent = new InternalEvent("", null, 0);
ievent.setEventObj(devent);
op.perform(ievent);
assertEquals(1, devent.payload.size());
assertEquals("?foo=bar&baz=qux", devent.getFieldAsString("foo"));
}
use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummpyMapEvent in project bender by Nextdoor.
the class URLDecodeOperationTest method testDecodeTwice.
@Test
public void testDecodeTwice() throws FieldNotFoundException {
DummpyMapEvent devent = new DummpyMapEvent();
devent.setField("foo", "%253Ffoo%253Dbar%2526baz%253Dqux");
URLDecodeOperation op = new URLDecodeOperation(Arrays.asList("foo"), 2);
InternalEvent ievent = new InternalEvent("", null, 0);
ievent.setEventObj(devent);
op.perform(ievent);
assertEquals(1, devent.payload.size());
assertEquals("?foo=bar&baz=qux", devent.getFieldAsString("foo"));
}
use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummpyMapEvent in project bender by Nextdoor.
the class FieldSubstitutionTest method testKnownField.
@Test
public void testKnownField() throws FieldNotFoundException {
ArrayList<Substitution> substitutions = new ArrayList<Substitution>();
substitutions.add(new FieldSubstitution("bar", Arrays.asList("foo"), false, 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(2, devent.payload.size());
assertEquals("1234", devent.getField("bar"));
assertEquals("1234", devent.getField("foo"));
}
Aggregations