From: Julien Lancelot Date: Thu, 25 Feb 2016 12:36:19 +0000 (+0100) Subject: SONAR-7330 Fix BackendCleanupMediumTest X-Git-Tag: 5.5-M6~67 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b19087b20734047e67a144d7240c2400d956cf97;p=sonarqube.git SONAR-7330 Fix BackendCleanupMediumTest --- diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/BackendCleanupMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/BackendCleanupMediumTest.java index b48c0bbc64d..527e6d0f3b7 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/platform/BackendCleanupMediumTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/platform/BackendCleanupMediumTest.java @@ -34,7 +34,6 @@ import org.sonar.server.issue.IssueTesting; import org.sonar.server.issue.index.IssueIndexDefinition; import org.sonar.server.rule.index.RuleDoc; import org.sonar.server.rule.index.RuleIndexDefinition; -import org.sonar.server.rule.index.RuleNormalizer; import org.sonar.server.search.IndexDefinition; import org.sonar.server.view.index.ViewDoc; import org.sonar.server.view.index.ViewIndexDefinition; @@ -51,7 +50,7 @@ public class BackendCleanupMediumTest { new RuleIndexDefinition(new Settings()), new IssueIndexDefinition(new Settings()), new ViewIndexDefinition(new Settings()) - ); + ); @Rule public DbTester dbTester = DbTester.create(System2.INSTANCE); @@ -78,7 +77,7 @@ public class BackendCleanupMediumTest { @Test public void clear_indexes() throws Exception { esTester.putDocuments(IssueIndexDefinition.INDEX, IssueIndexDefinition.TYPE_ISSUE, IssueTesting.newDoc()); - esTester.putDocuments(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexType(), newRuleDoc()); + esTester.putDocuments(RuleIndexDefinition.INDEX, RuleIndexDefinition.TYPE_RULE, newRuleDoc()); backendCleanup.clearIndexes(); @@ -89,7 +88,7 @@ public class BackendCleanupMediumTest { public void clear_all() throws Exception { dbTester.prepareDbUnit(getClass(), "shared.xml"); esTester.putDocuments(IssueIndexDefinition.INDEX, IssueIndexDefinition.TYPE_ISSUE, IssueTesting.newDoc()); - esTester.putDocuments(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexType(), newRuleDoc()); + esTester.putDocuments(RuleIndexDefinition.INDEX, RuleIndexDefinition.TYPE_RULE, newRuleDoc()); backendCleanup.clearAll(); @@ -107,22 +106,25 @@ public class BackendCleanupMediumTest { dbTester.prepareDbUnit(getClass(), "shared.xml"); esTester.putDocuments(IssueIndexDefinition.INDEX, IssueIndexDefinition.TYPE_ISSUE, IssueTesting.newDoc()); esTester.putDocuments(ViewIndexDefinition.INDEX, ViewIndexDefinition.TYPE_VIEW, new ViewDoc().setUuid("CDEF").setProjects(newArrayList("DEFG"))); - esTester.putDocuments(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexType(), newRuleDoc()); + esTester.putDocuments(RuleIndexDefinition.INDEX, RuleIndexDefinition.TYPE_RULE, newRuleDoc()); backendCleanup.resetData(); - assertThat(dbTester.countRowsOfTable("projects")).isEqualTo(0); - assertThat(dbTester.countRowsOfTable("snapshots")).isEqualTo(0); - assertThat(dbTester.countRowsOfTable("properties")).isEqualTo(0); - assertThat(esTester.countDocuments(IssueIndexDefinition.INDEX, IssueIndexDefinition.TYPE_ISSUE)).isEqualTo(0); - assertThat(esTester.countDocuments(ViewIndexDefinition.INDEX, ViewIndexDefinition.TYPE_VIEW)).isEqualTo(0); + assertThat(dbTester.countRowsOfTable("projects")).isZero(); + assertThat(dbTester.countRowsOfTable("snapshots")).isZero(); + assertThat(dbTester.countRowsOfTable("properties")).isZero(); + assertThat(esTester.countDocuments(IssueIndexDefinition.INDEX, IssueIndexDefinition.TYPE_ISSUE)).isZero(); + assertThat(esTester.countDocuments(ViewIndexDefinition.INDEX, ViewIndexDefinition.TYPE_VIEW)).isZero(); // Rules should not be removed assertThat(dbTester.countRowsOfTable("rules")).isEqualTo(1); - assertThat(esTester.countDocuments(IndexDefinition.RULE.getIndexName(), IndexDefinition.RULE.getIndexType())).isEqualTo(1); + assertThat(esTester.countDocuments(RuleIndexDefinition.INDEX, RuleIndexDefinition.TYPE_RULE)).isEqualTo(1); } private static RuleDoc newRuleDoc() { - return new RuleDoc(ImmutableMap.of(RuleNormalizer.RuleField.RULE_KEY.field(), RuleTesting.XOO_X1)); + return new RuleDoc(ImmutableMap.of( + RuleIndexDefinition.FIELD_RULE_KEY, RuleTesting.XOO_X1, + RuleIndexDefinition.FIELD_RULE_REPOSITORY, RuleTesting.XOO_X1.repository() + )); } } diff --git a/server/sonar-server/src/test/resources/org/sonar/server/platform/BackendCleanupMediumTest/shared.xml b/server/sonar-server/src/test/resources/org/sonar/server/platform/BackendCleanupMediumTest/shared.xml index 3ac6d6657c9..b8d14359444 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/platform/BackendCleanupMediumTest/shared.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/platform/BackendCleanupMediumTest/shared.xml @@ -9,13 +9,16 @@ depth="[null]" scope="PRJ" qualifier="TRK" version="[null]" path=""/> + effort_to_fix_description="squid.S115.effortToFix" description_format="MARKDOWN" + created_at="2013-12-16" updated_at="2013-12-16" + created_at_ms="150000" updated_at_ms="150000" + />