aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-api
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2021-11-18 16:45:02 -0600
committersonartech <sonartech@sonarsource.com>2021-11-20 20:03:51 +0000
commit3f9445c25962f914ccdd889c002ddd8e19b0cf89 (patch)
treeeb4f34a62b7164a71fd0bbe34d6f59621a687d8d /server/sonar-webserver-api
parentaa640be9e2b9cfa2c027ef0768940b31ebb5536c (diff)
downloadsonarqube-3f9445c25962f914ccdd889c002ddd8e19b0cf89.tar.gz
sonarqube-3f9445c25962f914ccdd889c002ddd8e19b0cf89.zip
Improve code quality
Diffstat (limited to 'server/sonar-webserver-api')
-rw-r--r--server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java2
-rw-r--r--server/sonar-webserver-api/src/test/java/org/sonar/server/exceptions/MessageTest.java26
-rw-r--r--server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/ServerPluginRepositoryTest.java1
-rw-r--r--server/sonar-webserver-api/src/test/java/org/sonar/server/project/RekeyedProjectTest.java26
4 files changed, 30 insertions, 25 deletions
diff --git a/server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java b/server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java
index ace04fd1a0a..3a28d206038 100644
--- a/server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java
+++ b/server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/ServerPluginRepository.java
@@ -60,7 +60,7 @@ public class ServerPluginRepository implements PluginRepository {
@Override
public Collection<PluginInfo> getPluginInfos() {
- return Collections.unmodifiableCollection(pluginByKey.values().stream().map(ServerPlugin::getPluginInfo).collect(Collectors.toList()));
+ return pluginByKey.values().stream().map(ServerPlugin::getPluginInfo).collect(Collectors.toUnmodifiableList());
}
@Override
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 bf3e75dbc1e..25a75923ccb 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
@@ -57,19 +57,21 @@ public class MessageTest {
Message message4 = Message.of("key1%s", "param2");
Message sameAsMessage1 = Message.of("key1%s", "param1");
- assertThat(message1).isEqualTo(message1);
- assertThat(message1).isNotEqualTo(message2);
- assertThat(message1).isNotEqualTo(message3);
- assertThat(message1).isNotEqualTo(message4);
- assertThat(message1).isEqualTo(sameAsMessage1);
- assertThat(message1).isNotEqualTo(null);
- assertThat(message1).isNotEqualTo(new Object());
+ assertThat(message1)
+ .isEqualTo(message1)
+ .isNotEqualTo(message2)
+ .isNotEqualTo(message3)
+ .isNotEqualTo(message4)
+ .isEqualTo(sameAsMessage1)
+ .isNotNull()
+ .isNotEqualTo(new Object())
+ .hasSameHashCodeAs(message1)
+ .hasSameHashCodeAs(sameAsMessage1);
- assertThat(message1.hashCode()).isEqualTo(message1.hashCode());
- assertThat(message1.hashCode()).isNotEqualTo(message2.hashCode());
- assertThat(message1.hashCode()).isNotEqualTo(message3.hashCode());
- assertThat(message1.hashCode()).isNotEqualTo(message4.hashCode());
- assertThat(message1.hashCode()).isEqualTo(sameAsMessage1.hashCode());
+ assertThat(message1.hashCode())
+ .isNotEqualTo(message2.hashCode())
+ .isNotEqualTo(message3.hashCode())
+ .isNotEqualTo(message4.hashCode());
}
@Test
diff --git a/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/ServerPluginRepositoryTest.java b/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/ServerPluginRepositoryTest.java
index 461c5d9f255..37578713596 100644
--- a/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/ServerPluginRepositoryTest.java
+++ b/server/sonar-webserver-api/src/test/java/org/sonar/server/plugins/ServerPluginRepositoryTest.java
@@ -22,6 +22,7 @@ package org.sonar.server.plugins;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+
import org.junit.Assert;
import org.junit.Test;
import org.sonar.api.Plugin;
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 e743cfc5ec6..aa8c0f57136 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
@@ -59,12 +59,13 @@ public class RekeyedProjectTest {
String previousKey = randomAlphanumeric(6);
RekeyedProject underTest = new RekeyedProject(project, previousKey);
- assertThat(underTest).isEqualTo(underTest);
- assertThat(underTest).isEqualTo(new RekeyedProject(project, previousKey));
- assertThat(underTest).isNotEqualTo(new RekeyedProject(project, randomAlphanumeric(11)));
- assertThat(underTest).isNotEqualTo(new RekeyedProject(newRandomProject(), previousKey));
- assertThat(underTest).isNotEqualTo(new Object());
- assertThat(underTest).isNotEqualTo(null);
+ assertThat(underTest)
+ .isEqualTo(underTest)
+ .isEqualTo(new RekeyedProject(project, previousKey))
+ .isNotEqualTo(new RekeyedProject(project, randomAlphanumeric(11)))
+ .isNotEqualTo(new RekeyedProject(newRandomProject(), previousKey))
+ .isNotEqualTo(new Object())
+ .isNotNull();
}
@Test
@@ -73,12 +74,13 @@ public class RekeyedProjectTest {
String previousKey = randomAlphanumeric(6);
RekeyedProject underTest = new RekeyedProject(project, previousKey);
- assertThat(underTest.hashCode()).isEqualTo(underTest.hashCode());
- assertThat(underTest.hashCode()).isEqualTo(new RekeyedProject(project, previousKey).hashCode());
- assertThat(underTest.hashCode()).isNotEqualTo(new RekeyedProject(project, randomAlphanumeric(11)).hashCode());
- assertThat(underTest.hashCode()).isNotEqualTo(new RekeyedProject(newRandomProject(), previousKey).hashCode());
- assertThat(underTest.hashCode()).isNotEqualTo(new Object().hashCode());
- assertThat(underTest.hashCode()).isNotEqualTo(null);
+ assertThat(underTest)
+ .hasSameHashCodeAs(underTest)
+ .hasSameHashCodeAs(new RekeyedProject(project, previousKey));
+ assertThat(underTest.hashCode())
+ .isNotEqualTo(new RekeyedProject(project, randomAlphanumeric(11)).hashCode())
+ .isNotEqualTo(new RekeyedProject(newRandomProject(), previousKey).hashCode())
+ .isNotEqualTo(new Object().hashCode());
}
@Test