use of com.nextdoor.bender.aws.AmazonSNSClientFactory in project bender by Nextdoor.
the class SNSS3HandlerTest method testExceptionHandlingd.
@Test
public void testExceptionHandlingd() throws Throwable {
BaseHandler.CONFIG_FILE = "/com/nextdoor/bender/handler/config_test_sns.json";
TestContext ctx = new TestContext();
ctx.setFunctionName("unittest");
ctx.setInvokedFunctionArn("arn:aws:lambda:us-east-1:123:function:test-function:staging");
/*
* Invoke handler
*/
SNSS3Handler fhandler = (SNSS3Handler) getHandler();
fhandler.init(ctx);
IpcSenderService ipcSpy = spy(fhandler.getIpcService());
doThrow(new TransportException("expected")).when(ipcSpy).shutdown();
fhandler.setIpcService(ipcSpy);
AmazonSNSClient mockClient = mock(AmazonSNSClient.class);
AmazonSNSClientFactory mockClientFactory = mock(AmazonSNSClientFactory.class);
doReturn(mockClient).when(mockClientFactory).newInstance();
fhandler.snsClientFactory = mockClientFactory;
SNSEvent event = getTestEvent();
try {
fhandler.handler(event, ctx);
} catch (Exception e) {
}
verify(mockClient, times(1)).publish("foo", "basic_input.log", "SNSS3Handler Failed");
}
Aggregations