aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-process
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-process
parentaa640be9e2b9cfa2c027ef0768940b31ebb5536c (diff)
downloadsonarqube-3f9445c25962f914ccdd889c002ddd8e19b0cf89.tar.gz
sonarqube-3f9445c25962f914ccdd889c002ddd8e19b0cf89.zip
Improve code quality
Diffstat (limited to 'server/sonar-process')
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/LifecycleTest.java2
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/ProcessEntryPointTest.java6
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/PropsTest.java4
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/SystemExitTest.java2
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/cluster/health/NodeDetailsTest.java5
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/cluster/health/NodeHealthTest.java5
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/logging/Log4JPropertiesBuilderTest.java12
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/logging/LogLevelConfigTest.java2
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/logging/LogbackHelperTest.java2
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/sharedmemoryfile/AllProcessesCommandsTest.java2
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/systeminfo/JvmStateSectionTest.java2
11 files changed, 23 insertions, 21 deletions
diff --git a/server/sonar-process/src/test/java/org/sonar/process/LifecycleTest.java b/server/sonar-process/src/test/java/org/sonar/process/LifecycleTest.java
index 37162c8c807..dd99d8bf068 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/LifecycleTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/LifecycleTest.java
@@ -42,7 +42,7 @@ public class LifecycleTest {
assertThat(init.equals(new Lifecycle())).isTrue();
assertThat(init.equals("INIT")).isFalse();
assertThat(init.equals(null)).isFalse();
- assertThat(init.hashCode()).isEqualTo(new Lifecycle().hashCode());
+ assertThat(init).hasSameHashCodeAs(new Lifecycle());
// different state
Lifecycle stopping = new Lifecycle();
diff --git a/server/sonar-process/src/test/java/org/sonar/process/ProcessEntryPointTest.java b/server/sonar-process/src/test/java/org/sonar/process/ProcessEntryPointTest.java
index 372c229dda6..92dc3d6cd90 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/ProcessEntryPointTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/ProcessEntryPointTest.java
@@ -111,8 +111,8 @@ public class ProcessEntryPointTest {
entryPoint.stop();
assertThat(process.getState()).isEqualTo(State.STOPPED);
- assertThat(process.wasStopped()).isEqualTo(true);
- assertThat(process.wasHardStopped()).isEqualTo(false);
+ assertThat(process.wasStopped()).isTrue();
+ assertThat(process.wasHardStopped()).isFalse();
}
@Test
@@ -131,7 +131,7 @@ public class ProcessEntryPointTest {
entryPoint.hardStop();
assertThat(process.getState()).isEqualTo(State.STOPPED);
- assertThat(process.wasHardStopped()).isEqualTo(true);
+ assertThat(process.wasHardStopped()).isTrue();
}
@Test
diff --git a/server/sonar-process/src/test/java/org/sonar/process/PropsTest.java b/server/sonar-process/src/test/java/org/sonar/process/PropsTest.java
index ebbb0e557ab..04aff7ca9dd 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/PropsTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/PropsTest.java
@@ -184,8 +184,8 @@ public class PropsTest {
assertThat(props.rawProperties()).hasSize(2);
// do not decrypt
- assertThat(props.rawProperties().get("encrypted_prop")).isEqualTo("{aes}abcde");
- assertThat(props.rawProperties().get("clear_prop")).isEqualTo("foo");
+ assertThat(props.rawProperties()).containsEntry("encrypted_prop", "{aes}abcde");
+ assertThat(props.rawProperties()).containsEntry("clear_prop", "foo");
}
@Test
diff --git a/server/sonar-process/src/test/java/org/sonar/process/SystemExitTest.java b/server/sonar-process/src/test/java/org/sonar/process/SystemExitTest.java
index d97a98808a3..3e18fe7f764 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/SystemExitTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/SystemExitTest.java
@@ -50,6 +50,6 @@ public class SystemExitTest {
assertThat(systemExit.isInShutdownHook()).isFalse();
systemExit.exit(1);
- assertThat(got.get()).isEqualTo(1);
+ assertThat(got.get()).isOne();
}
}
diff --git a/server/sonar-process/src/test/java/org/sonar/process/cluster/health/NodeDetailsTest.java b/server/sonar-process/src/test/java/org/sonar/process/cluster/health/NodeDetailsTest.java
index ab4ebedf871..d0866c3376c 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/cluster/health/NodeDetailsTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/cluster/health/NodeDetailsTest.java
@@ -163,8 +163,9 @@ public class NodeDetailsTest {
assertThat(builder.build())
.isEqualTo(underTest)
.isNotSameAs(underTest);
- assertThat(underTest).isNotEqualTo(null);
- assertThat(underTest).isNotEqualTo(new Object());
+ assertThat(underTest)
+ .isNotNull()
+ .isNotEqualTo(new Object());
}
@Test
diff --git a/server/sonar-process/src/test/java/org/sonar/process/cluster/health/NodeHealthTest.java b/server/sonar-process/src/test/java/org/sonar/process/cluster/health/NodeHealthTest.java
index d69d6a5c1b2..42ec3fce4cc 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/cluster/health/NodeHealthTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/cluster/health/NodeHealthTest.java
@@ -117,8 +117,9 @@ public class NodeHealthTest {
assertThat(builder.build())
.isEqualTo(underTest)
.isNotSameAs(underTest);
- assertThat(underTest).isNotEqualTo(null);
- assertThat(underTest).isNotEqualTo(new Object());
+ assertThat(underTest)
+ .isNotNull()
+ .isNotEqualTo(new Object());
}
@Test
diff --git a/server/sonar-process/src/test/java/org/sonar/process/logging/Log4JPropertiesBuilderTest.java b/server/sonar-process/src/test/java/org/sonar/process/logging/Log4JPropertiesBuilderTest.java
index bd0ceae2e9d..10ea096d4ac 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/logging/Log4JPropertiesBuilderTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/logging/Log4JPropertiesBuilderTest.java
@@ -748,9 +748,9 @@ public class Log4JPropertiesBuilderTest {
}
private void verifyProperties(Properties properties, String... expectedPropertyKeysAndValuesOrdered) {
- assertThat(properties.get("status")).isEqualTo("ERROR");
+ assertThat(properties).containsEntry("status", "ERROR");
if (expectedPropertyKeysAndValuesOrdered.length == 0) {
- assertThat(properties.size()).isEqualTo(1);
+ assertThat(properties.size()).isOne();
} else {
assertThat(expectedPropertyKeysAndValuesOrdered.length % 2).describedAs("Number of parameters must be even").isZero();
Set<String> keys = new HashSet<>(expectedPropertyKeysAndValuesOrdered.length / 2 + 1);
@@ -761,7 +761,7 @@ public class Log4JPropertiesBuilderTest {
assertThat(properties.get(key)).describedAs("Unexpected value for property " + key).isEqualTo(value);
keys.add(key);
}
- assertThat(properties.keySet()).containsOnly(keys.toArray());
+ assertThat(properties).containsOnlyKeys(keys.toArray());
}
}
@@ -770,8 +770,8 @@ public class Log4JPropertiesBuilderTest {
}
private void verifyLoggerProperties(Properties properties, String loggerName, Level expectedLevel) {
- assertThat(properties.get("logger." + loggerName + ".name")).isEqualTo(loggerName);
- assertThat(properties.get("logger." + loggerName + ".level")).isEqualTo(expectedLevel.toString());
+ assertThat(properties).containsEntry("logger." + loggerName + ".name", loggerName);
+ assertThat(properties).containsEntry("logger." + loggerName + ".level", expectedLevel.toString());
}
private void verifyNoLoggerProperties(Properties properties, String loggerName) {
@@ -780,7 +780,7 @@ public class Log4JPropertiesBuilderTest {
}
private void verifyRootLoggerLevel(Log4JPropertiesBuilder underTest, Level expectedLevel) {
- assertThat(underTest.build().get("rootLogger.level")).isEqualTo(expectedLevel.toString());
+ assertThat(underTest.build()).containsEntry("rootLogger.level", expectedLevel.toString());
}
@DataProvider
diff --git a/server/sonar-process/src/test/java/org/sonar/process/logging/LogLevelConfigTest.java b/server/sonar-process/src/test/java/org/sonar/process/logging/LogLevelConfigTest.java
index a9cf5d6ae5f..b7bee280369 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/logging/LogLevelConfigTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/logging/LogLevelConfigTest.java
@@ -161,7 +161,7 @@ public class LogLevelConfigTest {
assertThat(config.getConfiguredByProperties()).isEmpty();
assertThat(config.getConfiguredByHardcodedLevel()).hasSize(1);
- assertThat(config.getConfiguredByHardcodedLevel().get("bar")).isEqualTo(Level.INFO);
+ assertThat(config.getConfiguredByHardcodedLevel()).containsEntry("bar", Level.INFO);
}
@Test
diff --git a/server/sonar-process/src/test/java/org/sonar/process/logging/LogbackHelperTest.java b/server/sonar-process/src/test/java/org/sonar/process/logging/LogbackHelperTest.java
index bddd62d0406..4175a427309 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/logging/LogbackHelperTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/logging/LogbackHelperTest.java
@@ -146,7 +146,7 @@ public class LogbackHelperTest {
int countListeners = ctx.getCopyOfListenerList().size();
LoggerContextListener propagator = underTest.enableJulChangePropagation(ctx);
- assertThat(ctx.getCopyOfListenerList().size()).isEqualTo(countListeners + 1);
+ assertThat(ctx.getCopyOfListenerList()).hasSize(countListeners + 1);
ctx.removeListener(propagator);
}
diff --git a/server/sonar-process/src/test/java/org/sonar/process/sharedmemoryfile/AllProcessesCommandsTest.java b/server/sonar-process/src/test/java/org/sonar/process/sharedmemoryfile/AllProcessesCommandsTest.java
index 5821162fd59..4f776d4fd21 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/sharedmemoryfile/AllProcessesCommandsTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/sharedmemoryfile/AllProcessesCommandsTest.java
@@ -90,7 +90,7 @@ public class AllProcessesCommandsTest {
try (AllProcessesCommands commands = new AllProcessesCommands(temp.newFolder())) {
int offset = 5;
- assertThat(readLong(commands, offset)).isEqualTo(0L);
+ assertThat(readLong(commands, offset)).isZero();
long currentTime = System.currentTimeMillis();
commands.ping(PROCESS_NUMBER);
diff --git a/server/sonar-process/src/test/java/org/sonar/process/systeminfo/JvmStateSectionTest.java b/server/sonar-process/src/test/java/org/sonar/process/systeminfo/JvmStateSectionTest.java
index 87df778a013..a994116a028 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/systeminfo/JvmStateSectionTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/systeminfo/JvmStateSectionTest.java
@@ -38,7 +38,7 @@ public class JvmStateSectionTest {
ProtobufSystemInfo.Section section = underTest.toProtobuf();
assertThat(section.getName()).isEqualTo(PROCESS_NAME);
- assertThat(section.getAttributesCount()).isGreaterThan(0);
+ assertThat(section.getAttributesCount()).isPositive();
assertThat(section.getAttributesList()).extracting("key")
.contains(
"Max Memory (MB)", "Free Memory (MB)",