Search in sources :

Example 1 with Serializer

use of com.nextdoor.bender.serializer.Serializer 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());
}
Also used : TestContext(com.nextdoor.bender.aws.TestContext) ArrayList(java.util.ArrayList) DeserializationException(com.nextdoor.bender.deserializer.DeserializationException) Serializer(com.nextdoor.bender.serializer.Serializer) Test(org.junit.Test)

Aggregations

TestContext (com.nextdoor.bender.aws.TestContext)1 DeserializationException (com.nextdoor.bender.deserializer.DeserializationException)1 Serializer (com.nextdoor.bender.serializer.Serializer)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1