From 6519110cd4f98fabf3bef46896eecbead3eb646a Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Fri, 22 Oct 2021 10:38:45 -0500 Subject: Fix code quality issues --- .../src/test/java/org/sonar/db/alm/setting/AlmSettingDaoTest.java | 2 +- .../src/test/java/org/sonar/db/component/SnapshotDaoTest.java | 2 +- .../java/org/sonar/db/purge/period/DefaultPeriodCleanerTest.java | 5 ++--- server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDaoTest.java | 2 +- .../src/test/java/org/sonar/db/user/SessionTokensDaoTest.java | 4 ++-- .../src/test/java/org/sonar/db/user/UserTokenDaoTest.java | 2 +- 6 files changed, 8 insertions(+), 9 deletions(-) (limited to 'server/sonar-db-dao') 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 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 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 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 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(); } } -- cgit v1.2.3