diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2021-11-18 16:45:02 -0600 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2021-11-20 20:03:51 +0000 |
commit | 3f9445c25962f914ccdd889c002ddd8e19b0cf89 (patch) | |
tree | eb4f34a62b7164a71fd0bbe34d6f59621a687d8d /server/sonar-db-dao | |
parent | aa640be9e2b9cfa2c027ef0768940b31ebb5536c (diff) | |
download | sonarqube-3f9445c25962f914ccdd889c002ddd8e19b0cf89.tar.gz sonarqube-3f9445c25962f914ccdd889c002ddd8e19b0cf89.zip |
Improve code quality
Diffstat (limited to 'server/sonar-db-dao')
59 files changed, 215 insertions, 221 deletions
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java b/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java index cc088c10d12..12f3ab67d48 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/DaoModule.java @@ -19,8 +19,6 @@ */ package org.sonar.db; -import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.sonar.core.platform.Module; import org.sonar.db.alm.pat.AlmPatDao; @@ -59,8 +57,8 @@ import org.sonar.db.permission.template.PermissionTemplateCharacteristicDao; import org.sonar.db.permission.template.PermissionTemplateDao; import org.sonar.db.plugin.PluginDao; import org.sonar.db.portfolio.PortfolioDao; -import org.sonar.db.project.ProjectDao; import org.sonar.db.project.ProjectBadgeTokenDao; +import org.sonar.db.project.ProjectDao; import org.sonar.db.property.InternalComponentPropertiesDao; import org.sonar.db.property.InternalPropertiesDao; import org.sonar.db.property.PropertiesDao; @@ -95,7 +93,7 @@ import org.sonar.db.webhook.WebhookDao; import org.sonar.db.webhook.WebhookDeliveryDao; public class DaoModule extends Module { - private static final List<Class<? extends Dao>> classes = Collections.unmodifiableList(Arrays.asList( + private static final List<Class<? extends Dao>> classes = List.of( // ===================================================================== // for readability and easier merge, keep list ordered alphabetically // ===================================================================== @@ -168,7 +166,7 @@ public class DaoModule extends Module { UserPropertiesDao.class, UserTokenDao.class, WebhookDao.class, - WebhookDeliveryDao.class)); + WebhookDeliveryDao.class); @Override protected void configureModule() { diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeTaskCharacteristicDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeTaskCharacteristicDto.java index acf7f6783ee..75928668ec8 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeTaskCharacteristicDto.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/ce/CeTaskCharacteristicDto.java @@ -30,7 +30,7 @@ public class CeTaskCharacteristicDto { public static final String BRANCH_KEY = "branch"; public static final String BRANCH_TYPE_KEY = "branchType"; public static final String PULL_REQUEST = "pullRequest"; - public static final Set<String> SUPPORTED_KEYS = unmodifiableSet(new HashSet<>(asList(BRANCH_KEY, BRANCH_TYPE_KEY, PULL_REQUEST))); + public static final Set<String> SUPPORTED_KEYS = Set.of(BRANCH_KEY, BRANCH_TYPE_KEY, PULL_REQUEST); private String uuid; private String taskUuid; diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeProfiler.java b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeProfiler.java index 9d0a8250173..ec1e3ff7828 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeProfiler.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeProfiler.java @@ -55,12 +55,7 @@ public class PurgeProfiler { } void stop() { - final Long cumulatedDuration; - if (durations.containsKey(currentTable)) { - cumulatedDuration = durations.get(currentTable); - } else { - cumulatedDuration = 0L; - } + Long cumulatedDuration = durations.getOrDefault(currentTable, 0L); durations.put(currentTable, cumulatedDuration + (clock.now() - startTime)); } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/PaginationTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/PaginationTest.java index aaf90cbc676..e7b56559e4f 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/PaginationTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/PaginationTest.java @@ -31,7 +31,7 @@ public class PaginationTest { public void all_is_page_1_with_MAX_INTEGER_page_size() { Pagination pagination = Pagination.all(); - assertThat(pagination.getPage()).isEqualTo(1); + assertThat(pagination.getPage()).isOne(); assertThat(pagination.getPageSize()).isEqualTo(Integer.MAX_VALUE); } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/alm/setting/ProjectAlmSettingDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/alm/setting/ProjectAlmSettingDaoTest.java index c972d2d6ab6..5d987f1361d 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/alm/setting/ProjectAlmSettingDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/alm/setting/ProjectAlmSettingDaoTest.java @@ -183,7 +183,7 @@ public class ProjectAlmSettingDaoTest { underTest.deleteByAlmSetting(dbSession, githubAlmSetting); assertThat(underTest.countByAlmSetting(dbSession, githubAlmSetting)).isZero(); - assertThat(underTest.countByAlmSetting(dbSession, githubAlmSetting1)).isEqualTo(1); + assertThat(underTest.countByAlmSetting(dbSession, githubAlmSetting1)).isOne(); } } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/audit/AuditDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/audit/AuditDaoTest.java index 31c26933cf1..a36cb96ee9f 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/audit/AuditDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/audit/AuditDaoTest.java @@ -56,7 +56,7 @@ public class AuditDaoTest { List<AuditDto> auditDtos = testAuditDao.selectByPeriodPaginated(dbSession, 1, 20000, 2); - assertThat(auditDtos.size()).isEqualTo(1); + assertThat(auditDtos.size()).isOne(); } @Test @@ -64,7 +64,7 @@ public class AuditDaoTest { prepareRowsWithDeterministicCreatedAt(100_001); long purged = testAuditDao.deleteBefore(dbSession, 200_000); assertThat(purged).isEqualTo(100_000); - assertThat(db.countRowsOfTable(dbSession, "audits")).isEqualTo(1); + assertThat(db.countRowsOfTable(dbSession, "audits")).isOne(); assertThat(testAuditDao.selectOlderThan(dbSession, 100_002)) .extracting(AuditDto::getCreatedAt) .containsOnly(100_001L); diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/audit/model/LicenseNewValueTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/audit/model/LicenseNewValueTest.java index eba459637a6..cfa7e1f4be5 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/audit/model/LicenseNewValueTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/audit/model/LicenseNewValueTest.java @@ -28,7 +28,7 @@ public class LicenseNewValueTest { @Test public void toStringIsEmptyForNullEdition(){ LicenseNewValue newValue = new LicenseNewValue(null); - assertThat(newValue.toString()).isEqualTo("{}"); + assertThat(newValue).hasToString("{}"); } @Test diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java index 870eacaea7b..cca5ec95293 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeActivityDaoTest.java @@ -130,7 +130,7 @@ public class CeActivityDaoTest { assertThat(underTest.selectByUuid(dbSession, tasks[0].getUuid()).get().getWarningCount()).isEqualTo(moreThan1); assertThat(underTest.selectByUuid(dbSession, tasks[1].getUuid()).get().getWarningCount()).isZero(); - assertThat(underTest.selectByUuid(dbSession, tasks[2].getUuid()).get().getWarningCount()).isEqualTo(1); + assertThat(underTest.selectByUuid(dbSession, tasks[2].getUuid()).get().getWarningCount()).isOne(); } private void insertWarnings(CeActivityDto task, int warningCount) { @@ -691,9 +691,9 @@ public class CeActivityDaoTest { insert("TASK_3", "REPORT", MAINCOMPONENT_1, SUCCESS); underTest.deleteByUuids(db.getSession(), ImmutableSet.of("TASK_1", "TASK_3")); - assertThat(underTest.selectByUuid(db.getSession(), "TASK_1").isPresent()).isFalse(); + assertThat(underTest.selectByUuid(db.getSession(), "TASK_1")).isEmpty(); assertThat(underTest.selectByUuid(db.getSession(), "TASK_2")).isPresent(); - assertThat(underTest.selectByUuid(db.getSession(), "TASK_3").isPresent()).isFalse(); + assertThat(underTest.selectByUuid(db.getSession(), "TASK_3")).isEmpty(); } @Test @@ -718,7 +718,7 @@ public class CeActivityDaoTest { insert("TASK_5", CeTaskTypes.REPORT, MAINCOMPONENT_1, SUCCESS); db.commit(); - assertThat(underTest.countLastByStatusAndMainComponentUuid(dbSession, SUCCESS, MAINCOMPONENT_1)).isEqualTo(1); + assertThat(underTest.countLastByStatusAndMainComponentUuid(dbSession, SUCCESS, MAINCOMPONENT_1)).isOne(); assertThat(underTest.countLastByStatusAndMainComponentUuid(dbSession, SUCCESS, null)).isEqualTo(2); } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java index 0f2935c8014..c685c1ded01 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeQueueDaoTest.java @@ -126,7 +126,7 @@ public class CeQueueDaoTest { public void test_selectByUuid() { CeQueueDto ceQueueDto = insertPending(TASK_UUID_1, MAIN_COMPONENT_UUID_1); - assertThat(underTest.selectByUuid(db.getSession(), "TASK_UNKNOWN").isPresent()).isFalse(); + assertThat(underTest.selectByUuid(db.getSession(), "TASK_UNKNOWN")).isEmpty(); CeQueueDto saved = underTest.selectByUuid(db.getSession(), TASK_UUID_1).get(); assertThat(saved.getUuid()).isEqualTo(TASK_UUID_1); assertThat(saved.getTaskType()).isEqualTo(CeTaskTypes.REPORT); @@ -250,11 +250,11 @@ public class CeQueueDaoTest { assertThat(underTest.selectByUuid(db.getSession(), TASK_UUID_1)).isPresent(); deletedCount = underTest.deleteByUuid(db.getSession(), TASK_UUID_1); - assertThat(deletedCount).isEqualTo(1); + assertThat(deletedCount).isOne(); assertThat(underTest.selectByUuid(db.getSession(), TASK_UUID_1)).isEmpty(); deletedCount = underTest.deleteByUuid(db.getSession(), TASK_UUID_2, null); - assertThat(deletedCount).isEqualTo(1); + assertThat(deletedCount).isOne(); assertThat(underTest.selectByUuid(db.getSession(), TASK_UUID_2)).isEmpty(); } @@ -276,11 +276,11 @@ public class CeQueueDaoTest { assertThat(underTest.selectByUuid(db.getSession(), TASK_UUID_2)).isPresent(); deletedCount = underTest.deleteByUuid(db.getSession(), TASK_UUID_1, new DeleteIf(PENDING)); - assertThat(deletedCount).isEqualTo(1); + assertThat(deletedCount).isOne(); assertThat(underTest.selectByUuid(db.getSession(), TASK_UUID_1)).isEmpty(); deletedCount = underTest.deleteByUuid(db.getSession(), TASK_UUID_2, new DeleteIf(IN_PROGRESS)); - assertThat(deletedCount).isEqualTo(1); + assertThat(deletedCount).isOne(); assertThat(underTest.selectByUuid(db.getSession(), TASK_UUID_2)).isEmpty(); } @@ -445,7 +445,7 @@ public class CeQueueDaoTest { // do not peek second task as long as the first one is in progress peek = underTest.peek(db.getSession(), WORKER_UUID_1, false, false); - assertThat(peek.isPresent()).isFalse(); + assertThat(peek).isEmpty(); // first one is finished underTest.deleteByUuid(db.getSession(), TASK_UUID_1); @@ -577,7 +577,7 @@ public class CeQueueDaoTest { .setTaskType(CeTaskTypes.REPORT) .setCreatedAt(100_000L)); - assertThat(underTest.countByStatusAndMainComponentUuid(db.getSession(), IN_PROGRESS, MAIN_COMPONENT_UUID_1)).isEqualTo(1); + assertThat(underTest.countByStatusAndMainComponentUuid(db.getSession(), IN_PROGRESS, MAIN_COMPONENT_UUID_1)).isOne(); assertThat(underTest.countByStatus(db.getSession(), IN_PROGRESS)).isEqualTo(2); } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeScannerContextDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeScannerContextDaoTest.java index c30fc96f0bd..cce756a0a04 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeScannerContextDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeScannerContextDaoTest.java @@ -83,7 +83,7 @@ public class CeScannerContextDaoTest { underTest.insert(dbSession, SOME_UUID, scannerContextInputStreamOf("bla")); dbSession.commit(); - assertThat(dbTester.countRowsOfTable(dbSession, TABLE_NAME)).isEqualTo(1); + assertThat(dbTester.countRowsOfTable(dbSession, TABLE_NAME)).isOne(); assertThatThrownBy(() -> underTest.insert(dbSession, SOME_UUID, scannerContextInputStreamOf("blo"))) .isInstanceOf(IllegalStateException.class) diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeTaskInputDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeTaskInputDaoTest.java index 6242cd1bf92..2f6385fbb77 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeTaskInputDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/CeTaskInputDaoTest.java @@ -96,7 +96,7 @@ public class CeTaskInputDaoTest { @Test public void deleteByUuids() { insertData(A_UUID); - assertThat(dbTester.countRowsOfTable(TABLE_NAME)).isEqualTo(1); + assertThat(dbTester.countRowsOfTable(TABLE_NAME)).isOne(); underTest.deleteByUuids(dbTester.getSession(), singleton(A_UUID)); dbTester.commit(); diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/LogsIteratorInputStreamTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/LogsIteratorInputStreamTest.java index 85e7a8f1e5f..4fcab30f9c4 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/ce/LogsIteratorInputStreamTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/ce/LogsIteratorInputStreamTest.java @@ -43,7 +43,7 @@ public class LogsIteratorInputStreamTest { @Test public void read_from_ClosableIterator_with_single_empty_line() throws IOException { - assertThat(read(create(""))).isEqualTo(""); + assertThat(read(create(""))).isEmpty(); } @Test diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/AnalysisPropertiesDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/AnalysisPropertiesDaoTest.java index f4278817184..ccf2d576d1b 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/AnalysisPropertiesDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/AnalysisPropertiesDaoTest.java @@ -99,7 +99,7 @@ public class AnalysisPropertiesDaoTest { public void insert_as_empty() { AnalysisPropertyDto analysisPropertyDto = insertAnalysisPropertyDto(0); - assertThat(dbTester.countRowsOfTable(dbSession, "ANALYSIS_PROPERTIES")).isEqualTo(1); + assertThat(dbTester.countRowsOfTable(dbSession, "ANALYSIS_PROPERTIES")).isOne(); compareFirstValueWith(analysisPropertyDto); } @@ -107,7 +107,7 @@ public class AnalysisPropertiesDaoTest { public void insert_as_text() { AnalysisPropertyDto analysisPropertyDto = insertAnalysisPropertyDto(1 + random.nextInt(3999)); - assertThat(dbTester.countRowsOfTable(dbSession, "ANALYSIS_PROPERTIES")).isEqualTo(1); + assertThat(dbTester.countRowsOfTable(dbSession, "ANALYSIS_PROPERTIES")).isOne(); compareFirstValueWith(analysisPropertyDto); } @@ -115,7 +115,7 @@ public class AnalysisPropertiesDaoTest { public void insert_as_clob() { AnalysisPropertyDto analysisPropertyDto = insertAnalysisPropertyDto(4000 + random.nextInt(100)); - assertThat(dbTester.countRowsOfTable(dbSession, "ANALYSIS_PROPERTIES")).isEqualTo(1); + assertThat(dbTester.countRowsOfTable(dbSession, "ANALYSIS_PROPERTIES")).isOne(); compareFirstValueWith(analysisPropertyDto); } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDaoTest.java index fa598e92797..3e4e152ca12 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDaoTest.java @@ -605,8 +605,8 @@ public class BranchDaoTest { assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.BRANCH, 0L)).isEqualTo(3); assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.BRANCH, NOW)).isEqualTo(3); assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.BRANCH, NOW + 100)).isZero(); - assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.PULL_REQUEST, 0L)).isEqualTo(1); - assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.PULL_REQUEST, NOW)).isEqualTo(1); + assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.PULL_REQUEST, 0L)).isOne(); + assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.PULL_REQUEST, NOW)).isOne(); assertThat(underTest.countByTypeAndCreationDate(dbSession, BranchType.PULL_REQUEST, NOW + 100)).isZero(); } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java index ccb93d46484..f440ca6af10 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java @@ -1123,9 +1123,9 @@ public class ComponentDaoTest { db.components().insertProjectAndSnapshot(ComponentTesting.newPortfolio()); Supplier<ComponentQuery.Builder> query = () -> ComponentQuery.builder().setOnProvisionedOnly(true); - assertThat(underTest.countByQuery(dbSession, query.get().setQualifiers(PROJECT).build())).isEqualTo(1); + assertThat(underTest.countByQuery(dbSession, query.get().setQualifiers(PROJECT).build())).isOne(); assertThat(underTest.countByQuery(dbSession, query.get().setQualifiers(Qualifiers.VIEW).build())).isZero(); - assertThat(underTest.countByQuery(dbSession, query.get().setQualifiers(PROJECT, Qualifiers.VIEW).build())).isEqualTo(1); + assertThat(underTest.countByQuery(dbSession, query.get().setQualifiers(PROJECT, Qualifiers.VIEW).build())).isOne(); } @Test @@ -1245,18 +1245,20 @@ public class ComponentDaoTest { Map<String, Object> row = selectBColumnsForUuid("U1"); assertThat(row.get("bChanged")).isIn(true, /* for Oracle */1L, 1); - assertThat(row.get("bKey")).isEqualTo("key"); - assertThat(row.get("bCopyComponentUuid")).isEqualTo("copy"); - assertThat(row.get("bDescription")).isEqualTo("desc"); + assertThat(row) + .containsEntry("bKey", "key") + .containsEntry("bCopyComponentUuid", "copy") + .containsEntry("bDescription", "desc"); assertThat(row.get("bEnabled")).isIn(true, /* for Oracle */1L, 1); - assertThat(row.get("bUuidPath")).isEqualTo("uuid_path"); - assertThat(row.get("bLanguage")).isEqualTo("lang"); - assertThat(row.get("bLongName")).isEqualTo("longName"); - assertThat(row.get("bModuleUuid")).isEqualTo("moduleUuid"); - assertThat(row.get("bModuleUuidPath")).isEqualTo("moduleUuidPath"); - assertThat(row.get("bName")).isEqualTo("name"); - assertThat(row.get("bPath")).isEqualTo("path"); - assertThat(row.get("bQualifier")).isEqualTo("qualifier"); + assertThat(row) + .containsEntry("bUuidPath", "uuid_path") + .containsEntry("bLanguage", "lang") + .containsEntry("bLongName", "longName") + .containsEntry("bModuleUuid", "moduleUuid") + .containsEntry("bModuleUuidPath", "moduleUuidPath") + .containsEntry("bName", "name") + .containsEntry("bPath", "path") + .containsEntry("bQualifier", "qualifier"); } @Test @@ -1271,33 +1273,37 @@ public class ComponentDaoTest { Map<String, Object> row1 = selectBColumnsForUuid("U1"); assertThat(row1.get("bChanged")).isIn(true, /* for Oracle */1L, 1); - assertThat(row1.get("bKey")).isEqualTo(dto1.getDbKey()); - assertThat(row1.get("bCopyComponentUuid")).isEqualTo(dto1.getCopyComponentUuid()); - assertThat(row1.get("bDescription")).isEqualTo(dto1.description()); + assertThat(row1) + .containsEntry("bKey", dto1.getDbKey()) + .containsEntry("bCopyComponentUuid", dto1.getCopyComponentUuid()) + .containsEntry("bDescription", dto1.description()); assertThat(row1.get("bEnabled")).isIn(false, /* for Oracle */0L, 0); - assertThat(row1.get("bUuidPath")).isEqualTo(dto1.getUuidPath()); - assertThat(row1.get("bLanguage")).isEqualTo(dto1.language()); - assertThat(row1.get("bLongName")).isEqualTo(dto1.longName()); - assertThat(row1.get("bModuleUuid")).isEqualTo(dto1.moduleUuid()); - assertThat(row1.get("bModuleUuidPath")).isEqualTo(dto1.moduleUuidPath()); - assertThat(row1.get("bName")).isEqualTo(dto1.name()); - assertThat(row1.get("bPath")).isEqualTo(dto1.path()); - assertThat(row1.get("bQualifier")).isEqualTo(dto1.qualifier()); + assertThat(row1) + .containsEntry("bUuidPath", dto1.getUuidPath()) + .containsEntry("bLanguage", dto1.language()) + .containsEntry("bLongName", dto1.longName()) + .containsEntry("bModuleUuid", dto1.moduleUuid()) + .containsEntry("bModuleUuidPath", dto1.moduleUuidPath()) + .containsEntry("bName", dto1.name()) + .containsEntry("bPath", dto1.path()) + .containsEntry("bQualifier", dto1.qualifier()); Map<String, Object> row2 = selectBColumnsForUuid("U2"); assertThat(row2.get("bChanged")).isIn(true, /* for Oracle */1L, 1); - assertThat(row2.get("bKey")).isEqualTo(dto2.getDbKey()); - assertThat(row2.get("bCopyComponentUuid")).isEqualTo(dto2.getCopyComponentUuid()); - assertThat(row2.get("bDescription")).isEqualTo(dto2.description()); + assertThat(row2) + .containsEntry("bKey", dto2.getDbKey()) + .containsEntry("bCopyComponentUuid", dto2.getCopyComponentUuid()) + .containsEntry("bDescription", dto2.description()); assertThat(row2.get("bEnabled")).isIn(false, /* for Oracle */0L, 0); - assertThat(row2.get("bUuidPath")).isEqualTo(dto2.getUuidPath()); - assertThat(row2.get("bLanguage")).isEqualTo(dto2.language()); - assertThat(row2.get("bLongName")).isEqualTo(dto2.longName()); - assertThat(row2.get("bModuleUuid")).isEqualTo(dto2.moduleUuid()); - assertThat(row2.get("bModuleUuidPath")).isEqualTo(dto2.moduleUuidPath()); - assertThat(row2.get("bName")).isEqualTo(dto2.name()); - assertThat(row2.get("bPath")).isEqualTo(dto2.path()); - assertThat(row2.get("bQualifier")).isEqualTo(dto2.qualifier()); + assertThat(row2) + .containsEntry("bUuidPath", dto2.getUuidPath()) + .containsEntry("bLanguage", dto2.language()) + .containsEntry("bLongName", dto2.longName()) + .containsEntry("bModuleUuid", dto2.moduleUuid()) + .containsEntry("bModuleUuidPath", dto2.moduleUuidPath()) + .containsEntry("bName", dto2.name()) + .containsEntry("bPath", dto2.path()) + .containsEntry("bQualifier", dto2.qualifier()); Map<String, Object> row3 = selectBColumnsForUuid("U3"); assertThat(row3.get("bChanged")).isIn(false, /* for Oracle */0L, 0); @@ -1370,7 +1376,7 @@ public class ComponentDaoTest { ComponentDto main = db.components().insertPublicProject(); ComponentDto branch = db.components().insertProjectBranch(main); - assertThat(underTest.countByQuery(dbSession, ALL_PROJECTS_COMPONENT_QUERY)).isEqualTo(1); + assertThat(underTest.countByQuery(dbSession, ALL_PROJECTS_COMPONENT_QUERY)).isOne(); } @Test diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDtoTest.java index 64974077864..ae332bab59f 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDtoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDtoTest.java @@ -61,12 +61,12 @@ public class ComponentDtoTest { ComponentDto dtoWithSameUuid = new ComponentDto().setUuid("u1"); ComponentDto dtoWithDifferentUuid = new ComponentDto().setUuid("u2"); - assertThat(dto).isEqualTo(dto); - assertThat(dto).isEqualTo(dtoWithSameUuid); - assertThat(dto).isNotEqualTo(dtoWithDifferentUuid); - - assertThat(dto.hashCode()).isEqualTo(dto.hashCode()); - assertThat(dto.hashCode()).isEqualTo(dtoWithSameUuid.hashCode()); + assertThat(dto) + .isEqualTo(dto) + .isEqualTo(dtoWithSameUuid) + .isNotEqualTo(dtoWithDifferentUuid) + .hasSameHashCodeAs(dto) + .hasSameHashCodeAs(dtoWithSameUuid); assertThat(dto.hashCode()).isNotEqualTo(dtoWithDifferentUuid.hashCode()); } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ScrapAnalysisPropertyDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ScrapAnalysisPropertyDtoTest.java index 5902c4b1b35..1d3effdb77f 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/ScrapAnalysisPropertyDtoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/ScrapAnalysisPropertyDtoTest.java @@ -34,7 +34,7 @@ public class ScrapAnalysisPropertyDtoTest { ScrapAnalysisPropertyDto underTest = new ScrapAnalysisPropertyDto(); underTest.setEmpty(true); - assertThat(underTest.getValue()).isEqualTo(""); + assertThat(underTest.getValue()).isEmpty(); } @Test 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 7164082cff9..40ae2f1fc67 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 @@ -321,7 +321,7 @@ public class SnapshotDaoTest { Optional<SnapshotDto> dto = underTest.selectOldestSnapshot(dbSession, project.uuid()); assertThat(dto).isNotEmpty(); - assertThat(dto.get().getCreatedAt()).isEqualTo(1L); + assertThat(dto.get().getCreatedAt()).isOne(); assertThat(underTest.selectOldestSnapshot(dbSession, "blabla")).isEmpty(); } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/duplication/DuplicationDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/duplication/DuplicationDaoTest.java index dba8d566232..d1bcc206be5 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/duplication/DuplicationDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/duplication/DuplicationDaoTest.java @@ -150,12 +150,13 @@ public class DuplicationDaoTest { Assertions.assertThat(rows).hasSize(1); Map<String, Object> row = rows.get(0); Assertions.assertThat(row.get("UUID")).isNotNull(); - Assertions.assertThat(row.get("ANALYSIS")).isEqualTo(analysis.getUuid()); - Assertions.assertThat(row.get("COMPONENT")).isEqualTo(project.uuid()); - Assertions.assertThat(row.get("HASH")).isEqualTo("bb"); - Assertions.assertThat(row.get("INDEX")).isEqualTo(0L); - Assertions.assertThat(row.get("START")).isEqualTo(1L); - Assertions.assertThat(row.get("END")).isEqualTo(2L); + Assertions.assertThat(row) + .containsEntry("ANALYSIS", analysis.getUuid()) + .containsEntry("COMPONENT", project.uuid()) + .containsEntry("HASH", "bb") + .containsEntry("INDEX", 0L) + .containsEntry("START", 1L) + .containsEntry("END", 2L); } public void insert(ComponentDto project, SnapshotDto analysis, String hash, int indexInFile, int startLine, int endLine) { diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueChangeDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueChangeDaoTest.java index 02d87460711..d73c927d90c 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueChangeDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueChangeDaoTest.java @@ -110,7 +110,7 @@ public class IssueChangeDaoTest { assertThat(underTest.delete(db.getSession(), issueChange1.getKey())).isTrue(); - assertThat(db.countRowsOfTable(db.getSession(), "issue_changes")).isEqualTo(1); + assertThat(db.countRowsOfTable(db.getSession(), "issue_changes")).isOne(); } @Test diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java index d3ba10a6349..13772704f58 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDaoTest.java @@ -326,14 +326,14 @@ public class IssueDaoTest { assertThat(result.stream().filter(g -> g.getRuleType() == RuleType.VULNERABILITY.getDbConstant()).mapToLong(IssueGroupDto::getCount).sum()).isZero(); assertThat(result.stream().filter(g -> g.getSeverity().equals("CRITICAL")).mapToLong(IssueGroupDto::getCount).sum()).isEqualTo(2); - assertThat(result.stream().filter(g -> g.getSeverity().equals("MAJOR")).mapToLong(IssueGroupDto::getCount).sum()).isEqualTo(1); + assertThat(result.stream().filter(g -> g.getSeverity().equals("MAJOR")).mapToLong(IssueGroupDto::getCount).sum()).isOne(); assertThat(result.stream().filter(g -> g.getSeverity().equals("MINOR")).mapToLong(IssueGroupDto::getCount).sum()).isZero(); assertThat(result.stream().filter(g -> g.getStatus().equals("OPEN")).mapToLong(IssueGroupDto::getCount).sum()).isEqualTo(2); - assertThat(result.stream().filter(g -> g.getStatus().equals("RESOLVED")).mapToLong(IssueGroupDto::getCount).sum()).isEqualTo(1); + assertThat(result.stream().filter(g -> g.getStatus().equals("RESOLVED")).mapToLong(IssueGroupDto::getCount).sum()).isOne(); assertThat(result.stream().filter(g -> g.getStatus().equals("CLOSED")).mapToLong(IssueGroupDto::getCount).sum()).isZero(); - assertThat(result.stream().filter(g -> "FALSE-POSITIVE".equals(g.getResolution())).mapToLong(IssueGroupDto::getCount).sum()).isEqualTo(1); + assertThat(result.stream().filter(g -> "FALSE-POSITIVE".equals(g.getResolution())).mapToLong(IssueGroupDto::getCount).sum()).isOne(); assertThat(result.stream().filter(g -> g.getResolution() == null).mapToLong(IssueGroupDto::getCount).sum()).isEqualTo(2); assertThat(result.stream().filter(g -> g.isInLeak()).mapToLong(IssueGroupDto::getCount).sum()).isEqualTo(3); diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDtoTest.java index 644f33d74f7..8f1b5dabeb7 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDtoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueDtoTest.java @@ -89,7 +89,7 @@ public class IssueDtoTest { DefaultIssue issue = dto.toDefaultIssue(); assertThat(issue.key()).isEqualTo("100"); assertThat(issue.type()).isEqualTo(RuleType.VULNERABILITY); - assertThat(issue.ruleKey().toString()).isEqualTo("squid:AvoidCycle"); + assertThat(issue.ruleKey()).hasToString("squid:AvoidCycle"); assertThat(issue.language()).isEqualTo("xoo"); assertThat(issue.componentUuid()).isEqualTo("CDEF"); assertThat(issue.projectUuid()).isEqualTo("GHIJ"); @@ -124,9 +124,9 @@ public class IssueDtoTest { assertThat(dto.getRuleUuid()).isEqualTo("uuid-1"); assertThat(dto.getRuleRepo()).isEqualTo("squid"); assertThat(dto.getRule()).isEqualTo("AvoidCycle"); - assertThat(dto.getRuleKey().toString()).isEqualTo("squid:AvoidCycle"); + assertThat(dto.getRuleKey()).hasToString("squid:AvoidCycle"); assertThat(dto.getLanguage()).isEqualTo("xoo"); - assertThat(dto.isExternal()).isEqualTo(true); + assertThat(dto.isExternal()).isTrue(); } @Test diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueMapperTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueMapperTest.java index fc40fcab457..2d3ab3091ed 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueMapperTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/issue/IssueMapperTest.java @@ -188,7 +188,7 @@ public class IssueMapperTest { dto.setSelectedAt(1500000000000L); int count = underTest.updateIfBeforeSelectedDate(dto); - assertThat(count).isEqualTo(1); + assertThat(count).isOne(); dbTester.getSession().commit(); IssueDto result = underTest.selectByKey("ABCDE"); diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java index 76ebd5c01b4..734345fd31a 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/measure/LiveMeasureDaoTest.java @@ -334,7 +334,7 @@ public class LiveMeasureDaoTest { .build(); long result = underTest.sumNclocOfBiggestBranch(db.getSession(), query); - assertThat(result).isEqualTo(0L); + assertThat(result).isZero(); } @Test @@ -457,7 +457,7 @@ public class LiveMeasureDaoTest { db.measures().insertLiveMeasure(project1, metric2); assertThat(underTest.countProjectsHavingMeasure(db.getSession(), metric1.getKey())).isEqualTo(2); - assertThat(underTest.countProjectsHavingMeasure(db.getSession(), metric2.getKey())).isEqualTo(1); + assertThat(underTest.countProjectsHavingMeasure(db.getSession(), metric2.getKey())).isOne(); assertThat(underTest.countProjectsHavingMeasure(db.getSession(), "unknown")).isZero(); } @@ -472,14 +472,14 @@ public class LiveMeasureDaoTest { int count = underTest.upsert(db.getSession(), dto); verifyPersisted(dto); verifyTableSize(1); - assertThat(count).isEqualTo(1); + assertThat(count).isOne(); // update dto.setValue(dto.getValue() + 1); dto.setVariation(dto.getVariation() + 10); dto.setData(dto.getDataAsString() + "_new"); count = underTest.upsert(db.getSession(), dto); - assertThat(count).isEqualTo(1); + assertThat(count).isOne(); verifyPersisted(dto); verifyTableSize(1); } @@ -512,7 +512,7 @@ public class LiveMeasureDaoTest { // update dto.setData(RandomStringUtils.random(dto.getDataAsString().length() + 10)); int count = underTest.upsert(db.getSession(), dto); - assertThat(count).isEqualTo(1); + assertThat(count).isOne(); verifyPersisted(dto); verifyTableSize(1); } @@ -544,7 +544,7 @@ public class LiveMeasureDaoTest { // update dto.setData((String) null); int count = underTest.upsert(db.getSession(), dto); - assertThat(count).isEqualTo(1); + assertThat(count).isOne(); verifyPersisted(dto); verifyTableSize(1); } @@ -560,7 +560,7 @@ public class LiveMeasureDaoTest { // update dto.setVariation(50.0); int count = underTest.upsert(db.getSession(), dto); - assertThat(count).isEqualTo(1); + assertThat(count).isOne(); verifyPersisted(dto); verifyTableSize(1); } @@ -576,7 +576,7 @@ public class LiveMeasureDaoTest { // update dto.setVariation(null); int count = underTest.upsert(db.getSession(), dto); - assertThat(count).isEqualTo(1); + assertThat(count).isOne(); verifyPersisted(dto); verifyTableSize(1); } @@ -592,7 +592,7 @@ public class LiveMeasureDaoTest { // update dto.setVariation(40.0); int count = underTest.upsert(db.getSession(), dto); - assertThat(count).isEqualTo(1); + assertThat(count).isOne(); verifyPersisted(dto); verifyTableSize(1); } @@ -608,7 +608,7 @@ public class LiveMeasureDaoTest { // update dto.setValue(50.0); int count = underTest.upsert(db.getSession(), dto); - assertThat(count).isEqualTo(1); + assertThat(count).isOne(); verifyPersisted(dto); verifyTableSize(1); } @@ -624,7 +624,7 @@ public class LiveMeasureDaoTest { // update dto.setValue(null); int count = underTest.upsert(db.getSession(), dto); - assertThat(count).isEqualTo(1); + assertThat(count).isOne(); verifyPersisted(dto); verifyTableSize(1); } @@ -640,7 +640,7 @@ public class LiveMeasureDaoTest { // update dto.setValue(40.0); int count = underTest.upsert(db.getSession(), dto); - assertThat(count).isEqualTo(1); + assertThat(count).isOne(); verifyPersisted(dto); verifyTableSize(1); } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/metric/MetricDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/metric/MetricDaoTest.java index 6297f2bfe84..56e4302086c 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/metric/MetricDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/metric/MetricDaoTest.java @@ -134,7 +134,7 @@ public class MetricDaoTest { assertThat(result.getDescription()).isEqualTo("Coverage by unit tests"); assertThat(result.getDomain()).isEqualTo("Tests"); assertThat(result.getValueType()).isEqualTo("PERCENT"); - assertThat(result.getDirection()).isEqualTo(1); + assertThat(result.getDirection()).isOne(); assertThat(result.isQualitative()).isTrue(); assertThat(result.getWorstValue()).isEqualTo(0d); assertThat(result.getBestValue()).isEqualTo(100d); diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/metric/MetricDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/metric/MetricDtoTest.java index 0748e068b4e..495d15dba5e 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/metric/MetricDtoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/metric/MetricDtoTest.java @@ -57,7 +57,7 @@ public class MetricDtoTest { assertThat(metricDto.getWorstValue()).isEqualTo(0d); assertThat(metricDto.getBestValue()).isEqualTo(100d); assertThat(metricDto.isOptimizedBestValue()).isTrue(); - assertThat(metricDto.getDirection()).isEqualTo(1); + assertThat(metricDto.getDirection()).isOne(); assertThat(metricDto.isHidden()).isTrue(); assertThat(metricDto.isDeleteHistoricalData()).isTrue(); assertThat(metricDto.isEnabled()).isTrue(); diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/notification/NotificationQueueDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/notification/NotificationQueueDaoTest.java index db21cc0ce02..a07409eef7c 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/notification/NotificationQueueDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/notification/NotificationQueueDaoTest.java @@ -51,7 +51,7 @@ public class NotificationQueueDaoTest { dao.insert(Arrays.asList(notificationQueueDto)); - assertThat(dao.count()).isEqualTo(1); + assertThat(dao.count()).isOne(); assertThat(dao.selectOldest(1).get(0).toNotification().getType()).isEqualTo("email"); } @@ -63,7 +63,7 @@ public class NotificationQueueDaoTest { dao.insert(Arrays.asList(notificationQueueDto)); - assertThat(dao.count()).isEqualTo(1); + assertThat(dao.count()).isOne(); } @Test diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/GroupPermissionDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/GroupPermissionDaoTest.java index 77aeec19786..aab2045957f 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/GroupPermissionDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/GroupPermissionDaoTest.java @@ -173,13 +173,13 @@ public class GroupPermissionDaoTest { assertThat(underTest.countGroupsByQuery(dbSession, newQuery().build())).isEqualTo(4); assertThat(underTest.countGroupsByQuery(dbSession, - newQuery().setPermission(PROVISION_PROJECTS.getKey()).build())).isEqualTo(1); + newQuery().setPermission(PROVISION_PROJECTS.getKey()).build())).isOne(); assertThat(underTest.countGroupsByQuery(dbSession, newQuery().withAtLeastOnePermission().build())).isEqualTo(2); assertThat(underTest.countGroupsByQuery(dbSession, newQuery().setSearchQuery("Group-").build())).isEqualTo(3); assertThat(underTest.countGroupsByQuery(dbSession, - newQuery().setSearchQuery("Any").build())).isEqualTo(1); + newQuery().setSearchQuery("Any").build())).isOne(); } @Test @@ -701,7 +701,7 @@ public class GroupPermissionDaoTest { int deletedCount = underTest.deleteByRootComponentUuidAndGroupUuid(dbSession, null, project); - assertThat(deletedCount).isEqualTo(1); + assertThat(deletedCount).isOne(); assertThat(underTest.selectProjectPermissionsOfGroup(dbSession, null, project.uuid())) .isEmpty(); assertThat(underTest.selectProjectPermissionsOfGroup(dbSession, group.getUuid(), project.uuid())) @@ -739,7 +739,7 @@ public class GroupPermissionDaoTest { int deletedCount = underTest.deleteByRootComponentUuidAndGroupUuid(dbSession, group1.getUuid(), project); - assertThat(deletedCount).isEqualTo(1); + assertThat(deletedCount).isOne(); assertThat(underTest.selectProjectPermissionsOfGroup(dbSession, null, project.uuid())) .containsOnly("p1"); assertThat(underTest.selectProjectPermissionsOfGroup(dbSession, group1.getUuid(), project.uuid())) diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/GroupWithPermissionTemplateDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/GroupWithPermissionTemplateDaoTest.java index dcac233f428..98b419bcd29 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/GroupWithPermissionTemplateDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/GroupWithPermissionTemplateDaoTest.java @@ -103,9 +103,7 @@ public class GroupWithPermissionTemplateDaoTest { @Test public void selectGroupNamesByQueryAndTemplate_is_order_by_groups_with_permission_then_by_name_when_many_groups() { PermissionTemplateDto template = permissionTemplateDbTester.insertTemplate(); - IntStream.rangeClosed(1, DEFAULT_PAGE_SIZE + 1).forEach(i -> { - db.users().insertGroup("Group-" + i); - }); + IntStream.rangeClosed(1, DEFAULT_PAGE_SIZE + 1).forEach(i -> db.users().insertGroup("Group-" + i)); String lastGroupName = "Group-" + (DEFAULT_PAGE_SIZE + 1); permissionTemplateDbTester.addGroupToTemplate(template, db.users().selectGroup(lastGroupName).get(), UserRole.USER); @@ -177,15 +175,15 @@ public class GroupWithPermissionTemplateDaoTest { .isEqualTo(4); assertThat(countGroupNamesByQueryAndTemplate(builder().withAtLeastOnePermission(), template)) .isEqualTo(2); - assertThat(countGroupNamesByQueryAndTemplate(builder().setPermission(USER), template)).isEqualTo(1); + assertThat(countGroupNamesByQueryAndTemplate(builder().setPermission(USER), template)).isOne(); assertThat(countGroupNamesByQueryAndTemplate(builder().setPermission(USER), anotherTemplate)) - .isEqualTo(1); + .isOne(); assertThat(countGroupNamesByQueryAndTemplate(builder().setSearchQuery("groU"), template)) .isEqualTo(3); assertThat(countGroupNamesByQueryAndTemplate(builder().setSearchQuery("nYo"), template)) - .isEqualTo(1); + .isOne(); assertThat(countGroupNamesByQueryAndTemplate(builder().setSearchQuery("p-2"), template)) - .isEqualTo(1); + .isOne(); assertThat(countGroupNamesByQueryAndTemplate(builder().withAtLeastOnePermission().build(), "123")) .isZero(); diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/property/InternalComponentPropertyDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/property/InternalComponentPropertyDtoTest.java index 1089188d382..799e56fcc17 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/property/InternalComponentPropertyDtoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/property/InternalComponentPropertyDtoTest.java @@ -93,6 +93,6 @@ public class InternalComponentPropertyDtoTest { .setCreatedAt(10L) .setUpdatedAt(15L); - assertThat(underTest.toString()).isEqualTo("InternalComponentPropertyDto{uuid=uuid1, key=key1, value=value1, componentUuid=component1, updatedAt=15, createdAt=10}"); + assertThat(underTest).hasToString("InternalComponentPropertyDto{uuid=uuid1, key=key1, value=value1, componentUuid=component1, updatedAt=15, createdAt=10}"); } } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/property/PropertyDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/property/PropertyDtoTest.java index 28372586bbb..5fd21c24f13 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/property/PropertyDtoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/property/PropertyDtoTest.java @@ -33,7 +33,7 @@ public class PropertyDtoTest { public void testEquals() { assertThat(new PropertyDto().setKey("123").setComponentUuid("uuid123")).isEqualTo(new PropertyDto().setKey("123").setComponentUuid("uuid123")); assertThat(new PropertyDto().setKey("1234").setComponentUuid("uuid123")).isNotEqualTo(new PropertyDto().setKey("123").setComponentUuid("uuid123")); - assertThat(new PropertyDto().setKey("1234").setComponentUuid("uuid123")).isNotEqualTo(null); + assertThat(new PropertyDto().setKey("1234").setComponentUuid("uuid123")).isNotNull(); assertThat(new PropertyDto().setKey("1234").setComponentUuid("uuid123")).isNotEqualTo(new Object()); } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeCommandsTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeCommandsTest.java index f0851b0858c..a5c5ddf86bd 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeCommandsTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeCommandsTest.java @@ -199,10 +199,10 @@ public class PurgeCommandsTest { underTest.deleteComponents(component.uuid()); assertThat(dbTester.countRowsOfTable("components")).isZero(); - assertThat(dbTester.countRowsOfTable("snapshots")).isEqualTo(1); - assertThat(dbTester.countRowsOfTable("events")).isEqualTo(1); - assertThat(dbTester.countRowsOfTable("issues")).isEqualTo(1); - assertThat(dbTester.countRowsOfTable("issue_changes")).isEqualTo(1); + assertThat(dbTester.countRowsOfTable("snapshots")).isOne(); + assertThat(dbTester.countRowsOfTable("events")).isOne(); + assertThat(dbTester.countRowsOfTable("issues")).isOne(); + assertThat(dbTester.countRowsOfTable("issue_changes")).isOne(); } @Test @@ -222,10 +222,10 @@ public class PurgeCommandsTest { assertThat(dbTester.countRowsOfTable("projects")).isZero(); assertThat(dbTester.countRowsOfTable("components")).isZero(); - assertThat(dbTester.countRowsOfTable("snapshots")).isEqualTo(1); - assertThat(dbTester.countRowsOfTable("events")).isEqualTo(1); - assertThat(dbTester.countRowsOfTable("issues")).isEqualTo(1); - assertThat(dbTester.countRowsOfTable("issue_changes")).isEqualTo(1); + assertThat(dbTester.countRowsOfTable("snapshots")).isOne(); + assertThat(dbTester.countRowsOfTable("events")).isOne(); + assertThat(dbTester.countRowsOfTable("issues")).isOne(); + assertThat(dbTester.countRowsOfTable("issue_changes")).isOne(); } @Test @@ -359,14 +359,14 @@ public class PurgeCommandsTest { underTest.deleteAbortedAnalyses(projectOrView.uuid()); - assertThat(countAnalysesOfRoot(projectOrView, STATUS_UNPROCESSED, true)).isEqualTo(1); + assertThat(countAnalysesOfRoot(projectOrView, STATUS_UNPROCESSED, true)).isOne(); assertThat(countAnalysesOfRoot(projectOrView, STATUS_UNPROCESSED, false)).isZero(); - assertThat(countAnalysesOfRoot(projectOrView, STATUS_PROCESSED, true)).isEqualTo(1); - assertThat(countAnalysesOfRoot(projectOrView, STATUS_PROCESSED, false)).isEqualTo(1); - assertThat(countAnalysesOfRoot(otherProject, STATUS_UNPROCESSED, true)).isEqualTo(1); - assertThat(countAnalysesOfRoot(otherProject, STATUS_UNPROCESSED, false)).isEqualTo(1); - assertThat(countAnalysesOfRoot(otherProject, STATUS_PROCESSED, true)).isEqualTo(1); - assertThat(countAnalysesOfRoot(otherProject, STATUS_PROCESSED, false)).isEqualTo(1); + assertThat(countAnalysesOfRoot(projectOrView, STATUS_PROCESSED, true)).isOne(); + assertThat(countAnalysesOfRoot(projectOrView, STATUS_PROCESSED, false)).isOne(); + assertThat(countAnalysesOfRoot(otherProject, STATUS_UNPROCESSED, true)).isOne(); + assertThat(countAnalysesOfRoot(otherProject, STATUS_UNPROCESSED, false)).isOne(); + assertThat(countAnalysesOfRoot(otherProject, STATUS_PROCESSED, true)).isOne(); + assertThat(countAnalysesOfRoot(otherProject, STATUS_PROCESSED, false)).isOne(); } @Test @@ -543,7 +543,7 @@ public class PurgeCommandsTest { purgeCommands.deletePermissions(project.uuid()); assertThat(dbTester.countRowsOfTable("group_roles")).isEqualTo(2); - assertThat(dbTester.countRowsOfTable("user_roles")).isEqualTo(1); + assertThat(dbTester.countRowsOfTable("user_roles")).isOne(); } @Test @@ -554,8 +554,8 @@ public class PurgeCommandsTest { PurgeCommands purgeCommands = new PurgeCommands(dbTester.getSession(), profiler, system2); purgeCommands.deletePermissions(project.uuid()); - assertThat(dbTester.countRowsOfTable("group_roles")).isEqualTo(1); - assertThat(dbTester.countRowsOfTable("user_roles")).isEqualTo(1); + assertThat(dbTester.countRowsOfTable("group_roles")).isOne(); + assertThat(dbTester.countRowsOfTable("user_roles")).isOne(); } @Test @@ -567,7 +567,7 @@ public class PurgeCommandsTest { purgeCommands.deletePermissions(project.uuid()); assertThat(dbTester.countRowsOfTable("group_roles")).isEqualTo(2); - assertThat(dbTester.countRowsOfTable("user_roles")).isEqualTo(1); + assertThat(dbTester.countRowsOfTable("user_roles")).isOne(); } @Test @@ -611,7 +611,7 @@ public class PurgeCommandsTest { purgeCommands.deleteNewCodePeriods(project.uuid()); // should delete branch and project settings only - assertThat(dbTester.countRowsOfTable("new_code_periods")).isEqualTo(1); + assertThat(dbTester.countRowsOfTable("new_code_periods")).isOne(); } @Test @@ -649,7 +649,7 @@ public class PurgeCommandsTest { purgeCommands.deleteUserDismissedMessages(project.getUuid()); - assertThat(dbTester.countRowsOfTable("user_dismissed_messages")).isEqualTo(1); + assertThat(dbTester.countRowsOfTable("user_dismissed_messages")).isOne(); } @Test diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java index f2566237fe2..80238ce0ae5 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeDaoTest.java @@ -285,7 +285,7 @@ public class PurgeDaoTest { verify(purgeListener).onComponentsDisabling(project.uuid(), ImmutableSet.of(dir.uuid())); // set purge_status=1 for non-last snapshot - assertThat(db.countSql("select count(*) from snapshots where purge_status = 1")).isEqualTo(1); + assertThat(db.countSql("select count(*) from snapshots where purge_status = 1")).isOne(); // close open issues of selected assertThat(db.countSql("select count(*) from issues where status = 'CLOSED'")).isEqualTo(4); @@ -301,7 +301,7 @@ public class PurgeDaoTest { } // delete file sources of selected - assertThat(db.countRowsOfTable("file_sources")).isEqualTo(1); + assertThat(db.countRowsOfTable("file_sources")).isOne(); assertThat(db.getDbClient().fileSourceDao().selectByFileUuid(dbSession, nonSelectedFileSource.getFileUuid())).isNotNull(); // deletes live measure of selected @@ -369,7 +369,7 @@ public class PurgeDaoTest { assertThat(uuidsIn("event_component_changes", "event_analysis_uuid")) .containsOnly(projectAnalysis2.getUuid()); assertThat(db.countRowsOfTable("event_component_changes")) - .isEqualTo(1); + .isOne(); assertThat(uuidsIn("events")) .containsOnly(projectEvent2.getUuid(), projectEvent3.getUuid()); @@ -377,7 +377,7 @@ public class PurgeDaoTest { assertThat(uuidsIn("event_component_changes", "event_analysis_uuid")) .containsOnly(projectAnalysis2.getUuid()); assertThat(db.countRowsOfTable("event_component_changes")) - .isEqualTo(1); + .isOne(); assertThat(uuidsIn("events")) .containsOnly(projectEvent2.getUuid(), projectEvent3.getUuid()); @@ -385,7 +385,7 @@ public class PurgeDaoTest { assertThat(uuidsIn("event_component_changes", "event_analysis_uuid")) .containsOnly(projectAnalysis2.getUuid()); assertThat(db.countRowsOfTable("event_component_changes")) - .isEqualTo(1); + .isOne(); assertThat(uuidsIn("events")) .containsOnly(projectEvent2.getUuid()); @@ -833,7 +833,7 @@ public class PurgeDaoTest { underTest.deleteProject(dbSession, projectToBeDeleted.uuid(), projectToBeDeleted.qualifier(), projectToBeDeleted.name(), projectToBeDeleted.getKey()); dbSession.commit(); - assertThat(db.countRowsOfTable("ce_queue")).isEqualTo(1); + assertThat(db.countRowsOfTable("ce_queue")).isOne(); assertThat(db.countSql("select count(*) from ce_queue where main_component_uuid='" + projectToBeDeleted.uuid() + "'")).isZero(); } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeableAnalysisDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeableAnalysisDtoTest.java index 4905705ce2c..37e360e8747 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeableAnalysisDtoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeableAnalysisDtoTest.java @@ -41,7 +41,6 @@ public class PurgeableAnalysisDtoTest { @Test public void testHasCode() { PurgeableAnalysisDto dto = new PurgeableAnalysisDto().setAnalysisUuid("u3"); - assertThat(dto.hashCode()).isEqualTo(dto.hashCode()); // no uuid => NPE dto = new PurgeableAnalysisDto(); 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 2b314333bf6..ab9acbc02e8 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 @@ -59,7 +59,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.get(0).count()).isEqualTo(1); + assertThat(intervals.get(0).count()).isOne(); assertThat(calendarField(intervals.get(0), Calendar.MONTH)).isEqualTo((Calendar.APRIL)); assertThat(intervals.get(1).count()).isEqualTo(2); @@ -80,11 +80,11 @@ public class IntervalTest { 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.get(0).count()).isEqualTo(1); + assertThat(intervals.get(0).count()).isOne(); assertThat(calendarField(intervals.get(0), Calendar.MONTH)).isEqualTo((Calendar.APRIL)); assertThat(calendarField(intervals.get(0), Calendar.YEAR)).isEqualTo((2010)); - assertThat(intervals.get(1).count()).isEqualTo(1); + assertThat(intervals.get(1).count()).isOne(); assertThat(calendarField(intervals.get(1), Calendar.MONTH)).isEqualTo((Calendar.APRIL)); assertThat(calendarField(intervals.get(1), Calendar.YEAR)).isEqualTo((2011)); } @@ -100,8 +100,8 @@ public class IntervalTest { List<Interval> intervals = Interval.group(snapshots, DateUtils.parseDateTime("2011-05-25T00:00:00+0100"), DateUtils.parseDateTime("2012-01-26T00:00:00+0100"), Calendar.MONTH); - assertThat(intervals.size()).isEqualTo(1); - assertThat(intervals.get(0).count()).isEqualTo(1); + assertThat(intervals.size()).isOne(); + assertThat(intervals.get(0).count()).isOne(); assertThat(intervals.get(0).get().get(0).getAnalysisUuid()).isEqualTo(("u2")); } } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/period/KeepOneFilterTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/period/KeepOneFilterTest.java index ef2dfd7329a..645ef2246a7 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/period/KeepOneFilterTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/period/KeepOneFilterTest.java @@ -33,7 +33,7 @@ import static org.assertj.core.api.Assertions.assertThat; public class KeepOneFilterTest { private static List<String> analysisUuids(List<PurgeableAnalysisDto> snapshotDtos) { - return snapshotDtos.stream().map(input -> input.getAnalysisUuid()).collect(Collectors.toList()); + return snapshotDtos.stream().map(PurgeableAnalysisDto::getAnalysisUuid).collect(Collectors.toList()); } @Test diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/qualitygate/ProjectQgateAssociationDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/qualitygate/ProjectQgateAssociationDaoTest.java index 594f3ec87df..bf807721f8f 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/qualitygate/ProjectQgateAssociationDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/qualitygate/ProjectQgateAssociationDaoTest.java @@ -151,7 +151,7 @@ public class ProjectQgateAssociationDaoTest { Optional<String> result = underTest.selectQGateUuidByProjectUuid(dbSession, project.uuid()); - assertThat(result.isPresent()).isFalse(); + assertThat(result).isEmpty(); } @Test diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/qualitygate/QualityGateGroupPermissionsDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/qualitygate/QualityGateGroupPermissionsDaoTest.java index d76815dc5a9..b07083fa5ce 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/qualitygate/QualityGateGroupPermissionsDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/qualitygate/QualityGateGroupPermissionsDaoTest.java @@ -121,7 +121,7 @@ public class QualityGateGroupPermissionsDaoTest { assertThat(underTest.countByQuery(dbSession, builder() .setQualityGate(qualityGateDto) .setMembership(OUT).build())) - .isEqualTo(1); + .isOne(); } @Test diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/qualitygate/QualityGateUserPermissionsDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/qualitygate/QualityGateUserPermissionsDaoTest.java index 8cf82da9ef1..327f87cab84 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/qualitygate/QualityGateUserPermissionsDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/qualitygate/QualityGateUserPermissionsDaoTest.java @@ -120,7 +120,7 @@ public class QualityGateUserPermissionsDaoTest { assertThat(underTest.countByQuery(db.getSession(), builder() .setQualityGate(qualityGate) .setMembership(OUT).build())) - .isEqualTo(1); + .isOne(); } @Test diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleDaoTest.java index 5126294af22..9c74633b3bd 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleDaoTest.java @@ -374,7 +374,7 @@ public class ActiveRuleDaoTest { underTest.deleteByRuleProfileUuids(dbSession, singletonList(profile1.getRulesProfileUuid())); - assertThat(db.countRowsOfTable(dbSession, "active_rules")).isEqualTo(1); + assertThat(db.countRowsOfTable(dbSession, "active_rules")).isOne(); assertThat(underTest.selectByKey(dbSession, ActiveRuleKey.of(profile2, rule1.getKey()))).isPresent(); } @@ -384,7 +384,7 @@ public class ActiveRuleDaoTest { underTest.deleteByRuleProfileUuids(dbSession, singletonList("does_not_exist")); - assertThat(db.countRowsOfTable(dbSession, "active_rules")).isEqualTo(1); + assertThat(db.countRowsOfTable(dbSession, "active_rules")).isOne(); } @Test @@ -395,7 +395,7 @@ public class ActiveRuleDaoTest { underTest.deleteByUuids(dbSession, asList(ar1.getUuid(), ar3.getUuid())); - assertThat(db.countRowsOfTable(dbSession, "active_rules")).isEqualTo(1); + assertThat(db.countRowsOfTable(dbSession, "active_rules")).isOne(); assertThat(underTest.selectByProfile(dbSession, profile1)) .extracting(ActiveRuleDto::getUuid) .containsExactly(ar2.getUuid()); @@ -407,7 +407,7 @@ public class ActiveRuleDaoTest { underTest.deleteByUuids(dbSession, emptyList()); - assertThat(db.countRowsOfTable(dbSession, "active_rules")).isEqualTo(1); + assertThat(db.countRowsOfTable(dbSession, "active_rules")).isOne(); } private static ActiveRuleDto newRow(QProfileDto profile, RuleDefinitionDto rule) { 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 42ed856bc4f..256f1aa5434 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 @@ -79,6 +79,6 @@ public class ActiveRuleKeyTest { assertThat(key1.equals(key2)).isFalse(); assertThat(key1.equals(key3)).isFalse(); - assertThat(key1.hashCode()).isEqualTo(key1.hashCode()); + assertThat(key1).hasSameHashCodeAs(key1); } } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleParamDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleParamDtoTest.java index 0c2b13ab3bd..9706d29792e 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleParamDtoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/ActiveRuleParamDtoTest.java @@ -37,6 +37,6 @@ public class ActiveRuleParamDtoTest { new ActiveRuleParamDto().setKey("foo"), new ActiveRuleParamDto().setKey("bar") ); Map<String, ActiveRuleParamDto> group = ActiveRuleParamDto.groupByKey(dtos); - assertThat(group.keySet()).containsOnly("foo", "bar"); + assertThat(group).containsOnlyKeys("foo", "bar"); } } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/DefaultQProfileDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/DefaultQProfileDaoTest.java index 81bbf2912e5..2c763ec85b9 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/DefaultQProfileDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/DefaultQProfileDaoTest.java @@ -48,7 +48,7 @@ public class DefaultQProfileDaoTest { underTest.insertOrUpdate(dbSession, dto); dbSession.commit(); - assertThat(countRows()).isEqualTo(1); + assertThat(countRows()).isOne(); assertThatIsDefault(profile); } @@ -66,7 +66,7 @@ public class DefaultQProfileDaoTest { underTest.insertOrUpdate(dbSession, dto); dbSession.commit(); - assertThat(countRows()).isEqualTo(1); + assertThat(countRows()).isOne(); assertThat(selectUuidOfDefaultProfile(dto.getLanguage())).hasValue(newQProfileUuid); } @@ -78,7 +78,7 @@ public class DefaultQProfileDaoTest { .setQProfileUuid(previousQProfileUuid); underTest.insert(dbSession, dto); dbSession.commit(); - assertThat(countRows()).isEqualTo(1); + assertThat(countRows()).isOne(); assertThat(selectUuidOfDefaultProfile(dto.getLanguage())).hasValue(dto.getQProfileUuid()); } @@ -90,7 +90,7 @@ public class DefaultQProfileDaoTest { underTest.deleteByQProfileUuids(dbSession, asList("u1", "u3")); dbSession.commit(); - assertThat(countRows()).isEqualTo(1); + assertThat(countRows()).isOne(); assertThat(selectUuidOfDefaultProfile("java")).isEmpty(); assertThat(selectUuidOfDefaultProfile("js")).hasValue("u2"); } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QProfileChangeDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QProfileChangeDaoTest.java index cd49fca93ca..b725275fedb 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QProfileChangeDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QProfileChangeDaoTest.java @@ -194,7 +194,7 @@ public class QProfileChangeDaoTest { long end = system2.now(); assertThat(underTest.countByQuery(dbSession, new QProfileChangeQuery(profile1.getKee()))).isEqualTo(2); - assertThat(underTest.countByQuery(dbSession, new QProfileChangeQuery(profile2.getKee()))).isEqualTo(1); + assertThat(underTest.countByQuery(dbSession, new QProfileChangeQuery(profile2.getKee()))).isOne(); assertThat(underTest.countByQuery(dbSession, new QProfileChangeQuery("does_not_exist"))).isZero(); QProfileChangeQuery query = new QProfileChangeQuery(profile1.getKee()); @@ -217,7 +217,7 @@ public class QProfileChangeDaoTest { underTest.deleteByRulesProfileUuids(dbSession, asList(profile1.getRulesProfileUuid())); assertThat(underTest.countByQuery(dbSession, new QProfileChangeQuery(profile1.getKee()))).isZero(); - assertThat(underTest.countByQuery(dbSession, new QProfileChangeQuery(profile2.getKee()))).isEqualTo(1); + assertThat(underTest.countByQuery(dbSession, new QProfileChangeQuery(profile2.getKee()))).isOne(); } @Test @@ -227,7 +227,7 @@ public class QProfileChangeDaoTest { underTest.deleteByRulesProfileUuids(dbSession, asList("does not exist")); - assertThat(underTest.countByQuery(dbSession, new QProfileChangeQuery(profile1.getKee()))).isEqualTo(1); + assertThat(underTest.countByQuery(dbSession, new QProfileChangeQuery(profile1.getKee()))).isOne(); } private QProfileChangeDto insertChange(QProfileDto profile, String type, @Nullable String login, @Nullable String data) { diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QProfileEditGroupsDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QProfileEditGroupsDaoTest.java index 919f596e8fd..724b0a66a82 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QProfileEditGroupsDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QProfileEditGroupsDaoTest.java @@ -100,7 +100,7 @@ public class QProfileEditGroupsDaoTest { assertThat(underTest.countByQuery(db.getSession(), builder() .setProfile(profile) .setMembership(OUT).build())) - .isEqualTo(1); + .isOne(); } @Test diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QProfileEditUsersDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QProfileEditUsersDaoTest.java index 05df576f38b..4b9ec4e3ecb 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QProfileEditUsersDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QProfileEditUsersDaoTest.java @@ -105,7 +105,7 @@ public class QProfileEditUsersDaoTest { assertThat(underTest.countByQuery(db.getSession(), builder() .setProfile(profile) .setMembership(OUT).build())) - .isEqualTo(1); + .isOne(); } @Test diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java index 0f0abc2178c..d3c4c9d2a08 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java @@ -146,7 +146,7 @@ public class QualityProfileDaoTest { int count = underTest.updateLastUsedDate(dbSession, initial, 15_000L); - assertThat(count).isEqualTo(1); + assertThat(count).isOne(); QProfileDto reloaded = underTest.selectByUuid(dbSession, initial.getKee()); assertThat(reloaded).isNotNull(); assertThat(reloaded.getLastUsed()).isEqualTo(15_000L); @@ -160,7 +160,7 @@ public class QualityProfileDaoTest { int count = underTest.updateLastUsedDate(dbSession, initial, 15_000L); - assertThat(count).isEqualTo(1); + assertThat(count).isOne(); QProfileDto reloaded = underTest.selectByUuid(dbSession, initial.getKee()); assertThat(reloaded).isNotNull(); assertThat(reloaded.getLastUsed()).isEqualTo(15_000L); @@ -206,7 +206,7 @@ public class QualityProfileDaoTest { underTest.deleteRulesProfilesByUuids(dbSession, emptyList()); - assertThat(db.countRowsOfTable(dbSession, "rules_profiles")).isEqualTo(1); + assertThat(db.countRowsOfTable(dbSession, "rules_profiles")).isOne(); } @Test @@ -215,7 +215,7 @@ public class QualityProfileDaoTest { underTest.deleteRulesProfilesByUuids(dbSession, singletonList("does_not_exist")); - assertThat(db.countRowsOfTable(dbSession, "rules_profiles")).isEqualTo(1); + assertThat(db.countRowsOfTable(dbSession, "rules_profiles")).isOne(); } private RulesProfileDto insertRulesProfile() { @@ -258,7 +258,7 @@ public class QualityProfileDaoTest { underTest.deleteProjectAssociationsByProfileUuids(dbSession, Collections.emptyList()); - assertThat(db.countRowsOfTable(dbSession, "project_qprofiles")).isEqualTo(1); + assertThat(db.countRowsOfTable(dbSession, "project_qprofiles")).isOne(); } @Test 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 0aa60519e8b..288a8c07d6f 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 @@ -97,7 +97,7 @@ public class RuleDaoTest { public void selectDefinitionByKey() { RuleDefinitionDto rule = db.rules().insert(); - assertThat(underTest.selectDefinitionByKey(db.getSession(), RuleKey.of("NOT", "FOUND")).isPresent()).isFalse(); + assertThat(underTest.selectDefinitionByKey(db.getSession(), RuleKey.of("NOT", "FOUND"))).isEmpty(); Optional<RuleDefinitionDto> reloaded = underTest.selectDefinitionByKey(db.getSession(), rule.getKey()); assertThat(reloaded).isPresent(); @@ -298,7 +298,7 @@ public class RuleDaoTest { ResultHandler<RuleDefinitionDto> resultHandler = resultContext -> rules.add(resultContext.getResultObject()); underTest.selectEnabled(db.getSession(), resultHandler); - assertThat(rules.size()).isEqualTo(1); + assertThat(rules.size()).isOne(); RuleDefinitionDto ruleDto = rules.get(0); assertThat(ruleDto.getUuid()).isEqualTo(rule.getUuid()); } @@ -610,7 +610,7 @@ public class RuleDaoTest { underTest.insertOrUpdate(db.getSession(), metadataV1); db.commit(); - assertThat(db.countRowsOfTable("RULES_METADATA")).isEqualTo(1); + assertThat(db.countRowsOfTable("RULES_METADATA")).isOne(); RuleDto ruleDto = underTest.selectOrFailByKey(db.getSession(), rule.getKey()); assertThat(ruleDto.getNoteData()).isNull(); assertThat(ruleDto.getNoteUserUuid()).isNull(); @@ -676,7 +676,7 @@ public class RuleDaoTest { List<RuleParamDto> ruleDtos = underTest.selectRuleParamsByRuleKey(db.getSession(), rule.getKey()); - assertThat(ruleDtos.size()).isEqualTo(1); + assertThat(ruleDtos.size()).isOne(); RuleParamDto ruleDto = ruleDtos.get(0); assertThat(ruleDto.getUuid()).isEqualTo(ruleParam.getUuid()); assertThat(ruleDto.getName()).isEqualTo(ruleParam.getName()); diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDefinitionDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDefinitionDtoTest.java index 1080e43b22e..cb27398ea37 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDefinitionDtoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/rule/RuleDefinitionDtoTest.java @@ -32,13 +32,14 @@ public class RuleDefinitionDtoTest { String uuid = Uuids.createFast(); RuleDefinitionDto dto = newRule().setUuid(uuid); - assertThat(dto).isEqualTo(dto); - assertThat(dto).isEqualTo(newRule().setUuid(uuid)); - assertThat(dto).isEqualTo(newRule().setRuleKey(dto.getRuleKey()).setUuid(uuid)); - assertThat(dto).isNotEqualTo(null); - assertThat(dto).isNotEqualTo(new Object()); - assertThat(dto).isNotEqualTo(newRule().setRuleKey(dto.getRuleKey()).setUuid(Uuids.createFast())); - assertThat(dto).isNotEqualTo(newRule().setUuid(Uuids.createFast())); + assertThat(dto) + .isEqualTo(dto) + .isEqualTo(newRule().setUuid(uuid)) + .isEqualTo(newRule().setRuleKey(dto.getRuleKey()).setUuid(uuid)) + .isNotNull() + .isNotEqualTo(new Object()) + .isNotEqualTo(newRule().setRuleKey(dto.getRuleKey()).setUuid(Uuids.createFast())) + .isNotEqualTo(newRule().setUuid(Uuids.createFast())); } @Test @@ -46,12 +47,13 @@ public class RuleDefinitionDtoTest { String uuid = Uuids.createFast(); RuleDefinitionDto dto = newRule().setUuid(uuid); - assertThat(dto.hashCode()).isEqualTo(dto.hashCode()); - assertThat(dto.hashCode()).isEqualTo(newRule().setUuid(uuid).hashCode()); - assertThat(dto.hashCode()).isEqualTo(newRule().setRuleKey(dto.getRuleKey()).setUuid(uuid).hashCode()); - assertThat(dto.hashCode()).isNotEqualTo(null); - assertThat(dto.hashCode()).isNotEqualTo(new Object().hashCode()); - assertThat(dto.hashCode()).isNotEqualTo(newRule().setRuleKey(dto.getRuleKey()).setUuid(Uuids.createFast()).hashCode()); - assertThat(dto.hashCode()).isNotEqualTo(newRule().setUuid(Uuids.createFast()).hashCode()); + assertThat(dto) + .hasSameHashCodeAs(dto) + .hasSameHashCodeAs(newRule().setUuid(uuid)) + .hasSameHashCodeAs(newRule().setRuleKey(dto.getRuleKey()).setUuid(uuid)); + assertThat(dto.hashCode()) + .isNotEqualTo(new Object().hashCode()) + .isNotEqualTo(newRule().setRuleKey(dto.getRuleKey()).setUuid(Uuids.createFast()).hashCode()) + .isNotEqualTo(newRule().setUuid(Uuids.createFast()).hashCode()); } } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/source/FileSourceDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/source/FileSourceDaoTest.java index ddd107ce125..b60ae0ecf58 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/source/FileSourceDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/source/FileSourceDaoTest.java @@ -304,7 +304,7 @@ public class FileSourceDaoTest { assertThat(fileSourceDto.getDataHash()).isEqualTo("NEW_DATA_HASH"); assertThat(fileSourceDto.getRawLineHashes()).isEqualTo("NEW_LINE_HASHES"); assertThat(fileSourceDto.getLineHashes()).isEqualTo(singletonList("NEW_LINE_HASHES")); - assertThat(fileSourceDto.getLineCount()).isEqualTo(1); + assertThat(fileSourceDto.getLineCount()).isOne(); assertThat(fileSourceDto.getSrcHash()).isEqualTo("NEW_FILE_HASH"); assertThat(fileSourceDto.getCreatedAt()).isEqualTo(expected.getCreatedAt()); assertThat(fileSourceDto.getUpdatedAt()).isEqualTo(1500000000002L); @@ -335,6 +335,6 @@ public class FileSourceDaoTest { FileSourceDto res = underTest.selectByFileUuid(dbSession, fileSourceDto.getFileUuid()); assertThat(res.getLineHashes()).isEmpty(); - assertThat(res.getLineCount()).isEqualTo(1); + assertThat(res.getLineCount()).isOne(); } } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/source/FileSourceDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/source/FileSourceDtoTest.java index ae89e31d7bc..6c0f8f8c1bb 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/source/FileSourceDtoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/source/FileSourceDtoTest.java @@ -100,7 +100,7 @@ public class FileSourceDtoTest { FileSourceDto underTest = new FileSourceDto(); underTest.setLineHashes(Collections.emptyList()); - assertThat(underTest.getLineCount()).isEqualTo(1); + assertThat(underTest.getLineCount()).isOne(); assertThat(underTest.getLineHashes()).isEmpty(); assertThat(underTest.getRawLineHashes()).isNull(); } diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/user/GroupDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/user/GroupDaoTest.java index a7602c17fa3..45301c533a7 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/user/GroupDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/user/GroupDaoTest.java @@ -189,7 +189,7 @@ public class GroupDaoTest { assertThat(result).hasSize(1); assertThat(result.get(0).getName()).isEqualTo(groupNameWithSpecialCharacters); - assertThat(resultCount).isEqualTo(1); + assertThat(resultCount).isOne(); } @Test diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/user/GroupMembershipDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/user/GroupMembershipDaoTest.java index d8c9c95b43a..f882c972241 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/user/GroupMembershipDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/user/GroupMembershipDaoTest.java @@ -69,7 +69,7 @@ public class GroupMembershipDaoTest { assertThat(underTest.countGroups(db.getSession(), builder().membership(IN).build(), user1.getUuid())).isEqualTo(3); assertThat(underTest.countGroups(db.getSession(), builder().membership(OUT).build(), user1.getUuid())).isZero(); // user2 is member of 1 group on 3 - assertThat(underTest.countGroups(db.getSession(), builder().membership(IN).build(), user2.getUuid())).isEqualTo(1); + assertThat(underTest.countGroups(db.getSession(), builder().membership(IN).build(), user2.getUuid())).isOne(); assertThat(underTest.countGroups(db.getSession(), builder().membership(OUT).build(), user2.getUuid())).isEqualTo(2); // user3 is member of 0 group assertThat(underTest.countGroups(db.getSession(), builder().membership(IN).build(), user3.getUuid())).isZero(); @@ -137,14 +137,14 @@ public class GroupMembershipDaoTest { db.users().insertMember(group2, user2); // 100 has 1 member and 1 non member - assertThat(underTest.countMembers(db.getSession(), newQuery().groupUuid(group1.getUuid()).membership(UserMembershipQuery.IN).build())).isEqualTo(1); - assertThat(underTest.countMembers(db.getSession(), newQuery().groupUuid(group1.getUuid()).membership(UserMembershipQuery.OUT).build())).isEqualTo(1); + assertThat(underTest.countMembers(db.getSession(), newQuery().groupUuid(group1.getUuid()).membership(UserMembershipQuery.IN).build())).isOne(); + assertThat(underTest.countMembers(db.getSession(), newQuery().groupUuid(group1.getUuid()).membership(UserMembershipQuery.OUT).build())).isOne(); // 101 has 2 members assertThat(underTest.countMembers(db.getSession(), newQuery().groupUuid(group2.getUuid()).membership(UserMembershipQuery.IN).build())).isEqualTo(2); assertThat(underTest.countMembers(db.getSession(), newQuery().groupUuid(group2.getUuid()).membership(UserMembershipQuery.OUT).build())).isZero(); // 102 has 1 member and 1 non member - assertThat(underTest.countMembers(db.getSession(), newQuery().groupUuid(group3.getUuid()).membership(UserMembershipQuery.IN).build())).isEqualTo(1); - assertThat(underTest.countMembers(db.getSession(), newQuery().groupUuid(group3.getUuid()).membership(UserMembershipQuery.OUT).build())).isEqualTo(1); + assertThat(underTest.countMembers(db.getSession(), newQuery().groupUuid(group3.getUuid()).membership(UserMembershipQuery.IN).build())).isOne(); + assertThat(underTest.countMembers(db.getSession(), newQuery().groupUuid(group3.getUuid()).membership(UserMembershipQuery.OUT).build())).isOne(); // 103 has no member assertThat(underTest.countMembers(db.getSession(), newQuery().groupUuid(emptyGroup.getUuid()).membership(UserMembershipQuery.IN).build())).isZero(); assertThat(underTest.countMembers(db.getSession(), newQuery().groupUuid(emptyGroup.getUuid()).membership(UserMembershipQuery.OUT).build())).isEqualTo(2); diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDaoTest.java index d727f9a3973..f4733395994 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/user/UserDaoTest.java @@ -684,8 +684,8 @@ public class UserDaoTest { public void setRoot_set_root_flag_of_specified_user_to_specified_value_and_updates_udpateAt() { String login = insertActiveUser().getLogin(); UserDto otherUser = insertActiveUser(); - assertThat(underTest.selectByLogin(session, login).isRoot()).isEqualTo(false); - assertThat(underTest.selectByLogin(session, otherUser.getLogin()).isRoot()).isEqualTo(false); + assertThat(underTest.selectByLogin(session, login).isRoot()).isFalse(); + assertThat(underTest.selectByLogin(session, otherUser.getLogin()).isRoot()).isFalse(); // does not fail when changing to same value system2.setNow(15_000L); diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDeliveryDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDeliveryDaoTest.java index fb2b70c8a7b..9daad8073c6 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDeliveryDaoTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/webhook/WebhookDeliveryDaoTest.java @@ -202,7 +202,7 @@ public class WebhookDeliveryDaoTest { underTest.deleteByWebhook(dbSession, webhookDto); - assertThat(dbTester.countRowsOfTable(dbSession, "webhook_deliveries")).isEqualTo(1); + assertThat(dbTester.countRowsOfTable(dbSession, "webhook_deliveries")).isOne(); } @Test @@ -231,7 +231,7 @@ public class WebhookDeliveryDaoTest { underTest.deleteComponentBeforeDate(dbSession, "COMPONENT_2", 1_500_000L); - assertThat(dbTester.countRowsOfTable(dbSession, "webhook_deliveries")).isEqualTo(1); + assertThat(dbTester.countRowsOfTable(dbSession, "webhook_deliveries")).isOne(); } private void verifyMandatoryFields(WebhookDeliveryDto expected, WebhookDeliveryDto actual) { diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/TestDbImpl.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/TestDbImpl.java index da1e98bf22d..42c1aaab549 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/TestDbImpl.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/TestDbImpl.java @@ -21,7 +21,6 @@ package org.sonar.db; import java.util.Arrays; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.BiConsumer; @@ -57,9 +56,7 @@ class TestDbImpl extends CoreTestDb { } private void init(@Nullable String schemaPath, MyBatisConfExtension[] confExtensions) { - Consumer<Settings> loadOrchestratorSettings = settings -> { - OrchestratorSettingsUtils.loadOrchestratorSettings(settings); - }; + Consumer<Settings> loadOrchestratorSettings = OrchestratorSettingsUtils::loadOrchestratorSettings; Function<Settings, Database> databaseCreator = settings -> { String dialect = settings.getString("sonar.jdbc.dialect"); if (dialect != null && !"h2".equals(dialect)) { diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/ce/CeQueueTesting.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/ce/CeQueueTesting.java index f306496d419..1ced696c144 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/ce/CeQueueTesting.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/ce/CeQueueTesting.java @@ -52,7 +52,7 @@ public class CeQueueTesting { int touchedRows = mapper.updateIf(ceQueueDto.getUuid(), new UpdateIf.NewProperties(IN_PROGRESS, workerUuid, now, now), new UpdateIf.OldProperties(PENDING)); - assertThat(touchedRows).isEqualTo(1); + assertThat(touchedRows).isOne(); }); } @@ -65,7 +65,7 @@ public class CeQueueTesting { int touchedRows = mapper.updateIf(ceQueueDto.getUuid(), new UpdateIf.NewProperties(PENDING, ceQueueDto.getUuid(), now, now), new UpdateIf.OldProperties(IN_PROGRESS)); - assertThat(touchedRows).isEqualTo(1); + assertThat(touchedRows).isOne(); }); } } diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java index 85c552ab5b6..8c405f25c88 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/rule/RuleTesting.java @@ -165,7 +165,8 @@ public class RuleTesting { */ @Deprecated public static RuleDto newDto(RuleKey ruleKey) { - RuleDto res = new RuleDto() + + return new RuleDto() .setUuid("uuid_" + Uuids.createFast()) .setRuleKey(ruleKey.rule()) .setRepositoryKey(ruleKey.repository()) @@ -189,8 +190,6 @@ public class RuleTesting { .setTags(ImmutableSet.of("tag1", "tag2")) .setRemediationFunction("LINEAR") .setRemediationGapMultiplier("1h"); - - return res; } /** diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/user/UserTesting.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/user/UserTesting.java index c1ca8bcef15..93db0abe0fd 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/user/UserTesting.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/user/UserTesting.java @@ -25,7 +25,6 @@ import org.sonar.core.util.Uuids; import static java.util.Collections.singletonList; import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric; import static org.apache.commons.lang.math.RandomUtils.nextBoolean; -import static org.apache.commons.lang.math.RandomUtils.nextInt; import static org.apache.commons.lang.math.RandomUtils.nextLong; public class UserTesting { |