aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-es
diff options
context:
space:
mode:
authorJacek <jacek.poreda@sonarsource.com>2020-06-15 11:37:14 +0200
committersonartech <sonartech@sonarsource.com>2020-06-26 20:04:57 +0000
commit741d14c01451344f783208b061b60838386dee4a (patch)
tree21bedaa3796f81c02966fc31914fbe99ac0b2959 /server/sonar-webserver-es
parentb1b710b8e24c2bebf13a108ee75a3418f32fa6da (diff)
downloadsonarqube-741d14c01451344f783208b061b60838386dee4a.tar.gz
sonarqube-741d14c01451344f783208b061b60838386dee4a.zip
SONAR-13398 Verify needIssue sync flag at project level
Diffstat (limited to 'server/sonar-webserver-es')
-rw-r--r--server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndexSyncProgressChecker.java16
-rw-r--r--server/sonar-webserver-es/src/test/java/org/sonar/server/issue/index/IssueIndexSyncProgressCheckerTest.java16
2 files changed, 11 insertions, 21 deletions
diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndexSyncProgressChecker.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndexSyncProgressChecker.java
index b638e3ba2cf..8af309c34cf 100644
--- a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndexSyncProgressChecker.java
+++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndexSyncProgressChecker.java
@@ -23,7 +23,6 @@ import com.google.common.collect.Sets;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import javax.annotation.Nullable;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.server.es.EsIndexSyncInProgressException;
@@ -41,25 +40,16 @@ public class IssueIndexSyncProgressChecker {
return new IssueSyncProgress(completed, total);
}
- public void checkIfAnyComponentsNeedIssueSync(DbSession dbSession, List<String> componentKeys, @Nullable String branch,
- @Nullable String pullRequest) {
- boolean needIssueSync = dbClient.branchDao().doAnyOfComponentsNeedIssueSync(dbSession, componentKeys, branch, pullRequest);
+ public void checkIfAnyComponentsNeedIssueSync(DbSession dbSession, List<String> componentKeys) {
+ boolean needIssueSync = dbClient.branchDao().doAnyOfComponentsNeedIssueSync(dbSession, componentKeys);
if (needIssueSync) {
throw new EsIndexSyncInProgressException(IssueIndexDefinition.TYPE_ISSUE.getMainType(),
"Results are temporarily unavailable. Indexing of issues is in progress.");
}
}
- public void checkIfAnyComponentsNeedIssueSync(DbSession dbSession, List<String> componentKeys) {
- checkIfAnyComponentsNeedIssueSync(dbSession, componentKeys, null, null);
- }
-
public void checkIfComponentNeedIssueSync(DbSession dbSession, String componentKey) {
- checkIfComponentNeedIssueSync(dbSession, componentKey, null);
- }
-
- public void checkIfComponentNeedIssueSync(DbSession dbSession, String componentKey, @Nullable String branchKey) {
- checkIfAnyComponentsNeedIssueSync(dbSession, Collections.singletonList(componentKey), branchKey, null);
+ checkIfAnyComponentsNeedIssueSync(dbSession, Collections.singletonList(componentKey));
}
/**
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 d41cf3188da..7ef82fa5ad0 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
@@ -121,7 +121,7 @@ public class IssueIndexSyncProgressCheckerTest {
ProjectDto projectDto2 = insertProjectWithBranches(true, 0);
DbSession session = db.getSession();
List<String> projectKeys = Arrays.asList(projectDto1.getKey(), projectDto2.getKey());
- assertThatThrownBy(() -> underTest.checkIfAnyComponentsNeedIssueSync(session, projectKeys, null, null))
+ assertThatThrownBy(() -> underTest.checkIfAnyComponentsNeedIssueSync(session, projectKeys))
.isInstanceOf(EsIndexSyncInProgressException.class)
.hasFieldOrPropertyWithValue("httpCode", 503)
.hasMessage("Results are temporarily unavailable. Indexing of issues is in progress.");
@@ -129,10 +129,10 @@ public class IssueIndexSyncProgressCheckerTest {
@Test
public void checkIfAnyComponentsIssueSyncInProgress_does_not_throw_exception_if_all_components_have_need_issue_sync_FALSE() {
- underTest.checkIfAnyComponentsNeedIssueSync(db.getSession(), Collections.emptyList(), null, null);
+ underTest.checkIfAnyComponentsNeedIssueSync(db.getSession(), Collections.emptyList());
ProjectDto projectDto1 = insertProjectWithBranches(false, 0);
ProjectDto projectDto2 = insertProjectWithBranches(false, 0);
- underTest.checkIfAnyComponentsNeedIssueSync(db.getSession(), Arrays.asList(projectDto1.getKey(), projectDto2.getKey()), null, null);
+ underTest.checkIfAnyComponentsNeedIssueSync(db.getSession(), Arrays.asList(projectDto1.getKey(), projectDto2.getKey()));
}
@Test
@@ -142,7 +142,7 @@ public class IssueIndexSyncProgressCheckerTest {
DbSession session = db.getSession();
List<String> projectKeys = Arrays.asList(projectDto1.getKey(), projectDto2.getKey());
- assertThatThrownBy(() -> underTest.checkIfAnyComponentsNeedIssueSync(session, projectKeys, null, null))
+ assertThatThrownBy(() -> underTest.checkIfAnyComponentsNeedIssueSync(session, projectKeys))
.isInstanceOf(EsIndexSyncInProgressException.class)
.hasFieldOrPropertyWithValue("httpCode", 503)
.hasMessage("Results are temporarily unavailable. Indexing of issues is in progress.");
@@ -156,12 +156,12 @@ public class IssueIndexSyncProgressCheckerTest {
DbSession session = db.getSession();
List<String> projectKey1 = singletonList(projectDto2.getKey());
// do nothing when need issue sync false
- underTest.checkIfAnyComponentsNeedIssueSync(session, projectKey1, null, null);
+ underTest.checkIfAnyComponentsNeedIssueSync(session, projectKey1);
List<String> projectKey2 = singletonList(projectDto1.getKey());
// throws if flag set to TRUE
assertThatThrownBy(() -> underTest.checkIfAnyComponentsNeedIssueSync(session,
- projectKey2, null, null))
+ projectKey2))
.isInstanceOf(EsIndexSyncInProgressException.class)
.hasFieldOrPropertyWithValue("httpCode", 503)
.hasMessage("Results are temporarily unavailable. Indexing of issues is in progress.");
@@ -179,8 +179,8 @@ public class IssueIndexSyncProgressCheckerTest {
List<String> appViewOrSubviewKeys = Arrays.asList(projectDto1.getKey(), app.getDbKey(), view.getDbKey(), subview.getDbKey());
// throws if flag set to TRUE
- assertThatThrownBy(() -> underTest.checkIfAnyComponentsIssueSyncInProgress(session,
- appViewOrSubviewKeys, null, null))
+ assertThatThrownBy(() -> underTest.checkIfAnyComponentsNeedIssueSync(session,
+ appViewOrSubviewKeys))
.isInstanceOf(EsIndexSyncInProgressException.class)
.hasFieldOrPropertyWithValue("httpCode", 503)
.hasMessage("Results are temporarily unavailable. Indexing of issues is in progress.");