use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummpyMapEvent in project bender by Nextdoor.
the class GeoIpOperationTest method testNullIp.
@Test
public void testNullIp() throws Throwable {
GeoIpOperation op = setup(Arrays.asList(GeoProperty.LOCATION), false);
DummpyMapEvent devent = new DummpyMapEvent();
devent.setField("ip_address", null);
InternalEvent ievent = new InternalEvent("", null, 0);
ievent.setEventObj(devent);
op.perform(ievent);
}
use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummpyMapEvent 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);
DummpyMapEvent devent = new DummpyMapEvent();
devent.setField("ip_address", null);
InternalEvent ievent = new InternalEvent("", null, 0);
ievent.setEventObj(devent);
op.perform(ievent);
}
use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummpyMapEvent 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);
DummpyMapEvent devent = new DummpyMapEvent();
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();
}
}
use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummpyMapEvent in project bender by Nextdoor.
the class GeoIpOperationTest method testIpList.
@Test
public void testIpList() throws Throwable {
GeoIpOperation op = setup(Arrays.asList(GeoProperty.LOCATION), true);
DummpyMapEvent devent = new DummpyMapEvent();
devent.setField("ip_address", "5.5.5.5, 10.10.10.10");
InternalEvent ievent = new InternalEvent("", null, 0);
ievent.setEventObj(devent);
op.perform(ievent);
HashMap<String, Object> expected = new HashMap<String, Object>();
expected.put("ip_address", "5.5.5.5, 10.10.10.10");
HashMap<String, Object> expectedLoc = new HashMap<String, Object>();
expectedLoc.put("lat", new Double("51.75"));
expectedLoc.put("lon", new Double("2.25"));
Map<String, Object> expectedGeo = new HashMap<String, Object>();
expectedGeo.put("location", expectedLoc);
expected.put("geo_ip", expectedGeo);
assertEquals(expected, ievent.getEventObj().getPayload());
}
use of com.nextdoor.bender.testutils.DummyDeserializerHelper.DummpyMapEvent in project bender by Nextdoor.
the class GeoIpOperationTest method testAllKnownFields.
@Test
public void testAllKnownFields() throws Throwable {
GeoIpOperation op = setup(Arrays.asList(GeoProperty.COUNTRY_NAME, GeoProperty.COUNTRY_ISO_CODE, GeoProperty.SUBDIVISION_NAME, GeoProperty.SUBDIVISION_ISO_CODE, GeoProperty.CITY_NAME, GeoProperty.POSTAL_CODE, GeoProperty.LOCATION), true);
DummpyMapEvent devent = new DummpyMapEvent();
devent.setField("ip_address", "5.5.5.5");
InternalEvent ievent = new InternalEvent("", null, 0);
ievent.setEventObj(devent);
op.perform(ievent);
HashMap<String, Object> expected = new HashMap<String, Object>();
expected.put("ip_address", "5.5.5.5");
HashMap<String, Object> expectedLoc = new HashMap<String, Object>();
expectedLoc.put("lat", new Double("51.75"));
expectedLoc.put("lon", new Double("2.25"));
Map<String, Object> expectedGeo = new HashMap<String, Object>();
expectedGeo.put("location", expectedLoc);
expectedGeo.put("country_name", "Eriador");
expectedGeo.put("country_iso_code", "ER");
expectedGeo.put("subdivision_name", "Rivendell");
expectedGeo.put("subdivision_iso_code", "ENG");
expectedGeo.put("city_name", "Rivendell");
expectedGeo.put("postal_code", "1234");
expected.put("geo_ip", expectedGeo);
assertEquals(expected, ievent.getEventObj().getPayload());
}
Aggregations