Package org.sonar.server.rule.index

Examples of org.sonar.server.rule.index.RuleQuery


  /**
   * Used in manual_rules_controller.rb
   */
  public List<Rule> searchManualRules() {
    return service.search(new RuleQuery().setRepositories(newArrayList(RuleDoc.MANUAL_REPOSITORY)).setSortField(RuleNormalizer.RuleField.NAME), new QueryContext()).getHits();
  }
View Full Code Here


    dbSession.commit();

    // 0. No active rules so far (base case) and plenty rules available
    verifyZeroActiveRules(XOO_P1_KEY);
    assertThat(tester.get(RuleIndex.class)
      .search(new RuleQuery().setRepositories(Arrays.asList("bulk")), new QueryContext()).getTotal())
      .isEqualTo(bulkSize);

    // 1. bulk activate all the rules
    BulkChangeResult result = ruleActivator.bulkActivate(
      new RuleQuery().setRepositories(Arrays.asList("bulk")), XOO_P1_KEY, "MINOR");

    // 2. assert that all activation has been commit to DB and ES
    dbSession.clearCache();
    assertThat(db.activeRuleDao().findByProfileKey(dbSession, XOO_P1_KEY)).hasSize(bulkSize);
    assertThat(index.findByProfile(XOO_P1_KEY)).hasSize(bulkSize);
View Full Code Here

  }

  @Test
  public void bulk_activation_ignores_errors() {
    // 1. bulk activate all the rules, even non xoo-rules and xoo templates
    BulkChangeResult result = ruleActivator.bulkActivate(new RuleQuery(), XOO_P1_KEY, "MINOR");

    // 2. assert that all activations have been commit to DB and ES
    // -> xoo rules x1, x2 and custom1
    dbSession.clearCache();
    assertThat(db.activeRuleDao().findByProfileKey(dbSession, XOO_P1_KEY)).hasSize(3);
View Full Code Here

  public void bulk_deactivate() {
    activate(new RuleActivation(RuleTesting.XOO_X1), XOO_P1_KEY);
    activate(new RuleActivation(RuleTesting.XOO_X2), XOO_P1_KEY);
    assertThat(countActiveRules(XOO_P1_KEY)).isEqualTo(2);

    BulkChangeResult result = ruleActivator.bulkDeactivate(new RuleQuery().setActivation(true).setQProfileKey(XOO_P1_KEY), XOO_P1_KEY);

    dbSession.clearCache();
    assertThat(countActiveRules(XOO_P1_KEY)).isEqualTo(0);
    assertThat(result.countFailed()).isEqualTo(0);
    assertThat(result.countSucceeded()).isEqualTo(2);
View Full Code Here

    createChildProfiles();
    activate(new RuleActivation(RuleTesting.XOO_X1), XOO_P1_KEY);
    assertThat(countActiveRules(XOO_P2_KEY)).isEqualTo(1);

    // bulk deactivate on child profile P2 -> not possible
    BulkChangeResult result = ruleActivator.bulkDeactivate(new RuleQuery().setActivation(true).setQProfileKey(XOO_P2_KEY), XOO_P2_KEY);

    dbSession.clearCache();
    assertThat(countActiveRules(XOO_P2_KEY)).isEqualTo(1);
    assertThat(result.countFailed()).isEqualTo(1);
    assertThat(result.countSucceeded()).isEqualTo(0);
View Full Code Here

    activate(activation, XOO_P1_KEY);
    activation = new RuleActivation(RuleTesting.XOO_X2).setSeverity(Severity.INFO);
    activate(activation, XOO_P1_KEY);

    // bulk change severity to BLOCKER. Parameters are not set.
    RuleQuery query = new RuleQuery().setActivation(true).setQProfileKey(XOO_P1_KEY);
    BulkChangeResult result = ruleActivator.bulkActivate(query, XOO_P1_KEY, "BLOCKER");
    assertThat(result.countSucceeded()).isEqualTo(2);

    verifyHasActiveRule(XOO_P1_KEY, RuleTesting.XOO_X1, Severity.BLOCKER, null, ImmutableMap.of("max", "7"));
    verifyHasActiveRule(XOO_P1_KEY, RuleTesting.XOO_X2, Severity.BLOCKER, null, Collections.<String, String>emptyMap());
View Full Code Here

TOP

Related Classes of org.sonar.server.rule.index.RuleQuery

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.