aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisImplTest.java3
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/measurecomputer/MeasureComputerDefinitionImplTest.java17
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/duplication/DuplicationTest.java13
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/duplication/InProjectDuplicateTest.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/counter/IntSumCounterTest.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/counter/LongSumCounterTest.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/language/LanguageRepositoryImplTest.java5
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MapBasedRawMeasureRepositoryTest.java7
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureLevelTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureRepositoryImplTest.java12
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/notification/ReportAnalysisFailureNotificationHandlerTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/period/PeriodTest.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitygate/ConditionTest.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitygate/EvaluationResultTest.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitygate/QualityGateHolderImplTest.java4
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PublishTaskResultStepTest.java2
-rw-r--r--server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/SendIssueNotificationsStepTest.java5
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CeTasksMBeanImplTest.java14
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImplTest.java6
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/audit/model/ComponentKeyNewValueTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/audit/model/ComponentNewValueTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeTaskDtoLightTest.java14
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/component/AnalysisPropertyDtoTest.java68
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/purge/period/IntervalTest.java4
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleKeyTest.java4
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileExportDaoTest.java5
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/command/JvmOptionsTest.java2
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/config/AppSettingsImplTest.java4
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/es/EsYmlSettingsTest.java13
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/issue/IssueFieldsSetterTest.java1
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationHandlerTest.java2
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/FPOrWontFixNotificationHandlerTest.java2
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/MyNewIssuesNotificationHandlerTest.java2
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/NewIssuesNotificationHandlerTest.java2
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/issue/workflow/TransitionTest.java2
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/metric/UnanalyzedLanguageMetricsTest.java2
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/notification/EmailRecipientTest.java2
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/EvaluatedConditionTest.java4
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/QualityGateTest.java2
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/notification/QGChangeNotificationHandlerTest.java2
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/qualityprofile/QualityProfileTest.java2
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/webhook/ProjectAnalysisTest.java21
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/webhook/WebhookDeliveryTest.java2
-rw-r--r--server/sonar-webserver-api/src/test/java/org/sonar/server/exceptions/MessageTest.java6
-rw-r--r--server/sonar-webserver-api/src/test/java/org/sonar/server/project/RekeyedProjectTest.java2
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/notification/NotificationChannelTest.java2
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/platform/serverid/ServerIdFactoryImplTest.java4
-rw-r--r--server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryClientTest.java4
-rw-r--r--server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresQueryTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/ProjectMeasuresQueryFactoryTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/health/ClusterHealthTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/health/HealthTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/newcodeperiod/ws/ListActionTest.java671
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/plugins/ws/PluginUpdateAggregatorTest.java9
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileExportersTest.java8
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/source/HtmlTextDecoratorTest.java65
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/source/OpeningHtmlTagTest.java12
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/webhook/ws/ListActionTest.java4
-rw-r--r--server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/CacheWriterTest.java2
-rw-r--r--server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/ServletRequestTest.java4
-rw-r--r--server/sonar-webserver/src/test/java/org/sonar/server/platform/web/WebPagesFilterTest.java2
61 files changed, 558 insertions, 529 deletions
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisImplTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisImplTest.java
index 7b1c73b273c..5a50ac7dc02 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisImplTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/analysis/AnalysisImplTest.java
@@ -60,8 +60,7 @@ public class AnalysisImplTest {
assertThat(new Analysis.Builder()
.setUuid(UUID)
.setCreatedAt(CREATED_AT)
- .build().toString())
- .isEqualTo("Analysis{uuid='uuid ', createdAt=123456789}");
+ .build()).hasToString("Analysis{uuid='uuid ', createdAt=123456789}");
}
@Test
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/measurecomputer/MeasureComputerDefinitionImplTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/measurecomputer/MeasureComputerDefinitionImplTest.java
index efd7e6d257b..d6f1b9aa9fa 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/measurecomputer/MeasureComputerDefinitionImplTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/measurecomputer/MeasureComputerDefinitionImplTest.java
@@ -27,7 +27,6 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
public class MeasureComputerDefinitionImplTest {
-
@Test
public void build_measure_computer_definition() {
String inputMetric = "ncloc";
@@ -156,16 +155,14 @@ public class MeasureComputerDefinitionImplTest {
.setOutputMetrics("debt")
.build();
- assertThat(computer).isEqualTo(computer)
+ assertThat(computer)
+ .isEqualTo(computer)
.isEqualTo(sameComputer)
.isNotEqualTo(anotherComputer)
- .isNotNull();
-
- assertThat(computer)
+ .isNotNull()
.hasSameHashCodeAs(computer)
- .hasSameHashCodeAs(sameComputer);
-
- assertThat(computer.hashCode()).isNotEqualTo(anotherComputer.hashCode());
+ .hasSameHashCodeAs(sameComputer)
+ .doesNotHaveSameHashCodeAs(anotherComputer.hashCode());
}
@Test
@@ -173,8 +170,8 @@ public class MeasureComputerDefinitionImplTest {
assertThat(new MeasureComputerDefinitionImpl.BuilderImpl()
.setInputMetrics("ncloc", "comment")
.setOutputMetrics("comment_density_1", "comment_density_2")
- .build().toString())
- .isEqualTo("MeasureComputerDefinitionImpl{inputMetricKeys=[ncloc, comment], outputMetrics=[comment_density_1, comment_density_2]}");
+ .build())
+ .hasToString("MeasureComputerDefinitionImpl{inputMetricKeys=[ncloc, comment], outputMetrics=[comment_density_1, comment_density_2]}");
}
}
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/duplication/DuplicationTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/duplication/DuplicationTest.java
index 86cd153c0f1..cd54d2da20a 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/duplication/DuplicationTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/duplication/DuplicationTest.java
@@ -144,10 +144,11 @@ public class DuplicationTest {
public void equals_compares_on_original_and_duplicates() {
Duplication duplication = new Duplication(SOME_ORIGINAL_TEXTBLOCK, Arrays.asList(new InnerDuplicate(TEXT_BLOCK_1)));
- assertThat(duplication).isEqualTo(duplication);
- assertThat(duplication).isEqualTo(new Duplication(SOME_ORIGINAL_TEXTBLOCK, Arrays.asList(new InnerDuplicate(TEXT_BLOCK_1))));
- assertThat(duplication).isNotEqualTo(new Duplication(SOME_ORIGINAL_TEXTBLOCK, Arrays.asList(new InnerDuplicate(TEXT_BLOCK_2))));
- assertThat(duplication).isNotEqualTo(new Duplication(TEXT_BLOCK_1, Arrays.asList(new InnerDuplicate(SOME_ORIGINAL_TEXTBLOCK))));
+ assertThat(duplication)
+ .isEqualTo(duplication)
+ .isEqualTo(new Duplication(SOME_ORIGINAL_TEXTBLOCK, Arrays.asList(new InnerDuplicate(TEXT_BLOCK_1))))
+ .isNotEqualTo(new Duplication(SOME_ORIGINAL_TEXTBLOCK, Arrays.asList(new InnerDuplicate(TEXT_BLOCK_2))))
+ .isNotEqualTo(new Duplication(TEXT_BLOCK_1, Arrays.asList(new InnerDuplicate(SOME_ORIGINAL_TEXTBLOCK))));
}
@Test
@@ -165,8 +166,8 @@ public class DuplicationTest {
SOME_ORIGINAL_TEXTBLOCK,
Arrays.asList(new InnerDuplicate(TEXT_BLOCK_1)));
- assertThat(duplication.toString())
- .isEqualTo("Duplication{original=TextBlock{start=1, end=2}, duplicates=[InnerDuplicate{textBlock=TextBlock{start=2, end=2}}]}");
+ assertThat(duplication)
+ .hasToString("Duplication{original=TextBlock{start=1, end=2}, duplicates=[InnerDuplicate{textBlock=TextBlock{start=2, end=2}}]}");
}
@SafeVarargs
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/duplication/InProjectDuplicateTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/duplication/InProjectDuplicateTest.java
index aaeaad0ca6c..9b186b4a6e0 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/duplication/InProjectDuplicateTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/duplication/InProjectDuplicateTest.java
@@ -85,8 +85,8 @@ public class InProjectDuplicateTest {
@Test
public void verify_toString() {
- assertThat(new InProjectDuplicate(FILE_1, new TextBlock(1, 2)).toString())
- .isEqualTo("InProjectDuplicate{file=ReportComponent{ref=1, key='key_1', type=FILE}, textBlock=TextBlock{start=1, end=2}}");
+ assertThat(new InProjectDuplicate(FILE_1, new TextBlock(1, 2)))
+ .hasToString("InProjectDuplicate{file=ReportComponent{ref=1, key='key_1', type=FILE}, textBlock=TextBlock{start=1, end=2}}");
}
}
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/counter/IntSumCounterTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/counter/IntSumCounterTest.java
index aa5aa3fc774..035893ba2cd 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/counter/IntSumCounterTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/counter/IntSumCounterTest.java
@@ -48,7 +48,7 @@ public class IntSumCounterTest {
sumCounter.initialize(counterInitializationContext);
- assertThat(sumCounter.getValue().get()).isEqualTo(10);
+ assertThat(sumCounter.getValue()).contains(10);
}
@Test
@@ -68,7 +68,7 @@ public class IntSumCounterTest {
sumCounter.aggregate(anotherCounter);
- assertThat(sumCounter.getValue().get()).isEqualTo(10);
+ assertThat(sumCounter.getValue()).contains(10);
}
@Test
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/counter/LongSumCounterTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/counter/LongSumCounterTest.java
index 7aae4a36a53..fe573b0283c 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/counter/LongSumCounterTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/formula/counter/LongSumCounterTest.java
@@ -49,7 +49,7 @@ public class LongSumCounterTest {
sumCounter.initialize(counterInitializationContext);
- assertThat(sumCounter.getValue().get()).isEqualTo(MEASURE_VALUE);
+ assertThat(sumCounter.getValue()).contains(MEASURE_VALUE);
}
@Test
@@ -69,7 +69,7 @@ public class LongSumCounterTest {
sumCounter.aggregate(anotherCounter);
- assertThat(sumCounter.getValue().get()).isEqualTo(MEASURE_VALUE);
+ assertThat(sumCounter.getValue()).contains(MEASURE_VALUE);
}
@Test
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/language/LanguageRepositoryImplTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/language/LanguageRepositoryImplTest.java
index 646a57fe273..1e63347bd26 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/language/LanguageRepositoryImplTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/language/LanguageRepositoryImplTest.java
@@ -47,8 +47,9 @@ public class LanguageRepositoryImplTest {
public void find_by_key_returns_the_same_object() {
LanguageRepositoryImpl languageRepository = new LanguageRepositoryImpl(SOME_LANGUAGE);
Optional<Language> language = languageRepository.find(SOME_LANGUAGE_KEY);
- assertThat(language).isPresent();
- assertThat(language.get()).isSameAs(SOME_LANGUAGE);
+ assertThat(language)
+ .isPresent()
+ .containsSame(SOME_LANGUAGE);
}
@Test
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MapBasedRawMeasureRepositoryTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MapBasedRawMeasureRepositoryTest.java
index bf6b244c223..6d1988ff476 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MapBasedRawMeasureRepositoryTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MapBasedRawMeasureRepositoryTest.java
@@ -212,7 +212,7 @@ public class MapBasedRawMeasureRepositoryTest {
underTest.add(FILE_COMPONENT, metric1, SOME_MEASURE);
underTest.update(FILE_COMPONENT, metric1, newMeasure);
- assertThat(underTest.getRawMeasure(FILE_COMPONENT, metric1).get()).isSameAs(newMeasure);
+ assertThat(underTest.getRawMeasure(FILE_COMPONENT, metric1)).containsSame(newMeasure);
}
@Test
@@ -241,8 +241,9 @@ public class MapBasedRawMeasureRepositoryTest {
Optional<Measure> res = underTest.getRawMeasure(FILE_COMPONENT, metric1);
- assertThat(res).isPresent();
- assertThat(res.get()).isSameAs(SOME_MEASURE);
+ assertThat(res)
+ .isPresent()
+ .containsSame(SOME_MEASURE);
// make sure we really match on the specified component and metric
assertThat(underTest.getRawMeasure(OTHER_COMPONENT, metric1)).isNotPresent();
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureLevelTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureLevelTest.java
index 1fe21292af2..84bb42e17c9 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureLevelTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureLevelTest.java
@@ -32,7 +32,7 @@ public class MeasureLevelTest {
@Test
public void verify_toLevel_supports_all_Level_values() {
for (Measure.Level level : Measure.Level.values()) {
- assertThat(Measure.Level.toLevel(level.name()).get()).isEqualTo(level);
+ assertThat(Measure.Level.toLevel(level.name())).contains(level);
}
}
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureRepositoryImplTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureRepositoryImplTest.java
index 1b8ae83f092..608c66bb2b3 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureRepositoryImplTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/measure/MeasureRepositoryImplTest.java
@@ -283,7 +283,7 @@ public class MeasureRepositoryImplTest {
underTest.add(FILE_COMPONENT, metric1, SOME_MEASURE);
underTest.update(FILE_COMPONENT, metric1, newMeasure);
- assertThat(underTest.getRawMeasure(FILE_COMPONENT, metric1).get()).isSameAs(newMeasure);
+ assertThat(underTest.getRawMeasure(FILE_COMPONENT, metric1)).containsSame(newMeasure);
}
@Test
@@ -312,8 +312,9 @@ public class MeasureRepositoryImplTest {
Optional<Measure> res = underTest.getRawMeasure(FILE_COMPONENT, metric1);
- assertThat(res).isPresent();
- assertThat(res.get()).isSameAs(SOME_MEASURE);
+ assertThat(res)
+ .isPresent()
+ .containsSame(SOME_MEASURE);
// make sure we really match on the specified component and metric
assertThat(underTest.getRawMeasure(OTHER_COMPONENT, metric1)).isNotPresent();
@@ -363,8 +364,9 @@ public class MeasureRepositoryImplTest {
Optional<Measure> res = underTest.getRawMeasure(FILE_COMPONENT, metric1);
- assertThat(res).isPresent();
- assertThat(res.get()).isSameAs(addedMeasure);
+ assertThat(res)
+ .isPresent()
+ .containsSame(addedMeasure);
}
@Test
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/notification/ReportAnalysisFailureNotificationHandlerTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/notification/ReportAnalysisFailureNotificationHandlerTest.java
index 3ac67b2f538..34cff0b7b4e 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/notification/ReportAnalysisFailureNotificationHandlerTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/notification/ReportAnalysisFailureNotificationHandlerTest.java
@@ -57,7 +57,7 @@ public class ReportAnalysisFailureNotificationHandlerTest {
@Test
public void getMetadata_returns_same_instance_as_static_method() {
- assertThat(underTest.getMetadata().get()).isSameAs(ReportAnalysisFailureNotificationHandler.newMetadata());
+ assertThat(underTest.getMetadata()).containsSame(ReportAnalysisFailureNotificationHandler.newMetadata());
}
@Test
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/period/PeriodTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/period/PeriodTest.java
index 7098b29c240..1e375fa0bc9 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/period/PeriodTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/period/PeriodTest.java
@@ -41,8 +41,8 @@ public class PeriodTest {
@Test
public void verify_to_string() {
- assertThat(new Period(NewCodePeriodType.PREVIOUS_VERSION.name(), "2.3", 1420034400000L).toString())
- .isEqualTo("Period{mode=PREVIOUS_VERSION, modeParameter=2.3, date=1420034400000}");
+ assertThat(new Period(NewCodePeriodType.PREVIOUS_VERSION.name(), "2.3", 1420034400000L))
+ .hasToString("Period{mode=PREVIOUS_VERSION, modeParameter=2.3, date=1420034400000}");
}
@Test
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitygate/ConditionTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitygate/ConditionTest.java
index bec6d981287..fc0c4e7b3ca 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitygate/ConditionTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitygate/ConditionTest.java
@@ -73,8 +73,8 @@ public class ConditionTest {
public void all_fields_are_displayed_in_toString() {
when(SOME_METRIC.toString()).thenReturn("metric1");
- assertThat(new Condition(SOME_METRIC, SOME_OPERATOR, "error_l").toString())
- .isEqualTo("Condition{metric=metric1, operator=LESS_THAN, errorThreshold=error_l}");
+ assertThat(new Condition(SOME_METRIC, SOME_OPERATOR, "error_l"))
+ .hasToString("Condition{metric=metric1, operator=LESS_THAN, errorThreshold=error_l}");
}
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitygate/EvaluationResultTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitygate/EvaluationResultTest.java
index 86cb51ce34d..f13272cd998 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitygate/EvaluationResultTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitygate/EvaluationResultTest.java
@@ -44,7 +44,7 @@ public class EvaluationResultTest {
@Test
public void toString_is_defined() {
- assertThat(new EvaluationResult(Measure.Level.OK, "toto").toString())
- .isEqualTo("EvaluationResult{level=OK, value=toto}");
+ assertThat(new EvaluationResult(Measure.Level.OK, "toto"))
+ .hasToString("EvaluationResult{level=OK, value=toto}");
}
}
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitygate/QualityGateHolderImplTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitygate/QualityGateHolderImplTest.java
index 83440d868a1..6bd19a60b53 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitygate/QualityGateHolderImplTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/qualitygate/QualityGateHolderImplTest.java
@@ -60,7 +60,7 @@ public class QualityGateHolderImplTest {
holder.setQualityGate(QUALITY_GATE);
- assertThat(holder.getQualityGate().get()).isSameAs(QUALITY_GATE);
+ assertThat(holder.getQualityGate()).containsSame(QUALITY_GATE);
}
@Test
@@ -94,7 +94,7 @@ public class QualityGateHolderImplTest {
EvaluatedQualityGate evaluation = mock(EvaluatedQualityGate.class);
holder.setEvaluation(evaluation);
- assertThat(holder.getEvaluation().get()).isSameAs(evaluation);
+ assertThat(holder.getEvaluation()).containsSame(evaluation);
}
}
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PublishTaskResultStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PublishTaskResultStepTest.java
index ab2a4ec490e..ba2accea873 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PublishTaskResultStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/PublishTaskResultStepTest.java
@@ -50,6 +50,6 @@ public class PublishTaskResultStepTest {
underTest.execute(new TestComputationStepContext());
- assertThat(taskResultHolder.getResult().getAnalysisUuid().get()).isEqualTo(AN_ANALYSIS_UUID);
+ assertThat(taskResultHolder.getResult().getAnalysisUuid()).contains(AN_ANALYSIS_UUID);
}
}
diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/SendIssueNotificationsStepTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/SendIssueNotificationsStepTest.java
index 8d788b1c6d8..f6a9526dd8a 100644
--- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/SendIssueNotificationsStepTest.java
+++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/step/SendIssueNotificationsStepTest.java
@@ -624,8 +624,9 @@ public class SendIssueNotificationsStepTest extends BaseStepTest {
assertThat(newIssuesFactoryCaptor.issuesSetCaptor.get(0)).hasSize(1000);
assertThat(newIssuesFactoryCaptor.issuesSetCaptor.get(1)).hasSize(1000);
assertThat(newIssuesFactoryCaptor.issuesSetCaptor.get(2)).hasSize(issues.size() - 2000);
- assertThat(newIssuesFactoryCaptor.assigneeCacheCaptor).hasSize(3);
- assertThat(newIssuesFactoryCaptor.assigneeCacheCaptor).containsOnly(newIssuesFactoryCaptor.assigneeCacheCaptor.iterator().next());
+ assertThat(newIssuesFactoryCaptor.assigneeCacheCaptor)
+ .hasSize(3)
+ .containsOnly(newIssuesFactoryCaptor.assigneeCacheCaptor.iterator().next());
ArgumentCaptor<Collection> collectionCaptor = forClass(Collection.class);
verify(notificationService, times(3)).deliverEmails(collectionCaptor.capture());
assertThat(collectionCaptor.getAllValues()).hasSize(3);
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CeTasksMBeanImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CeTasksMBeanImplTest.java
index cdb8b6b37b0..ec7f64a3fe7 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CeTasksMBeanImplTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/monitoring/CeTasksMBeanImplTest.java
@@ -123,9 +123,10 @@ public class CeTasksMBeanImplTest {
public void getWorkerUuids_returns_ordered_list_of_uuids_of_worker_from_CeWorkerFactory_instance() {
List<String> workerUuids = underTest.getWorkerUuids();
- assertThat(workerUuids).isEqualTo(WORKERS.stream().map(CeWorker::getUUID).sorted().collect(Collectors.toList()));
- // ImmutableSet can not be serialized
- assertThat(workerUuids).isNotInstanceOf(ImmutableSet.class);
+ assertThat(workerUuids).
+ isEqualTo(WORKERS.stream().map(CeWorker::getUUID).sorted().collect(Collectors.toList()))
+ // ImmutableSet can not be serialized
+ .isNotInstanceOf(ImmutableSet.class);
}
@Test
@@ -145,9 +146,10 @@ public class CeTasksMBeanImplTest {
List<String> enabledWorkerUuids = underTest.getEnabledWorkerUuids();
- assertThat(enabledWorkerUuids).isEqualTo(Stream.of(enabledWorkers).map(CeWorker::getUUID).sorted().collect(Collectors.toList()));
- // ImmutableSet can not be serialized
- assertThat(enabledWorkerUuids).isNotInstanceOf(ImmutableSet.class);
+ assertThat(enabledWorkerUuids)
+ .isEqualTo(Stream.of(enabledWorkers).map(CeWorker::getUUID).sorted().collect(Collectors.toList()))
+ // ImmutableSet can not be serialized
+ .isNotInstanceOf(ImmutableSet.class);
}
@Test
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImplTest.java
index 31593cccac8..bf3e7f97514 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImplTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/taskprocessor/CeTaskProcessorRepositoryImplTest.java
@@ -87,8 +87,8 @@ public class CeTaskProcessorRepositoryImplTest {
CeTaskProcessor taskProcessor = createCeTaskProcessor(SOME_CE_TASK_TYPE);
CeTaskProcessorRepositoryImpl underTest = new CeTaskProcessorRepositoryImpl(new CeTaskProcessor[] {taskProcessor});
- assertThat(underTest.getForCeTask(createCeTask(SOME_CE_TASK_TYPE, SOME_COMPONENT_KEY)).get()).isSameAs(taskProcessor);
- assertThat(underTest.getForCeTask(createCeTask(SOME_CE_TASK_TYPE, SOME_COMPONENT_KEY + "2")).get()).isSameAs(taskProcessor);
+ assertThat(underTest.getForCeTask(createCeTask(SOME_CE_TASK_TYPE, SOME_COMPONENT_KEY))).containsSame(taskProcessor);
+ assertThat(underTest.getForCeTask(createCeTask(SOME_CE_TASK_TYPE, SOME_COMPONENT_KEY + "2"))).containsSame(taskProcessor);
}
@Test
@@ -96,7 +96,7 @@ public class CeTaskProcessorRepositoryImplTest {
CeTaskProcessor taskProcessor = createCeTaskProcessor(SOME_CE_TASK_TYPE + "_1", SOME_CE_TASK_TYPE, SOME_CE_TASK_TYPE + "_3");
CeTaskProcessorRepositoryImpl underTest = new CeTaskProcessorRepositoryImpl(new CeTaskProcessor[] {taskProcessor});
- assertThat(underTest.getForCeTask(createCeTask(SOME_CE_TASK_TYPE, SOME_COMPONENT_KEY)).get()).isSameAs(taskProcessor);
+ assertThat(underTest.getForCeTask(createCeTask(SOME_CE_TASK_TYPE, SOME_COMPONENT_KEY))).containsSame(taskProcessor);
}
private CeTaskProcessor createCeTaskProcessor(final String... ceTaskTypes) {
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/audit/model/ComponentKeyNewValueTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/audit/model/ComponentKeyNewValueTest.java
index c6cfb43bc10..45797cefe2a 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/audit/model/ComponentKeyNewValueTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/audit/model/ComponentKeyNewValueTest.java
@@ -34,6 +34,6 @@ public class ComponentKeyNewValueTest {
JSONObject jsonObject = (JSONObject) new JSONParser().parse(newValue.toString());
- assertThat(jsonObject.size()).isEqualTo(3);
+ assertThat(jsonObject).hasSize(3);
}
}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/audit/model/ComponentNewValueTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/audit/model/ComponentNewValueTest.java
index 49f49500876..0eee39d9f8c 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/audit/model/ComponentNewValueTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/audit/model/ComponentNewValueTest.java
@@ -34,7 +34,7 @@ public class ComponentNewValueTest {
JSONObject jsonObject = (JSONObject) new JSONParser().parse(newValue.toString());
- assertThat(jsonObject.size()).isEqualTo(5);
+ assertThat(jsonObject).hasSize(5);
}
@Test
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeTaskDtoLightTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeTaskDtoLightTest.java
index a218272a90b..a7d9428e2b6 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeTaskDtoLightTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeTaskDtoLightTest.java
@@ -44,9 +44,10 @@ public class CeTaskDtoLightTest {
@Test
public void equals_is_based_on_created_date_and_uuid() {
- assertThat(task1).isEqualTo(task2);
- assertThat(task1).isNotEqualTo(task3);
- assertThat(task1).isNotEqualTo(task4);
+ assertThat(task1)
+ .isEqualTo(task2)
+ .isNotEqualTo(task3)
+ .isNotEqualTo(task4);
}
@Test
@@ -56,8 +57,9 @@ public class CeTaskDtoLightTest {
@Test
public void compareTo_is_based_on_created_date_and_uuid() {
- assertThat(task1).isEqualByComparingTo(task2);
- assertThat(task1).isLessThan(task3);
- assertThat(task1).isLessThan(task4);
+ assertThat(task1)
+ .isEqualByComparingTo(task2)
+ .isLessThan(task3)
+ .isLessThan(task4);
}
}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/AnalysisPropertyDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/AnalysisPropertyDtoTest.java
index 3369b9299f8..b168db80882 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/AnalysisPropertyDtoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/AnalysisPropertyDtoTest.java
@@ -27,14 +27,13 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
public class AnalysisPropertyDtoTest {
-
private AnalysisPropertyDto underTest;
@Test
public void null_key_should_throw_NPE() {
underTest = new AnalysisPropertyDto();
- assertThatThrownBy(() -> underTest.setKey(null))
+ assertThatThrownBy(() -> underTest.setKey(null))
.isInstanceOf(NullPointerException.class)
.hasMessage("key cannot be null");
}
@@ -74,40 +73,37 @@ public class AnalysisPropertyDtoTest {
.setKey(randomAlphanumeric(512))
.setValue(randomAlphanumeric(10000));
- assertThat(underTest).isEqualTo(
- new AnalysisPropertyDto()
- .setUuid(underTest.getUuid())
- .setAnalysisUuid(underTest.getAnalysisUuid())
- .setKey(underTest.getKey())
- .setValue(underTest.getValue()));
-
- assertThat(underTest).isNotEqualTo(
- new AnalysisPropertyDto()
- .setUuid("1" + underTest.getUuid())
- .setAnalysisUuid(underTest.getAnalysisUuid())
- .setKey(underTest.getKey())
- .setValue(underTest.getValue()));
-
- assertThat(underTest).isNotEqualTo(
- new AnalysisPropertyDto()
- .setUuid(underTest.getUuid())
- .setAnalysisUuid("1" + underTest.getAnalysisUuid())
- .setKey(underTest.getKey())
- .setValue(underTest.getValue()));
-
- assertThat(underTest).isNotEqualTo(
- new AnalysisPropertyDto()
- .setUuid(underTest.getUuid())
- .setAnalysisUuid(underTest.getAnalysisUuid())
- .setKey("1" + underTest.getKey())
- .setValue(underTest.getValue()));
-
- assertThat(underTest).isNotEqualTo(
- new AnalysisPropertyDto()
- .setUuid(underTest.getUuid())
- .setAnalysisUuid(underTest.getAnalysisUuid())
- .setKey(underTest.getKey())
- .setValue("1" + underTest.getValue()));
+ assertThat(underTest)
+ .isEqualTo(
+ new AnalysisPropertyDto()
+ .setUuid(underTest.getUuid())
+ .setAnalysisUuid(underTest.getAnalysisUuid())
+ .setKey(underTest.getKey())
+ .setValue(underTest.getValue()))
+ .isNotEqualTo(
+ new AnalysisPropertyDto()
+ .setUuid("1" + underTest.getUuid())
+ .setAnalysisUuid(underTest.getAnalysisUuid())
+ .setKey(underTest.getKey())
+ .setValue(underTest.getValue()))
+ .isNotEqualTo(
+ new AnalysisPropertyDto()
+ .setUuid(underTest.getUuid())
+ .setAnalysisUuid("1" + underTest.getAnalysisUuid())
+ .setKey(underTest.getKey())
+ .setValue(underTest.getValue()))
+ .isNotEqualTo(
+ new AnalysisPropertyDto()
+ .setUuid(underTest.getUuid())
+ .setAnalysisUuid(underTest.getAnalysisUuid())
+ .setKey("1" + underTest.getKey())
+ .setValue(underTest.getValue()))
+ .isNotEqualTo(
+ new AnalysisPropertyDto()
+ .setUuid(underTest.getUuid())
+ .setAnalysisUuid(underTest.getAnalysisUuid())
+ .setKey(underTest.getKey())
+ .setValue("1" + underTest.getValue()));
}
@Test
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/period/IntervalTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/period/IntervalTest.java
index b5ed25e4fe2..12fdf75a6a7 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/period/IntervalTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/period/IntervalTest.java
@@ -57,7 +57,7 @@ public class IntervalTest {
);
List<Interval> intervals = Interval.group(snapshots, DateUtils.parseDate("2010-01-01"), DateUtils.parseDate("2011-12-31"), Calendar.MONTH);
- assertThat(intervals.size()).isEqualTo(3);
+ assertThat(intervals).hasSize(3);
assertThat(intervals.get(0).count()).isOne();
assertThat(calendarField(intervals.get(0), Calendar.MONTH)).isEqualTo((Calendar.APRIL));
@@ -78,7 +78,7 @@ public class IntervalTest {
List<Interval> intervals = Interval.group(snapshots,
DateUtils.parseDateTime("2010-01-01T00:00:00+0100"), DateUtils.parseDateTime("2011-12-31T00:00:00+0100"), Calendar.MONTH);
- assertThat(intervals.size()).isEqualTo(2);
+ assertThat(intervals).hasSize(2);
assertThat(intervals.get(0).count()).isOne();
assertThat(calendarField(intervals.get(0), Calendar.MONTH)).isEqualTo((Calendar.APRIL));
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleKeyTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleKeyTest.java
index 8ea7ee818b0..a30b49e37a2 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleKeyTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleKeyTest.java
@@ -35,7 +35,7 @@ public class ActiveRuleKeyTest {
ActiveRuleKey key = ActiveRuleKey.of(profile, ruleKey);
assertThat(key.getRuleProfileUuid()).isEqualTo(profile.getRulesProfileUuid());
assertThat(key.getRuleKey()).isSameAs(ruleKey);
- assertThat(key.toString()).isEqualTo(profile.getRulesProfileUuid() + ":xoo:R1");
+ assertThat(key).hasToString(profile.getRulesProfileUuid() + ":xoo:R1");
}
@Test
@@ -45,7 +45,7 @@ public class ActiveRuleKeyTest {
ActiveRuleKey key = ActiveRuleKey.of(profile, ruleKey);
assertThat(key.getRuleProfileUuid()).isEqualTo(profile.getRulesProfileUuid());
assertThat(key.getRuleKey()).isSameAs(ruleKey);
- assertThat(key.toString()).isEqualTo(profile.getRulesProfileUuid() + ":java:Key:With:Some::Colons");
+ assertThat(key).hasToString(profile.getRulesProfileUuid() + ":java:Key:With:Some::Colons");
}
@Test
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileExportDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileExportDaoTest.java
index a93c1905629..fa3ffb89e8d 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileExportDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileExportDaoTest.java
@@ -85,8 +85,9 @@ public class QualityProfileExportDaoTest {
List<ActiveRuleDto> activeRules = activate(profile, customRule, rule);
List<ExportRuleDto> results = underTest.selectRulesByProfile(dbSession, profile);
- assertThat(results).isNotNull();
- assertThat(results).isNotEmpty();
+ assertThat(results)
+ .isNotNull()
+ .isNotEmpty();
// verify custom rule
ExportRuleDto exportCustomRuleDto = results.stream().filter(ExportRuleDto::isCustomRule).findFirst().get();
diff --git a/server/sonar-main/src/test/java/org/sonar/application/command/JvmOptionsTest.java b/server/sonar-main/src/test/java/org/sonar/application/command/JvmOptionsTest.java
index 3e23bed0305..3c6b727efcb 100644
--- a/server/sonar-main/src/test/java/org/sonar/application/command/JvmOptionsTest.java
+++ b/server/sonar-main/src/test/java/org/sonar/application/command/JvmOptionsTest.java
@@ -338,7 +338,7 @@ public class JvmOptionsTest {
public void toString_prints_all_jvm_options() {
underTest.add("-foo").add("-bar");
- assertThat(underTest.toString()).isEqualTo("[-foo, -bar]");
+ assertThat(underTest).hasToString("[-foo, -bar]");
}
private void expectJvmOptionNotNullNPE(ThrowingCallable callback) {
diff --git a/server/sonar-main/src/test/java/org/sonar/application/config/AppSettingsImplTest.java b/server/sonar-main/src/test/java/org/sonar/application/config/AppSettingsImplTest.java
index e42c4bf13bd..c274323d413 100644
--- a/server/sonar-main/src/test/java/org/sonar/application/config/AppSettingsImplTest.java
+++ b/server/sonar-main/src/test/java/org/sonar/application/config/AppSettingsImplTest.java
@@ -38,8 +38,8 @@ public class AppSettingsImplTest {
AppSettingsImpl underTest = new AppSettingsImpl(initialProps);
underTest.reload(newProps);
- assertThat(underTest.getValue("foo").get()).isEqualTo("baz");
- assertThat(underTest.getValue("newProp").get()).isEqualTo("newVal");
+ assertThat(underTest.getValue("foo")).contains("baz");
+ assertThat(underTest.getValue("newProp")).contains("newVal");
assertThat(underTest.getProps().rawProperties()).hasSize(2);
}
}
diff --git a/server/sonar-main/src/test/java/org/sonar/application/es/EsYmlSettingsTest.java b/server/sonar-main/src/test/java/org/sonar/application/es/EsYmlSettingsTest.java
index 30c1284c18c..fe7887e2d7d 100644
--- a/server/sonar-main/src/test/java/org/sonar/application/es/EsYmlSettingsTest.java
+++ b/server/sonar-main/src/test/java/org/sonar/application/es/EsYmlSettingsTest.java
@@ -39,14 +39,15 @@ public class EsYmlSettingsTest {
File yamlFile = temp.newFile();
new EsYmlSettings(new HashMap<>()).writeToYmlSettingsFile(yamlFile);
- assertThat(yamlFile).exists();
- assertThat(yamlFile).hasContent("""
- # This file has been automatically generated by SonarQube during startup.
+ assertThat(yamlFile)
+ .exists()
+ .hasContent("""
+ # This file has been automatically generated by SonarQube during startup.
- # DO NOT EDIT THIS FILE
+ # DO NOT EDIT THIS FILE
- {
- }""");
+ {
+ }""");
}
@Test
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/issue/IssueFieldsSetterTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/issue/IssueFieldsSetterTest.java
index f8a08862d6d..375ec976e73 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/issue/IssueFieldsSetterTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/issue/IssueFieldsSetterTest.java
@@ -23,6 +23,7 @@ import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Random;
+import java.util.function.Predicate;
import org.apache.commons.lang.time.DateUtils;
import org.junit.Test;
import org.sonar.api.utils.Duration;
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationHandlerTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationHandlerTest.java
index d1fbb495c9e..0a583409014 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationHandlerTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/ChangesOnMyIssueNotificationHandlerTest.java
@@ -81,7 +81,7 @@ public class ChangesOnMyIssueNotificationHandlerTest {
@Test
public void getMetadata_returns_same_instance_as_static_method() {
- assertThat(underTest.getMetadata().get()).isSameAs(ChangesOnMyIssueNotificationHandler.newMetadata());
+ assertThat(underTest.getMetadata()).containsSame(ChangesOnMyIssueNotificationHandler.newMetadata());
}
@Test
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/FPOrWontFixNotificationHandlerTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/FPOrWontFixNotificationHandlerTest.java
index 9e4e19d3e22..7f8184450d8 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/FPOrWontFixNotificationHandlerTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/FPOrWontFixNotificationHandlerTest.java
@@ -81,7 +81,7 @@ public class FPOrWontFixNotificationHandlerTest {
@Test
public void getMetadata_returns_same_instance_as_static_method() {
- assertThat(underTest.getMetadata().get()).isSameAs(FPOrWontFixNotificationHandler.newMetadata());
+ assertThat(underTest.getMetadata()).containsSame(FPOrWontFixNotificationHandler.newMetadata());
}
@Test
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/MyNewIssuesNotificationHandlerTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/MyNewIssuesNotificationHandlerTest.java
index 124f818685f..78bda2543a6 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/MyNewIssuesNotificationHandlerTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/MyNewIssuesNotificationHandlerTest.java
@@ -57,7 +57,7 @@ public class MyNewIssuesNotificationHandlerTest {
@Test
public void getMetadata_returns_same_instance_as_static_method() {
- assertThat(underTest.getMetadata().get()).isSameAs(MyNewIssuesNotificationHandler.newMetadata());
+ assertThat(underTest.getMetadata()).containsSame(MyNewIssuesNotificationHandler.newMetadata());
}
@Test
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/NewIssuesNotificationHandlerTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/NewIssuesNotificationHandlerTest.java
index 1650a77004a..f7cea888707 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/NewIssuesNotificationHandlerTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/NewIssuesNotificationHandlerTest.java
@@ -55,7 +55,7 @@ public class NewIssuesNotificationHandlerTest {
@Test
public void getMetadata_returns_same_instance_as_static_method() {
- assertThat(underTest.getMetadata().get()).isSameAs(NewIssuesNotificationHandler.newMetadata());
+ assertThat(underTest.getMetadata()).containsSame(NewIssuesNotificationHandler.newMetadata());
}
@Test
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/issue/workflow/TransitionTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/issue/workflow/TransitionTest.java
index 8f25b759baa..33dacd3aeb5 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/issue/workflow/TransitionTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/issue/workflow/TransitionTest.java
@@ -138,7 +138,7 @@ public class TransitionTest {
@Test
public void test_toString() {
Transition t1 = Transition.create("resolve", "OPEN", "RESOLVED");
- assertThat(t1.toString()).isEqualTo("OPEN->resolve->RESOLVED");
+ assertThat(t1).hasToString("OPEN->resolve->RESOLVED");
}
@Test
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/metric/UnanalyzedLanguageMetricsTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/metric/UnanalyzedLanguageMetricsTest.java
index 77a8a428188..9045f106c1d 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/metric/UnanalyzedLanguageMetricsTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/metric/UnanalyzedLanguageMetricsTest.java
@@ -31,7 +31,7 @@ public class UnanalyzedLanguageMetricsTest {
public void count_metrics() {
UnanalyzedLanguageMetrics coreCustomMetrics = new UnanalyzedLanguageMetrics();
List<Metric> metrics = coreCustomMetrics.getMetrics();
- assertThat(metrics.size()).isEqualTo(2);
+ assertThat(metrics).hasSize(2);
}
}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/notification/EmailRecipientTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/notification/EmailRecipientTest.java
index 3966753a7cc..da19938a9b9 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/notification/EmailRecipientTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/notification/EmailRecipientTest.java
@@ -82,6 +82,6 @@ public class EmailRecipientTest {
String login = randomAlphabetic(11);
String email = randomAlphabetic(12);
- assertThat(new EmailRecipient(login, email).toString()).isEqualTo("EmailRecipient{'" + login + "':'" + email + "'}");
+ assertThat(new EmailRecipient(login, email)).hasToString("EmailRecipient{'" + login + "':'" + email + "'}");
}
}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/EvaluatedConditionTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/EvaluatedConditionTest.java
index 4c0d1ada8c3..3b71bba1c98 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/EvaluatedConditionTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/EvaluatedConditionTest.java
@@ -64,7 +64,7 @@ public class EvaluatedConditionTest {
@Test
public void override_toString() {
- assertThat(underTest.toString()).isEqualTo("EvaluatedCondition{condition=" +
+ assertThat(underTest).hasToString("EvaluatedCondition{condition=" +
"Condition{metricKey='metricKey', operator=GREATER_THAN, errorThreshold='2'}, " +
"status=ERROR, value='value'}");
}
@@ -73,7 +73,7 @@ public class EvaluatedConditionTest {
public void toString_does_not_quote_null_value() {
EvaluatedCondition underTest = new EvaluatedCondition(CONDITION_1, ERROR, null);
- assertThat(underTest.toString()).isEqualTo("EvaluatedCondition{condition=" +
+ assertThat(underTest).hasToString("EvaluatedCondition{condition=" +
"Condition{metricKey='metricKey', operator=GREATER_THAN, errorThreshold='2'}, " +
"status=ERROR, value=null}");
}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/QualityGateTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/QualityGateTest.java
index d462d2f0a8e..181d4bb5f10 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/QualityGateTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/QualityGateTest.java
@@ -89,7 +89,7 @@ public class QualityGateTest {
public void toString_is_override() {
QualityGate underTest = new QualityGate(QUALIGATE_ID, QUALIGATE_NAME, ImmutableSet.of(CONDITION_2));
- assertThat(underTest.toString()).isEqualTo("QualityGate{id=qg_id, name='qg_name', conditions=[" +
+ assertThat(underTest).hasToString("QualityGate{id=qg_id, name='qg_name', conditions=[" +
"Condition{metricKey='m2', operator=LESS_THAN, errorThreshold='2'}" +
"]}");
}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/notification/QGChangeNotificationHandlerTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/notification/QGChangeNotificationHandlerTest.java
index 941dd76ba43..32a6c873912 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/notification/QGChangeNotificationHandlerTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/qualitygate/notification/QGChangeNotificationHandlerTest.java
@@ -53,7 +53,7 @@ public class QGChangeNotificationHandlerTest {
@Test
public void getMetadata_returns_same_instance_as_static_method() {
- assertThat(underTest.getMetadata().get()).isSameAs(QGChangeNotificationHandler.newMetadata());
+ assertThat(underTest.getMetadata()).containsSame(QGChangeNotificationHandler.newMetadata());
}
@Test
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/qualityprofile/QualityProfileTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/qualityprofile/QualityProfileTest.java
index dabd5618065..ac35a913ac8 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/qualityprofile/QualityProfileTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/qualityprofile/QualityProfileTest.java
@@ -88,6 +88,6 @@ public class QualityProfileTest {
@Test
public void verify_toString() {
- assertThat(QUALITY_PROFILE.toString()).isEqualTo("QualityProfile{key=qpKey, name=qpName, language=languageKey, rulesUpdatedAt=1274194245000}");
+ assertThat(QUALITY_PROFILE).hasToString("QualityProfile{key=qpKey, name=qpName, language=languageKey, rulesUpdatedAt=1274194245000}");
}
}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/webhook/ProjectAnalysisTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/webhook/ProjectAnalysisTest.java
index 9f70619f5da..1bf827e6c53 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/webhook/ProjectAnalysisTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/webhook/ProjectAnalysisTest.java
@@ -76,12 +76,12 @@ public class ProjectAnalysisTest {
@Test
public void verify_getters() {
- assertThat(underTest.getCeTask().get()).isSameAs(ceTask);
+ assertThat(underTest.getCeTask()).containsSame(ceTask);
assertThat(underTest.getProject()).isSameAs(project);
- assertThat(underTest.getBranch().get()).isSameAs(branch);
- assertThat(underTest.getQualityGate().get()).isSameAs(qualityGate);
+ assertThat(underTest.getBranch()).containsSame(branch);
+ assertThat(underTest.getQualityGate()).containsSame(qualityGate);
assertThat(underTest.getProperties()).isEqualTo(properties);
- assertThat(underTest.getAnalysis().get()).isEqualTo(analysis);
+ assertThat(underTest.getAnalysis()).contains(analysis);
ProjectAnalysis underTestWithNulls = new ProjectAnalysis(project, null, null, null, null, null, emptyMap());
assertThat(underTestWithNulls.getCeTask()).isEmpty();
@@ -111,11 +111,12 @@ public class ProjectAnalysisTest {
.setQualityGate(new QualityGate("A", "B", emptySet()))
.setStatus(Metric.Level.ERROR)
.build();
- assertThat(underTest).isNotEqualTo(new ProjectAnalysis(project, ceTask, analysis, branch, otherQualityGate, 1L, properties));
- assertThat(underTest).isNotEqualTo(new ProjectAnalysis(project, ceTask, analysis, branch, qualityGate, null, properties));
- assertThat(underTest).isNotEqualTo(new ProjectAnalysis(project, ceTask, analysis, branch, qualityGate, 2L, properties));
- assertThat(underTest).isNotEqualTo(new ProjectAnalysis(project, ceTask, analysis, branch, qualityGate, 1L, emptyMap()));
- assertThat(underTest).isNotEqualTo(new ProjectAnalysis(project, ceTask, analysis, branch, qualityGate, 1L, ImmutableMap.of("A", "B")));
+ assertThat(underTest)
+ .isNotEqualTo(new ProjectAnalysis(project, ceTask, analysis, branch, otherQualityGate, 1L, properties))
+ .isNotEqualTo(new ProjectAnalysis(project, ceTask, analysis, branch, qualityGate, null, properties))
+ .isNotEqualTo(new ProjectAnalysis(project, ceTask, analysis, branch, qualityGate, 2L, properties))
+ .isNotEqualTo(new ProjectAnalysis(project, ceTask, analysis, branch, qualityGate, 1L, emptyMap()))
+ .isNotEqualTo(new ProjectAnalysis(project, ceTask, analysis, branch, qualityGate, 1L, ImmutableMap.of("A", "B")));
}
@Test
@@ -151,7 +152,7 @@ public class ProjectAnalysisTest {
@Test
public void verify_toString() {
- assertThat(underTest.toString()).isEqualTo(
+ assertThat(underTest).hasToString(
"ProjectAnalysis{project=Project{uuid='uuid', key='key', name='name'}, ceTask=CeTask{id='id', status=SUCCESS}, branch=Branch{main=true, name='name', type=BRANCH}, qualityGate=EvaluatedQualityGate{qualityGate=QualityGate{id=id, name='name', conditions=[]}, status=ERROR, evaluatedConditions=[]}, updatedAt=1, properties={a=b}, analysis=Analysis{uuid='analysis_uuid', date=1500, revision=sha1}}");
}
}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/webhook/WebhookDeliveryTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/webhook/WebhookDeliveryTest.java
index 0e213399bb7..bc67f84ca88 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/webhook/WebhookDeliveryTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/webhook/WebhookDeliveryTest.java
@@ -70,7 +70,7 @@ public class WebhookDeliveryTest {
.setError(cause)
.build();
- assertThat(delivery.getErrorMessage().get()).isEqualTo("fail to connect");
+ assertThat(delivery.getErrorMessage()).contains("fail to connect");
}
private static WebhookDelivery.Builder newBuilderTemplate() {
diff --git a/server/sonar-webserver-api/src/test/java/org/sonar/server/exceptions/MessageTest.java b/server/sonar-webserver-api/src/test/java/org/sonar/server/exceptions/MessageTest.java
index 27e10c8a18a..d7bbaf89e13 100644
--- a/server/sonar-webserver-api/src/test/java/org/sonar/server/exceptions/MessageTest.java
+++ b/server/sonar-webserver-api/src/test/java/org/sonar/server/exceptions/MessageTest.java
@@ -76,8 +76,8 @@ public class MessageTest {
@Test
public void to_string() {
- assertThat(Message.of("key1 %s", "param1").toString()).isEqualTo("key1 param1");
- assertThat(Message.of("key1").toString()).isEqualTo("key1");
- assertThat(Message.of("key1", (Object[])null).toString()).isEqualTo("key1");
+ assertThat(Message.of("key1 %s", "param1")).hasToString("key1 param1");
+ assertThat(Message.of("key1")).hasToString("key1");
+ assertThat(Message.of("key1", (Object[])null)).hasToString("key1");
}
}
diff --git a/server/sonar-webserver-api/src/test/java/org/sonar/server/project/RekeyedProjectTest.java b/server/sonar-webserver-api/src/test/java/org/sonar/server/project/RekeyedProjectTest.java
index e175bed9b10..131545b0eb4 100644
--- a/server/sonar-webserver-api/src/test/java/org/sonar/server/project/RekeyedProjectTest.java
+++ b/server/sonar-webserver-api/src/test/java/org/sonar/server/project/RekeyedProjectTest.java
@@ -89,7 +89,7 @@ public class RekeyedProjectTest {
String previousKey = "E";
RekeyedProject underTest = new RekeyedProject(project, previousKey);
- assertThat(underTest.toString()).isEqualTo("RekeyedProject{project=Project{uuid='A', key='B', name='C', description='D'}, previousKey='E'}");
+ assertThat(underTest).hasToString("RekeyedProject{project=Project{uuid='A', key='B', name='C', description='D'}, previousKey='E'}");
}
private static Project newRandomProject() {
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/notification/NotificationChannelTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/notification/NotificationChannelTest.java
index 40b0a25d890..edd6354a881 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/notification/NotificationChannelTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/notification/NotificationChannelTest.java
@@ -31,7 +31,7 @@ public class NotificationChannelTest {
public void defaultMethods() {
NotificationChannel channel = new FakeNotificationChannel();
assertThat(channel.getKey()).isEqualTo("FakeNotificationChannel");
- assertThat(channel.toString()).isEqualTo("FakeNotificationChannel");
+ assertThat(channel).hasToString("FakeNotificationChannel");
}
private static class FakeNotificationChannel extends NotificationChannel {
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/serverid/ServerIdFactoryImplTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/serverid/ServerIdFactoryImplTest.java
index 897d6ebe5fc..11ec21846fd 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/serverid/ServerIdFactoryImplTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/platform/serverid/ServerIdFactoryImplTest.java
@@ -71,7 +71,7 @@ public class ServerIdFactoryImplTest {
ServerId serverId = underTest.create();
- assertThat(serverId.getDatabaseId().get()).isEqualTo(crc32Hex(sanitizedJdbcUrl));
+ assertThat(serverId.getDatabaseId()).contains(crc32Hex(sanitizedJdbcUrl));
assertThat(serverId.getDatasetId()).isEqualTo(uuid);
}
@@ -91,7 +91,7 @@ public class ServerIdFactoryImplTest {
ServerId serverId = underTest.create(currentServerId);
- assertThat(serverId.getDatabaseId().get()).isEqualTo(crc32Hex(sanitizedJdbcUrl));
+ assertThat(serverId.getDatabaseId()).contains(crc32Hex(sanitizedJdbcUrl));
assertThat(serverId.getDatasetId()).isEqualTo(currentServerId.getDatasetId());
}
diff --git a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryClientTest.java b/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryClientTest.java
index 765dc58d825..2beb1f54f47 100644
--- a/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryClientTest.java
+++ b/server/sonar-webserver-core/src/test/java/org/sonar/server/telemetry/TelemetryClientTest.java
@@ -61,7 +61,7 @@ public class TelemetryClientTest {
Buffer body = new Buffer();
request.body().writeTo(body);
assertThat(body.readUtf8()).isEqualTo(JSON);
- assertThat(request.url().toString()).isEqualTo(TELEMETRY_URL);
+ assertThat(request.url()).hasToString(TELEMETRY_URL);
}
@Test
@@ -79,6 +79,6 @@ public class TelemetryClientTest {
Buffer body = new Buffer();
request.body().writeTo(body);
assertThat(body.readUtf8()).isEqualTo(JSON);
- assertThat(request.url().toString()).isEqualTo(TELEMETRY_URL);
+ assertThat(request.url()).hasToString(TELEMETRY_URL);
}
}
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresQueryTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresQueryTest.java
index a03773659d2..04eb3c1d332 100644
--- a/server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresQueryTest.java
+++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresQueryTest.java
@@ -70,7 +70,7 @@ public class ProjectMeasuresQueryTest {
public void set_quality_gate_status() {
underTest.setQualityGateStatus(OK);
- assertThat(underTest.getQualityGateStatus().get()).isEqualTo(Level.OK);
+ assertThat(underTest.getQualityGateStatus()).contains(Level.OK);
}
@Test
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/ProjectMeasuresQueryFactoryTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/ProjectMeasuresQueryFactoryTest.java
index f94965da229..f1527779f6a 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/ProjectMeasuresQueryFactoryTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/component/ws/ProjectMeasuresQueryFactoryTest.java
@@ -223,7 +223,7 @@ public class ProjectMeasuresQueryFactoryTest {
ProjectMeasuresQuery underTest = newProjectMeasuresQuery(criteria, emptySet());
- assertThat(underTest.getQueryText().get()).isEqualTo("Sonar Qube");
+ assertThat(underTest.getQueryText()).contains("Sonar Qube");
}
@Test
@@ -232,7 +232,7 @@ public class ProjectMeasuresQueryFactoryTest {
ProjectMeasuresQuery underTest = newProjectMeasuresQuery(criteria, emptySet());
- assertThat(underTest.getQueryText().get()).isEqualTo("Sonar Qube");
+ assertThat(underTest.getQueryText()).contains("Sonar Qube");
}
@Test
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/health/ClusterHealthTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/health/ClusterHealthTest.java
index 92877530b13..77607d5326b 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/health/ClusterHealthTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/health/ClusterHealthTest.java
@@ -103,7 +103,7 @@ public class ClusterHealthTest {
ClusterHealth underTest = new ClusterHealth(health, nodeHealths);
- assertThat(underTest.toString()).isEqualTo("ClusterHealth{health=" + health + ", nodes=" + nodeHealths + "}");
+ assertThat(underTest).hasToString("ClusterHealth{health=" + health + ", nodes=" + nodeHealths + "}");
}
@Test
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/health/HealthTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/health/HealthTest.java
index 6bd73db2a5b..53b8db9b9f0 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/health/HealthTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/health/HealthTest.java
@@ -142,7 +142,7 @@ public class HealthTest {
@Test
public void verify_toString() {
- assertThat(Health.GREEN.toString()).isEqualTo("Health{GREEN, causes=[]}");
+ assertThat(Health.GREEN).hasToString("Health{GREEN, causes=[]}");
Health.Builder builder = Health.builder().setStatus(anyStatus);
randomCauses.forEach(builder::addCause);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/newcodeperiod/ws/ListActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/newcodeperiod/ws/ListActionTest.java
index 950663c8ee1..6d2a67396f5 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/newcodeperiod/ws/ListActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/newcodeperiod/ws/ListActionTest.java
@@ -17,351 +17,372 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.server.newcodeperiod.ws;
-
-import java.time.Instant;
-import java.util.Optional;
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonar.api.server.ws.WebService;
-import org.sonar.api.utils.DateUtils;
-import org.sonar.api.utils.System2;
-import org.sonar.api.web.UserRole;
-import org.sonar.core.util.UuidFactoryFast;
-import org.sonar.db.DbClient;
-import org.sonar.db.DbTester;
-import org.sonar.db.component.BranchType;
-import org.sonar.db.component.ComponentDbTester;
-import org.sonar.db.component.ComponentDto;
-import org.sonar.db.component.SnapshotDto;
-import org.sonar.db.newcodeperiod.NewCodePeriodDao;
-import org.sonar.db.newcodeperiod.NewCodePeriodDbTester;
-import org.sonar.db.newcodeperiod.NewCodePeriodDto;
-import org.sonar.db.newcodeperiod.NewCodePeriodType;
-import org.sonar.server.component.ComponentFinder;
-import org.sonar.server.component.TestComponentFinder;
-import org.sonar.server.exceptions.ForbiddenException;
-import org.sonar.server.exceptions.NotFoundException;
-import org.sonar.server.tester.UserSessionRule;
-import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.NewCodePeriods;
-import org.sonarqube.ws.NewCodePeriods.ListWSResponse;
-import org.sonarqube.ws.NewCodePeriods.ShowWSResponse;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
-import static org.sonar.db.component.SnapshotTesting.newAnalysis;
-
-public class ListActionTest {
- @Rule
- public UserSessionRule userSession = UserSessionRule.standalone();
- @Rule
- public DbTester db = DbTester.create(System2.INSTANCE);
-
- private ComponentDbTester componentDb = new ComponentDbTester(db);
- private DbClient dbClient = db.getDbClient();
- private ComponentFinder componentFinder = TestComponentFinder.from(db);
- private NewCodePeriodDao dao = new NewCodePeriodDao(System2.INSTANCE, UuidFactoryFast.getInstance());
- private NewCodePeriodDbTester tester = new NewCodePeriodDbTester(db);
- private ListAction underTest = new ListAction(dbClient, userSession, componentFinder, dao);
- private WsActionTester ws = new WsActionTester(underTest);
-
- @Test
- public void test_definition() {
- WebService.Action definition = ws.getDef();
-
- assertThat(definition.key()).isEqualTo("list");
- assertThat(definition.isInternal()).isFalse();
- assertThat(definition.since()).isEqualTo("8.0");
- assertThat(definition.isPost()).isFalse();
-
- assertThat(definition.params()).extracting(WebService.Param::key).containsOnly("project");
- assertThat(definition.param("project").isRequired()).isTrue();
- }
+ /*
+ * SonarQube
+ * Copyright (C) 2009-2023 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+ package org.sonar.server.newcodeperiod.ws;
+
+ import java.time.Instant;
+ import java.util.Optional;
+ import org.junit.Rule;
+ import org.junit.Test;
+ import org.sonar.api.server.ws.WebService;
+ import org.sonar.api.utils.DateUtils;
+ import org.sonar.api.utils.System2;
+ import org.sonar.api.web.UserRole;
+ import org.sonar.core.util.UuidFactoryFast;
+ import org.sonar.db.DbClient;
+ import org.sonar.db.DbTester;
+ import org.sonar.db.component.BranchType;
+ import org.sonar.db.component.ComponentDbTester;
+ import org.sonar.db.component.ComponentDto;
+ import org.sonar.db.component.SnapshotDto;
+ import org.sonar.db.newcodeperiod.NewCodePeriodDao;
+ import org.sonar.db.newcodeperiod.NewCodePeriodDbTester;
+ import org.sonar.db.newcodeperiod.NewCodePeriodDto;
+ import org.sonar.db.newcodeperiod.NewCodePeriodType;
+ import org.sonar.server.component.ComponentFinder;
+ import org.sonar.server.component.TestComponentFinder;
+ import org.sonar.server.exceptions.ForbiddenException;
+ import org.sonar.server.exceptions.NotFoundException;
+ import org.sonar.server.tester.UserSessionRule;
+ import org.sonar.server.ws.WsActionTester;
+ import org.sonarqube.ws.NewCodePeriods;
+ import org.sonarqube.ws.NewCodePeriods.ListWSResponse;
+ import org.sonarqube.ws.NewCodePeriods.ShowWSResponse;
+
+ import static org.assertj.core.api.Assertions.assertThat;
+ import static org.assertj.core.api.Assertions.assertThatThrownBy;
+ import static org.sonar.db.component.BranchDto.DEFAULT_MAIN_BRANCH_NAME;
+ import static org.sonar.db.component.SnapshotTesting.newAnalysis;
+
+ public class ListActionTest {
+ @Rule
+ public UserSessionRule userSession = UserSessionRule.standalone();
+ @Rule
+ public DbTester db = DbTester.create(System2.INSTANCE);
+
+ private ComponentDbTester componentDb = new ComponentDbTester(db);
+ private DbClient dbClient = db.getDbClient();
+ private ComponentFinder componentFinder = TestComponentFinder.from(db);
+ private NewCodePeriodDao dao = new NewCodePeriodDao(System2.INSTANCE, UuidFactoryFast.getInstance());
+ private NewCodePeriodDbTester tester = new NewCodePeriodDbTester(db);
+ private ListAction underTest = new ListAction(dbClient, userSession, componentFinder, dao);
+ private WsActionTester ws = new WsActionTester(underTest);
+
+ @Test
+ public void test_definition() {
+ WebService.Action definition = ws.getDef();
+
+ assertThat(definition.key()).isEqualTo("list");
+ assertThat(definition.isInternal()).isFalse();
+ assertThat(definition.since()).isEqualTo("8.0");
+ assertThat(definition.isPost()).isFalse();
+
+ assertThat(definition.params()).extracting(WebService.Param::key).containsOnly("project");
+ assertThat(definition.param("project").isRequired()).isTrue();
+ }
- @Test
- public void throw_NFE_if_project_not_found() {
- assertThatThrownBy(() -> ws.newRequest()
- .setParam("project", "unknown")
- .execute())
- .isInstanceOf(NotFoundException.class)
- .hasMessageContaining("Project 'unknown' not found");
- }
+ @Test
+ public void throw_NFE_if_project_not_found() {
+ assertThatThrownBy(() -> ws.newRequest()
+ .setParam("project", "unknown")
+ .execute())
+ .isInstanceOf(NotFoundException.class)
+ .hasMessageContaining("Project 'unknown' not found");
+ }
- @Test
- public void throw_FE_if_no_project_permission() {
- ComponentDto project = componentDb.insertPublicProject();
+ @Test
+ public void throw_FE_if_no_project_permission() {
+ ComponentDto project = componentDb.insertPublicProject();
- assertThatThrownBy(() -> ws.newRequest()
- .setParam("project", project.getKey())
- .execute())
- .isInstanceOf(ForbiddenException.class)
- .hasMessageContaining("Insufficient privileges");
- }
+ assertThatThrownBy(() -> ws.newRequest()
+ .setParam("project", project.getKey())
+ .execute())
+ .isInstanceOf(ForbiddenException.class)
+ .hasMessageContaining("Insufficient privileges");
+ }
- @Test
- public void list_only_branches() {
- ComponentDto project = componentDb.insertPublicProject();
+ @Test
+ public void list_only_branches() {
+ ComponentDto project = componentDb.insertPublicProject();
- createBranches(project, 5, BranchType.BRANCH);
- createBranches(project, 3, BranchType.PULL_REQUEST);
+ createBranches(project, 5, BranchType.BRANCH);
+ createBranches(project, 3, BranchType.PULL_REQUEST);
- logInAsProjectAdministrator(project);
+ logInAsProjectAdministrator(project);
- ListWSResponse response = ws.newRequest()
- .setParam("project", project.getKey())
- .executeProtobuf(ListWSResponse.class);
+ ListWSResponse response = ws.newRequest()
+ .setParam("project", project.getKey())
+ .executeProtobuf(ListWSResponse.class);
- assertThat(response).isNotNull();
- assertThat(response.getNewCodePeriodsCount()).isEqualTo(6);
- assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey)
- .contains(DEFAULT_MAIN_BRANCH_NAME, "BRANCH_0", "BRANCH_1", "BRANCH_2", "BRANCH_3", "BRANCH_4");
+ assertThat(response).isNotNull();
+ assertThat(response.getNewCodePeriodsCount()).isEqualTo(6);
+ assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey)
+ .contains(DEFAULT_MAIN_BRANCH_NAME, "BRANCH_0", "BRANCH_1", "BRANCH_2", "BRANCH_3", "BRANCH_4");
- //check if global default is set
- assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getType)
- .contains(NewCodePeriods.NewCodePeriodType.PREVIOUS_VERSION);
- }
+ //check if global default is set
+ assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getType)
+ .contains(NewCodePeriods.NewCodePeriodType.PREVIOUS_VERSION);
+ }
- @Test
- public void list_inherited_global_settings() {
- ComponentDto project = componentDb.insertPublicProject();
- tester.insert(new NewCodePeriodDto().setType(NewCodePeriodType.SPECIFIC_ANALYSIS).setValue("uuid"));
+ @Test
+ public void list_inherited_global_settings() {
+ ComponentDto project = componentDb.insertPublicProject();
+ tester.insert(new NewCodePeriodDto().setType(NewCodePeriodType.SPECIFIC_ANALYSIS).setValue("uuid"));
- createBranches(project, 5, BranchType.BRANCH);
+ createBranches(project, 5, BranchType.BRANCH);
- logInAsProjectAdministrator(project);
+ logInAsProjectAdministrator(project);
- ListWSResponse response = ws.newRequest()
- .setParam("project", project.getKey())
- .executeProtobuf(ListWSResponse.class);
+ ListWSResponse response = ws.newRequest()
+ .setParam("project", project.getKey())
+ .executeProtobuf(ListWSResponse.class);
- assertThat(response).isNotNull();
- assertThat(response.getNewCodePeriodsCount()).isEqualTo(6);
- assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey)
- .contains(DEFAULT_MAIN_BRANCH_NAME, "BRANCH_0", "BRANCH_1", "BRANCH_2", "BRANCH_3", "BRANCH_4");
+ assertThat(response).isNotNull();
+ assertThat(response.getNewCodePeriodsCount()).isEqualTo(6);
+ assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey)
+ .contains(DEFAULT_MAIN_BRANCH_NAME, "BRANCH_0", "BRANCH_1", "BRANCH_2", "BRANCH_3", "BRANCH_4");
- //check if global default is set
- assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getType)
- .contains(NewCodePeriods.NewCodePeriodType.SPECIFIC_ANALYSIS);
- assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getValue)
- .contains("uuid");
- assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getInherited)
- .contains(true);
- }
+ //check if global default is set
+ assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getType)
+ .contains(NewCodePeriods.NewCodePeriodType.SPECIFIC_ANALYSIS);
+ assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getValue)
+ .contains("uuid");
+ assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getInherited)
+ .contains(true);
+ }
- @Test
- public void list_inherited_project_settings() {
- ComponentDto projectWithOwnSettings = componentDb.insertPublicProject();
- ComponentDto projectWithGlobalSettings = componentDb.insertPublicProject();
- tester.insert(new NewCodePeriodDto()
- .setType(NewCodePeriodType.SPECIFIC_ANALYSIS)
- .setValue("global_uuid"));
- tester.insert(new NewCodePeriodDto()
- .setProjectUuid(projectWithOwnSettings.uuid())
- .setType(NewCodePeriodType.SPECIFIC_ANALYSIS)
- .setValue("project_uuid"));
-
- createBranches(projectWithOwnSettings, 5, BranchType.BRANCH);
-
- logInAsProjectAdministrator(projectWithOwnSettings, projectWithGlobalSettings);
-
- ListWSResponse response = ws.newRequest()
- .setParam("project", projectWithOwnSettings.getKey())
- .executeProtobuf(ListWSResponse.class);
-
- //verify project with project level settings
- assertThat(response).isNotNull();
- assertThat(response.getNewCodePeriodsCount()).isEqualTo(6);
- assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey)
- .contains(DEFAULT_MAIN_BRANCH_NAME, "BRANCH_0", "BRANCH_1", "BRANCH_2", "BRANCH_3", "BRANCH_4");
-
- //check if project setting is set
- assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getType)
- .contains(NewCodePeriods.NewCodePeriodType.SPECIFIC_ANALYSIS);
- assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getValue)
- .containsOnly("project_uuid");
- assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getInherited)
- .containsOnly(true);
-
- //verify project with global level settings
- response = ws.newRequest()
- .setParam("project", projectWithGlobalSettings.getKey())
- .executeProtobuf(ListWSResponse.class);
-
- assertThat(response).isNotNull();
- assertThat(response.getNewCodePeriodsCount()).isOne();
- assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey)
- .containsOnly(DEFAULT_MAIN_BRANCH_NAME);
-
- //check if global setting is set
- assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getType)
- .contains(NewCodePeriods.NewCodePeriodType.SPECIFIC_ANALYSIS);
- assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getValue)
- .contains("global_uuid");
- assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getInherited)
- .containsOnly(true);
- }
+ @Test
+ public void list_inherited_project_settings() {
+ ComponentDto projectWithOwnSettings = componentDb.insertPublicProject();
+ ComponentDto projectWithGlobalSettings = componentDb.insertPublicProject();
+ tester.insert(new NewCodePeriodDto()
+ .setType(NewCodePeriodType.SPECIFIC_ANALYSIS)
+ .setValue("global_uuid"));
+ tester.insert(new NewCodePeriodDto()
+ .setProjectUuid(projectWithOwnSettings.uuid())
+ .setType(NewCodePeriodType.SPECIFIC_ANALYSIS)
+ .setValue("project_uuid"));
+
+ createBranches(projectWithOwnSettings, 5, BranchType.BRANCH);
+
+ logInAsProjectAdministrator(projectWithOwnSettings, projectWithGlobalSettings);
+
+ ListWSResponse response = ws.newRequest()
+ .setParam("project", projectWithOwnSettings.getKey())
+ .executeProtobuf(ListWSResponse.class);
+
+ //verify project with project level settings
+ assertThat(response).isNotNull();
+ assertThat(response.getNewCodePeriodsCount()).isEqualTo(6);
+ assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey)
+ .contains(DEFAULT_MAIN_BRANCH_NAME, "BRANCH_0", "BRANCH_1", "BRANCH_2", "BRANCH_3", "BRANCH_4");
+
+ //check if project setting is set
+ assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getType)
+ .contains(NewCodePeriods.NewCodePeriodType.SPECIFIC_ANALYSIS);
+ assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getValue)
+ .containsOnly("project_uuid");
+ assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getInherited)
+ .containsOnly(true);
+
+ //verify project with global level settings
+ response = ws.newRequest()
+ .setParam("project", projectWithGlobalSettings.getKey())
+ .executeProtobuf(ListWSResponse.class);
+
+ assertThat(response).isNotNull();
+ assertThat(response.getNewCodePeriodsCount()).isOne();
+ assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey)
+ .containsOnly(DEFAULT_MAIN_BRANCH_NAME);
+
+ //check if global setting is set
+ assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getType)
+ .contains(NewCodePeriods.NewCodePeriodType.SPECIFIC_ANALYSIS);
+ assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getValue)
+ .contains("global_uuid");
+ assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getInherited)
+ .containsOnly(true);
+ }
- @Test
- public void list_branch_and_inherited_global_settings() {
- ComponentDto project = componentDb.insertPublicProject();
- ComponentDto branchWithOwnSettings = componentDb.insertProjectBranch(project, branchDto -> branchDto.setKey("OWN_SETTINGS"));
- componentDb.insertProjectBranch(project, branchDto -> branchDto.setKey("GLOBAL_SETTINGS"));
-
- tester.insert(new NewCodePeriodDto()
- .setType(NewCodePeriodType.SPECIFIC_ANALYSIS)
- .setValue("global_uuid"));
-
- tester.insert(new NewCodePeriodDto()
- .setProjectUuid(project.uuid())
- .setBranchUuid(branchWithOwnSettings.uuid())
- .setType(NewCodePeriodType.SPECIFIC_ANALYSIS)
- .setValue("branch_uuid"));
-
- logInAsProjectAdministrator(project);
-
- ListWSResponse response = ws.newRequest()
- .setParam("project", project.getKey())
- .executeProtobuf(ListWSResponse.class);
-
- assertThat(response).isNotNull();
- assertThat(response.getNewCodePeriodsCount()).isEqualTo(3);
- assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey)
- .contains(DEFAULT_MAIN_BRANCH_NAME, "OWN_SETTINGS", "GLOBAL_SETTINGS");
-
- Optional<ShowWSResponse> ownSettings = response.getNewCodePeriodsList().stream()
- .filter(s -> !s.getInherited())
- .findFirst();
-
- assertThat(ownSettings).isNotNull();
- assertThat(ownSettings).isNotEmpty();
- assertThat(ownSettings.get().getProjectKey()).isEqualTo(project.getKey());
- assertThat(ownSettings.get().getBranchKey()).isEqualTo("OWN_SETTINGS");
- assertThat(ownSettings.get().getType()).isEqualTo(NewCodePeriods.NewCodePeriodType.SPECIFIC_ANALYSIS);
- assertThat(ownSettings.get().getValue()).isEqualTo("branch_uuid");
- assertThat(ownSettings.get().getInherited()).isFalse();
-
- //check if global default is set
- assertThat(response.getNewCodePeriodsList())
- .filteredOn(ShowWSResponse::getInherited)
- .extracting(ShowWSResponse::getType)
- .contains(NewCodePeriods.NewCodePeriodType.SPECIFIC_ANALYSIS);
- assertThat(response.getNewCodePeriodsList())
- .filteredOn(ShowWSResponse::getInherited)
- .extracting(ShowWSResponse::getValue)
- .contains("global_uuid");
- }
+ @Test
+ public void list_branch_and_inherited_global_settings() {
+ ComponentDto project = componentDb.insertPublicProject();
+ ComponentDto branchWithOwnSettings = componentDb.insertProjectBranch(project, branchDto -> branchDto.setKey("OWN_SETTINGS"));
+ componentDb.insertProjectBranch(project, branchDto -> branchDto.setKey("GLOBAL_SETTINGS"));
+
+ tester.insert(new NewCodePeriodDto()
+ .setType(NewCodePeriodType.SPECIFIC_ANALYSIS)
+ .setValue("global_uuid"));
+
+ tester.insert(new NewCodePeriodDto()
+ .setProjectUuid(project.uuid())
+ .setBranchUuid(branchWithOwnSettings.uuid())
+ .setType(NewCodePeriodType.SPECIFIC_ANALYSIS)
+ .setValue("branch_uuid"));
+
+ logInAsProjectAdministrator(project);
+
+ ListWSResponse response = ws.newRequest()
+ .setParam("project", project.getKey())
+ .executeProtobuf(ListWSResponse.class);
+
+ assertThat(response).isNotNull();
+ assertThat(response.getNewCodePeriodsCount()).isEqualTo(3);
+ assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey)
+ .contains(DEFAULT_MAIN_BRANCH_NAME, "OWN_SETTINGS", "GLOBAL_SETTINGS");
+
+ Optional<ShowWSResponse> ownSettings = response.getNewCodePeriodsList().stream()
+ .filter(s -> !s.getInherited())
+ .findFirst();
+
+ assertThat(ownSettings)
+ .isNotNull()
+ .isNotEmpty();
+ assertThat(ownSettings.get().getProjectKey()).isEqualTo(project.getKey());
+ assertThat(ownSettings.get().getBranchKey()).isEqualTo("OWN_SETTINGS");
+ assertThat(ownSettings.get().getType()).isEqualTo(NewCodePeriods.NewCodePeriodType.SPECIFIC_ANALYSIS);
+ assertThat(ownSettings.get().getValue()).isEqualTo("branch_uuid");
+ assertThat(ownSettings.get().getInherited()).isFalse();
+
+ //check if global default is set
+ assertThat(response.getNewCodePeriodsList())
+ .filteredOn(ShowWSResponse::getInherited)
+ .extracting(ShowWSResponse::getType)
+ .contains(NewCodePeriods.NewCodePeriodType.SPECIFIC_ANALYSIS);
+ assertThat(response.getNewCodePeriodsList())
+ .filteredOn(ShowWSResponse::getInherited)
+ .extracting(ShowWSResponse::getValue)
+ .contains("global_uuid");
+ }
- @Test
- public void list_branch_and_inherited_project_settings() {
- ComponentDto project = componentDb.insertPublicProject();
- ComponentDto branchWithOwnSettings = componentDb.insertProjectBranch(project, branchDto -> branchDto.setKey("OWN_SETTINGS"));
- componentDb.insertProjectBranch(project, branchDto -> branchDto.setKey("PROJECT_SETTINGS"));
-
- tester.insert(new NewCodePeriodDto()
- .setType(NewCodePeriodType.SPECIFIC_ANALYSIS)
- .setValue("global_uuid"));
-
- tester.insert(new NewCodePeriodDto()
- .setProjectUuid(project.uuid())
- .setType(NewCodePeriodType.SPECIFIC_ANALYSIS)
- .setValue("project_uuid"));
-
- tester.insert(new NewCodePeriodDto()
- .setProjectUuid(project.uuid())
- .setBranchUuid(branchWithOwnSettings.uuid())
- .setType(NewCodePeriodType.SPECIFIC_ANALYSIS)
- .setValue("branch_uuid"));
-
- logInAsProjectAdministrator(project);
-
- ListWSResponse response = ws.newRequest()
- .setParam("project", project.getKey())
- .executeProtobuf(ListWSResponse.class);
-
- assertThat(response).isNotNull();
- assertThat(response.getNewCodePeriodsCount()).isEqualTo(3);
- assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey)
- .contains(DEFAULT_MAIN_BRANCH_NAME, "OWN_SETTINGS", "PROJECT_SETTINGS");
-
- Optional<ShowWSResponse> ownSettings = response.getNewCodePeriodsList().stream()
- .filter(s -> !s.getInherited())
- .findFirst();
-
- assertThat(ownSettings).isNotNull();
- assertThat(ownSettings).isNotEmpty();
- assertThat(ownSettings.get().getProjectKey()).isEqualTo(project.getKey());
- assertThat(ownSettings.get().getBranchKey()).isEqualTo("OWN_SETTINGS");
- assertThat(ownSettings.get().getType()).isEqualTo(NewCodePeriods.NewCodePeriodType.SPECIFIC_ANALYSIS);
- assertThat(ownSettings.get().getValue()).isEqualTo("branch_uuid");
- assertThat(ownSettings.get().getInherited()).isFalse();
-
- //check if global default is set
- assertThat(response.getNewCodePeriodsList())
- .filteredOn(ShowWSResponse::getInherited)
- .extracting(ShowWSResponse::getType)
- .contains(NewCodePeriods.NewCodePeriodType.SPECIFIC_ANALYSIS);
- assertThat(response.getNewCodePeriodsList())
- .filteredOn(ShowWSResponse::getInherited)
- .extracting(ShowWSResponse::getValue)
- .contains("project_uuid");
- }
+ @Test
+ public void list_branch_and_inherited_project_settings() {
+ ComponentDto project = componentDb.insertPublicProject();
+ ComponentDto branchWithOwnSettings = componentDb.insertProjectBranch(project, branchDto -> branchDto.setKey("OWN_SETTINGS"));
+ componentDb.insertProjectBranch(project, branchDto -> branchDto.setKey("PROJECT_SETTINGS"));
+
+ tester.insert(new NewCodePeriodDto()
+ .setType(NewCodePeriodType.SPECIFIC_ANALYSIS)
+ .setValue("global_uuid"));
+
+ tester.insert(new NewCodePeriodDto()
+ .setProjectUuid(project.uuid())
+ .setType(NewCodePeriodType.SPECIFIC_ANALYSIS)
+ .setValue("project_uuid"));
+
+ tester.insert(new NewCodePeriodDto()
+ .setProjectUuid(project.uuid())
+ .setBranchUuid(branchWithOwnSettings.uuid())
+ .setType(NewCodePeriodType.SPECIFIC_ANALYSIS)
+ .setValue("branch_uuid"));
+
+ logInAsProjectAdministrator(project);
+
+ ListWSResponse response = ws.newRequest()
+ .setParam("project", project.getKey())
+ .executeProtobuf(ListWSResponse.class);
+
+ assertThat(response).isNotNull();
+ assertThat(response.getNewCodePeriodsCount()).isEqualTo(3);
+ assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey)
+ .contains(DEFAULT_MAIN_BRANCH_NAME, "OWN_SETTINGS", "PROJECT_SETTINGS");
+
+ Optional<ShowWSResponse> ownSettings = response.getNewCodePeriodsList().stream()
+ .filter(s -> !s.getInherited())
+ .findFirst();
+
+ assertThat(ownSettings)
+ .isNotNull()
+ .isNotEmpty();
+ assertThat(ownSettings.get().getProjectKey()).isEqualTo(project.getKey());
+ assertThat(ownSettings.get().getBranchKey()).isEqualTo("OWN_SETTINGS");
+ assertThat(ownSettings.get().getType()).isEqualTo(NewCodePeriods.NewCodePeriodType.SPECIFIC_ANALYSIS);
+ assertThat(ownSettings.get().getValue()).isEqualTo("branch_uuid");
+ assertThat(ownSettings.get().getInherited()).isFalse();
+
+ //check if global default is set
+ assertThat(response.getNewCodePeriodsList())
+ .filteredOn(ShowWSResponse::getInherited)
+ .extracting(ShowWSResponse::getType)
+ .contains(NewCodePeriods.NewCodePeriodType.SPECIFIC_ANALYSIS);
+ assertThat(response.getNewCodePeriodsList())
+ .filteredOn(ShowWSResponse::getInherited)
+ .extracting(ShowWSResponse::getValue)
+ .contains("project_uuid");
+ }
- @Test
- public void verify_specific_analysis_effective_value() {
- ComponentDto project = componentDb.insertPublicProject();
- ComponentDto branch = componentDb.insertProjectBranch(project, branchDto -> branchDto.setKey("PROJECT_BRANCH"));
-
- SnapshotDto analysis = componentDb.insertSnapshot(newAnalysis(project)
- .setUuid("A1")
- .setCreatedAt(Instant.now().toEpochMilli())
- .setProjectVersion("1.2")
- .setBuildString("1.2.0.322")
- .setRevision("bfe36592eb7f9f2708b5d358b5b5f33ed535c8cf")
- );
-
- componentDb.insertSnapshot(newAnalysis(project)
- .setUuid("A2")
- .setCreatedAt(Instant.now().toEpochMilli())
- .setProjectVersion("1.2")
- .setBuildString("1.2.0.322")
- .setRevision("2d6d5d8d5fabe2223f07aa495e794d0401ff4b04")
- );
-
- tester.insert(new NewCodePeriodDto()
- .setProjectUuid(project.uuid())
- .setBranchUuid(branch.uuid())
- .setType(NewCodePeriodType.SPECIFIC_ANALYSIS)
- .setValue(analysis.getUuid()));
-
- logInAsProjectAdministrator(project);
-
- ListWSResponse response = ws.newRequest()
- .setParam("project", project.getKey())
- .executeProtobuf(ListWSResponse.class);
-
- assertThat(response).isNotNull();
- assertThat(response.getNewCodePeriodsCount()).isEqualTo(2);
- assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey)
- .containsOnly(DEFAULT_MAIN_BRANCH_NAME, "PROJECT_BRANCH");
-
- ShowWSResponse result = response.getNewCodePeriodsList().get(0);
- assertThat(result.getType()).isEqualTo(NewCodePeriods.NewCodePeriodType.SPECIFIC_ANALYSIS);
- assertThat(result.getValue()).isEqualTo("A1");
- assertThat(result.getProjectKey()).isEqualTo(project.getKey());
- assertThat(result.getBranchKey()).isEqualTo("PROJECT_BRANCH");
- assertThat(result.getEffectiveValue()).isEqualTo(DateUtils.formatDateTime(analysis.getCreatedAt()));
- }
+ @Test
+ public void verify_specific_analysis_effective_value() {
+ ComponentDto project = componentDb.insertPublicProject();
+ ComponentDto branch = componentDb.insertProjectBranch(project, branchDto -> branchDto.setKey("PROJECT_BRANCH"));
+
+ SnapshotDto analysis = componentDb.insertSnapshot(newAnalysis(project)
+ .setUuid("A1")
+ .setCreatedAt(Instant.now().toEpochMilli())
+ .setProjectVersion("1.2")
+ .setBuildString("1.2.0.322")
+ .setRevision("bfe36592eb7f9f2708b5d358b5b5f33ed535c8cf")
+ );
+
+ componentDb.insertSnapshot(newAnalysis(project)
+ .setUuid("A2")
+ .setCreatedAt(Instant.now().toEpochMilli())
+ .setProjectVersion("1.2")
+ .setBuildString("1.2.0.322")
+ .setRevision("2d6d5d8d5fabe2223f07aa495e794d0401ff4b04")
+ );
+
+ tester.insert(new NewCodePeriodDto()
+ .setProjectUuid(project.uuid())
+ .setBranchUuid(branch.uuid())
+ .setType(NewCodePeriodType.SPECIFIC_ANALYSIS)
+ .setValue(analysis.getUuid()));
+
+ logInAsProjectAdministrator(project);
+
+ ListWSResponse response = ws.newRequest()
+ .setParam("project", project.getKey())
+ .executeProtobuf(ListWSResponse.class);
+
+ assertThat(response).isNotNull();
+ assertThat(response.getNewCodePeriodsCount()).isEqualTo(2);
+ assertThat(response.getNewCodePeriodsList()).extracting(ShowWSResponse::getBranchKey)
+ .containsOnly(DEFAULT_MAIN_BRANCH_NAME, "PROJECT_BRANCH");
+
+ ShowWSResponse result = response.getNewCodePeriodsList().get(0);
+ assertThat(result.getType()).isEqualTo(NewCodePeriods.NewCodePeriodType.SPECIFIC_ANALYSIS);
+ assertThat(result.getValue()).isEqualTo("A1");
+ assertThat(result.getProjectKey()).isEqualTo(project.getKey());
+ assertThat(result.getBranchKey()).isEqualTo("PROJECT_BRANCH");
+ assertThat(result.getEffectiveValue()).isEqualTo(DateUtils.formatDateTime(analysis.getCreatedAt()));
+ }
- private void createBranches(ComponentDto project, int numberOfBranches, BranchType branchType) {
- for (int branchCount = 0; branchCount < numberOfBranches; branchCount++) {
- String branchKey = String.format("%s_%d", branchType.name(), branchCount);
- componentDb.insertProjectBranch(project, branchDto -> branchDto.setKey(branchKey).setBranchType(branchType));
+ private void createBranches(ComponentDto project, int numberOfBranches, BranchType branchType) {
+ for (int branchCount = 0; branchCount < numberOfBranches; branchCount++) {
+ String branchKey = String.format("%s_%d", branchType.name(), branchCount);
+ componentDb.insertProjectBranch(project, branchDto -> branchDto.setKey(branchKey).setBranchType(branchType));
+ }
}
- }
- private void logInAsProjectAdministrator(ComponentDto... project) {
- userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
+ private void logInAsProjectAdministrator(ComponentDto... project) {
+ userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
+ }
}
-}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/plugins/ws/PluginUpdateAggregatorTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/plugins/ws/PluginUpdateAggregatorTest.java
index bb0e805760c..f0acf654436 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/plugins/ws/PluginUpdateAggregatorTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/plugins/ws/PluginUpdateAggregatorTest.java
@@ -71,10 +71,11 @@ public class PluginUpdateAggregatorTest {
assertThat(aggregates).hasSize(1);
Collection<PluginUpdate> releases = aggregates.iterator().next().getUpdates();
- assertThat(releases).hasSize(3);
- assertThat(releases).contains(pluginUpdate1);
- assertThat(releases).contains(pluginUpdate2);
- assertThat(releases).contains(pluginUpdate3);
+ assertThat(releases)
+ .hasSize(3)
+ .contains(pluginUpdate1)
+ .contains(pluginUpdate2)
+ .contains(pluginUpdate3);
}
private PluginUpdate createPluginUpdate(String pluginKey) {
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileExportersTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileExportersTest.java
index 4610df73e85..067403a5ec8 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileExportersTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileExportersTest.java
@@ -151,11 +151,11 @@ public class QProfileExportersTest {
StringWriter writer = new StringWriter();
underTest.export(db.getSession(), profile, "standard", writer);
- assertThat(writer.toString()).isEqualTo("standard -> " + profile.getName() + " -> 0");
+ assertThat(writer).hasToString("standard -> " + profile.getName() + " -> 0");
writer = new StringWriter();
underTest.export(db.getSession(), profile, "xootool", writer);
- assertThat(writer.toString()).isEqualTo("xoo -> " + profile.getName() + " -> 0");
+ assertThat(writer).hasToString("xoo -> " + profile.getName() + " -> 0");
}
@Test
@@ -165,11 +165,11 @@ public class QProfileExportersTest {
StringWriter writer = new StringWriter();
underTest.export(db.getSession(), profile, "standard", writer);
- assertThat(writer.toString()).isEqualTo("standard -> " + profile.getName() + " -> 1");
+ assertThat(writer).hasToString("standard -> " + profile.getName() + " -> 1");
writer = new StringWriter();
underTest.export(db.getSession(), profile, "xootool", writer);
- assertThat(writer.toString()).isEqualTo("xoo -> " + profile.getName() + " -> 1");
+ assertThat(writer).hasToString("xoo -> " + profile.getName() + " -> 1");
}
@Test
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/source/HtmlTextDecoratorTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/source/HtmlTextDecoratorTest.java
index fc1e3212642..5da5be8c060 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/source/HtmlTextDecoratorTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/source/HtmlTextDecoratorTest.java
@@ -19,9 +19,8 @@
*/
package org.sonar.server.source;
-import org.junit.Test;
-
import java.util.List;
+import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.server.source.HtmlTextDecorator.CR_END_OF_LINE;
@@ -322,19 +321,19 @@ public class HtmlTextDecoratorTest {
HtmlTextDecorator htmlTextDecorator = new HtmlTextDecorator();
List<String> htmlOutput = htmlTextDecorator.decorateTextWithHtml(javadocWithHtml, decorationData, 4, null);
- assertThat(htmlOutput).hasSize(9);
-
- // Begin from line 4
- assertThat(htmlOutput).containsExactly(
- "<span class=\"cppd\"> * This framework can used for instance in order to :</span>",
- "<span class=\"cppd\"> * &lt;ul&gt;</span>",
- "<span class=\"cppd\"> * &lt;li&gt;Create a lexer in charge to generate a list of tokens from a character stream&lt;/li&gt;</span>",
- "<span class=\"cppd\"> * &lt;li&gt;Create a source code syntax highligther in charge to decorate a source code with HTML tags&lt;/li&gt;</span>",
- "<span class=\"cppd\"> * &lt;li&gt;Create a javadoc generator&lt;/li&gt;</span>",
- "<span class=\"cppd\"> * &lt;li&gt;...&lt;/li&gt;</span>",
- "<span class=\"cppd\"> * &lt;/ul&gt;</span>",
- "<span class=\"cppd\"> */</span>",
- "");
+ assertThat(htmlOutput)
+ .hasSize(9)
+ // Begin from line 4
+ .containsExactly(
+ "<span class=\"cppd\"> * This framework can used for instance in order to :</span>",
+ "<span class=\"cppd\"> * &lt;ul&gt;</span>",
+ "<span class=\"cppd\"> * &lt;li&gt;Create a lexer in charge to generate a list of tokens from a character stream&lt;/li&gt;</span>",
+ "<span class=\"cppd\"> * &lt;li&gt;Create a source code syntax highligther in charge to decorate a source code with HTML tags&lt;/li&gt;</span>",
+ "<span class=\"cppd\"> * &lt;li&gt;Create a javadoc generator&lt;/li&gt;</span>",
+ "<span class=\"cppd\"> * &lt;li&gt;...&lt;/li&gt;</span>",
+ "<span class=\"cppd\"> * &lt;/ul&gt;</span>",
+ "<span class=\"cppd\"> */</span>",
+ "");
}
@Test
@@ -358,14 +357,14 @@ public class HtmlTextDecoratorTest {
HtmlTextDecorator htmlTextDecorator = new HtmlTextDecorator();
List<String> htmlOutput = htmlTextDecorator.decorateTextWithHtml(javadocWithHtml, decorationData, null, 4);
- assertThat(htmlOutput).hasSize(4);
-
- // End at line 4
- assertThat(htmlOutput).containsExactly(
- "<span class=\"cppd\">/**</span>",
- "<span class=\"cppd\"> * Provides a basic framework to sequentially read any kind of character stream in order to feed a generic OUTPUT.</span>",
- "<span class=\"cppd\"> * </span>",
- "<span class=\"cppd\"> * This framework can used for instance in order to :</span>");
+ assertThat(htmlOutput)
+ .hasSize(4)
+ // End at line 4
+ .containsExactly(
+ "<span class=\"cppd\">/**</span>",
+ "<span class=\"cppd\"> * Provides a basic framework to sequentially read any kind of character stream in order to feed a generic OUTPUT.</span>",
+ "<span class=\"cppd\"> * </span>",
+ "<span class=\"cppd\"> * This framework can used for instance in order to :</span>");
}
@Test
@@ -389,15 +388,15 @@ public class HtmlTextDecoratorTest {
HtmlTextDecorator htmlTextDecorator = new HtmlTextDecorator();
List<String> htmlOutput = htmlTextDecorator.decorateTextWithHtml(javadocWithHtml, decorationData, 4, 8);
- assertThat(htmlOutput).hasSize(5);
-
- // Begin from line 4 and finish at line 8
- assertThat(htmlOutput).containsExactly(
- "<span class=\"cppd\"> * This framework can used for instance in order to :</span>",
- "<span class=\"cppd\"> * &lt;ul&gt;</span>",
- "<span class=\"cppd\"> * &lt;li&gt;Create a lexer in charge to generate a list of tokens from a character stream&lt;/li&gt;</span>",
- "<span class=\"cppd\"> * &lt;li&gt;Create a source code syntax highligther in charge to decorate a source code with HTML tags&lt;/li&gt;</span>",
- "<span class=\"cppd\"> * &lt;li&gt;Create a javadoc generator&lt;/li&gt;</span>"
- );
+ assertThat(htmlOutput)
+ .hasSize(5)
+ // Begin from line 4 and finish at line 8
+ .containsExactly(
+ "<span class=\"cppd\"> * This framework can used for instance in order to :</span>",
+ "<span class=\"cppd\"> * &lt;ul&gt;</span>",
+ "<span class=\"cppd\"> * &lt;li&gt;Create a lexer in charge to generate a list of tokens from a character stream&lt;/li&gt;</span>",
+ "<span class=\"cppd\"> * &lt;li&gt;Create a source code syntax highligther in charge to decorate a source code with HTML tags&lt;/li&gt;</span>",
+ "<span class=\"cppd\"> * &lt;li&gt;Create a javadoc generator&lt;/li&gt;</span>"
+ );
}
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/source/OpeningHtmlTagTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/source/OpeningHtmlTagTest.java
index b53cc2767e7..faccac2cab6 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/source/OpeningHtmlTagTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/source/OpeningHtmlTagTest.java
@@ -39,11 +39,13 @@ public class OpeningHtmlTagTest {
OpeningHtmlTag openingHtmlTagWithDifferentValues = new OpeningHtmlTag(5, "tag2");
OpeningHtmlTag openingHtmlTagWithNoCssClass = new OpeningHtmlTag(3, null);
- assertThat(openingHtmlTag).isEqualTo(openingHtmlTagWithSameValues);
- assertThat(openingHtmlTag).isEqualTo(openingHtmlTag);
- assertThat(openingHtmlTag).isNotEqualTo(openingHtmlTagWithDifferentValues);
- assertThat(openingHtmlTag).isNotEqualTo(openingHtmlTagWithNoCssClass);
- assertThat(openingHtmlTag).isNotEqualTo(new OpeningHtmlTag(3, "tag"){});
+ assertThat(openingHtmlTag)
+ .isEqualTo(openingHtmlTagWithSameValues)
+ .isEqualTo(openingHtmlTag)
+ .isNotEqualTo(openingHtmlTagWithDifferentValues)
+ .isNotEqualTo(openingHtmlTagWithNoCssClass)
+ .isNotEqualTo(new OpeningHtmlTag(3, "tag") {
+ });
}
@Test
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/webhook/ws/ListActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/webhook/ws/ListActionTest.java
index 59990bc11d5..550d750588a 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/webhook/ws/ListActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/webhook/ws/ListActionTest.java
@@ -110,7 +110,7 @@ public class ListActionTest {
ListResponse response = wsActionTester.newRequest().executeProtobuf(ListResponse.class);
List<Webhooks.ListResponseElement> elements = response.getWebhooksList();
- assertThat(elements.size()).isEqualTo(2);
+ assertThat(elements).hasSize(2);
assertThat(elements.get(0)).extracting(Webhooks.ListResponseElement::getKey).isEqualTo(webhook1.getUuid());
assertThat(elements.get(0)).extracting(Webhooks.ListResponseElement::getName).isEqualTo("aaa");
@@ -133,7 +133,7 @@ public class ListActionTest {
ListResponse response = wsActionTester.newRequest().executeProtobuf(ListResponse.class);
List<Webhooks.ListResponseElement> elements = response.getWebhooksList();
- assertThat(elements.size()).isEqualTo(2);
+ assertThat(elements).hasSize(2);
assertThat(elements.get(0)).extracting(Webhooks.ListResponseElement::getKey).isEqualTo(webhook1.getUuid());
assertThat(elements.get(0)).extracting(Webhooks.ListResponseElement::getName).isEqualTo("aaa");
diff --git a/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/CacheWriterTest.java b/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/CacheWriterTest.java
index 0d84ae71fe0..d451d8f2000 100644
--- a/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/CacheWriterTest.java
+++ b/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/CacheWriterTest.java
@@ -40,7 +40,7 @@ public class CacheWriterTest {
underTest.close();
- assertThat(writer.toString()).isEqualTo("content");
+ assertThat(writer).hasToString("content");
}
@Test
diff --git a/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/ServletRequestTest.java b/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/ServletRequestTest.java
index e9bc796ab11..f491ecf89c7 100644
--- a/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/ServletRequestTest.java
+++ b/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/ServletRequestTest.java
@@ -177,11 +177,11 @@ public class ServletRequestTest {
@Test
public void to_string() {
when(source.getRequestURL()).thenReturn(new StringBuffer("http:localhost:9000/api/issues"));
- assertThat(underTest.toString()).isEqualTo("http:localhost:9000/api/issues");
+ assertThat(underTest).hasToString("http:localhost:9000/api/issues");
when(source.getQueryString()).thenReturn("components=sonar");
- assertThat(underTest.toString()).isEqualTo("http:localhost:9000/api/issues?components=sonar");
+ assertThat(underTest).hasToString("http:localhost:9000/api/issues?components=sonar");
}
@Test
diff --git a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/WebPagesFilterTest.java b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/WebPagesFilterTest.java
index a10c30c65d2..553f57543f0 100644
--- a/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/WebPagesFilterTest.java
+++ b/server/sonar-webserver/src/test/java/org/sonar/server/platform/web/WebPagesFilterTest.java
@@ -67,7 +67,7 @@ public class WebPagesFilterTest {
verify(response).setContentType("text/html");
verify(response).setCharacterEncoding("utf-8");
verify(response).setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
- assertThat(outputStream.toString()).isEqualTo("test");
+ assertThat(outputStream).hasToString("test");
}
@Test