summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacek <jacek.poreda@sonarsource.com>2020-12-04 11:34:36 +0100
committersonartech <sonartech@sonarsource.com>2020-12-09 20:07:21 +0000
commit720c19e83f2299a848c18c6921a3c22281b87eb6 (patch)
treefdbdc8b99a62296fbb7eec5812ed336e70ea9e3d
parent5380a8080eb0d52981739fc3fe5459c66b204f11 (diff)
downloadsonarqube-720c19e83f2299a848c18c6921a3c22281b87eb6.tar.gz
sonarqube-720c19e83f2299a848c18c6921a3c22281b87eb6.zip
Code smells test fixes
-rw-r--r--server/sonar-auth-github/src/test/java/org/sonar/auth/github/GitHubSettingsTest.java2
-rw-r--r--server/sonar-db-dao/src/main/java/org/sonar/db/newcodeperiod/NewCodePeriodDto.java5
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDtoTest.java9
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/component/ComponentDaoTest.java9
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/newcodeperiod/NewCodePeriodDaoTest.java90
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/PermissionTemplateCharacteristicDaoTest.java38
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/property/PropertyDtoTest.java11
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/qualityprofile/QualityProfileDaoTest.java29
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingMeasuresTest.java10
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatusTest.java22
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpotsTest.java22
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/PopulateSummaryCommentEnabledColumnForGitHubTest.java6
-rw-r--r--server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/RemoveFilesFavouritesFromPropertiesTest.java4
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/es/response/NodeStatsResponseTest.java4
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/es/searchrequest/AllFiltersTest.java6
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/es/searchrequest/NestedFieldFilterScopeTest.java3
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/es/searchrequest/RequestFiltersComputerTest.java30
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/es/searchrequest/SimpleFieldFilterScopeTest.java4
-rw-r--r--server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/IssuesChangesNotificationBuilderTest.java59
-rw-r--r--server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSyncProgressCheckerTest.java14
-rw-r--r--server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/hotspot/ws/AssignActionTest.java31
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AddCommentActionTest.java7
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java11
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/ChangelogActionTest.java5
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/DeleteCommentActionTest.java8
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/DoTransitionActionTest.java7
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/EditCommentActionTest.java3
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java12
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetSeverityActionTest.java7
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetTypeActionTest.java14
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/custom/ws/CreateActionTest.java42
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/custom/ws/DeleteActionTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/custom/ws/UpdateActionTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/metric/ws/DeleteActionTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/metric/ws/SearchActionTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/metric/ws/UpdateActionTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/GroupsActionTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/AddGroupToTemplateActionTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateActionTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/projecttag/ws/SetActionTest.java23
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryImplTest.java24
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/UpdateActionTest.java4
45 files changed, 320 insertions, 297 deletions
diff --git a/server/sonar-auth-github/src/test/java/org/sonar/auth/github/GitHubSettingsTest.java b/server/sonar-auth-github/src/test/java/org/sonar/auth/github/GitHubSettingsTest.java
index f15933e922a..729ff7dae90 100644
--- a/server/sonar-auth-github/src/test/java/org/sonar/auth/github/GitHubSettingsTest.java
+++ b/server/sonar-auth-github/src/test/java/org/sonar/auth/github/GitHubSettingsTest.java
@@ -139,7 +139,7 @@ public class GitHubSettingsTest {
String[] setting = null;
settings.setProperty("sonar.auth.github.organizations", setting);
String[] actual = underTest.organizations();
- assertThat(actual).hasSize(0);
+ assertThat(actual).isEmpty();
}
@Test
diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/newcodeperiod/NewCodePeriodDto.java b/server/sonar-db-dao/src/main/java/org/sonar/db/newcodeperiod/NewCodePeriodDto.java
index db857d0d296..442c02ac1ad 100644
--- a/server/sonar-db-dao/src/main/java/org/sonar/db/newcodeperiod/NewCodePeriodDto.java
+++ b/server/sonar-db-dao/src/main/java/org/sonar/db/newcodeperiod/NewCodePeriodDto.java
@@ -20,6 +20,7 @@
package org.sonar.db.newcodeperiod;
import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
public class NewCodePeriodDto {
private String uuid = null;
@@ -66,7 +67,7 @@ public class NewCodePeriodDto {
return projectUuid;
}
- public NewCodePeriodDto setProjectUuid(String projectUuid) {
+ public NewCodePeriodDto setProjectUuid(@Nullable String projectUuid) {
this.projectUuid = projectUuid;
return this;
}
@@ -76,7 +77,7 @@ public class NewCodePeriodDto {
return branchUuid;
}
- public NewCodePeriodDto setBranchUuid(String branchUuid) {
+ public NewCodePeriodDto setBranchUuid(@Nullable String branchUuid) {
this.branchUuid = branchUuid;
return this;
}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDtoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDtoTest.java
index feda89a2963..efecdaa068f 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDtoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/component/BranchDtoTest.java
@@ -19,19 +19,14 @@
*/
package org.sonar.db.component;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.sonar.db.protobuf.DbProjectBranches;
import static org.assertj.core.api.Assertions.assertThat;
public class BranchDtoTest {
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- private BranchDto underTest = new BranchDto();
+ private final BranchDto underTest = new BranchDto();
@Test
public void isMain_is_true_if_branch_uuid_equals_project_uuid() {
@@ -58,7 +53,7 @@ public class BranchDtoTest {
underTest.setMergeBranchUuid("U3");
underTest.setExcludeFromPurge(true);
- assertThat(underTest.toString()).isEqualTo("BranchDto{uuid='U1', " +
+ assertThat(underTest).hasToString("BranchDto{uuid='U1', " +
"projectUuid='U2', kee='K1', branchType=BRANCH, mergeBranchUuid='U3', excludeFromPurge=true, needIssueSync=false}");
}
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 a3d473b0c05..7f1c2e7b403 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
@@ -390,7 +390,8 @@ public class ComponentDaoTest {
@Test
public void fail_with_IAE_select_component_keys_by_qualifiers_on_empty_qualifier() {
- assertThatThrownBy(() -> underTest.selectComponentsByQualifiers(dbSession, Collections.emptySet()))
+ Set<String> set = emptySet();
+ assertThatThrownBy(() -> underTest.selectComponentsByQualifiers(dbSession, set))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Qualifiers cannot be empty");
}
@@ -1190,7 +1191,8 @@ public class ComponentDaoTest {
}
private void assertThatCountByQueryThrowsIAE(ComponentQuery.Builder query, String expectedMessage) {
- assertThatThrownBy(() -> underTest.countByQuery(dbSession, query.build()))
+ ComponentQuery componentQuery = query.build();
+ assertThatThrownBy(() -> underTest.countByQuery(dbSession, componentQuery))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage(expectedMessage);
}
@@ -1392,7 +1394,8 @@ public class ComponentDaoTest {
}
private void assertThatSelectByQueryThrowsIAE(ComponentQuery.Builder query, String expectedMessage) {
- assertThatThrownBy(() -> underTest.selectByQuery(dbSession, query.build(), 0, Integer.MAX_VALUE))
+ ComponentQuery componentQuery = query.build();
+ assertThatThrownBy(() -> underTest.selectByQuery(dbSession, componentQuery, 0, Integer.MAX_VALUE))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage(expectedMessage);
}
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/newcodeperiod/NewCodePeriodDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/newcodeperiod/NewCodePeriodDaoTest.java
index 25f2deddfcd..edb9c031822 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/newcodeperiod/NewCodePeriodDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/newcodeperiod/NewCodePeriodDaoTest.java
@@ -22,13 +22,13 @@ package org.sonar.db.newcodeperiod;
import java.util.Optional;
import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
import org.sonar.core.util.UuidFactory;
import org.sonar.db.DbSession;
import org.sonar.db.DbTester;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -37,12 +37,9 @@ public class NewCodePeriodDaoTest {
@Rule
public DbTester db = DbTester.create(System2.INSTANCE);
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- private DbSession dbSession = db.getSession();
- private UuidFactory uuidFactory = mock(UuidFactory.class);
- private NewCodePeriodDao underTest = new NewCodePeriodDao(System2.INSTANCE, uuidFactory);
+ private final DbSession dbSession = db.getSession();
+ private final UuidFactory uuidFactory = mock(UuidFactory.class);
+ private final NewCodePeriodDao underTest = new NewCodePeriodDao(System2.INSTANCE, uuidFactory);
private static final String NEW_CODE_PERIOD_UUID = "ncp-uuid-1";
@@ -57,8 +54,8 @@ public class NewCodePeriodDaoTest {
Optional<NewCodePeriodDto> resultOpt = underTest.selectByUuid(dbSession, NEW_CODE_PERIOD_UUID);
- assertThat(resultOpt).isNotNull();
- assertThat(resultOpt).isNotEmpty();
+ assertThat(resultOpt).isNotNull()
+ .isNotEmpty();
NewCodePeriodDto result = resultOpt.get();
assertThat(result.getUuid()).isEqualTo(NEW_CODE_PERIOD_UUID);
@@ -66,8 +63,8 @@ public class NewCodePeriodDaoTest {
assertThat(result.getBranchUuid()).isEqualTo("branch-uuid");
assertThat(result.getType()).isEqualTo(NewCodePeriodType.NUMBER_OF_DAYS);
assertThat(result.getValue()).isEqualTo("5");
- assertThat(result.getCreatedAt()).isNotEqualTo(0);
- assertThat(result.getUpdatedAt()).isNotEqualTo(0);
+ assertThat(result.getCreatedAt()).isNotZero();
+ assertThat(result.getUpdatedAt()).isNotZero();
db.commit();
assertNewCodePeriodRowCount(1);
@@ -97,8 +94,8 @@ public class NewCodePeriodDaoTest {
Optional<NewCodePeriodDto> resultOpt = underTest.selectByUuid(dbSession, NEW_CODE_PERIOD_UUID);
- assertThat(resultOpt).isNotNull();
- assertThat(resultOpt).isNotEmpty();
+ assertThat(resultOpt).isNotNull()
+ .isNotEmpty();
NewCodePeriodDto result = resultOpt.get();
assertThat(result.getUuid()).isEqualTo(NEW_CODE_PERIOD_UUID);
@@ -106,8 +103,8 @@ public class NewCodePeriodDaoTest {
assertThat(result.getBranchUuid()).isEqualTo("branch-uuid");
assertThat(result.getType()).isEqualTo(NewCodePeriodType.SPECIFIC_ANALYSIS);
assertThat(result.getValue()).isEqualTo("analysis-uuid");
- assertThat(result.getCreatedAt()).isNotEqualTo(0);
- assertThat(result.getUpdatedAt()).isNotEqualTo(0);
+ assertThat(result.getCreatedAt()).isNotZero();
+ assertThat(result.getUpdatedAt()).isNotZero();
db.commit();
assertNewCodePeriodRowCount(1);
@@ -126,8 +123,9 @@ public class NewCodePeriodDaoTest {
Optional<NewCodePeriodDto> resultOpt = underTest.selectByUuid(dbSession, NEW_CODE_PERIOD_UUID);
- assertThat(resultOpt).isNotNull();
- assertThat(resultOpt).isNotEmpty();
+ assertThat(resultOpt)
+ .isNotNull()
+ .isNotEmpty();
NewCodePeriodDto result = resultOpt.get();
assertThat(result.getUuid()).isEqualTo(NEW_CODE_PERIOD_UUID);
@@ -135,8 +133,8 @@ public class NewCodePeriodDaoTest {
assertThat(result.getBranchUuid()).isEqualTo("branch-uuid");
assertThat(result.getType()).isEqualTo(NewCodePeriodType.NUMBER_OF_DAYS);
assertThat(result.getValue()).isEqualTo("5");
- assertThat(result.getCreatedAt()).isNotEqualTo(0);
- assertThat(result.getUpdatedAt()).isNotEqualTo(0);
+ assertThat(result.getCreatedAt()).isNotZero();
+ assertThat(result.getUpdatedAt()).isNotZero();
db.commit();
assertNewCodePeriodRowCount(1);
@@ -161,8 +159,9 @@ public class NewCodePeriodDaoTest {
Optional<NewCodePeriodDto> resultOpt = underTest.selectByUuid(dbSession, NEW_CODE_PERIOD_UUID);
- assertThat(resultOpt).isNotNull();
- assertThat(resultOpt).isNotEmpty();
+ assertThat(resultOpt)
+ .isNotNull()
+ .isNotEmpty();
NewCodePeriodDto result = resultOpt.get();
assertThat(result.getUuid()).isEqualTo(NEW_CODE_PERIOD_UUID);
@@ -170,8 +169,8 @@ public class NewCodePeriodDaoTest {
assertThat(result.getBranchUuid()).isEqualTo("branch-uuid");
assertThat(result.getType()).isEqualTo(NewCodePeriodType.SPECIFIC_ANALYSIS);
assertThat(result.getValue()).isEqualTo("analysis-uuid");
- assertThat(result.getCreatedAt()).isNotEqualTo(0);
- assertThat(result.getUpdatedAt()).isNotEqualTo(0);
+ assertThat(result.getCreatedAt()).isNotZero();
+ assertThat(result.getUpdatedAt()).isNotZero();
db.commit();
assertNewCodePeriodRowCount(1);
@@ -188,8 +187,9 @@ public class NewCodePeriodDaoTest {
.setValue("5"));
Optional<NewCodePeriodDto> resultOpt = underTest.selectByBranch(dbSession, "proj-uuid", "branch-uuid");
- assertThat(resultOpt).isNotNull();
- assertThat(resultOpt).isNotEmpty();
+ assertThat(resultOpt)
+ .isNotNull()
+ .isNotEmpty();
NewCodePeriodDto result = resultOpt.get();
assertThat(result.getUuid()).isEqualTo(NEW_CODE_PERIOD_UUID);
@@ -197,8 +197,8 @@ public class NewCodePeriodDaoTest {
assertThat(result.getBranchUuid()).isEqualTo("branch-uuid");
assertThat(result.getType()).isEqualTo(NewCodePeriodType.NUMBER_OF_DAYS);
assertThat(result.getValue()).isEqualTo("5");
- assertThat(result.getCreatedAt()).isNotEqualTo(0);
- assertThat(result.getUpdatedAt()).isNotEqualTo(0);
+ assertThat(result.getCreatedAt()).isNotZero();
+ assertThat(result.getUpdatedAt()).isNotZero();
}
@Test
@@ -212,8 +212,9 @@ public class NewCodePeriodDaoTest {
.setValue("5"));
Optional<NewCodePeriodDto> resultOpt = underTest.selectByProject(dbSession, "proj-uuid");
- assertThat(resultOpt).isNotNull();
- assertThat(resultOpt).isNotEmpty();
+ assertThat(resultOpt)
+ .isNotNull()
+ .isNotEmpty();
NewCodePeriodDto result = resultOpt.get();
assertThat(result.getUuid()).isEqualTo(NEW_CODE_PERIOD_UUID);
@@ -221,8 +222,8 @@ public class NewCodePeriodDaoTest {
assertThat(result.getBranchUuid()).isNull();
assertThat(result.getType()).isEqualTo(NewCodePeriodType.NUMBER_OF_DAYS);
assertThat(result.getValue()).isEqualTo("5");
- assertThat(result.getCreatedAt()).isNotEqualTo(0);
- assertThat(result.getUpdatedAt()).isNotEqualTo(0);
+ assertThat(result.getCreatedAt()).isNotZero();
+ assertThat(result.getUpdatedAt()).isNotZero();
}
@Test
@@ -235,14 +236,17 @@ public class NewCodePeriodDaoTest {
.setType(NewCodePeriodType.NUMBER_OF_DAYS)
.setValue("30"));
- NewCodePeriodDto result = underTest.selectGlobal(dbSession).get();
+ Optional<NewCodePeriodDto> newCodePeriodDto = underTest.selectGlobal(dbSession);
+ assertThat(newCodePeriodDto).isNotEmpty();
+
+ NewCodePeriodDto result = newCodePeriodDto.get();
assertThat(result.getUuid()).isEqualTo(NEW_CODE_PERIOD_UUID);
assertThat(result.getProjectUuid()).isNull();
assertThat(result.getBranchUuid()).isNull();
assertThat(result.getType()).isEqualTo(NewCodePeriodType.NUMBER_OF_DAYS);
assertThat(result.getValue()).isEqualTo("30");
- assertThat(result.getCreatedAt()).isNotEqualTo(0);
- assertThat(result.getUpdatedAt()).isNotEqualTo(0);
+ assertThat(result.getCreatedAt()).isNotZero();
+ assertThat(result.getUpdatedAt()).isNotZero();
}
@Test
@@ -309,23 +313,23 @@ public class NewCodePeriodDaoTest {
@Test
public void fail_select_by_project_and_branch_uuids_if_project_uuid_not_provided() {
- expectedException.expect(NullPointerException.class);
- expectedException.expectMessage("Project uuid must be specified.");
- underTest.selectByBranch(dbSession, null, "random-uuid");
+ assertThatThrownBy(() -> underTest.selectByBranch(dbSession, null, "random-uuid"))
+ .isInstanceOf(NullPointerException.class)
+ .hasMessage("Project uuid must be specified.");
}
@Test
public void fail_select_by_project_and_branch_uuids_if_branch_uuid_not_provided() {
- expectedException.expect(NullPointerException.class);
- expectedException.expectMessage("Branch uuid must be specified.");
- underTest.selectByBranch(dbSession, "random-uuid", null);
+ assertThatThrownBy(() -> underTest.selectByBranch(dbSession, "random-uuid", null))
+ .isInstanceOf(NullPointerException.class)
+ .hasMessage("Branch uuid must be specified.");
}
@Test
public void fail_select_by_project_uuid_if_project_uuid_not_provided() {
- expectedException.expect(NullPointerException.class);
- expectedException.expectMessage("Project uuid must be specified.");
- underTest.selectByProject(dbSession, null);
+ assertThatThrownBy(() -> underTest.selectByProject(dbSession, null))
+ .isInstanceOf(NullPointerException.class)
+ .hasMessage("Project uuid must be specified.");
}
private void assertNewCodePeriodRowCount(int expected) {
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/PermissionTemplateCharacteristicDaoTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/PermissionTemplateCharacteristicDaoTest.java
index 891d84d5686..ae7661d6b8b 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/PermissionTemplateCharacteristicDaoTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/permission/template/PermissionTemplateCharacteristicDaoTest.java
@@ -23,7 +23,6 @@ import java.util.List;
import java.util.Optional;
import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
import org.sonar.api.web.UserRole;
import org.sonar.db.DbSession;
@@ -32,15 +31,15 @@ import org.sonar.db.DbTester;
import static com.google.common.collect.Lists.newArrayList;
import static java.util.Arrays.asList;
import static java.util.Collections.emptyList;
+import static java.util.Collections.singletonList;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
public class PermissionTemplateCharacteristicDaoTest {
@Rule
- public ExpectedException expectedException = ExpectedException.none();
- @Rule
public DbTester db = DbTester.create(System2.INSTANCE);
- private DbSession dbSession = db.getSession();
- private PermissionTemplateCharacteristicDao underTest = new PermissionTemplateCharacteristicDao();
+ private final DbSession dbSession = db.getSession();
+ private final PermissionTemplateCharacteristicDao underTest = new PermissionTemplateCharacteristicDao();
@Test
public void selectByTemplateId_filter_by_template_uuid() {
@@ -162,38 +161,39 @@ public class PermissionTemplateCharacteristicDaoTest {
@Test
public void fail_insert_if_created_at_is_equal_to_0() {
- expectedException.expect(IllegalArgumentException.class);
-
- underTest.insert(dbSession, new PermissionTemplateCharacteristicDto()
+ PermissionTemplateCharacteristicDto characteristicDto = new PermissionTemplateCharacteristicDto()
.setUuid("uuid")
.setPermission(UserRole.USER)
.setTemplateUuid("1")
.setWithProjectCreator(true)
- .setUpdatedAt(2_000_000_000L));
+ .setUpdatedAt(2_000_000_000L);
+ assertThatThrownBy(() -> underTest.insert(dbSession, characteristicDto))
+ .isInstanceOf(IllegalArgumentException.class);
}
@Test
public void fail_insert_if_updated_at_is_equal_to_0() {
- expectedException.expect(IllegalArgumentException.class);
-
- underTest.insert(dbSession, new PermissionTemplateCharacteristicDto()
+ PermissionTemplateCharacteristicDto characteristicDto = new PermissionTemplateCharacteristicDto()
.setUuid("uuid")
.setPermission(UserRole.USER)
.setTemplateUuid("1")
.setWithProjectCreator(true)
- .setCreatedAt(2_000_000_000L));
+ .setCreatedAt(2_000_000_000L);
+ assertThatThrownBy(() -> underTest.insert(dbSession, characteristicDto))
+ .isInstanceOf(IllegalArgumentException.class);
+
}
@Test
public void fail_update_if_uuid_is_null() {
- expectedException.expect(NullPointerException.class);
-
- underTest.update(dbSession, new PermissionTemplateCharacteristicDto()
+ PermissionTemplateCharacteristicDto characteristicDto = new PermissionTemplateCharacteristicDto()
.setPermission(UserRole.USER)
.setTemplateUuid("1")
.setWithProjectCreator(true)
.setCreatedAt(123_456_789L)
- .setUpdatedAt(2_000_000_000L));
+ .setUpdatedAt(2_000_000_000L);
+ assertThatThrownBy(() -> underTest.update(dbSession, characteristicDto))
+ .isInstanceOf(NullPointerException.class);
}
@Test
@@ -213,12 +213,12 @@ public class PermissionTemplateCharacteristicDaoTest {
.setCreatedAt(123_456_789L)
.setUpdatedAt(2_000_000_000L));
- assertThat(underTest.selectByTemplateUuids(dbSession, asList("1"))).hasSize(1);
+ assertThat(underTest.selectByTemplateUuids(dbSession, singletonList("1"))).hasSize(1);
assertThat(underTest.selectByTemplateUuids(dbSession, asList("1", "2"))).hasSize(2);
dbSession.getMapper(PermissionTemplateCharacteristicMapper.class).deleteByTemplateUuid("1");
- assertThat(underTest.selectByTemplateUuids(dbSession, asList("1"))).hasSize(0);
+ assertThat(underTest.selectByTemplateUuids(dbSession, singletonList("1"))).isEmpty();
assertThat(underTest.selectByTemplateUuids(dbSession, asList("1", "2"))).hasSize(1);
}
}
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 28698489024..f9f9d58654e 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
@@ -20,15 +20,12 @@
package org.sonar.db.property;
import com.google.common.base.Strings;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
public class PropertyDtoTest {
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
PropertyDto underTest = new PropertyDto();
@@ -55,9 +52,9 @@ public class PropertyDtoTest {
@Test
public void fail_if_key_longer_than_512_characters() {
String veryLongKey = Strings.repeat("a", 513);
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("Setting key length (513) is longer than the maximum authorized (512). '" + veryLongKey + "' was provided");
- underTest.setKey(veryLongKey);
+ assertThatThrownBy(() -> underTest.setKey(veryLongKey))
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessage("Setting key length (513) is longer than the maximum authorized (512). '" + veryLongKey + "' was provided");
}
}
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 ce85e85643c..02b718c992a 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
@@ -56,13 +56,12 @@ import static org.sonar.db.qualityprofile.QualityProfileTesting.newQualityProfil
public class QualityProfileDaoTest {
- private System2 system = mock(System2.class);
-
+ private final System2 system = mock(System2.class);
@Rule
public DbTester db = DbTester.create(system);
- private DbSession dbSession = db.getSession();
- private QualityProfileDao underTest = db.getDbClient().qualityProfileDao();
+ private final DbSession dbSession = db.getSession();
+ private final QualityProfileDao underTest = db.getDbClient().qualityProfileDao();
@Before
public void before() {
@@ -90,6 +89,7 @@ public class QualityProfileDaoTest {
underTest.insert(dbSession, dto);
QProfileDto reloaded = underTest.selectByUuid(dbSession, dto.getKee());
+ assertThat(reloaded).isNotNull();
assertThat(reloaded.getKee()).isEqualTo(dto.getKee());
assertThat(reloaded.getRulesProfileUuid()).isEqualTo(dto.getRulesProfileUuid());
assertThat(reloaded.getLanguage()).isEqualTo(dto.getLanguage());
@@ -127,6 +127,7 @@ public class QualityProfileDaoTest {
underTest.update(dbSession, update);
QProfileDto reloaded = underTest.selectByUuid(dbSession, initial.getKee());
+ assertThat(reloaded).isNotNull();
assertThat(reloaded.getKee()).isEqualTo(initial.getKee());
// updated fields
@@ -148,6 +149,7 @@ public class QualityProfileDaoTest {
assertThat(count).isEqualTo(1);
QProfileDto reloaded = underTest.selectByUuid(dbSession, initial.getKee());
+ assertThat(reloaded).isNotNull();
assertThat(reloaded.getLastUsed()).isEqualTo(15_000L);
}
@@ -161,6 +163,7 @@ public class QualityProfileDaoTest {
assertThat(count).isEqualTo(1);
QProfileDto reloaded = underTest.selectByUuid(dbSession, initial.getKee());
+ assertThat(reloaded).isNotNull();
assertThat(reloaded.getLastUsed()).isEqualTo(15_000L);
}
@@ -174,6 +177,7 @@ public class QualityProfileDaoTest {
assertThat(count).isZero();
QProfileDto reloaded = underTest.selectByUuid(dbSession, initial.getKee());
+ assertThat(reloaded).isNotNull();
assertThat(reloaded.getLastUsed()).isEqualTo(10_000L);
}
@@ -190,11 +194,11 @@ public class QualityProfileDaoTest {
RulesProfileDto rp1 = insertRulesProfile();
RulesProfileDto rp2 = insertRulesProfile();
- underTest.deleteRulesProfilesByUuids(dbSession, asList(rp1.getUuid()));
+ underTest.deleteRulesProfilesByUuids(dbSession, singletonList(rp1.getUuid()));
List<Map<String, Object>> uuids = db.select(dbSession, "select uuid as \"uuid\" from rules_profiles");
assertThat(uuids).hasSize(1);
- assertThat(uuids.get(0).get("uuid")).isEqualTo(rp2.getUuid());
+ assertThat(uuids.get(0)).containsEntry("uuid", rp2.getUuid());
}
@Test
@@ -210,7 +214,7 @@ public class QualityProfileDaoTest {
public void deleteRulesProfilesByUuids_does_nothing_if_specified_uuid_does_not_exist() {
insertRulesProfile();
- underTest.deleteRulesProfilesByUuids(dbSession, asList("does_not_exist"));
+ underTest.deleteRulesProfilesByUuids(dbSession, singletonList("does_not_exist"));
assertThat(db.countRowsOfTable(dbSession, "rules_profiles")).isEqualTo(1);
}
@@ -243,8 +247,8 @@ public class QualityProfileDaoTest {
List<Map<String, Object>> rows = db.select(dbSession, "select project_uuid as \"projectUuid\", profile_key as \"profileKey\" from project_qprofiles");
assertThat(rows).hasSize(1);
- assertThat(rows.get(0).get("projectUuid")).isEqualTo(project3.getUuid());
- assertThat(rows.get(0).get("profileKey")).isEqualTo(profile2.getKee());
+ assertThat(rows.get(0)).containsEntry("projectUuid", project3.getUuid());
+ assertThat(rows.get(0)).containsEntry("profileKey", profile2.getKee());
}
@Test
@@ -356,6 +360,7 @@ public class QualityProfileDaoTest {
List<QProfileDto> sharedData = createSharedData();
QProfileDto dto = underTest.selectByNameAndLanguage(dbSession, "Sonar Way", "java");
+ assertThat(dto).isNotNull();
assertThat(dto.getName()).isEqualTo("Sonar Way");
assertThat(dto.getLanguage()).isEqualTo("java");
assertThat(dto.getParentKee()).isNull();
@@ -591,14 +596,14 @@ public class QualityProfileDaoTest {
// descendants of a single base profile
verifyDescendants(singleton(base1), asList(child1OfBase1, child2OfBase1, grandChildOfBase1));
- verifyDescendants(singleton(child1OfBase1), asList(grandChildOfBase1));
+ verifyDescendants(singleton(child1OfBase1), singletonList(grandChildOfBase1));
verifyDescendants(singleton(child2OfBase1), emptyList());
verifyDescendants(singleton(grandChildOfBase1), emptyList());
// descendants of a multiple base profiles
verifyDescendants(asList(base1, base2), asList(child1OfBase1, child2OfBase1, grandChildOfBase1, childOfBase2, grandChildOfBase2));
verifyDescendants(asList(base1, childOfBase2), asList(child1OfBase1, child2OfBase1, grandChildOfBase1, grandChildOfBase2));
- verifyDescendants(asList(child1OfBase1, grandChildOfBase2), asList(grandChildOfBase1));
+ verifyDescendants(asList(child1OfBase1, grandChildOfBase2), singletonList(grandChildOfBase1));
verifyDescendants(asList(other, base2), asList(childOfBase2, grandChildOfBase2));
}
@@ -795,7 +800,7 @@ public class QualityProfileDaoTest {
QProfileDto fooInOrg1 = db.qualityProfiles().insert(p -> p.setName("foo"));
QProfileDto bar = db.qualityProfiles().insert(p -> p.setName("bar"));
- underTest.renameRulesProfilesAndCommit(dbSession, asList(fooInOrg1.getRulesProfileUuid()), "foo (copy)");
+ underTest.renameRulesProfilesAndCommit(dbSession, singletonList(fooInOrg1.getRulesProfileUuid()), "foo (copy)");
assertThat(underTest.selectOrFailByUuid(dbSession, fooInOrg1.getKee()).getName()).isEqualTo("foo (copy)");
assertThat(underTest.selectOrFailByUuid(dbSession, bar.getKee()).getName()).isEqualTo("bar");
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingMeasuresTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingMeasuresTest.java
index 162cac3e402..c814efb5171 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingMeasuresTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DeleteSecurityReviewRatingMeasuresTest.java
@@ -49,7 +49,7 @@ public class DeleteSecurityReviewRatingMeasuresTest {
@Rule
public CoreDbTester db = CoreDbTester.createForSchema(DeleteSecurityReviewRatingMeasuresTest.class, "schema.sql");
- private DataChange underTest = new DeleteSecurityReviewRatingMeasures(db.database());
+ private final DataChange underTest = new DeleteSecurityReviewRatingMeasures(db.database());
@Before
public void before() {
@@ -228,8 +228,8 @@ public class DeleteSecurityReviewRatingMeasuresTest {
underTest.execute();
- assertThat(db.countRowsOfTable(PROJECT_MEASURES_TABLE_NAME)).isEqualTo(0);
- assertThat(db.countRowsOfTable(LIVE_MEASURES_TABLE_NAME)).isEqualTo(0);
+ assertThat(db.countRowsOfTable(PROJECT_MEASURES_TABLE_NAME)).isZero();
+ assertThat(db.countRowsOfTable(LIVE_MEASURES_TABLE_NAME)).isZero();
}
private void generateOtherMetricsLiveMeasures(String componentUuid) {
@@ -248,12 +248,12 @@ public class DeleteSecurityReviewRatingMeasuresTest {
private void assertSecurityReviewRatingLiveMeasuresDeleted() {
assertThat(db.countSql("select count(uuid) from LIVE_MEASURES where metric_id = " + SECURITY_REVIEW_RATING_METRIC_ID))
- .isEqualTo(0);
+ .isZero();
}
private void assertSecurityReviewRatingMeasuresDeleted() {
assertThat(db.countSql("select count(id) from project_measures where metric_id = " + SECURITY_REVIEW_RATING_METRIC_ID))
- .isEqualTo(0);
+ .isZero();
}
private void insertMeasure(int id, int metricId, String componentUuid) {
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatusTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatusTest.java
index 9ede542c649..5b4904d88f7 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatusTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/DropSecurityHotSpotsInReviewStatusTest.java
@@ -27,7 +27,6 @@ import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
import org.sonar.db.CoreDbTester;
import org.sonar.server.platform.db.migration.step.DataChange;
@@ -42,12 +41,10 @@ public class DropSecurityHotSpotsInReviewStatusTest {
@Rule
public CoreDbTester db = CoreDbTester.createForSchema(DropSecurityHotSpotsInReviewStatusTest.class, "schema.sql");
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
- private System2 system2 = System2.INSTANCE;
+ private final System2 system2 = System2.INSTANCE;
- private DataChange underTest = new DropSecurityHotSpotsInReviewStatus(db.database(), system2);
+ private final DataChange underTest = new DropSecurityHotSpotsInReviewStatus(db.database(), system2);
@Test
public void should_change_IN_REVIEW_statuses_only() throws SQLException {
@@ -75,22 +72,23 @@ public class DropSecurityHotSpotsInReviewStatusTest {
@Test
public void should_not_fail_if_no_issues() throws SQLException {
underTest.execute();
- assertThat(db.countRowsOfTable("issues")).isEqualTo(0);
+ assertThat(db.countRowsOfTable("issues")).isZero();
}
private void assertIssueChanged(int issueId) {
List<Map<String, Object>> row = db.select(String.format("select status from issues where kee = '%s'", "issue-key-" + issueId));
assertThat(row).hasSize(1);
- assertThat(row.get(0).get("STATUS"))
- .isEqualTo("TO_REVIEW");
+ assertThat(row.get(0))
+ .containsEntry("STATUS", "TO_REVIEW");
List<Map<String, Object>> changelogRows = db.select(String.format("select change_type, change_data, created_at, updated_at, issue_change_creation_date" +
" from issue_changes where issue_key = '%s'", "issue-key-" + issueId));
assertThat(changelogRows).hasSize(1);
Map<String, Object> changelogRow = changelogRows.get(0);
- assertThat(changelogRow.get("CHANGE_TYPE")).isEqualTo("diff");
- assertThat(changelogRow.get("CHANGE_DATA")).isEqualTo("status=IN_REVIEW|TO_REVIEW");
+ assertThat(changelogRow)
+ .containsEntry("CHANGE_TYPE", "diff")
+ .containsEntry("CHANGE_DATA", "status=IN_REVIEW|TO_REVIEW");
assertThat(changelogRow.get("CREATED_AT")).isNotNull();
assertThat(changelogRow.get("UPDATED_AT")).isNotNull();
@@ -100,8 +98,8 @@ public class DropSecurityHotSpotsInReviewStatusTest {
private void assertIssueNotChanged(int issueId, String expectedStatus) {
List<Map<String, Object>> row = db.select(String.format("select status from issues where kee = '%s'", "issue-key-" + issueId));
assertThat(row).hasSize(1);
- assertThat(row.get(0).get("STATUS"))
- .isEqualTo(expectedStatus);
+ assertThat(row.get(0))
+ .containsEntry("STATUS", expectedStatus);
List<Map<String, Object>> changelogRows = db.select(String.format("select change_type, change_data, created_at, updated_at, issue_change_creation_date" +
" from issue_changes where issue_key = '%s'", "issue-key-" + issueId));
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpotsTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpotsTest.java
index 50cba019e05..6c66eb18fdb 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpotsTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v82/MigrateManualVulnerabilitiesToSecurityHotSpotsTest.java
@@ -29,7 +29,6 @@ import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.sonar.api.utils.System2;
import org.sonar.db.CoreDbTester;
import org.sonar.server.platform.db.migration.step.DataChange;
@@ -47,12 +46,10 @@ public class MigrateManualVulnerabilitiesToSecurityHotSpotsTest {
@Rule
public CoreDbTester db = CoreDbTester.createForSchema(MigrateManualVulnerabilitiesToSecurityHotSpotsTest.class, "schema.sql");
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
- private System2 system2 = System2.INSTANCE;
+ private final System2 system2 = System2.INSTANCE;
- private DataChange underTest = new MigrateManualVulnerabilitiesToSecurityHotSpots(db.database(), system2);
+ private final DataChange underTest = new MigrateManualVulnerabilitiesToSecurityHotSpots(db.database(), system2);
@Test
public void should_migrate_manual_vulnerabilities_only() throws SQLException {
@@ -92,22 +89,23 @@ public class MigrateManualVulnerabilitiesToSecurityHotSpotsTest {
@Test
public void should_not_fail_if_no_issues() throws SQLException {
underTest.execute();
- assertThat(db.countRowsOfTable("issues")).isEqualTo(0);
+ assertThat(db.countRowsOfTable("issues")).isZero();
}
private void assertIssueChanged(int issueId) {
List<Map<String, Object>> row = db.select(String.format("select status from issues where kee = '%s'", "issue-key-" + issueId));
assertThat(row).hasSize(1);
- assertThat(row.get(0).get("STATUS"))
- .isEqualTo("TO_REVIEW");
+ assertThat(row.get(0))
+ .containsEntry("STATUS", "TO_REVIEW");
List<Map<String, Object>> changelogRows = db.select(String.format("select change_type, change_data, created_at, updated_at, issue_change_creation_date" +
" from issue_changes where issue_key = '%s'", "issue-key-" + issueId));
assertThat(changelogRows).hasSize(1);
Map<String, Object> changelogRow = changelogRows.get(0);
- assertThat(changelogRow.get("CHANGE_TYPE")).isEqualTo("diff");
- assertThat(changelogRow.get("CHANGE_DATA")).isEqualTo("type=VULNERABILITY|SECURITY_HOTSPOT,status=OPEN|TO_REVIEW");
+ assertThat(changelogRow)
+ .containsEntry("CHANGE_TYPE", "diff")
+ .containsEntry("CHANGE_DATA", "type=VULNERABILITY|SECURITY_HOTSPOT,status=OPEN|TO_REVIEW");
assertThat(changelogRow.get("CREATED_AT")).isNotNull();
assertThat(changelogRow.get("UPDATED_AT")).isNotNull();
@@ -121,8 +119,8 @@ public class MigrateManualVulnerabilitiesToSecurityHotSpotsTest {
Map<String, Object> issueData = row.get(0);
assertThat(issueData.get("STATUS"))
.isNull();
- assertThat(issueData.get("ISSUE_TYPE"))
- .isEqualTo(expectedType);
+ assertThat(issueData)
+ .containsEntry("ISSUE_TYPE", expectedType);
List<Map<String, Object>> changelogRows = db.select(String.format("select change_type, change_data, created_at, updated_at, issue_change_creation_date" +
" from issue_changes where issue_key = '%s'", "issue-key-" + issueId));
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/PopulateSummaryCommentEnabledColumnForGitHubTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/PopulateSummaryCommentEnabledColumnForGitHubTest.java
index ddda3597887..d5a8512c7b1 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/PopulateSummaryCommentEnabledColumnForGitHubTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v83/PopulateSummaryCommentEnabledColumnForGitHubTest.java
@@ -35,16 +35,16 @@ public class PopulateSummaryCommentEnabledColumnForGitHubTest {
@Rule
public CoreDbTester db = CoreDbTester.createForSchema(PopulateSummaryCommentEnabledColumnForGitHubTest.class, "schema.sql");
- private System2 system = System2.INSTANCE;
+ private final System2 system = System2.INSTANCE;
- private DataChange underTest = new PopulateSummaryCommentEnabledColumnForGitHub(db.database(), system);
+ private final DataChange underTest = new PopulateSummaryCommentEnabledColumnForGitHub(db.database(), system);
@Test
public void does_not_fail_if_alm_settings_are_empty() throws SQLException {
underTest.execute();
assertThat(db.countSql("select count(uuid) from project_alm_settings where summary_comment_enabled is null"))
- .isEqualTo(0);
+ .isZero();
// re-entrant migration
underTest.execute();
diff --git a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/RemoveFilesFavouritesFromPropertiesTest.java b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/RemoveFilesFavouritesFromPropertiesTest.java
index 0e9f472c641..5a02f58326f 100644
--- a/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/RemoveFilesFavouritesFromPropertiesTest.java
+++ b/server/sonar-db-migration/src/test/java/org/sonar/server/platform/db/migration/version/v84/RemoveFilesFavouritesFromPropertiesTest.java
@@ -43,7 +43,7 @@ public class RemoveFilesFavouritesFromPropertiesTest {
@Rule
public CoreDbTester dbTester = CoreDbTester.createForSchema(RemoveFilesFavouritesFromPropertiesTest.class, "schema.sql");
- private DataChange underTest = new RemoveFilesFavouritesFromProperties(dbTester.database());
+ private final DataChange underTest = new RemoveFilesFavouritesFromProperties(dbTester.database());
private static final String APPLICATION_UUID_1 = Uuids.createFast();
private static final String PROJECT_UUID_2 = Uuids.createFast();
@@ -89,7 +89,7 @@ public class RemoveFilesFavouritesFromPropertiesTest {
underTest.execute();
- assertThat(dbTester.countRowsOfTable(PROPERTIES_TABLE_NAME)).isEqualTo(0);
+ assertThat(dbTester.countRowsOfTable(PROPERTIES_TABLE_NAME)).isZero();
}
@Test
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/es/response/NodeStatsResponseTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/es/response/NodeStatsResponseTest.java
index 6c7c6e7eef3..007432a9ba4 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/es/response/NodeStatsResponseTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/es/response/NodeStatsResponseTest.java
@@ -123,9 +123,9 @@ public class NodeStatsResponseTest {
assertThat(indicesStats).isNotNull();
assertThat(indicesStats.getStoreSizeInBytes()).isEqualTo(8670970);
assertThat(indicesStats.getTranslogSizeInBytes()).isEqualTo(8274137);
- assertThat(indicesStats.getRequestCacheMemorySizeInBytes()).isEqualTo(0);
+ assertThat(indicesStats.getRequestCacheMemorySizeInBytes()).isZero();
assertThat(indicesStats.getFieldDataMemorySizeInBytes()).isEqualTo(4880);
- assertThat(indicesStats.getQueryCacheMemorySizeInBytes()).isEqualTo(0);
+ assertThat(indicesStats.getQueryCacheMemorySizeInBytes()).isZero();
}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/es/searchrequest/AllFiltersTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/es/searchrequest/AllFiltersTest.java
index 9e7a299112c..68696e4e5fb 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/es/searchrequest/AllFiltersTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/es/searchrequest/AllFiltersTest.java
@@ -52,7 +52,8 @@ public class AllFiltersTest {
FilterScope filterScope = mock(FilterScope.class);
RequestFiltersComputer.AllFilters allFilters = RequestFiltersComputer.newAllFilters();
- assertThatThrownBy(() -> allFilters.addFilter(null, filterScope, boolQuery()))
+ BoolQueryBuilder boolQuery = boolQuery();
+ assertThatThrownBy(() -> allFilters.addFilter(null, filterScope, boolQuery))
.isInstanceOf(NullPointerException.class)
.hasMessage("name can't be null");
}
@@ -62,7 +63,8 @@ public class AllFiltersTest {
String name = randomAlphabetic(12);
RequestFiltersComputer.AllFilters allFilters = RequestFiltersComputer.newAllFilters();
- assertThatThrownBy(() -> allFilters.addFilter(name, null, boolQuery()))
+ BoolQueryBuilder boolQuery = boolQuery();
+ assertThatThrownBy(() -> allFilters.addFilter(name, null, boolQuery))
.isInstanceOf(NullPointerException.class)
.hasMessage("filterScope can't be null");
}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/es/searchrequest/NestedFieldFilterScopeTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/es/searchrequest/NestedFieldFilterScopeTest.java
index 9d97622c5b5..e5b47d68071 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/es/searchrequest/NestedFieldFilterScopeTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/es/searchrequest/NestedFieldFilterScopeTest.java
@@ -83,8 +83,7 @@ public class NestedFieldFilterScopeTest {
assertThat(underTest)
.isEqualTo(underTest)
- .isEqualTo(new NestedFieldFilterScope<>(fieldName, nestedFieldName, value));
- assertThat(underTest)
+ .isEqualTo(new NestedFieldFilterScope<>(fieldName, nestedFieldName, value))
.isNotEqualTo(null)
.isNotEqualTo(new Object())
.isNotEqualTo(new NestedFieldFilterScope<>(fieldName2, nestedFieldName, value))
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/es/searchrequest/RequestFiltersComputerTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/es/searchrequest/RequestFiltersComputerTest.java
index 98480f6533b..8880d4c8a9b 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/es/searchrequest/RequestFiltersComputerTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/es/searchrequest/RequestFiltersComputerTest.java
@@ -99,7 +99,7 @@ public class RequestFiltersComputerTest {
AllFilters allFilters = randomNonEmptyAllFilters();
RequestFiltersComputer underTest = new RequestFiltersComputer(allFilters, Collections.emptySet());
- assertThat(underTest.getQueryFilters().get()).isEqualTo(toBoolQuery(allFilters.stream()));
+ assertThat(underTest.getQueryFilters()).contains(toBoolQuery(allFilters.stream()));
}
@Test
@@ -116,7 +116,7 @@ public class RequestFiltersComputerTest {
Set<TopAggregationDefinition<?>> atLeastOneNonStickyTopAggs = randomNonEmptyTopAggregations(() -> false);
RequestFiltersComputer underTest = new RequestFiltersComputer(allFilters, atLeastOneNonStickyTopAggs);
- assertThat(underTest.getQueryFilters().get()).isEqualTo(toBoolQuery(allFilters.stream()));
+ assertThat(underTest.getQueryFilters()).contains(toBoolQuery(allFilters.stream()));
}
@Test
@@ -179,9 +179,9 @@ public class RequestFiltersComputerTest {
RequestFiltersComputer underTest = new RequestFiltersComputer(allFilters, declaredTopAggregations);
- assertThat(underTest.getQueryFilters().get()).isEqualTo(toBoolQuery(filterField3, filterField4));
+ assertThat(underTest.getQueryFilters()).contains(toBoolQuery(filterField3, filterField4));
QueryBuilder[] postFilters = {filterField1_1, filterField1_2, filterField2};
- assertThat(underTest.getPostFilters().get()).isEqualTo(toBoolQuery(postFilters));
+ assertThat(underTest.getPostFilters()).contains(toBoolQuery(postFilters));
assertTopAggregationFilter(underTest, stickyTopAggField1, filterField2);
assertTopAggregationFilter(underTest, nonStickyTopAggField1, postFilters);
assertTopAggregationFilter(underTest, stickyTopAggField2, filterField1_1, filterField1_2);
@@ -215,9 +215,9 @@ public class RequestFiltersComputerTest {
RequestFiltersComputer underTest = new RequestFiltersComputer(allFilters, declaredTopAggregations);
- assertThat(underTest.getQueryFilters().get()).isEqualTo(toBoolQuery(filterField2));
+ assertThat(underTest.getQueryFilters()).contains(toBoolQuery(filterField2));
QueryBuilder[] postFilters = {filterField1_1, filterField1_2};
- assertThat(underTest.getPostFilters().get()).isEqualTo(toBoolQuery(postFilters));
+ assertThat(underTest.getPostFilters()).contains(toBoolQuery(postFilters));
assertThat(underTest.getTopAggregationFilter(stickyTopAggField1)).isEmpty();
assertTopAggregationFilter(underTest, nonStickyTopAggField1, postFilters);
assertTopAggregationFilter(underTest, nonStickyTopAggField2, postFilters);
@@ -269,9 +269,9 @@ public class RequestFiltersComputerTest {
RequestFiltersComputer underTest = new RequestFiltersComputer(allFilters, declaredTopAggregations);
- assertThat(underTest.getQueryFilters().get()).isEqualTo(toBoolQuery(filterField3, filterField4));
+ assertThat(underTest.getQueryFilters()).contains(toBoolQuery(filterField3, filterField4));
QueryBuilder[] postFilters = {filterField1_1, filterField1_2, filterField2};
- assertThat(underTest.getPostFilters().get()).isEqualTo(toBoolQuery(postFilters));
+ assertThat(underTest.getPostFilters()).contains(toBoolQuery(postFilters));
assertTopAggregationFilter(underTest, stickyTopAggField1, filterField2);
assertTopAggregationFilter(underTest, nonStickyTopAggField1, postFilters);
assertTopAggregationFilter(underTest, stickyTopAggField2, filterField1_1, filterField1_2);
@@ -343,14 +343,14 @@ public class RequestFiltersComputerTest {
RequestFiltersComputer underTest = new RequestFiltersComputer(allFilters, declaredTopAggregations);
- assertThat(underTest.getQueryFilters().get()).isEqualTo(toBoolQuery(queryFilter));
+ assertThat(underTest.getQueryFilters()).contains(toBoolQuery(queryFilter));
QueryBuilder[] postFilters = {
filterNestedField1_value1_1, filterNestedField1_value1_2,
filterNestedField1_value2_1, filterNestedField1_value2_2,
filterField1_1, filterField1_2,
filterField2_1, filterField2_2,
filterNestedField3_1, filterNestedField3_2};
- assertThat(underTest.getPostFilters().get()).isEqualTo(toBoolQuery(postFilters));
+ assertThat(underTest.getPostFilters()).contains(toBoolQuery(postFilters));
assertTopAggregationFilter(underTest, stickyTopAggNestedField1_value1,
filterNestedField1_value2_1, filterNestedField1_value2_2,
filterField1_1, filterField1_2,
@@ -408,9 +408,9 @@ public class RequestFiltersComputerTest {
RequestFiltersComputer underTest = new RequestFiltersComputer(allFilters, declaredTopAggregations);
- assertThat(underTest.getQueryFilters().get()).isEqualTo(toBoolQuery(filterField2));
+ assertThat(underTest.getQueryFilters()).contains(toBoolQuery(filterField2));
QueryBuilder[] postFilters = {filterField1_1, filterField1_2};
- assertThat(underTest.getPostFilters().get()).isEqualTo(toBoolQuery(postFilters));
+ assertThat(underTest.getPostFilters()).contains(toBoolQuery(postFilters));
assertThat(underTest.getTopAggregationFilter(stickyTopAggField1)).isEmpty();
assertTopAggregationFilter(underTest, nonStickyTopAggField1, postFilters);
assertTopAggregationFilter(underTest, nonStickyTopAggField2, postFilters);
@@ -442,7 +442,7 @@ public class RequestFiltersComputerTest {
assertThat(underTest.getQueryFilters()).isEmpty();
QueryBuilder[] postFilters = {filterField1_1, filterField1_2, filterField2};
- assertThat(underTest.getPostFilters().get()).isEqualTo(toBoolQuery(postFilters));
+ assertThat(underTest.getPostFilters()).contains(toBoolQuery(postFilters));
assertTopAggregationFilter(underTest, stickyTopAggField1, filterField2);
assertTopAggregationFilter(underTest, nonStickyTopAggField1, postFilters);
assertTopAggregationFilter(underTest, stickyTopAggField2, filterField1_1, filterField1_2);
@@ -496,11 +496,11 @@ public class RequestFiltersComputerTest {
private static void assertTopAggregationFilter(RequestFiltersComputer underTest,
TopAggregationDefinition<?> topAggregation, QueryBuilder firstFilter, QueryBuilder... otherFilters) {
- assertThat(underTest.getTopAggregationFilter(topAggregation).get()).isEqualTo(toBoolQuery(firstFilter, otherFilters));
+ assertThat(underTest.getTopAggregationFilter(topAggregation)).contains(toBoolQuery(firstFilter, otherFilters));
}
private static void assertTopAggregationFilter(RequestFiltersComputer underTest,
TopAggregationDefinition<?> topAggregation, QueryBuilder[] filters) {
- assertThat(underTest.getTopAggregationFilter(topAggregation).get()).isEqualTo(toBoolQuery(filters));
+ assertThat(underTest.getTopAggregationFilter(topAggregation)).contains(toBoolQuery(filters));
}
}
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/es/searchrequest/SimpleFieldFilterScopeTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/es/searchrequest/SimpleFieldFilterScopeTest.java
index 00847c6e878..63c1cea117f 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/es/searchrequest/SimpleFieldFilterScopeTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/es/searchrequest/SimpleFieldFilterScopeTest.java
@@ -51,8 +51,7 @@ public class SimpleFieldFilterScopeTest {
assertThat(underTest)
.isEqualTo(underTest)
- .isEqualTo(new SimpleFieldFilterScope(fieldName1));
- assertThat(underTest)
+ .isEqualTo(new SimpleFieldFilterScope(fieldName1))
.isNotEqualTo(null)
.isNotEqualTo(new Object())
.isNotEqualTo(new SimpleFieldFilterScope(fieldName2))
@@ -70,7 +69,6 @@ public class SimpleFieldFilterScopeTest {
.isEqualTo(underTest.hashCode())
.isEqualTo(new SimpleFieldFilterScope(fieldName1).hashCode());
assertThat(underTest.hashCode())
- .isNotEqualTo(null)
.isNotEqualTo(new Object().hashCode())
.isNotEqualTo(new SimpleFieldFilterScope(fieldName2).hashCode())
.isNotEqualTo(new NestedFieldFilterScope<>(fieldName1, "foo", "bar").hashCode())
diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/IssuesChangesNotificationBuilderTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/IssuesChangesNotificationBuilderTest.java
index 4db76a1818a..1b7316c2722 100644
--- a/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/IssuesChangesNotificationBuilderTest.java
+++ b/server/sonar-server-common/src/test/java/org/sonar/server/issue/notification/IssuesChangesNotificationBuilderTest.java
@@ -64,7 +64,8 @@ public class IssuesChangesNotificationBuilderTest {
@Test
public void fail_if_changed_issues_empty() {
AnalysisChange analysisChange = new AnalysisChange(1_000_000_000L);
- assertThatThrownBy(() -> new IssuesChangesNotificationBuilder(Collections.emptySet(), analysisChange))
+ Set<ChangedIssue> issues = Collections.emptySet();
+ assertThatThrownBy(() -> new IssuesChangesNotificationBuilder(issues, analysisChange))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("issues can't be empty");
}
@@ -89,8 +90,8 @@ public class IssuesChangesNotificationBuilderTest {
long date = 1_000_000_000L;
UserChange userChange = new UserChange(date, new User("user_uuid", "user_login", null));
- assertThat(userChange.toString())
- .isEqualTo("UserChange{date=1000000000, user=User{uuid='user_uuid', login='user_login', name='null'}}");
+ assertThat(userChange)
+ .hasToString("UserChange{date=1000000000, user=User{uuid='user_uuid', login='user_login', name='null'}}");
}
@Test
@@ -102,8 +103,9 @@ public class IssuesChangesNotificationBuilderTest {
UserChange userChange1 = new UserChange(now, new User(uuid_1, login_1, name_1));
UserChange userChange2 = new UserChange(now, new User(uuid_1, login_1, name_1));
- assertThat(userChange1.equals(userChange2)).isTrue();
- assertThat(userChange1.equals(userChange1)).isTrue();
+ assertThat(userChange1)
+ .isEqualTo(userChange2)
+ .isEqualTo(userChange1);
}
@DataProvider
@@ -132,7 +134,7 @@ public class IssuesChangesNotificationBuilderTest {
String name_1 = "name-1";
UserChange userChange1 = new UserChange(now, new User(uuid_1, login_1, name_1));
- assertThat(userChange1.equals(object)).isFalse();
+ assertThat(userChange1).isNotEqualTo(object);
}
@Test
@@ -166,8 +168,7 @@ public class IssuesChangesNotificationBuilderTest {
long date = 1_000_000_000L;
AnalysisChange userChange = new AnalysisChange(date);
- assertThat(userChange.toString())
- .isEqualTo("AnalysisChange{1000000000}");
+ assertThat(userChange).hasToString("AnalysisChange{1000000000}");
}
@Test
@@ -175,8 +176,9 @@ public class IssuesChangesNotificationBuilderTest {
AnalysisChange analysisChange1 = new AnalysisChange(1_000_000_000L);
AnalysisChange analysisChange2 = new AnalysisChange(1_000_000_000L);
- assertThat(analysisChange1.equals(analysisChange2)).isTrue();
- assertThat(analysisChange1.equals(analysisChange1)).isTrue();
+ assertThat(analysisChange1)
+ .isEqualTo(analysisChange2)
+ .isEqualTo(analysisChange1);
}
@Test
@@ -184,21 +186,21 @@ public class IssuesChangesNotificationBuilderTest {
AnalysisChange analysisChange1 = new AnalysisChange(1_000_000_000L);
AnalysisChange analysisChange2 = new AnalysisChange(2_000_000_000L);
- assertThat(analysisChange1.equals(analysisChange2)).isFalse();
+ assertThat(analysisChange1).isNotEqualTo(analysisChange2);
}
@Test
public void AnalysisChange_not_equal_with_null() {
AnalysisChange analysisChange1 = new AnalysisChange(1_000_000_000L);
- assertThat(analysisChange1.equals(null)).isFalse();
+ assertThat(analysisChange1).isNotEqualTo(null);
}
@Test
public void AnalysisChange_not_equal_with_Object() {
AnalysisChange analysisChange1 = new AnalysisChange(1_000_000_000L);
- assertThat(analysisChange1.equals(new Object())).isFalse();
+ assertThat(analysisChange1).isNotEqualTo(new Object());
}
@Test
@@ -215,8 +217,8 @@ public class IssuesChangesNotificationBuilderTest {
.setBranchName("branch-name")
.build();
- assertThat(project.toString())
- .isEqualTo("Project{uuid='uuid', key='key', projectName='name', branchName='branch-name'}");
+ assertThat(project)
+ .hasToString("Project{uuid='uuid', key='key', projectName='name', branchName='branch-name'}");
}
@Test
@@ -233,8 +235,9 @@ public class IssuesChangesNotificationBuilderTest {
.setBranchName("branch-name")
.build();
- assertThat(project1.equals(project2)).isTrue();
- assertThat(project1.equals(project1)).isTrue();
+ assertThat(project1)
+ .isEqualTo(project2)
+ .isEqualTo(project1);
}
@DataProvider
@@ -263,7 +266,7 @@ public class IssuesChangesNotificationBuilderTest {
.setBranchName("branch-name1")
.build();
- assertThat(project1.equals(object)).isFalse();
+ assertThat(project1).isNotEqualTo(object);
}
@Test
@@ -284,8 +287,8 @@ public class IssuesChangesNotificationBuilderTest {
public void Rule_toString() {
Rule rule = newRule("repository", "key", RuleType.CODE_SMELL, "name");
- assertThat(rule.toString())
- .isEqualTo("Rule{key=repository:key, type=CODE_SMELL, name='name'}");
+ assertThat(rule)
+ .hasToString("Rule{key=repository:key, type=CODE_SMELL, name='name'}");
}
@Test
@@ -293,8 +296,9 @@ public class IssuesChangesNotificationBuilderTest {
Rule rule1 = newRule("repository", "key", RuleType.CODE_SMELL, "name");
Rule rule2 = newRule("repository", "key", RuleType.CODE_SMELL, "name");
- assertThat(rule1.equals(rule2)).isTrue();
- assertThat(rule1.equals(rule1)).isTrue();
+ assertThat(rule1)
+ .isEqualTo(rule2)
+ .isEqualTo(rule1);
}
@DataProvider
@@ -341,8 +345,8 @@ public class IssuesChangesNotificationBuilderTest {
.setAssignee(new User("uuid", "login", "name"))
.build();
- assertThat(changedIssue.toString())
- .isEqualTo("ChangedIssue{key='key', newStatus='status', newResolution='resolution', " +
+ assertThat(changedIssue)
+ .hasToString("ChangedIssue{key='key', newStatus='status', newResolution='resolution', " +
"assignee=User{uuid='uuid', login='login', name='name'}, " +
"rule=Rule{key=repository:key, type=CODE_SMELL, name='name'}, " +
"project=Project{uuid='uuid', key='key', projectName='name', branchName='branch-name'}}");
@@ -365,8 +369,9 @@ public class IssuesChangesNotificationBuilderTest {
.setAssignee(new User("uuid", "login", "name"))
.build();
- assertThat(changedIssue1.equals(changedIssue2)).isTrue();
- assertThat(changedIssue1.equals(changedIssue1)).isTrue();
+ assertThat(changedIssue1)
+ .isEqualTo(changedIssue2)
+ .isEqualTo(changedIssue1);
}
@DataProvider
@@ -430,7 +435,7 @@ public class IssuesChangesNotificationBuilderTest {
.setAssignee(new User("uuid", "login", "name"))
.build();
- assertThat(changedIssue.equals(object)).isFalse();
+ assertThat(changedIssue).isNotEqualTo(object);
}
@Test
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSyncProgressCheckerTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSyncProgressCheckerTest.java
index 06f073d3564..f3cbe525ab4 100644
--- a/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSyncProgressCheckerTest.java
+++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSyncProgressCheckerTest.java
@@ -48,12 +48,12 @@ import static org.sonar.db.ce.CeActivityDto.Status.SUCCESS;
@RunWith(DataProviderRunner.class)
public class IssueIndexSyncProgressCheckerTest {
- private System2 system2 = new System2();
+ private final System2 system2 = new System2();
@Rule
public DbTester db = DbTester.create(System2.INSTANCE);
- private IssueIndexSyncProgressChecker underTest = new IssueIndexSyncProgressChecker(db.getDbClient());
+ private final IssueIndexSyncProgressChecker underTest = new IssueIndexSyncProgressChecker(db.getDbClient());
@Test
public void return_100_if_there_is_no_tasks_left() {
@@ -246,11 +246,11 @@ public class IssueIndexSyncProgressCheckerTest {
underTest.checkIfComponentNeedIssueSync(session, projectDto2.getKey());
// throws if flag set to TRUE
- assertThatThrownBy(() -> underTest.checkIfComponentNeedIssueSync(session,
- projectDto1.getKey()))
- .isInstanceOf(EsIndexSyncInProgressException.class)
- .hasFieldOrPropertyWithValue("httpCode", 503)
- .hasMessage("Results are temporarily unavailable. Indexing of issues is in progress.");
+ String key = projectDto1.getKey();
+ assertThatThrownBy(() -> underTest.checkIfComponentNeedIssueSync(session, key))
+ .isInstanceOf(EsIndexSyncInProgressException.class)
+ .hasFieldOrPropertyWithValue("httpCode", 503)
+ .hasMessage("Results are temporarily unavailable. Indexing of issues is in progress.");
}
@Test
diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java
index 4e6ae085da2..7a4315ac9c9 100644
--- a/server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java
+++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/measure/index/ProjectMeasuresIndexTest.java
@@ -1664,7 +1664,7 @@ public class ProjectMeasuresIndexTest {
ProjectMeasuresStatistics result = underTest.searchTelemetryStatistics();
- assertThat(result.getProjectCount()).isEqualTo(0);
+ assertThat(result.getProjectCount()).isZero();
assertThat(result.getProjectCountByLanguage()).isEmpty();
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/hotspot/ws/AssignActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/hotspot/ws/AssignActionTest.java
index f5798c2d951..e5708fff691 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/hotspot/ws/AssignActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/hotspot/ws/AssignActionTest.java
@@ -178,9 +178,10 @@ public class AssignActionTest {
when(issueFieldsSetter.assign(eq(hotspot.toDefaultIssue()), userMatcher(assignee), any(IssueChangeContext.class))).thenReturn(true);
- assertThatThrownBy(() -> executeRequest(hotspot, assignee.getLogin(), null))
+ String login = assignee.getLogin();
+ assertThatThrownBy(() -> executeRequest(hotspot, login, null))
.isInstanceOf(IllegalArgumentException.class)
- .hasMessage("Provided user with login '%s' does not have 'Browse' permission to project", assignee.getLogin());
+ .hasMessage("Provided user with login '%s' does not have 'Browse' permission to project", login);
}
@Test
@@ -195,9 +196,10 @@ public class AssignActionTest {
when(issueFieldsSetter.assign(eq(hotspot.toDefaultIssue()), userMatcher(assignee), any(IssueChangeContext.class))).thenReturn(true);
- assertThatThrownBy(() -> executeRequest(hotspot, assignee.getLogin(), null))
+ String login = assignee.getLogin();
+ assertThatThrownBy(() -> executeRequest(hotspot, login, null))
.isInstanceOf(IllegalArgumentException.class)
- .hasMessage("Provided user with login '%s' does not have 'Browse' permission to project", assignee.getLogin());
+ .hasMessage("Provided user with login '%s' does not have 'Browse' permission to project", login);
}
@Test
@@ -282,7 +284,8 @@ public class AssignActionTest {
UserDto userDto = insertUser(randomAlphanumeric(10));
userSessionRule.logIn(userDto).registerComponents(project);
- assertThatThrownBy(() -> executeRequest(hotspot, userSessionRule.getLogin(), null))
+ String login = userSessionRule.getLogin();
+ assertThatThrownBy(() -> executeRequest(hotspot, login, null))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Assignee can only be changed on Security Hotspots with status 'TO_REVIEW'");
}
@@ -297,7 +300,8 @@ public class AssignActionTest {
UserDto userDto = insertUser(randomAlphanumeric(10));
userSessionRule.logIn(userDto).registerComponents(project);
- assertThatThrownBy(() -> executeRequest(hotspot, userSessionRule.getLogin(), null))
+ String login = userSessionRule.getLogin();
+ assertThatThrownBy(() -> executeRequest(hotspot, login, null))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Assignee can only be changed on Security Hotspots with status 'TO_REVIEW'");
}
@@ -321,7 +325,8 @@ public class AssignActionTest {
UserDto assignee = insertUser(randomAlphanumeric(15));
- assertThatThrownBy(() -> executeRequest(hotspot, assignee.getLogin(), null))
+ String login = assignee.getLogin();
+ assertThatThrownBy(() -> executeRequest(hotspot, login, null))
.isInstanceOf(ForbiddenException.class)
.hasMessage("Insufficient privileges");
}
@@ -336,7 +341,8 @@ public class AssignActionTest {
when(issueFieldsSetter.assign(eq(hotspot.toDefaultIssue()), userMatcher(me), any(IssueChangeContext.class))).thenReturn(true);
- assertThatThrownBy(() -> executeRequest(hotspot, me.getLogin(), null))
+ String login = me.getLogin();
+ assertThatThrownBy(() -> executeRequest(hotspot, login, null))
.isInstanceOf(ForbiddenException.class)
.hasMessage("Insufficient privileges");
}
@@ -349,7 +355,8 @@ public class AssignActionTest {
userSessionRule.logIn().registerComponents(project);
String notExistingHotspotKey = randomAlphanumeric(10);
- assertThatThrownBy(() -> executeRequest(notExistingHotspotKey, me.getLogin(), null))
+ String login = me.getLogin();
+ assertThatThrownBy(() -> executeRequest(notExistingHotspotKey, login, null))
.isInstanceOf(NotFoundException.class)
.hasMessage("Hotspot '%s' does not exist", notExistingHotspotKey);
}
@@ -367,7 +374,8 @@ public class AssignActionTest {
UserDto me = insertUser(randomAlphanumeric(10));
userSessionRule.logIn().registerComponents(project);
- assertThatThrownBy(() -> executeRequest(issue, me.getLogin(), null))
+ String login = me.getLogin();
+ assertThatThrownBy(() -> executeRequest(issue, login, null))
.isInstanceOf(NotFoundException.class)
.hasMessage("Hotspot '%s' does not exist", issue.getKey());
}
@@ -397,7 +405,8 @@ public class AssignActionTest {
UserDto me = insertUser(randomAlphanumeric(10));
userSessionRule.logIn().registerComponents(project);
- assertThatThrownBy(() -> executeRequest(issue, me.getLogin(), null))
+ String login = me.getLogin();
+ assertThatThrownBy(() -> executeRequest(issue, login, null))
.isInstanceOf(NotFoundException.class)
.hasMessage("Hotspot '%s' does not exist", issue.getKey());
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AddCommentActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AddCommentActionTest.java
index 82401c7c01f..404a550ed88 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AddCommentActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AddCommentActionTest.java
@@ -50,8 +50,6 @@ import org.sonar.server.issue.index.IssueIndexer;
import org.sonar.server.issue.index.IssueIteratorFactory;
import org.sonar.server.issue.notification.IssuesChangesNotificationSerializer;
import org.sonar.server.notification.NotificationManager;
-import org.sonar.server.organization.DefaultOrganizationProvider;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.rule.DefaultRuleFinder;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestRequest;
@@ -140,9 +138,10 @@ public class AddCommentActionTest {
IssueDto issueDto = issueDbTester.insertHotspot();
loginWithBrowsePermission(issueDto, USER);
- assertThatThrownBy(() -> call(issueDto.getKey(), "please fix it"))
+ String dtoKey = issueDto.getKey();
+ assertThatThrownBy(() -> call(dtoKey, "please fix it"))
.isInstanceOf(NotFoundException.class)
- .hasMessage("Issue with key '%s' does not exist", issueDto.getKey());
+ .hasMessage("Issue with key '%s' does not exist", dtoKey);
}
@Test
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java
index cf394dc20ac..e96389815e4 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/AssignActionTest.java
@@ -47,6 +47,7 @@ import org.sonar.server.issue.notification.IssuesChangesNotificationSerializer;
import org.sonar.server.notification.NotificationManager;
import org.sonar.server.rule.DefaultRuleFinder;
import org.sonar.server.tester.UserSessionRule;
+import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
import static org.assertj.core.api.Assertions.assertThat;
@@ -212,12 +213,12 @@ public class AssignActionTest {
setUserWithBrowsePermission(hotspot);
UserDto arthur = insertUser("arthur");
- assertThatThrownBy(() -> ws.newRequest()
+ TestRequest request = ws.newRequest()
.setParam("issue", hotspot.getKey())
- .setParam("assignee", arthur.getLogin())
- .execute())
- .isInstanceOf(NotFoundException.class)
- .hasMessage("Issue with key '%s' does not exist", hotspot.getKey());
+ .setParam("assignee", arthur.getLogin());
+ assertThatThrownBy(request::execute)
+ .isInstanceOf(NotFoundException.class)
+ .hasMessage("Issue with key '%s' does not exist", hotspot.getKey());
}
@Test
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/ChangelogActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/ChangelogActionTest.java
index d74f74b9361..b645d470a8d 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/ChangelogActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/ChangelogActionTest.java
@@ -302,9 +302,10 @@ public class ChangelogActionTest {
IssueDto issueDto = db.issues().insertHotspot();
userSession.logIn("john").addProjectPermission(USER, project, file);
- assertThatThrownBy(() -> call(issueDto.getKey()))
+ String issueDtoKey = issueDto.getKey();
+ assertThatThrownBy(() -> call(issueDtoKey))
.isInstanceOf(NotFoundException.class)
- .hasMessage("Issue with key '%s' does not exist", issueDto.getKey());
+ .hasMessage("Issue with key '%s' does not exist", issueDtoKey);
}
@Test
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/DeleteCommentActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/DeleteCommentActionTest.java
index e77959904d7..3ad16bdb473 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/DeleteCommentActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/DeleteCommentActionTest.java
@@ -24,7 +24,6 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.ArgumentCaptor;
-import org.sonar.api.rules.RuleType;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
@@ -163,9 +162,10 @@ public class DeleteCommentActionTest {
IssueChangeDto commentDto = issueDbTester.insertComment(hotspot, user, "please fix it");
loginAndAddProjectPermission(user, hotspot, USER);
- assertThatThrownBy(() -> call(commentDto.getKey()))
- .isInstanceOf(NotFoundException.class)
- .hasMessage("Issue with key '%s' does not exist", hotspot.getKey());
+ String commentDtoKey = commentDto.getKey();
+ assertThatThrownBy(() -> call(commentDtoKey))
+ .isInstanceOf(NotFoundException.class)
+ .hasMessage("Issue with key '%s' does not exist", hotspot.getKey());
}
@Test
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/DoTransitionActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/DoTransitionActionTest.java
index 6c8b5e83b7a..8c1cacbe424 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/DoTransitionActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/DoTransitionActionTest.java
@@ -51,8 +51,6 @@ import org.sonar.server.issue.notification.IssuesChangesNotificationSerializer;
import org.sonar.server.issue.workflow.FunctionExecutor;
import org.sonar.server.issue.workflow.IssueWorkflow;
import org.sonar.server.notification.NotificationManager;
-import org.sonar.server.organization.DefaultOrganizationProvider;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.rule.DefaultRuleFinder;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestRequest;
@@ -152,9 +150,10 @@ public class DoTransitionActionTest {
IssueDto hotspot = db.issues().insertHotspot(rule, project, file, i -> i.setType(RuleType.SECURITY_HOTSPOT));
userSession.logIn().addProjectPermission(USER, project, file);
- assertThatThrownBy(() -> call(hotspot.getKey(), "confirm"))
+ String hotspotKey = hotspot.getKey();
+ assertThatThrownBy(() -> call(hotspotKey, "confirm"))
.isInstanceOf(NotFoundException.class)
- .hasMessage("Issue with key '%s' does not exist", hotspot.getKey());
+ .hasMessage("Issue with key '%s' does not exist", hotspotKey);
}
@Test
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/EditCommentActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/EditCommentActionTest.java
index 6bd9543509a..b2c40aa68ef 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/EditCommentActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/EditCommentActionTest.java
@@ -122,7 +122,8 @@ public class EditCommentActionTest {
UserDto another = dbTester.users().insertUser();
loginWithBrowsePermission(another, USER, hotspot);
- assertThatThrownBy(() -> call(commentDto.getKey(), "please have a look"))
+ String commentDtoKey = commentDto.getKey();
+ assertThatThrownBy(() -> call(commentDtoKey, "please have a look"))
.isInstanceOf(NotFoundException.class)
.hasMessage("Issue with key '%s' does not exist", hotspot.getKey());
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java
index 8dc98c832a0..8968fb75308 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java
@@ -61,7 +61,6 @@ import org.sonar.db.rule.RuleTesting;
import org.sonar.db.user.UserDto;
import org.sonar.server.es.EsTester;
import org.sonar.server.es.SearchOptions;
-import org.sonar.server.es.StartupIndexer;
import org.sonar.server.issue.AvatarResolverImpl;
import org.sonar.server.issue.IssueFieldsSetter;
import org.sonar.server.issue.TextRangeResponseFormatter;
@@ -77,6 +76,7 @@ import org.sonar.server.issue.workflow.IssueWorkflow;
import org.sonar.server.permission.index.PermissionIndexer;
import org.sonar.server.permission.index.WebAuthorizationTypeSupport;
import org.sonar.server.tester.UserSessionRule;
+import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.TestResponse;
import org.sonar.server.ws.WsActionTester;
import org.sonarqube.ws.Common;
@@ -1193,11 +1193,11 @@ public class SearchActionTest {
indexPermissions();
indexIssues();
- assertThatThrownBy(() -> ws.newRequest()
- .setParam("types", RuleType.SECURITY_HOTSPOT.toString())
- .execute())
- .isInstanceOf(IllegalArgumentException.class)
- .hasMessage("Value of parameter 'types' (SECURITY_HOTSPOT) must be one of: [CODE_SMELL, BUG, VULNERABILITY]");
+ TestRequest request = ws.newRequest()
+ .setParam("types", RuleType.SECURITY_HOTSPOT.toString());
+ assertThatThrownBy(request::execute)
+ .isInstanceOf(IllegalArgumentException.class)
+ .hasMessage("Value of parameter 'types' (SECURITY_HOTSPOT) must be one of: [CODE_SMELL, BUG, VULNERABILITY]");
}
@Test
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetSeverityActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetSeverityActionTest.java
index ed97ae7ae08..9d1fa6f63b7 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetSeverityActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetSeverityActionTest.java
@@ -50,8 +50,6 @@ import org.sonar.server.issue.index.IssueIndexer;
import org.sonar.server.issue.index.IssueIteratorFactory;
import org.sonar.server.issue.notification.IssuesChangesNotificationSerializer;
import org.sonar.server.notification.NotificationManager;
-import org.sonar.server.organization.DefaultOrganizationProvider;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.rule.DefaultRuleFinder;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestRequest;
@@ -144,9 +142,10 @@ public class SetSeverityActionTest {
IssueDto hotspot = issueDbTester.insertHotspot(h -> h.setSeverity("CRITICAL"));
setUserWithBrowseAndAdministerIssuePermission(hotspot);
- assertThatThrownBy(() -> call(hotspot.getKey(), "MAJOR"))
+ String hotspotKey = hotspot.getKey();
+ assertThatThrownBy(() -> call(hotspotKey, "MAJOR"))
.isInstanceOf(NotFoundException.class)
- .hasMessage("Issue with key '%s' does not exist", hotspot.getKey());
+ .hasMessage("Issue with key '%s' does not exist", hotspotKey);
}
@Test
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetTypeActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetTypeActionTest.java
index 68d6beeb565..f3d0c8a778f 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetTypeActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SetTypeActionTest.java
@@ -58,8 +58,6 @@ import org.sonar.server.issue.index.IssueIndexer;
import org.sonar.server.issue.index.IssueIteratorFactory;
import org.sonar.server.issue.notification.IssuesChangesNotificationSerializer;
import org.sonar.server.notification.NotificationManager;
-import org.sonar.server.organization.DefaultOrganizationProvider;
-import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.rule.DefaultRuleFinder;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestRequest;
@@ -153,7 +151,8 @@ public class SetTypeActionTest {
IssueDto issueDto = newIssueWithProject(CODE_SMELL);
setUserWithBrowseAndAdministerIssuePermission(issueDto);
- assertThatThrownBy(() -> call(issueDto.getKey(), "unknown"))
+ String issueDtoKey = issueDto.getKey();
+ assertThatThrownBy(() -> call(issueDtoKey, "unknown"))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Value of parameter 'type' (unknown) must be one of: [CODE_SMELL, BUG, VULNERABILITY]");
}
@@ -163,7 +162,8 @@ public class SetTypeActionTest {
IssueDto issueDto = newIssueWithProject(CODE_SMELL);
setUserWithBrowseAndAdministerIssuePermission(issueDto);
- assertThatThrownBy(() -> call(issueDto.getKey(), "SECURITY_HOTSPOT"))
+ String issueDtoKey = issueDto.getKey();
+ assertThatThrownBy(() -> call(issueDtoKey, "SECURITY_HOTSPOT"))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Value of parameter 'type' (SECURITY_HOTSPOT) must be one of: [CODE_SMELL, BUG, VULNERABILITY]");
}
@@ -203,9 +203,11 @@ public class SetTypeActionTest {
IssueDto hotspot = issueDbTester.insertHotspot();
setUserWithBrowseAndAdministerIssuePermission(hotspot);
- assertThatThrownBy(() -> call(hotspot.getKey(), type.name()))
+ String hotspotKey = hotspot.getKey();
+ String typeName = type.name();
+ assertThatThrownBy(() -> call(hotspotKey, typeName))
.isInstanceOf(NotFoundException.class)
- .hasMessage("Issue with key '%s' does not exist", hotspot.getKey());
+ .hasMessage("Issue with key '%s' does not exist", hotspotKey);
}
@Test
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/custom/ws/CreateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/custom/ws/CreateActionTest.java
index 88e949c8ee7..1e6c45b9260 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/custom/ws/CreateActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/custom/ws/CreateActionTest.java
@@ -67,7 +67,7 @@ public class CreateActionTest {
@Rule
public EsTester es = EsTester.create();
- private WsActionTester ws = new WsActionTester(
+ private final WsActionTester ws = new WsActionTester(
new CreateAction(db.getDbClient(), userSession, System2.INSTANCE, new CustomMeasureValidator(newFullTypeValidations()),
new CustomMeasureJsonWriter(new UserJsonWriter(userSession)), TestComponentFinder.from(db)));
@@ -76,9 +76,9 @@ public class CreateActionTest {
Action wsDef = ws.getDef();
assertThat(wsDef.deprecatedSince()).isEqualTo("7.4");
- assertThat(wsDef.isInternal()).isEqualTo(false);
+ assertThat(wsDef.isInternal()).isFalse();
assertThat(wsDef.since()).isEqualTo("5.2");
- assertThat(wsDef.isPost()).isEqualTo(true);
+ assertThat(wsDef.isPost()).isTrue();
assertThat(wsDef.changelog()).extracting(Change::getVersion, Change::getDescription).containsOnly(
tuple("8.4", "Param 'metricId' data type changes from integer to string."));
}
@@ -111,7 +111,7 @@ public class CreateActionTest {
ws.newRequest()
.setParam(CreateAction.PARAM_PROJECT_ID, project.uuid())
- .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid().toString())
+ .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid())
.setParam(CreateAction.PARAM_VALUE, "42")
.execute();
@@ -129,7 +129,7 @@ public class CreateActionTest {
ws.newRequest()
.setParam(CreateAction.PARAM_PROJECT_ID, project.uuid())
- .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid().toString())
+ .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid())
.setParam(CreateAction.PARAM_VALUE, "custom-measure-free-text")
.execute();
@@ -165,7 +165,7 @@ public class CreateActionTest {
ws.newRequest()
.setParam(CreateAction.PARAM_PROJECT_KEY, project.getKey())
- .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid().toString())
+ .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid())
.setParam(CreateAction.PARAM_VALUE, "whatever-value")
.execute();
@@ -183,7 +183,7 @@ public class CreateActionTest {
ws.newRequest()
.setParam(CreateAction.PARAM_PROJECT_ID, project.uuid())
- .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid().toString())
+ .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid())
.setParam(CreateAction.PARAM_VALUE, "4.2")
.execute();
@@ -201,7 +201,7 @@ public class CreateActionTest {
ws.newRequest()
.setParam(CreateAction.PARAM_PROJECT_ID, project.uuid())
- .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid().toString())
+ .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid())
.setParam(CreateAction.PARAM_VALUE, "253")
.execute();
@@ -219,7 +219,7 @@ public class CreateActionTest {
ws.newRequest()
.setParam(CreateAction.PARAM_PROJECT_ID, project.uuid())
- .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid().toString())
+ .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid())
.setParam(CreateAction.PARAM_VALUE, Metric.Level.ERROR.name())
.execute();
@@ -237,7 +237,7 @@ public class CreateActionTest {
String response = ws.newRequest()
.setParam(CreateAction.PARAM_PROJECT_ID, project.uuid())
- .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid().toString())
+ .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid())
.setParam(CreateAction.PARAM_DESCRIPTION, "custom-measure-description")
.setParam(CreateAction.PARAM_VALUE, "custom-measure-free-text")
.execute()
@@ -291,7 +291,7 @@ public class CreateActionTest {
ws.newRequest()
.setParam(CreateAction.PARAM_PROJECT_ID, view.uuid())
- .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid().toString())
+ .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid())
.setParam(CreateAction.PARAM_DESCRIPTION, "custom-measure-description")
.setParam(CreateAction.PARAM_VALUE, "true")
.execute();
@@ -312,7 +312,7 @@ public class CreateActionTest {
ws.newRequest()
.setParam(CreateAction.PARAM_PROJECT_ID, subView.uuid())
- .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid().toString())
+ .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid())
.setParam(CreateAction.PARAM_DESCRIPTION, "custom-measure-description")
.setParam(CreateAction.PARAM_VALUE, "true")
.execute();
@@ -334,7 +334,7 @@ public class CreateActionTest {
ws.newRequest()
.setParam(CreateAction.PARAM_METRIC_ID, "whatever-id")
- .setParam(CreateAction.PARAM_VALUE, metric.getUuid().toString())
+ .setParam(CreateAction.PARAM_VALUE, metric.getUuid())
.execute();
}
@@ -351,7 +351,7 @@ public class CreateActionTest {
ws.newRequest()
.setParam(CreateAction.PARAM_PROJECT_ID, project.uuid())
.setParam(CreateAction.PARAM_PROJECT_KEY, project.getKey())
- .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid().toString())
+ .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid())
.setParam(CreateAction.PARAM_VALUE, "whatever-value")
.execute();
}
@@ -368,7 +368,7 @@ public class CreateActionTest {
ws.newRequest()
.setParam(CreateAction.PARAM_PROJECT_KEY, "another-project-key")
- .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid().toString())
+ .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid())
.setParam(CreateAction.PARAM_VALUE, "whatever-value")
.execute();
}
@@ -385,7 +385,7 @@ public class CreateActionTest {
ws.newRequest()
.setParam(CreateAction.PARAM_PROJECT_ID, "another-project-uuid")
- .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid().toString())
+ .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid())
.setParam(CreateAction.PARAM_VALUE, "whatever-value")
.execute();
}
@@ -417,7 +417,7 @@ public class CreateActionTest {
ws.newRequest()
.setParam(CreateAction.PARAM_PROJECT_ID, project.uuid())
- .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid().toString())
+ .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid())
.setParam(CreateAction.PARAM_METRIC_KEY, metric.getKey())
.setParam(CreateAction.PARAM_VALUE, "whatever-value")
.execute();
@@ -469,7 +469,7 @@ public class CreateActionTest {
ws.newRequest()
.setParam(CreateAction.PARAM_PROJECT_ID, project.uuid())
- .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid().toString())
+ .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid())
.setParam(CreateAction.PARAM_VALUE, "whatever-value")
.execute();
}
@@ -486,7 +486,7 @@ public class CreateActionTest {
ws.newRequest()
.setParam(CreateAction.PARAM_PROJECT_ID, project.uuid())
- .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid().toString())
+ .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid())
.setParam(CreateAction.PARAM_VALUE, "non-correct-boolean-value")
.execute();
}
@@ -502,7 +502,7 @@ public class CreateActionTest {
ws.newRequest()
.setParam(CreateAction.PARAM_PROJECT_ID, project.uuid())
- .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid().toString())
+ .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid())
.setParam(CreateAction.PARAM_VALUE, "whatever-value")
.execute();
}
@@ -520,7 +520,7 @@ public class CreateActionTest {
ws.newRequest()
.setParam(CreateAction.PARAM_PROJECT_ID, directory.uuid())
- .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid().toString())
+ .setParam(CreateAction.PARAM_METRIC_ID, metric.getUuid())
.setParam(CreateAction.PARAM_VALUE, "whatever-value")
.execute();
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/custom/ws/DeleteActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/custom/ws/DeleteActionTest.java
index 179dabb352b..58950cc3494 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/custom/ws/DeleteActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/custom/ws/DeleteActionTest.java
@@ -61,9 +61,9 @@ public class DeleteActionTest {
Action wsDef = ws.getDef();
assertThat(wsDef.deprecatedSince()).isEqualTo("7.4");
- assertThat(wsDef.isInternal()).isEqualTo(false);
+ assertThat(wsDef.isInternal()).isFalse();
assertThat(wsDef.since()).isEqualTo("5.2");
- assertThat(wsDef.isPost()).isEqualTo(true);
+ assertThat(wsDef.isPost()).isTrue();
assertThat(wsDef.changelog()).extracting(Change::getVersion, Change::getDescription).containsOnly(
tuple("8.4", "Param 'id' data type changes from integer to string."));
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/custom/ws/UpdateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/custom/ws/UpdateActionTest.java
index 93320f17756..717487d8800 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/custom/ws/UpdateActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/measure/custom/ws/UpdateActionTest.java
@@ -73,9 +73,9 @@ public class UpdateActionTest {
Action wsDef = ws.getDef();
assertThat(wsDef.deprecatedSince()).isEqualTo("7.4");
- assertThat(wsDef.isInternal()).isEqualTo(false);
+ assertThat(wsDef.isInternal()).isFalse();
assertThat(wsDef.since()).isEqualTo("5.2");
- assertThat(wsDef.isPost()).isEqualTo(true);
+ assertThat(wsDef.isPost()).isTrue();
assertThat(wsDef.changelog()).extracting(Change::getVersion, Change::getDescription).containsOnly(
tuple("8.4", "Param 'id' data type changes from integer to string."));
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/metric/ws/DeleteActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/metric/ws/DeleteActionTest.java
index 6c29327d0e4..dcf914b3507 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/metric/ws/DeleteActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/metric/ws/DeleteActionTest.java
@@ -62,9 +62,9 @@ public class DeleteActionTest {
Action wsDef = ws.getDef();
assertThat(wsDef.deprecatedSince()).isEqualTo("7.7");
- assertThat(wsDef.isInternal()).isEqualTo(false);
+ assertThat(wsDef.isInternal()).isFalse();
assertThat(wsDef.since()).isEqualTo("5.2");
- assertThat(wsDef.isPost()).isEqualTo(true);
+ assertThat(wsDef.isPost()).isTrue();
assertThat(wsDef.changelog()).extracting(Change::getVersion, Change::getDescription)
.containsExactly(
tuple("8.4", "Parameter 'ids' format changes from integer to string."));
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/metric/ws/SearchActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/metric/ws/SearchActionTest.java
index f759201fb13..a7f6e9a6ee0 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/metric/ws/SearchActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/metric/ws/SearchActionTest.java
@@ -53,9 +53,9 @@ public class SearchActionTest {
Action wsDef = ws.getDef();
assertThat(wsDef.deprecatedSince()).isNull();
- assertThat(wsDef.isInternal()).isEqualTo(false);
+ assertThat(wsDef.isInternal()).isFalse();
assertThat(wsDef.since()).isEqualTo("5.2");
- assertThat(wsDef.isPost()).isEqualTo(false);
+ assertThat(wsDef.isPost()).isFalse();
assertThat(wsDef.changelog()).extracting(Change::getVersion, Change::getDescription)
.containsExactlyInAnyOrder(
tuple("8.4", "Field 'id' in the response is deprecated"),
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/metric/ws/UpdateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/metric/ws/UpdateActionTest.java
index 38b9d648765..431e05cb875 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/metric/ws/UpdateActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/metric/ws/UpdateActionTest.java
@@ -79,9 +79,9 @@ public class UpdateActionTest {
Action wsDef = ws.getDef();
assertThat(wsDef.deprecatedSince()).isEqualTo("7.7");
- assertThat(wsDef.isInternal()).isEqualTo(false);
+ assertThat(wsDef.isInternal()).isFalse();
assertThat(wsDef.since()).isEqualTo("5.2");
- assertThat(wsDef.isPost()).isEqualTo(true);
+ assertThat(wsDef.isPost()).isTrue();
assertThat(wsDef.changelog()).extracting(Change::getVersion, Change::getDescription)
.containsExactly(
tuple("8.4", "Parameter 'id' format changes from integer to string."));
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java
index 3214b6cd0b3..332bab6513e 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java
@@ -75,9 +75,9 @@ public class AddGroupActionTest extends BasePermissionWsTest<AddGroupAction> {
public void verify_definition() {
Action wsDef = wsTester.getDef();
- assertThat(wsDef.isInternal()).isEqualTo(false);
+ assertThat(wsDef.isInternal()).isFalse();
assertThat(wsDef.since()).isEqualTo("5.2");
- assertThat(wsDef.isPost()).isEqualTo(true);
+ assertThat(wsDef.isPost()).isTrue();
assertThat(wsDef.changelog()).extracting(Change::getVersion, Change::getDescription).containsOnly(
tuple("8.4", "Parameter 'groupId' is deprecated. Format changes from integer to string. Use 'name' instead."));
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/GroupsActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/GroupsActionTest.java
index cf25ffdb81d..e7d0c7806dd 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/GroupsActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/GroupsActionTest.java
@@ -87,9 +87,9 @@ public class GroupsActionTest extends BasePermissionWsTest<GroupsAction> {
public void verify_definition() {
Action wsDef = wsTester.getDef();
- assertThat(wsDef.isInternal()).isEqualTo(true);
+ assertThat(wsDef.isInternal()).isTrue();
assertThat(wsDef.since()).isEqualTo("5.2");
- assertThat(wsDef.isPost()).isEqualTo(false);
+ assertThat(wsDef.isPost()).isFalse();
assertThat(wsDef.changelog()).extracting(Change::getVersion, Change::getDescription).containsExactlyInAnyOrder(
tuple("8.4", "Field 'id' in the response is deprecated. Format changes from integer to string."),
tuple("7.4", "The response list is returning all groups even those without permissions, the groups with permission are at the top of the list."));
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java
index 0514202b70b..4a27f57f9c9 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java
@@ -79,9 +79,9 @@ public class RemoveGroupActionTest extends BasePermissionWsTest<RemoveGroupActio
public void verify_definition() {
Action wsDef = wsTester.getDef();
- assertThat(wsDef.isInternal()).isEqualTo(false);
+ assertThat(wsDef.isInternal()).isFalse();
assertThat(wsDef.since()).isEqualTo("5.2");
- assertThat(wsDef.isPost()).isEqualTo(true);
+ assertThat(wsDef.isPost()).isTrue();
assertThat(wsDef.changelog()).extracting(Change::getVersion, Change::getDescription).containsOnly(
tuple("8.4", "Parameter 'groupId' is deprecated. Format changes from integer to string. Use 'groupName' instead."));
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/AddGroupToTemplateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/AddGroupToTemplateActionTest.java
index b7f21d221f6..c0f030a4db4 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/AddGroupToTemplateActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/AddGroupToTemplateActionTest.java
@@ -77,9 +77,9 @@ public class AddGroupToTemplateActionTest extends BasePermissionWsTest<AddGroupT
public void verify_definition() {
Action wsDef = wsTester.getDef();
- assertThat(wsDef.isInternal()).isEqualTo(false);
+ assertThat(wsDef.isInternal()).isFalse();
assertThat(wsDef.since()).isEqualTo("5.2");
- assertThat(wsDef.isPost()).isEqualTo(true);
+ assertThat(wsDef.isPost()).isTrue();
assertThat(wsDef.changelog()).extracting(Change::getVersion, Change::getDescription).containsOnly(
tuple("8.4", "Parameter 'groupId' is deprecated. Format changes from integer to string. Use 'groupName' instead."));
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateActionTest.java
index 92e0639b856..c665d4f99d0 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateActionTest.java
@@ -81,9 +81,9 @@ public class RemoveGroupFromTemplateActionTest extends BasePermissionWsTest<Remo
public void verify_definition() {
Action wsDef = wsTester.getDef();
- assertThat(wsDef.isInternal()).isEqualTo(false);
+ assertThat(wsDef.isInternal()).isFalse();
assertThat(wsDef.since()).isEqualTo("5.2");
- assertThat(wsDef.isPost()).isEqualTo(true);
+ assertThat(wsDef.isPost()).isTrue();
assertThat(wsDef.changelog()).extracting(Change::getVersion, Change::getDescription).containsOnly(
tuple("8.4", "Parameter 'groupId' is deprecated. Format changes from integer to string. Use 'groupName' instead."));
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projecttag/ws/SetActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projecttag/ws/SetActionTest.java
index 3699e6ea46c..152311b5ff7 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projecttag/ws/SetActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/projecttag/ws/SetActionTest.java
@@ -120,7 +120,8 @@ public class SetActionTest {
@Test
public void fail_if_tag_does_not_respect_format() {
- assertThatThrownBy(() -> call(project.getKey(), "_finance_"))
+ String projectKey = project.getKey();
+ assertThatThrownBy(() -> call(projectKey, "_finance_"))
.isInstanceOf(BadRequestException.class)
.hasMessage("Tag '_finance_' is invalid. Tags accept only the characters: a-z, 0-9, '+', '-', '#', '.'");
}
@@ -129,7 +130,8 @@ public class SetActionTest {
public void fail_if_not_project_admin() {
userSession.logIn().addProjectPermission(UserRole.USER, project);
- assertThatThrownBy(() -> call(project.getKey(), "platform"))
+ String projectKey = project.getKey();
+ assertThatThrownBy(() -> call(projectKey, "platform"))
.isInstanceOf(ForbiddenException.class);
}
@@ -141,7 +143,8 @@ public class SetActionTest {
@Test
public void fail_if_no_tags() {
- assertThatThrownBy(() -> call(project.getKey(), null))
+ String projectKey = project.getKey();
+ assertThatThrownBy(() -> call(projectKey, null))
.isInstanceOf(IllegalArgumentException.class);
}
@@ -149,7 +152,8 @@ public class SetActionTest {
public void fail_if_component_is_a_view() {
ComponentDto view = db.components().insertView(v -> v.setDbKey("VIEW_KEY"));
- assertThatThrownBy(() -> call(view.getKey(), "point-of-view"))
+ String viewKey = view.getKey();
+ assertThatThrownBy(() -> call(viewKey, "point-of-view"))
.isInstanceOf(NotFoundException.class)
.hasMessage("Project 'VIEW_KEY' not found");
}
@@ -159,7 +163,8 @@ public class SetActionTest {
ComponentDto projectComponent = dbClient.componentDao().selectByUuid(dbSession, project.getUuid()).get();
ComponentDto module = db.components().insertComponent(newModuleDto(projectComponent).setDbKey("MODULE_KEY"));
- assertThatThrownBy(() -> call(module.getKey(), "modz"))
+ String moduleKey = module.getKey();
+ assertThatThrownBy(() -> call(moduleKey, "modz"))
.isInstanceOf(NotFoundException.class)
.hasMessage("Project 'MODULE_KEY' not found");
}
@@ -169,7 +174,8 @@ public class SetActionTest {
ComponentDto projectComponent = dbClient.componentDao().selectByUuid(dbSession, project.getUuid()).get();
ComponentDto file = db.components().insertComponent(newFileDto(projectComponent).setDbKey("FILE_KEY"));
- assertThatThrownBy(() -> call(file.getKey(), "secret"))
+ String fileKey = file.getKey();
+ assertThatThrownBy(() -> call(fileKey, "secret"))
.isInstanceOf(NotFoundException.class)
.hasMessage("Project 'FILE_KEY' not found");
}
@@ -181,9 +187,10 @@ public class SetActionTest {
userSession.logIn().addProjectPermission(UserRole.USER, project);
ComponentDto branch = db.components().insertProjectBranch(project);
- assertThatThrownBy(() -> call(branch.getDbKey(), "secret"))
+ String branchDbKey = branch.getDbKey();
+ assertThatThrownBy(() -> call(branchDbKey, "secret"))
.isInstanceOf(NotFoundException.class)
- .hasMessage(format("Project '%s' not found", branch.getDbKey()));
+ .hasMessage(format("Project '%s' not found", branchDbKey));
}
@Test
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryImplTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryImplTest.java
index e0da7a31952..c8d152eb1ba 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryImplTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/qualityprofile/QProfileFactoryImplTest.java
@@ -307,30 +307,30 @@ public class QProfileFactoryImplTest {
assertThat(db.getDbClient().qualityProfileDao().selectBuiltInRuleProfiles(dbSession))
.extracting(RulesProfileDto::getUuid)
.containsExactly(rulesProfile.getUuid());
- assertThat(db.countRowsOfTable(dbSession, "active_rules")).isGreaterThan(0);
- assertThat(db.countRowsOfTable(dbSession, "active_rule_parameters")).isGreaterThan(0);
- assertThat(db.countRowsOfTable(dbSession, "qprofile_changes")).isGreaterThan(0);
+ assertThat(db.countRowsOfTable(dbSession, "active_rules")).isPositive();
+ assertThat(db.countRowsOfTable(dbSession, "active_rule_parameters")).isPositive();
+ assertThat(db.countRowsOfTable(dbSession, "qprofile_changes")).isPositive();
}
private void assertThatCustomProfileDoesNotExist(QProfileDto profile) {
- assertThat(db.countSql(dbSession, "select count(*) from org_qprofiles where uuid = '" + profile.getKee() + "'")).isEqualTo(0);
- assertThat(db.countSql(dbSession, "select count(*) from project_qprofiles where profile_key = '" + profile.getKee() + "'")).isEqualTo(0);
- assertThat(db.countSql(dbSession, "select count(*) from default_qprofiles where qprofile_uuid = '" + profile.getKee() + "'")).isEqualTo(0);
- assertThat(db.countSql(dbSession, "select count(*) from rules_profiles where uuid = '" + profile.getRulesProfileUuid() + "'")).isEqualTo(0);
- assertThat(db.countSql(dbSession, "select count(*) from active_rules where profile_uuid = '" + profile.getRulesProfileUuid() + "'")).isEqualTo(0);
- assertThat(db.countSql(dbSession, "select count(*) from qprofile_changes where rules_profile_uuid = '" + profile.getRulesProfileUuid() + "'")).isEqualTo(0);
+ assertThat(db.countSql(dbSession, "select count(*) from org_qprofiles where uuid = '" + profile.getKee() + "'")).isZero();
+ assertThat(db.countSql(dbSession, "select count(*) from project_qprofiles where profile_key = '" + profile.getKee() + "'")).isZero();
+ assertThat(db.countSql(dbSession, "select count(*) from default_qprofiles where qprofile_uuid = '" + profile.getKee() + "'")).isZero();
+ assertThat(db.countSql(dbSession, "select count(*) from rules_profiles where uuid = '" + profile.getRulesProfileUuid() + "'")).isZero();
+ assertThat(db.countSql(dbSession, "select count(*) from active_rules where profile_uuid = '" + profile.getRulesProfileUuid() + "'")).isZero();
+ assertThat(db.countSql(dbSession, "select count(*) from qprofile_changes where rules_profile_uuid = '" + profile.getRulesProfileUuid() + "'")).isZero();
// TODO active_rule_parameters
}
private void assertThatCustomProfileExists(QProfileDto profile) {
- assertThat(db.countSql(dbSession, "select count(*) from org_qprofiles where uuid = '" + profile.getKee() + "'")).isGreaterThan(0);
+ assertThat(db.countSql(dbSession, "select count(*) from org_qprofiles where uuid = '" + profile.getKee() + "'")).isPositive();
// assertThat(db.countSql(dbSession, "select count(*) from project_qprofiles where profile_key = '" + profile.getKee() +
// "'")).isGreaterThan(0);
// assertThat(db.countSql(dbSession, "select count(*) from default_qprofiles where qprofile_uuid = '" + profile.getKee() +
// "'")).isGreaterThan(0);
assertThat(db.countSql(dbSession, "select count(*) from rules_profiles where uuid = '" + profile.getRulesProfileUuid() + "'")).isEqualTo(1);
- assertThat(db.countSql(dbSession, "select count(*) from active_rules where profile_uuid = '" + profile.getRulesProfileUuid() + "'")).isGreaterThan(0);
- assertThat(db.countSql(dbSession, "select count(*) from qprofile_changes where rules_profile_uuid = '" + profile.getRulesProfileUuid() + "'")).isGreaterThan(0);
+ assertThat(db.countSql(dbSession, "select count(*) from active_rules where profile_uuid = '" + profile.getRulesProfileUuid() + "'")).isPositive();
+ assertThat(db.countSql(dbSession, "select count(*) from qprofile_changes where rules_profile_uuid = '" + profile.getRulesProfileUuid() + "'")).isPositive();
// TODO active_rule_parameters
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/UpdateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/UpdateActionTest.java
index 6361ec3d520..7ce0433ffa7 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/UpdateActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/UpdateActionTest.java
@@ -56,9 +56,9 @@ public class UpdateActionTest {
public void verify_definition() {
Action wsDef = ws.getDef();
- assertThat(wsDef.isInternal()).isEqualTo(false);
+ assertThat(wsDef.isInternal()).isFalse();
assertThat(wsDef.since()).isEqualTo("5.2");
- assertThat(wsDef.isPost()).isEqualTo(true);
+ assertThat(wsDef.isPost()).isTrue();
assertThat(wsDef.changelog()).extracting(Change::getVersion, Change::getDescription).isNotEmpty();
}