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;
new RuleIndexDefinition(new Settings()),
new IssueIndexDefinition(new Settings()),
new ViewIndexDefinition(new Settings())
- );
+ );
@Rule
public DbTester dbTester = DbTester.create(System2.INSTANCE);
@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();
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();
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.<String, Object>of(RuleNormalizer.RuleField.RULE_KEY.field(), RuleTesting.XOO_X1));
+ return new RuleDoc(ImmutableMap.<String, Object>of(
+ RuleIndexDefinition.FIELD_RULE_KEY, RuleTesting.XOO_X1,
+ RuleIndexDefinition.FIELD_RULE_REPOSITORY, RuleTesting.XOO_X1.repository()
+ ));
}
}
depth="[null]" scope="PRJ" qualifier="TRK" version="[null]" path=""/>
<rules tags="[null]" system_tags="[null]" id="1" plugin_rule_key="NewRuleKey" plugin_name="plugin" name="new name" description="new description" status="DEPRECATED"
- plugin_config_key="NewConfigKey" priority="0" is_template="[true]" language="dart" created_at="2013-12-16" updated_at="2013-12-16" template_id="3"
+ plugin_config_key="NewConfigKey" priority="0" is_template="[true]" language="dart" template_id="3"
note_data="[null]" note_user_login="[null]" note_created_at="[null]" note_updated_at="[null]"
characteristic_id="100" default_characteristic_id="101"
remediation_function="LINEAR" default_remediation_function="LINEAR_OFFSET"
remediation_coeff="1h" default_remediation_coeff="5d"
remediation_offset="5min" default_remediation_offset="10h"
- effort_to_fix_description="squid.S115.effortToFix" description_format="MARKDOWN"/>
+ 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"
+ />
<properties id="1" prop_key="sonar.profile.java" text_value="Sonar Way" resource_id="1" user_id="[null]"/>