Testing my AWS Lambda function with a fake S3Event
You can use Mockito library and try to mock this S3Event
.
Another option to create S3Event
from JSON:
S3EventNotification notification = S3EventNotification.parseJson(loadJsonFromFile("s3-event.json"));
S3Event event = new S3Event(notification.getRecords());
EDIT:
Third option is to update your aws-lambda-java-events
to version 2.2.4
, where they added default constructor for S3Event
so you will be able to deserialize it like this:
objectMapper.readValue(loadJsonFromFile("s3-event.json"), S3Event.class)