DynamodbEventTransformer { public static List<Record> toRecordsV2(final DynamodbEvent dynamodbEvent) { return dynamodbEvent .getRecords() .stream() .filter(record -> !Objects.isNull(record)) .map(DynamodbRecordTransformer::toRecordV2) .collect(Collectors.toList()); }  static List<Record> toRecordsV2(final DynamodbEvent dynamodbEvent);  }
@Test public void testDynamodbEventToRecordsV2() { List<Record> convertedRecords = DynamodbEventTransformer.toRecordsV2(dynamodbEvent); Assertions.assertEquals(expectedRecordsV2, convertedRecords); }
@Test public void testDynamodbEventToRecordsV2_FiltersNullRecords() { DynamodbEvent event = dynamodbEvent.clone(); event.setRecords(Arrays.asList(record_event, null)); Assertions.assertEquals(2, event.getRecords().size()); List<Record> convertedRecords = DynamodbEventTransformer.toRecordsV2(event); Assertions.assertEquals(expectedRecordsV2, convertedRecords); Assertions.assertEquals(1, convertedRecords.size()); }