aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-db-dao
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2021-10-22 10:38:45 -0500
committersonartech <sonartech@sonarsource.com>2021-10-25 20:03:24 +0000
commit6519110cd4f98fabf3bef46896eecbead3eb646a (patch)
treead84a08da8ba0d590dd1a2d5e9bd2f85ff1c8a8e /server/sonar-db-dao
parent7525c90c3f489b47e902e5f8eecce2c9deab9658 (diff)
downloadsonarqube-6519110cd4f98fabf3bef46896eecbead3eb646a.tar.gz
sonarqube-6519110cd4f98fabf3bef46896eecbead3eb646a.zip
Fix code quality issues
Diffstat (limited to 'server/sonar-db-dao')
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/alm/setting/AlmSettingDaoTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotDaoTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/purge/period/DefaultPeriodCleanerTest.java5
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDaoTest.java2
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/user/SessionTokensDaoTest.java4
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/user/UserTokenDaoTest.java2
6 files changed, 8 insertions, 9 deletions
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/alm/setting/AlmSettingDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/alm/setting/AlmSettingDaoTest.java
index 2ff6c75f8a2..075c4c4037a 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/alm/setting/AlmSettingDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/alm/setting/AlmSettingDaoTest.java
@@ -182,7 +182,7 @@ public class AlmSettingDaoTest {
underTest.delete(dbSession, almSettingDto);
- assertThat(underTest.selectByKey(dbSession, almSettingDto.getKey()).isPresent()).isFalse();
+ assertThat(underTest.selectByKey(dbSession, almSettingDto.getKey())).isNotPresent();
}
}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotDaoTest.java
index 10c85739995..ed402198582 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/SnapshotDaoTest.java
@@ -104,7 +104,7 @@ public class SnapshotDaoTest {
assertThat(result.getCreatedAt()).isEqualTo(1403042400000L);
assertThat(result.getRevision()).isEqualTo("sha1");
- assertThat(underTest.selectByUuid(db.getSession(), "DOES_NOT_EXIST").isPresent()).isFalse();
+ assertThat(underTest.selectByUuid(db.getSession(), "DOES_NOT_EXIST")).isNotPresent();
}
@Test
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/period/DefaultPeriodCleanerTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/period/DefaultPeriodCleanerTest.java
index ec30df80e1f..e0ecdc95d8e 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/period/DefaultPeriodCleanerTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/period/DefaultPeriodCleanerTest.java
@@ -33,7 +33,6 @@ import org.sonar.db.purge.PurgeProfiler;
import org.sonar.db.purge.PurgeableAnalysisDto;
import static org.mockito.ArgumentMatchers.anyList;
-import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.when;
@@ -57,9 +56,9 @@ public class DefaultPeriodCleanerTest {
InOrder inOrder = Mockito.inOrder(dao, filter1, filter2);
inOrder.verify(filter1).log();
- inOrder.verify(dao, times(1)).deleteAnalyses(eq(session), eq(profiler), eq(ImmutableList.of("u999")));
+ inOrder.verify(dao, times(1)).deleteAnalyses(session, profiler, ImmutableList.of("u999"));
inOrder.verify(filter2).log();
- inOrder.verify(dao, times(1)).deleteAnalyses(eq(session), eq(profiler), eq(ImmutableList.of("u456")));
+ inOrder.verify(dao, times(1)).deleteAnalyses(session, profiler, ImmutableList.of("u456"));
inOrder.verifyNoMoreInteractions();
}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDaoTest.java
index 2bac02c47d9..f8bb1002e1d 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDaoTest.java
@@ -102,7 +102,7 @@ public class RuleDaoTest {
assertThat(underTest.selectDefinitionByKey(db.getSession(), RuleKey.of("NOT", "FOUND")).isPresent()).isFalse();
Optional<RuleDefinitionDto> reloaded = underTest.selectDefinitionByKey(db.getSession(), rule.getKey());
- assertThat(reloaded.isPresent()).isTrue();
+ assertThat(reloaded).isPresent();
}
@Test
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/user/SessionTokensDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/user/SessionTokensDaoTest.java
index a12a18956e2..83352bd5ecc 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/user/SessionTokensDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/user/SessionTokensDaoTest.java
@@ -52,7 +52,7 @@ public class SessionTokensDaoTest {
Optional<SessionTokenDto> result = underTest.selectByUuid(dbSession, dto.getUuid());
- assertThat(result.isPresent());
+ assertThat(result).isPresent();
assertThat(result.get().getUserUuid()).isEqualTo("ABCD");
assertThat(result.get().getExpirationDate()).isEqualTo(15_000_000_000L);
assertThat(result.get().getCreatedAt()).isEqualTo(NOW);
@@ -72,7 +72,7 @@ public class SessionTokensDaoTest {
Optional<SessionTokenDto> result = underTest.selectByUuid(dbSession, dto.getUuid());
- assertThat(result.isPresent());
+ assertThat(result).isPresent();
assertThat(result.get().getUuid()).isNotEqualTo("SHOULD_NOT_BE_USED");
assertThat(result.get().getCreatedAt()).isEqualTo(NOW);
assertThat(result.get().getUpdatedAt()).isEqualTo(NOW);
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserTokenDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserTokenDaoTest.java
index 8d640e17fd0..43b4f48a66c 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserTokenDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserTokenDaoTest.java
@@ -134,7 +134,7 @@ public class UserTokenDaoTest {
Map<String, Integer> result = underTest.countTokensByUsers(dbSession, singletonList(user));
- assertThat(result.get(user.getUuid())).isEqualTo(2);
+ assertThat(result).containsEntry(user.getUuid(), 2);
assertThat(result.get("unknown-user_uuid")).isNull();
}
}