Search in sources :

Example 51 with InternalEvent

use of com.nextdoor.bender.InternalEvent in project bender by Nextdoor.

the class GelfOperationTest method testFlattenPrefix.

@Test
public void testFlattenPrefix() throws JsonSyntaxException, UnsupportedEncodingException, IOException {
    JsonParser parser = new JsonParser();
    JsonElement input = parser.parse(getResourceString("flatten_prefixed_input.json"));
    String expectedOutput = getResourceString("flatten_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);
}
Also used : JsonElement(com.google.gson.JsonElement) GelfOperation(com.nextdoor.bender.operation.gelf.GelfOperation) JsonParser(com.google.gson.JsonParser) InternalEvent(com.nextdoor.bender.InternalEvent) Test(org.junit.Test) OperationTest(com.nextdoor.bender.operations.json.OperationTest)

Example 52 with InternalEvent

use of com.nextdoor.bender.InternalEvent in project bender by Nextdoor.

the class GeoIpOperationTest method testUnkownIpRequired.

@Test(expected = AddressNotFoundException.class)
public void testUnkownIpRequired() throws Throwable {
    GeoIpOperation op = setup(Arrays.asList(GeoProperty.LOCATION), true);
    DummpyEvent devent = new DummpyEvent();
    devent.setField("ip_address", "10.0.0.1");
    InternalEvent ievent = new InternalEvent("", null, 0);
    ievent.setEventObj(devent);
    try {
        op.perform(ievent);
    } catch (OperationException e) {
        throw e.getCause();
    }
}
Also used : OperationException(com.nextdoor.bender.operation.OperationException) InternalEvent(com.nextdoor.bender.InternalEvent) Test(org.junit.Test)

Example 53 with InternalEvent

use of com.nextdoor.bender.InternalEvent in project bender by Nextdoor.

the class GeoIpOperationTest method testInvalidIp.

@Test
public void testInvalidIp() throws Throwable {
    GeoIpOperation op = setup(Arrays.asList(GeoProperty.LOCATION), false);
    DummpyEvent devent = new DummpyEvent();
    devent.setField("ip_address", "noanip");
    InternalEvent ievent = new InternalEvent("", null, 0);
    ievent.setEventObj(devent);
    op.perform(ievent);
}
Also used : InternalEvent(com.nextdoor.bender.InternalEvent) Test(org.junit.Test)

Example 54 with InternalEvent

use of com.nextdoor.bender.InternalEvent in project bender by Nextdoor.

the class GeoIpOperationTest method testNullIpRequired.

@Test(expected = OperationException.class)
public void testNullIpRequired() throws Throwable {
    GeoIpOperation op = setup(Arrays.asList(GeoProperty.LOCATION), true);
    DummpyEvent devent = new DummpyEvent();
    devent.setField("ip_address", null);
    InternalEvent ievent = new InternalEvent("", null, 0);
    ievent.setEventObj(devent);
    op.perform(ievent);
}
Also used : InternalEvent(com.nextdoor.bender.InternalEvent) Test(org.junit.Test)

Example 55 with InternalEvent

use of com.nextdoor.bender.InternalEvent in project bender by Nextdoor.

the class GeoIpOperationTest method testNullIp.

@Test
public void testNullIp() throws Throwable {
    GeoIpOperation op = setup(Arrays.asList(GeoProperty.LOCATION), false);
    DummpyEvent devent = new DummpyEvent();
    devent.setField("ip_address", null);
    InternalEvent ievent = new InternalEvent("", null, 0);
    ievent.setEventObj(devent);
    op.perform(ievent);
}
Also used : InternalEvent(com.nextdoor.bender.InternalEvent) Test(org.junit.Test)

Aggregations

InternalEvent (com.nextdoor.bender.InternalEvent)68 Test (org.junit.Test)67 LinkedHashMap (java.util.LinkedHashMap)17 HashMap (java.util.HashMap)13 ArrayList (java.util.ArrayList)12 TestContext (com.nextdoor.bender.aws.TestContext)10 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)9 UploadPartRequest (com.amazonaws.services.s3.model.UploadPartRequest)9 DummyDeserializedEvent (com.nextdoor.bender.testutils.DummyDeserializerHelper.DummyDeserializedEvent)9 JsonElement (com.google.gson.JsonElement)7 JsonParser (com.google.gson.JsonParser)7 OperationTest (com.nextdoor.bender.operations.json.OperationTest)7 DummyOperationFactory (com.nextdoor.bender.testutils.DummyOperationHelper.DummyOperationFactory)6 GenericTransportBuffer (com.nextdoor.bender.ipc.generic.GenericTransportBuffer)5 GenericTransportSerializer (com.nextdoor.bender.ipc.generic.GenericTransportSerializer)5 DummyOperation (com.nextdoor.bender.testutils.DummyOperationHelper.DummyOperation)4 UploadPartResult (com.amazonaws.services.s3.model.UploadPartResult)3 Stat (com.nextdoor.bender.monitoring.Stat)3 KeyNameOperation (com.nextdoor.bender.operation.json.key.KeyNameOperation)3 ByteArrayOutputStream (org.apache.commons.io.output.ByteArrayOutputStream)3