aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-ce-task-projectanalysis
diff options
context:
space:
mode:
authorSteve Marion <steve.marion@sonarsource.com>2023-11-29 16:18:49 +0100
committersonartech <sonartech@sonarsource.com>2023-11-29 20:02:37 +0000
commit3481aabe00fc92d25a7b78710b41bfe055ff924b (patch)
tree059ffd195f4b1da0b831f00b8dc6a7c92c7f5ecd /server/sonar-ce-task-projectanalysis
parent833d3a4d845f6fcd86e01382133b860d5194de09 (diff)
downloadsonarqube-3481aabe00fc92d25a7b78710b41bfe055ff924b.tar.gz
sonarqube-3481aabe00fc92d25a7b78710b41bfe055ff924b.zip
[NO-JIRA] make log assertions resilient to unexpected log messages
Diffstat (limited to 'server/sonar-ce-task-projectanalysis')
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/metric/ReportMetricValidatorImplTest.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/metric/ReportMetricValidatorImplTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/metric/ReportMetricValidatorImplTest.java
index 8ce7b773f66..3c23166e673 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/metric/ReportMetricValidatorImplTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/metric/ReportMetricValidatorImplTest.java
@@ -44,6 +44,8 @@ public class ReportMetricValidatorImplTest {
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);
@@ -55,7 +57,7 @@ public class ReportMetricValidatorImplTest {
ReportMetricValidator validator = new ReportMetricValidatorImpl(scannerMetrics);
assertThat(validator.validate(METRIC_KEY)).isTrue();
- assertThat(logTester.logs()).isEmpty();
+ assertThat(logTester.logs()).noneMatch(expectedLog::equals);
}
@Test
@@ -64,7 +66,8 @@ public class ReportMetricValidatorImplTest {
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
@@ -73,8 +76,8 @@ public class ReportMetricValidatorImplTest {
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);
}
}