use of com.nextdoor.bender.InternalEvent in project bender by Nextdoor.
the class GeoIpOperationTest method testMissingField.
@Test(expected = OperationException.class)
public void testMissingField() throws Throwable {
GeoIpOperation op = setup(Arrays.asList(GeoProperty.LOCATION), true);
DummpyEvent devent = spy(new DummpyEvent());
when(devent.getField("ip_address")).thenThrow(new NoSuchElementException(""));
InternalEvent ievent = new InternalEvent("", null, 0);
ievent.setEventObj(devent);
op.perform(ievent);
}
use of com.nextdoor.bender.InternalEvent in project bender by Nextdoor.
the class GelfOperationTest method testPrefixing.
@Test
public void testPrefixing() throws JsonSyntaxException, UnsupportedEncodingException, IOException {
JsonParser parser = new JsonParser();
JsonElement input = parser.parse(getResourceString("prefixed_input.json"));
String expectedOutput = getResourceString("prefixed_output.json");
DummpyEvent devent = new DummpyEvent();
devent.payload = input.getAsJsonObject();
GelfOperation op = new GelfOperation(new ArrayList<>());
InternalEvent ievent = new InternalEvent("", null, 0);
ievent.setEventObj(devent);
op.perform(ievent);
assertEquals(parser.parse(expectedOutput), input);
}
use of com.nextdoor.bender.InternalEvent in project bender by Nextdoor.
the class PayloadOperationTest method testNonJsonObject.
@Test(expected = OperationException.class)
public void testNonJsonObject() {
KeyNameOperation operation = new KeyNameOperation();
DummpyEvent devent = new DummpyEvent();
devent.payload = new JsonPrimitive("foo");
InternalEvent ievent = new InternalEvent("", null, 0);
ievent.setEventObj(devent);
operation.perform(ievent);
}
use of com.nextdoor.bender.InternalEvent in project bender by Nextdoor.
the class SubstitutionOperationTest method testKnownField.
@Test
public void testKnownField() {
ArrayList<SubstitutionSpec> subSpecs = new ArrayList<SubstitutionSpec>();
subSpecs.add(new SubstitutionSpec("bar", "foo", Interpreter.FIELD));
DummpyEvent devent = new DummpyEvent();
devent.setField("foo", "1234");
InternalEvent ievent = new InternalEvent("", null, 0);
ievent.setEventObj(devent);
SubstitutionOperation op = new SubstitutionOperation(subSpecs);
op.perform(ievent);
assertEquals("1234", devent.getField("bar"));
assertEquals("1234", devent.getField("foo"));
}
use of com.nextdoor.bender.InternalEvent in project bender by Nextdoor.
the class GeoIpOperationTest method testUnkownIpPass.
@Test
public void testUnkownIpPass() throws Throwable {
GeoIpOperation op = setup(Arrays.asList(GeoProperty.LOCATION), false);
DummpyEvent devent = new DummpyEvent();
devent.setField("ip_address", "10.0.0.1");
InternalEvent ievent = new InternalEvent("", null, 0);
ievent.setEventObj(devent);
op.perform(ievent);
}
Aggregations