Examples of ActiveRule


Examples of org.sonar.api.rules.ActiveRule

  public void createCheckWithIntegerProperty() {
    RulesProfile profile = RulesProfile.create("repo", "java");
    Rule rule = Rule.create("repo", "org.sonar.api.checks.CheckWithIntegerProperty", "");
    rule.createParameter("max");

    ActiveRule activeRule = profile.activateRule(rule, null);
    activeRule.setParameter("max", "300");
    AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.<Class> asList(CheckWithIntegerProperty.class));

    Object check = factory.getCheck(activeRule);
    assertThat(((CheckWithIntegerProperty) check).getMax()).isEqualTo(300);
  }
View Full Code Here

Examples of org.sonar.api.rules.ActiveRule

  public void setValueOfInheritedField() {
    RulesProfile profile = RulesProfile.create("repo", "java");
    Rule rule = Rule.create("repo", "org.sonar.api.checks.ImplementedCheck", "");
    rule.createParameter("max");

    ActiveRule activeRule = profile.activateRule(rule, null);
    activeRule.setParameter("max", "300");
    AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.<Class> asList(ImplementedCheck.class));

    Object check = factory.getCheck(activeRule);
    assertThat(((ImplementedCheck) check).getMax()).isEqualTo(300);
  }
View Full Code Here

Examples of org.sonar.api.rules.ActiveRule

    RulesProfile profile = RulesProfile.create("repo", "java");
    Rule rule = Rule.create("repo", "org.sonar.api.checks.CheckWithUnsupportedPropertyType", "");
    rule.createParameter("max");

    ActiveRule activeRule = profile.activateRule(rule, null);
    activeRule.setParameter("max", "300");
    AnnotationCheckFactory.create(profile, "repo", Arrays.<Class> asList(CheckWithUnsupportedPropertyType.class));
  }
View Full Code Here

Examples of org.sonar.api.rules.ActiveRule

  public void shouldOverridePropertyKey() {
    RulesProfile profile = RulesProfile.create("repo", "java");
    Rule rule = Rule.create("repo", "org.sonar.api.checks.CheckWithOverriddenPropertyKey", "");
    rule.createParameter("maximum");

    ActiveRule activeRule = profile.activateRule(rule, null);
    activeRule.setParameter("maximum", "300");
    AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.<Class> asList(CheckWithOverriddenPropertyKey.class));

    Object check = factory.getCheck(activeRule);
    assertThat(((CheckWithOverriddenPropertyKey) check).getMax()).isEqualTo(300);
  }
View Full Code Here

Examples of org.sonar.api.rules.ActiveRule

   * SONAR-2900
   */
  @Test
  public void create_accept_objects() {
    RulesProfile profile = RulesProfile.create("repo", "java");
    ActiveRule activeRule = profile.activateRule(Rule.create("repo", "org.sonar.api.checks.CheckWithoutProperties", ""), null);
    CheckWithoutProperties checkInstance = new CheckWithoutProperties();
    AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.asList(checkInstance));

    Object check = factory.getCheck(activeRule);
    assertNotNull(check);
View Full Code Here

Examples of org.sonar.api.rules.ActiveRule

  public void create_instance_with_string_property() {
    RulesProfile profile = RulesProfile.create("repo", "java");
    Rule rule = Rule.create("repo", "org.sonar.api.checks.CheckWithStringProperty", "");
    rule.createParameter("pattern");

    ActiveRule activeRule = profile.activateRule(rule, null);
    activeRule.setParameter("pattern", "foo");
    CheckWithStringProperty checkInstance = new CheckWithStringProperty();
    AnnotationCheckFactory factory = AnnotationCheckFactory.create(profile, "repo", Arrays.asList(checkInstance));

    Object check = factory.getCheck(activeRule);
    assertNotNull(check);
View Full Code Here

Examples of org.sonar.server.qualityprofile.ActiveRule

        x1Rule.createParam("format2").setType(RuleParamType.STRING);
        x1Rule.createParam("max").setType(RuleParamType.INTEGER).setDefaultValue("10");
      }
    });

    ActiveRule activeRule = activeRuleIndex.getByKey(ActiveRuleKey.of(QProfileTesting.XOO_P1_KEY, RuleTesting.XOO_X1));
    Map<String, String> params = activeRule.params();
    assertThat(params).hasSize(2);

    // do not change default value on existing active rules -> keep min=5
    assertThat(params.get("min")).isEqualTo("5");
View Full Code Here

Examples of org.sonar.server.qualityprofile.ActiveRule

    RuleParam param = customRuleReloaded.params().get(0);
    assertThat(param.defaultValue()).isEqualTo("b.*");

    // Verify active rule parameters has been updated
    ActiveRule activeRule = tester.get(ActiveRuleIndex.class).getByKey(ActiveRuleKey.of(profileDto.getKey(), customRule.getKey()));
    assertThat(activeRule.params()).hasSize(2);
    assertThat(activeRule.params().get("regex")).isEqualTo("b.*");
    assertThat(activeRule.params().get("message")).isEqualTo("a message");
    assertThat(activeRule.params().get("format")).isNull();

    // Verify that severity has not changed
    assertThat(activeRule.severity()).isEqualTo(Severity.BLOCKER);
  }
View Full Code Here

Examples of org.sonar.server.qualityprofile.ActiveRule

    String profileKey = query.getQProfileKey();
    if (profileKey != null) {
      // Load details of active rules on the selected profile
      for (Rule rule : rules) {
        ActiveRule activeRule = loader.getActiveRule(ActiveRuleKey.of(profileKey, rule.key()));
        if (activeRule != null) {
          writeActiveRules(rule.key(), Arrays.asList(activeRule), json);
        }
      }
    } else {
View Full Code Here

Examples of org.sonar.server.qualityprofile.ActiveRule

    when(qProfileFactory.getByProjectAndLanguage(session, projectKey, "java")).thenReturn(
      QualityProfileDto.createFor("abcd").setName("Default").setLanguage("java").setRulesUpdatedAt("2014-01-14T14:00:00+0200")
      );

    RuleKey ruleKey = RuleKey.of("squid", "AvoidCycle");
    ActiveRule activeRule = mock(ActiveRule.class);
    when(activeRule.key()).thenReturn(ActiveRuleKey.of("abcd", ruleKey));
    when(activeRule.severity()).thenReturn(Severity.MINOR);
    when(activeRule.params()).thenReturn(ImmutableMap.of("max", "2"));
    when(qProfileLoader.findActiveRulesByProfile("abcd")).thenReturn(newArrayList(activeRule));

    Rule rule = mock(Rule.class);
    when(rule.name()).thenReturn("Avoid Cycle");
    when(rule.internalKey()).thenReturn("squid-1");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.