Search in sources :

Example 1 with BaseOperation

use of com.nextdoor.bender.operation.BaseOperation in project bender by Nextdoor.

the class BaseHandlerTest method testOperationException.

@Test
public void testOperationException() 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);
    List<OperationProcessor> operationProcessors = handler.sources.get(0).getOperationProcessors();
    for (OperationProcessor operationProcessor : operationProcessors) {
        BaseOperation operation = spy(operationProcessor.getOperation());
        doThrow(new OperationException("expected")).when(operation).perform(any());
        operationProcessor.setOperation(operation);
    }
    handler.handler(events, context);
    assertEquals(1, operationProcessors.get(0).getErrorCountStat().getValue());
}
Also used : TestContext(com.nextdoor.bender.aws.TestContext) ArrayList(java.util.ArrayList) BaseOperation(com.nextdoor.bender.operation.BaseOperation) OperationProcessor(com.nextdoor.bender.operation.OperationProcessor) OperationException(com.nextdoor.bender.operation.OperationException) Test(org.junit.Test)

Aggregations

TestContext (com.nextdoor.bender.aws.TestContext)1 BaseOperation (com.nextdoor.bender.operation.BaseOperation)1 OperationException (com.nextdoor.bender.operation.OperationException)1 OperationProcessor (com.nextdoor.bender.operation.OperationProcessor)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1