aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorStephane Gamard <stephane.gamard@searchbox.com>2014-05-21 21:03:49 +0200
committerStephane Gamard <stephane.gamard@searchbox.com>2014-05-22 10:01:29 +0200
commitf0bfe6e45dd30c76cea0f85e57db3b1d7157c11e (patch)
treee9dabfe21bb2cac77881a308623c9c413cd5ec66 /sonar-server
parent7564e4cfc94f143d4c7132ffa2f62ac1bbb3356d (diff)
downloadsonarqube-f0bfe6e45dd30c76cea0f85e57db3b1d7157c11e.tar.gz
sonarqube-f0bfe6e45dd30c76cea0f85e57db3b1d7157c11e.zip
DAOv.2 - removed explicit refresh
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleServiceMediumTest.java15
-rw-r--r--sonar-server/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexMediumTest.java6
-rw-r--r--sonar-server/src/test/java/org/sonar/server/rule2/RegisterRulesMediumTest.java4
-rw-r--r--sonar-server/src/test/java/org/sonar/server/rule2/RuleDataMediumTest.java12
-rw-r--r--sonar-server/src/test/java/org/sonar/server/rule2/RuleServiceMediumTest.java6
-rw-r--r--sonar-server/src/test/java/org/sonar/server/rule2/index/RuleIndexMediumTest.java34
6 files changed, 36 insertions, 41 deletions
diff --git a/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleServiceMediumTest.java b/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleServiceMediumTest.java
index 616db7de761..6a4ffa443bf 100644
--- a/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleServiceMediumTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/qualityprofile/ActiveRuleServiceMediumTest.java
@@ -32,7 +32,6 @@ import org.sonar.core.persistence.DbSession;
import org.sonar.core.qualityprofile.db.ActiveRuleDto;
import org.sonar.core.qualityprofile.db.ActiveRuleKey;
import org.sonar.core.qualityprofile.db.ActiveRuleParamDto;
-import org.sonar.core.qualityprofile.db.QualityProfileDao;
import org.sonar.core.qualityprofile.db.QualityProfileDto;
import org.sonar.core.qualityprofile.db.QualityProfileKey;
import org.sonar.core.rule.RuleDto;
@@ -40,8 +39,6 @@ import org.sonar.server.db.DbClient;
import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.qualityprofile.index.ActiveRuleIndex;
-import org.sonar.server.qualityprofile.persistence.ActiveRuleDao;
-import org.sonar.server.rule2.persistence.RuleDao;
import org.sonar.server.tester.ServerTester;
import org.sonar.server.user.MockUserSession;
@@ -93,7 +90,7 @@ public class ActiveRuleServiceMediumTest {
assertThat(params.get(0).getValue()).isEqualTo("7");
// verify es
- index.refresh();
+
ActiveRule activeRule = index.getByKey(activation.getKey());
assertThat(activeRule).isNotNull();
assertThat(activeRule.severity()).isEqualTo(Severity.BLOCKER);
@@ -118,7 +115,7 @@ public class ActiveRuleServiceMediumTest {
assertThat(params.get(0).getValue()).isEqualTo("10");
// verify es
- index.refresh();
+
ActiveRule activeRule = index.getByKey(activation.getKey());
assertThat(activeRule).isNotNull();
assertThat(activeRule.severity()).isEqualTo(Severity.MINOR);
@@ -151,7 +148,7 @@ public class ActiveRuleServiceMediumTest {
assertThat(params.get(0).getValue()).isEqualTo("42");
// verify es
- index.refresh();
+
ActiveRule activeRule = index.getByKey(activation.getKey());
assertThat(activeRule).isNotNull();
assertThat(activeRule.severity()).isEqualTo(Severity.CRITICAL);
@@ -188,7 +185,7 @@ public class ActiveRuleServiceMediumTest {
assertThat(params.get(0).getValue()).isEqualTo("42");
// verify es
- index.refresh();
+
ActiveRule activeRule = index.getByKey(activation.getKey());
assertThat(activeRule).isNotNull();
assertThat(activeRule.severity()).isEqualTo(Severity.CRITICAL);
@@ -220,7 +217,7 @@ public class ActiveRuleServiceMediumTest {
assertThat(params.get(0).getValue()).isEqualTo("10");
// verify es
- index.refresh();
+
ActiveRule activeRule = index.getByKey(activation.getKey());
assertThat(activeRule).isNotNull();
assertThat(activeRule.severity()).isEqualTo(Severity.MINOR);
@@ -399,7 +396,7 @@ public class ActiveRuleServiceMediumTest {
//TODO test params
// verify es
- index.refresh();
+
ActiveRule activeRule = index.getByKey(key);
assertThat(activeRule).isNull();
}
diff --git a/sonar-server/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexMediumTest.java b/sonar-server/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexMediumTest.java
index 3fdd7ab8163..7fa084912ad 100644
--- a/sonar-server/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexMediumTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/qualityprofile/index/ActiveRuleIndexMediumTest.java
@@ -93,7 +93,7 @@ public class ActiveRuleIndexMediumTest {
assertThat(persistedDtos).hasSize(1);
// verify that activeRules are indexed in es
- index.refresh();
+
ActiveRule hit = index.getByKey(activeRule.getKey());
@@ -148,7 +148,7 @@ public class ActiveRuleIndexMediumTest {
assertThat(persistedDtos).hasSize(2);
// verify that activeRulesParams are indexed in es
- index.refresh();
+
ActiveRule rule = index.getByKey(activeRule.getKey());
assertThat(rule.params()).hasSize(2);
@@ -201,7 +201,7 @@ public class ActiveRuleIndexMediumTest {
assertThat(persistedDtos).hasSize(1);
// verify that activeRules are indexed in es
- index.refresh();
+
Collection<ActiveRule> hits = index.findByRule(RuleKey.of("javascript", "S001"));
diff --git a/sonar-server/src/test/java/org/sonar/server/rule2/RegisterRulesMediumTest.java b/sonar-server/src/test/java/org/sonar/server/rule2/RegisterRulesMediumTest.java
index 111ecb4f6c7..10e12ce01ef 100644
--- a/sonar-server/src/test/java/org/sonar/server/rule2/RegisterRulesMediumTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/rule2/RegisterRulesMediumTest.java
@@ -50,7 +50,7 @@ public class RegisterRulesMediumTest {
verifyRulesInDb();
RuleIndex index = tester.get(RuleIndex.class);
- index.refresh();
+
RuleResult searchResult = index.search(new RuleQuery(), new QueryOptions());
assertThat(searchResult.getTotal()).isEqualTo(2);
@@ -74,7 +74,7 @@ public class RegisterRulesMediumTest {
tester.get(Platform.class).restart();
index = tester.get(RuleIndex.class);
- index.refresh();
+
verifyRulesInDb();
searchResult = index.search(new RuleQuery().setKey("xoo:x1"), new QueryOptions());
assertThat(searchResult.getTotal()).isEqualTo(1);
diff --git a/sonar-server/src/test/java/org/sonar/server/rule2/RuleDataMediumTest.java b/sonar-server/src/test/java/org/sonar/server/rule2/RuleDataMediumTest.java
index 8fe89796d6a..e2627bbb87a 100644
--- a/sonar-server/src/test/java/org/sonar/server/rule2/RuleDataMediumTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/rule2/RuleDataMediumTest.java
@@ -89,7 +89,7 @@ public class RuleDataMediumTest {
assertThat(persistedDto.getUpdatedAt()).isNotNull();
// verify that rule is indexed in es
- index.refresh();
+
Rule hit = index.getByKey(ruleKey);
assertThat(hit).isNotNull();
assertThat(hit.key().repository()).isEqualTo(ruleKey.repository());
@@ -139,7 +139,7 @@ public class RuleDataMediumTest {
assertThat(persistedDtos).hasSize(2);
// verify that parameters are indexed in es
- index.refresh();
+
Rule hit = index.getByKey(ruleKey);
assertThat(hit).isNotNull();
assertThat(hit.key()).isNotNull();
@@ -162,7 +162,7 @@ public class RuleDataMediumTest {
dbSession.commit();
// verify that parameters are indexed in es
- index.refresh();
+
Rule hit = index.getByKey(ruleKey);
assertThat(hit.tags()).containsExactly("hello");
assertThat(hit.name()).isEqualTo("first name");
@@ -174,7 +174,7 @@ public class RuleDataMediumTest {
dbSession.commit();
// verify that parameters are updated in es
- index.refresh();
+
hit = index.getByKey(ruleKey);
assertThat(hit.tags()).containsExactly("world");
assertThat(hit.name()).isEqualTo("second name");
@@ -207,7 +207,7 @@ public class RuleDataMediumTest {
dbSession.commit();
// verify that parameters are indexed in es
- index.refresh();
+
Rule hit = index.getByKey(ruleKey);
assertThat(hit.params()).hasSize(2);
@@ -225,7 +225,7 @@ public class RuleDataMediumTest {
dbSession.commit();
// verify that parameters are updated in es
- index.refresh();
+
hit = index.getByKey(ruleKey);
assertThat(hit.params()).hasSize(2);
diff --git a/sonar-server/src/test/java/org/sonar/server/rule2/RuleServiceMediumTest.java b/sonar-server/src/test/java/org/sonar/server/rule2/RuleServiceMediumTest.java
index daca32ff603..c5293d406e8 100644
--- a/sonar-server/src/test/java/org/sonar/server/rule2/RuleServiceMediumTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/rule2/RuleServiceMediumTest.java
@@ -140,7 +140,7 @@ public class RuleServiceMediumTest {
assertThat(dto.getNoteUserLogin()).isEqualTo("marius");
// verify es
- index.refresh();
+
Rule rule = index.getByKey(ruleKey);
// TODO
assertThat(rule.markdownNote()).isEqualTo("my *note*");
@@ -156,7 +156,7 @@ public class RuleServiceMediumTest {
assertThat(dto.getNoteCreatedAt()).isNull();
assertThat(dto.getNoteUpdatedAt()).isNull();
assertThat(dto.getNoteUserLogin()).isNull();
- index.refresh();
+
rule = index.getByKey(ruleKey);
assertThat(rule.markdownNote()).isNull();
assertThat(rule.noteCreatedAt()).isNull();
@@ -180,7 +180,7 @@ public class RuleServiceMediumTest {
.setSystemTags(Sets.newHashSet("")), dbSession);
dbSession.commit();
- index.refresh();
+
Set<String> tags = index.terms(RuleNormalizer.RuleField.TAGS.key(),
RuleNormalizer.RuleField.SYSTEM_TAGS.key());
diff --git a/sonar-server/src/test/java/org/sonar/server/rule2/index/RuleIndexMediumTest.java b/sonar-server/src/test/java/org/sonar/server/rule2/index/RuleIndexMediumTest.java
index 22afd0a2dea..9a0173dc2ae 100644
--- a/sonar-server/src/test/java/org/sonar/server/rule2/index/RuleIndexMediumTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/rule2/index/RuleIndexMediumTest.java
@@ -34,11 +34,9 @@ import org.sonar.check.Cardinality;
import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
import org.sonar.core.qualityprofile.db.ActiveRuleDto;
-import org.sonar.core.qualityprofile.db.QualityProfileDao;
import org.sonar.core.qualityprofile.db.QualityProfileDto;
import org.sonar.core.rule.RuleDto;
import org.sonar.server.db.DbClient;
-import org.sonar.server.qualityprofile.persistence.ActiveRuleDao;
import org.sonar.server.rule2.Rule;
import org.sonar.server.rule2.persistence.RuleDao;
import org.sonar.server.search.QueryOptions;
@@ -79,7 +77,7 @@ public class RuleIndexMediumTest {
dao.insert(ruleDto, dbSession);
dbSession.commit();
- index.refresh();
+
Rule rule = index.getByKey(RuleKey.of("javascript", "S001"));
@@ -109,7 +107,7 @@ public class RuleIndexMediumTest {
dao.insert(newRuleDto(RuleKey.of("cobol", "S001")).setRuleKey("X001"), dbSession);
dao.insert(newRuleDto(RuleKey.of("php", "S002")), dbSession);
dbSession.commit();
- index.refresh();
+
// should not have any facet!
RuleQuery query = new RuleQuery();
@@ -130,7 +128,7 @@ public class RuleIndexMediumTest {
public void return_all_doc_fields_by_default() {
dao.insert(newRuleDto(RuleKey.of("javascript", "S001")), dbSession);
dbSession.commit();
- index.refresh();
+
QueryOptions options = new QueryOptions().setFieldsToReturn(null);
Result<Rule> results = index.search(new RuleQuery(), options);
@@ -147,7 +145,7 @@ public class RuleIndexMediumTest {
public void select_doc_fields_to_return() {
dao.insert(newRuleDto(RuleKey.of("javascript", "S001")), dbSession);
dbSession.commit();
- index.refresh();
+
QueryOptions options = new QueryOptions();
options.addFieldsToReturn(RuleNormalizer.RuleField.LANGUAGE.key(), RuleNormalizer.RuleField.STATUS.key());
@@ -171,7 +169,7 @@ public class RuleIndexMediumTest {
dao.insert(newRuleDto(RuleKey.of("javascript", "S001"))
.setName("testing the partial match and matching of rule"), dbSession);
dbSession.commit();
- index.refresh();
+
// substring
RuleQuery query = new RuleQuery().setQueryText("test");
@@ -198,7 +196,7 @@ public class RuleIndexMediumTest {
.setRuleKey("X001"), dbSession);
dao.insert(newRuleDto(RuleKey.of("php", "S002")), dbSession);
dbSession.commit();
- index.refresh();
+
// key
RuleQuery query = new RuleQuery().setQueryText("X001");
@@ -219,7 +217,7 @@ public class RuleIndexMediumTest {
dao.insert(newRuleDto(RuleKey.of("javascript", "S001")), dbSession);
dao.insert(newRuleDto(RuleKey.of("java", "S002")), dbSession);
dbSession.commit();
- index.refresh();
+
Result results = index.search(new RuleQuery(), new QueryOptions());
@@ -232,7 +230,7 @@ public class RuleIndexMediumTest {
dao.insert(newRuleDto(RuleKey.of("findbugs", "S001")), dbSession);
dao.insert(newRuleDto(RuleKey.of("pmd", "S002")), dbSession);
dbSession.commit();
- index.refresh();
+
RuleQuery query = new RuleQuery().setRepositories(Arrays.asList("checkstyle", "pmd"));
Result<Rule> results = index.search(query, new QueryOptions());
@@ -253,7 +251,7 @@ public class RuleIndexMediumTest {
dao.insert(newRuleDto(RuleKey.of("java", "S001")).setLanguage("java"), dbSession);
dao.insert(newRuleDto(RuleKey.of("javascript", "S002")).setLanguage("js"), dbSession);
dbSession.commit();
- index.refresh();
+
RuleQuery query = new RuleQuery().setLanguages(Arrays.asList("cobol", "js"));
Result<Rule> results = index.search(query, new QueryOptions());
@@ -279,7 +277,7 @@ public class RuleIndexMediumTest {
dao.insert(newRuleDto(RuleKey.of("java", "S001")).setSeverity(Severity.BLOCKER), dbSession);
dao.insert(newRuleDto(RuleKey.of("java", "S002")).setSeverity(Severity.INFO), dbSession);
dbSession.commit();
- index.refresh();
+
RuleQuery query = new RuleQuery().setSeverities(Arrays.asList(Severity.INFO, Severity.MINOR));
Result<Rule> results = index.search(query, new QueryOptions());
@@ -304,7 +302,7 @@ public class RuleIndexMediumTest {
dao.insert(newRuleDto(RuleKey.of("java", "S001")).setStatus(RuleStatus.BETA.name()), dbSession);
dao.insert(newRuleDto(RuleKey.of("java", "S002")).setStatus(RuleStatus.READY.name()), dbSession);
dbSession.commit();
- index.refresh();
+
RuleQuery query = new RuleQuery().setStatuses(Arrays.asList(RuleStatus.DEPRECATED, RuleStatus.READY));
Result<Rule> results = index.search(query, new QueryOptions());
@@ -330,7 +328,7 @@ public class RuleIndexMediumTest {
dao.insert(newRuleDto(RuleKey.of("java", "S002")).setName("ABC"), dbSession);
dao.insert(newRuleDto(RuleKey.of("java", "S003")).setName("FGH"), dbSession);
dbSession.commit();
- index.refresh();
+
// ascending
RuleQuery query = new RuleQuery().setSortField(RuleQuery.SortField.NAME);
@@ -352,7 +350,7 @@ public class RuleIndexMediumTest {
dao.insert(newRuleDto(RuleKey.of("java", "S001")).setLanguage("java"), dbSession);
dao.insert(newRuleDto(RuleKey.of("java", "S002")).setLanguage("php"), dbSession);
dbSession.commit();
- index.refresh();
+
// ascending
RuleQuery query = new RuleQuery().setSortField(RuleQuery.SortField.LANGUAGE);
@@ -395,7 +393,7 @@ public class RuleIndexMediumTest {
dbSession.commit();
- index.refresh();
+
RuleResult result;
@@ -433,7 +431,7 @@ public class RuleIndexMediumTest {
dao.insert(newRuleDto(RuleKey.of("java", "S001")).setTags(ImmutableSet.of("tag1")), dbSession);
dao.insert(newRuleDto(RuleKey.of("java", "S002")).setTags(ImmutableSet.of("tag2")), dbSession);
dbSession.commit();
- index.refresh();
+
// find all
RuleQuery query = new RuleQuery();
@@ -477,7 +475,7 @@ public class RuleIndexMediumTest {
dao.insert(newRuleDto(RuleKey.of("java", "S002")), dbSession);
dao.insert(newRuleDto(RuleKey.of("java", "S003")), dbSession);
dbSession.commit();
- index.refresh();
+
// from 0 to 1 included
QueryOptions options = new QueryOptions();