aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBelen Pruvost <belen.pruvost@sonarsource.com>2022-01-28 11:25:24 -0300
committersonartech <sonartech@sonarsource.com>2022-01-28 20:03:09 +0000
commit8b8046f91a7f0dd72e85aa9ecf217dc2c2fd5356 (patch)
tree55327b9da9046b324e512b6e4d94f64147320a58
parent2f30a4b868f310faf3d5825b7fbe93de2e105321 (diff)
downloadsonarqube-8b8046f91a7f0dd72e85aa9ecf217dc2c2fd5356.tar.gz
sonarqube-8b8046f91a7f0dd72e85aa9ecf217dc2c2fd5356.zip
[NO-JIRA] Fix unstable Unit Test for PurgeCommands
-rw-r--r--server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeCommandsTest.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeCommandsTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeCommandsTest.java
index 9d617149791..5321db94f83 100644
--- a/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeCommandsTest.java
+++ b/server/sonar-db-dao/src/test/java/org/sonar/db/purge/PurgeCommandsTest.java
@@ -22,6 +22,7 @@ package org.sonar.db.purge;
import com.tngtech.java.junit.dataprovider.DataProvider;
import com.tngtech.java.junit.dataprovider.DataProviderRunner;
import com.tngtech.java.junit.dataprovider.UseDataProvider;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
@@ -541,17 +542,20 @@ public class PurgeCommandsTest {
RuleDefinitionDto rule = dbTester.rules().insert();
dbTester.components().insertComponent(projectOrView);
ComponentDto file = dbTester.components().insertComponent(newFileDto(projectOrView));
+ List<String> issueKeys = new ArrayList<>();
int count = 5;
IntStream.range(0, count).forEach(i -> {
IssueDto issue = dbTester.issues().insertIssue(t -> t.setRule(rule).setProject(projectOrView).setComponent(projectOrView));
dbTester.issues().insertNewCodeReferenceIssue(newCodeReferenceIssue(issue));
issue = dbTester.issues().insertIssue(t -> t.setRule(rule).setProject(projectOrView).setComponent(file));
dbTester.issues().insertNewCodeReferenceIssue(newCodeReferenceIssue(issue));
+ issueKeys.add("'" + issue.getKey() + "'");
});
underTest.deleteIssues(projectOrView.uuid());
- assertThat(dbTester.countRowsOfTable("NEW_CODE_REFERENCE_ISSUES")).isZero();
+ assertThat(dbTester.countSql("select count(uuid) from new_code_reference_issues where issue_key in (" +
+ String.join(", ", issueKeys) + ")")).isZero();
}
@Test
@@ -862,14 +866,14 @@ public class PurgeCommandsTest {
@DataProvider
public static Object[] projects() {
- return new Object[] {
+ return new Object[]{
ComponentTesting.newPrivateProjectDto(), ComponentTesting.newPublicProjectDto(),
};
}
@DataProvider
public static Object[] views() {
- return new Object[] {
+ return new Object[]{
ComponentTesting.newPortfolio(), ComponentTesting.newApplication()
};
}