SnsRequestHandler extends SimpleRequestHandler<SnsRecordAndLambdaContext, Void> { @Nonnull protected InputStream createEntityStream(@Nonnull SnsRecordAndLambdaContext snsRecordAndContext) { String message = snsRecordAndContext.getSnsRecord().getSNS().getMessage(); if (message == null) { return new ByteArrayInputStream(new byte[0]); } else { return new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8)); } } protected  SnsRequestHandler(); void handleReponse(SnsRecordAndLambdaContext snsRecordAndContext, StatusType statusType,
			Map<String, List<String>> headers, ByteArrayOutputStream entityOutputStream);  }
@Test public void createEntityStream_MessageGiven_ShouldUseMessageToCreateStream() { SnsRecordAndLambdaContext reqAndContext = createMinimalRequest(); final String requestBody = "some message body"; reqAndContext.getSnsRecord().getSNS().setMessage(requestBody); ByteArrayInputStream bais = (ByteArrayInputStream) new SnsRequestHandlerImpl() .createEntityStream(reqAndContext); assertArrayEquals(requestBody.getBytes(StandardCharsets.UTF_8), toBytes(bais)); }
@Test public void createEntityStream_NoMessageGiven_ShouldCreateEmptyStream() { SnsRecordAndLambdaContext reqAndContext = createMinimalRequest(); reqAndContext.getSnsRecord().getSNS().setMessage(null); ByteArrayInputStream bais = (ByteArrayInputStream) new SnsRequestHandlerImpl() .createEntityStream(reqAndContext); assertArrayEquals(new byte[0], toBytes(bais)); }