I'm trying to test my AWS Lambda function but I can't figure out how to mock the 2.0 SDK with Mockito. Basically, all I want is to create a couple DBSnapshot mocks and set a bit of test information on them (snapshot name and creation time would be enough for my purposes).
If I make a new DBSnapshot with the 'new' operator, I can't seem to set any parameters on it, or even mock a builder with a request to create one.
In the 1.0 SDK, I could mock a DBSnapshot and set various ".withBlah' params like below:
DBSnapshot testSnapshot = new DBSnapshot().withSnapshotCreateTime("2020-01-01")[...]
but it doesn't seem possible here since the 2.0 rewrite to force everything through a builder, and I'm not sure how to mock it now. Googling hasn't turned up any code examples for the 2.0 SDK/RDS in particular.
Any ideas?
Try this:
DBSnapshot testSnapshot = DBSnapshot
.builder()
.snapshotCreateTime(Instant.now())
.build();