RateLimitingProcessor implements Processor { protected void saveCurrentViolators(Map<String, ViolationMetaData> violators, String bucketName) { byte[] bytes; try { bytes = objectMapper.writeValueAsBytes(violators); } catch (JsonProcessingException e) { throw new RuntimeException("Failed to serialize violators data"); } InputStream jsonStream = new ByteArrayInputStream(bytes); ObjectMetadata metadata = new ObjectMetadata(); metadata.setContentLength(bytes.length); amazonS3.putObject(new PutObjectRequest(bucketName, SERIALIZED_DATA_FILE_NAME, jsonStream, metadata)); } RateLimitingProcessor(ObjectMapper objectMapper, AWSWAFRegional awsWaf, AmazonS3 amazonS3); void setCidrLimitForIpSetOverride(int limitOverride); @Override void processLogEvents(List<ALBAccessLogEvent> events, LogProcessorLambdaConfig config, String bucketName);  }
@Test public void testThatSaveCurrentViolatorsCallsPutObject() { Map<String, ViolationMetaData> violators = new HashMap<>(); violators.put("192.168.0.1", new ViolationMetaData(new Date(), 10)); processor.saveCurrentViolators(violators, FAKE_BUCKET_NAME); verify(amazonS3, times(1)).putObject(isA(PutObjectRequest.class)); }