ScannerMetrics scannerMetrics = mock(ScannerMetrics.class);
+ private static final String expectedLog = "The metric 'metric_key' is ignored and should not be send in the batch report";
+
@Before
public void before() {
logTester.setLevel(Level.DEBUG);
ReportMetricValidator validator = new ReportMetricValidatorImpl(scannerMetrics);
assertThat(validator.validate(METRIC_KEY)).isTrue();
- assertThat(logTester.logs()).isEmpty();
+ assertThat(logTester.logs()).noneMatch(expectedLog::equals);
}
@Test
ReportMetricValidator validator = new ReportMetricValidatorImpl(scannerMetrics);
assertThat(validator.validate(METRIC_KEY)).isFalse();
- assertThat(logTester.logs()).containsOnly("The metric 'metric_key' is ignored and should not be send in the batch report");
+
+ assertThat(logTester.logs()).contains(expectedLog);
}
@Test
ReportMetricValidator validator = new ReportMetricValidatorImpl(scannerMetrics);
assertThat(validator.validate(METRIC_KEY)).isFalse();
- assertThat(logTester.logs()).hasSize(1);
+ assertThat(logTester.logs()).filteredOn(expectedLog::equals).hasSize(1);
assertThat(validator.validate(METRIC_KEY)).isFalse();
- assertThat(logTester.logs()).hasSize(1);
+ assertThat(logTester.logs()).filteredOn(expectedLog::equals).hasSize(1);
}
}