use of com.nextdoor.bender.aws.TestContext in project bender by Nextdoor.
the class BaseHandlerTest method testFilterFailedDeserialization.
@Test
public void testFilterFailedDeserialization() throws HandlerException {
BaseHandler.CONFIG_FILE = "/config/handler_config.json";
handler.skipWriteStats = true;
List<DummyEvent> events = new ArrayList<DummyEvent>(1);
events.add(new DummyEvent("foo", 0));
TestContext context = new TestContext();
context.setInvokedFunctionArn("arn:aws:lambda:us-east-1:123:function:test:tag");
handler.init(context);
DeserializerProcessor proc = handler.sources.get(0).getDeserProcessor();
Deserializer deserSpy = spy(proc.getDeserializer());
doThrow(new DeserializationException("expected")).when(deserSpy).deserialize(anyString());
proc.setDeserializer(deserSpy);
handler.handler(events, context);
assertEquals(0, BufferedTransporter.output.size());
}
use of com.nextdoor.bender.aws.TestContext in project bender by Nextdoor.
the class BaseHandlerTest method testSerializationException.
@Test
public void testSerializationException() throws HandlerException, SerializationException {
BaseHandler.CONFIG_FILE = "/config/handler_config.json";
handler.skipWriteStats = true;
List<DummyEvent> events = new ArrayList<DummyEvent>(1);
events.add(new DummyEvent("foo", 0));
TestContext context = new TestContext();
context.setInvokedFunctionArn("arn:aws:lambda:us-east-1:123:function:test:tag");
handler.init(context);
Serializer serSpy = spy(handler.ser.getSerializer());
doThrow(new DeserializationException("")).when(serSpy).serialize(any());
handler.ser.setSerializer(serSpy);
handler.handler(events, context);
assertEquals(1, handler.ser.getErrorCountStat().getValue());
}
use of com.nextdoor.bender.aws.TestContext in project bender by Nextdoor.
the class BaseHandlerTest method testMultipleOperationsConfig.
@Test
public void testMultipleOperationsConfig() throws HandlerException {
BaseHandler.CONFIG_FILE = "/config/handler_config_two_operations.json";
List<DummyEvent> events = new ArrayList<DummyEvent>(1);
events.add(new DummyEvent("foo", 0));
TestContext context = new TestContext();
context.setInvokedFunctionArn("arn:aws:lambda:us-east-1:123:function:test:tag");
handler.init(context);
List<OperationProcessor> operationProcessores = handler.sources.get(0).getOperationProcessors();
for (int i = 0; i < operationProcessores.size(); i++) {
OperationProcessor operationProcessor = spy(operationProcessores.get(i));
operationProcessores.set(i, operationProcessor);
}
handler.handler(events, context);
/*
* 2 operations specified in the config file
*/
verify(operationProcessores.get(0), times(1)).perform(any());
verify(operationProcessores.get(1), times(1)).perform(any());
}
use of com.nextdoor.bender.aws.TestContext in project bender by Nextdoor.
the class BaseHandlerTest method testContains.
@Test
public void testContains() throws HandlerException {
BaseHandler.CONFIG_FILE = "/config/handler_config_contains.json";
List<DummyEvent> events = new ArrayList<DummyEvent>(2);
events.add(new DummyEvent("foo", 0));
events.add(new DummyEvent("bar", 0));
events.add(new DummyEvent("loop", 0));
TestContext context = new TestContext();
context.setInvokedFunctionArn("arn:aws:lambda:us-east-1:123:function:test:tag");
handler.handler(events, context);
/*
* Verify Events made it all the way through
*/
assertEquals(1, BufferedTransporter.output.size());
assertEquals("bar", BufferedTransporter.output.get(0));
}
use of com.nextdoor.bender.aws.TestContext in project bender by Nextdoor.
the class BaseHandlerTest method testLatestTagConfig.
@Test
public void testLatestTagConfig() throws HandlerException {
List<DummyEvent> events = new ArrayList<DummyEvent>(1);
TestContext context = new TestContext();
context.setInvokedFunctionArn("arn:aws:lambda:us-east-1:123:function:test");
handler.handler(events, context);
assertEquals("/config/$LATEST.json", handler.config.getConfigFile());
}
Aggregations