use of com.nextdoor.bender.operation.OperationException in project bender by Nextdoor.
the class JsonRootNodeOperation method mutateEvent.
/**
* The {@link DeserializedEvent} payload must be a {@link JsonObject}.
*
* @param event Event with payload to mutate.
*/
protected void mutateEvent(DeserializedEvent event) throws OperationException {
Object payload = event.getPayload();
if (payload == null) {
return;
}
if (!(payload instanceof JsonObject)) {
throw new OperationException("Payload data is not a JsonObject");
}
JsonObject jsonPayload = (JsonObject) payload;
event.setPayload(JsonPathProvider.read(jsonPayload, path));
}
use of com.nextdoor.bender.operation.OperationException 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();
}
}
Aggregations