Package org.sonar.api.rule

Examples of org.sonar.api.rule.RuleKey


  }

  @Test
  public void disable_characteristic_on_rule_having_no_debt_info() throws Exception {
    RuleDto dto = new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck");
    RuleKey ruleKey = RuleKey.of("squid", "UselessImportCheck");

    when(ruleDao.getNullableByKey(session, ruleKey)).thenReturn(dto);

    operations.updateRule(new RuleChange().setRuleKey(ruleKey).setDebtCharacteristicKey(null), authorizedUserSession);
View Full Code Here


  }

  @Test
  public void not_disable_characteristic_when_update_rule_if_already_disabled() throws Exception {
    RuleDto dto = new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck").setSubCharacteristicId(-1);
    RuleKey ruleKey = RuleKey.of("squid", "UselessImportCheck");

    when(ruleDao.getNullableByKey(session, ruleKey)).thenReturn(dto);

    operations.updateRule(
      new RuleChange().setRuleKey(ruleKey).setDebtCharacteristicKey(null),
View Full Code Here

    verify(session, never()).commit();
  }

  @Test
  public void fail_to_update_rule_on_unknown_rule() throws Exception {
    RuleKey ruleKey = RuleKey.of("squid", "UselessImportCheck");

    when(ruleDao.getNullableByKey(session, ruleKey)).thenReturn(null);

    try {
      operations.updateRule(
View Full Code Here

  @Test
  public void fail_to_update_rule_on_unknown_sub_characteristic() throws Exception {
    RuleDto dto = new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck")
      .setSubCharacteristicId(2).setRemediationFunction("CONSTANT_ISSUE").setRemediationOffset("10min");
    RuleKey ruleKey = RuleKey.of("squid", "UselessImportCheck");

    when(ruleDao.getNullableByKey(session, ruleKey)).thenReturn(dto);

    when(characteristicDao.selectByKey("COMPILER", session)).thenReturn(null);
View Full Code Here

  @Test
  public void fail_to_update_rule_on_invalid_coefficient() throws Exception {
    RuleDto dto = new RuleDto().setId(1).setRepositoryKey("squid").setRuleKey("UselessImportCheck")
      .setSubCharacteristicId(2).setRemediationFunction("LINEAR").setRemediationCoefficient("1h");
    RuleKey ruleKey = RuleKey.of("squid", "UselessImportCheck");

    when(ruleDao.getNullableByKey(session, ruleKey)).thenReturn(dto);

    CharacteristicDto subCharacteristic = new CharacteristicDto().setId(2).setKey("COMPILER").setName("Compiler").setParentId(1);
    when(characteristicDao.selectByKey("COMPILER", session)).thenReturn(subCharacteristic);
View Full Code Here

  }

  @Test
  public void count_rules() throws Exception {
    RulesAggregation rulesAggregation = new RulesAggregation();
    RuleKey ruleKey = RuleKey.of("xoo", "S001");
    RuleDto ruleDto = RuleTesting.newDto(ruleKey).setName("Rule name");
    rulesAggregation.add(ruleDto);
    rulesAggregation.add(ruleDto);

    RulesAggregation.Rule rule = new RulesAggregation.Rule(ruleKey, "Rule name");
View Full Code Here

    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));
View Full Code Here

  @Test
  public void search_qprofile_activity_without_severity() throws InterruptedException {
    MockUserSession.set().setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN).setLogin("me");

    RuleKey ruleKey = RuleKey.of("xoo", "deleted_rule");

    tester.get(ActivityService.class).write(dbSession, Activity.Type.QPROFILE,
      ActiveRuleChange.createFor(ActiveRuleChange.Type.UPDATED, ActiveRuleKey.of(XOO_P1_KEY, ruleKey))
        .setParameter("max", "10")
    );
View Full Code Here

  @Test
  public void search_qprofile_activity_with_rule_not_found() throws InterruptedException {
    MockUserSession.set().setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN).setLogin("me");

    RuleKey ruleKey = RuleKey.of("xoo", "deleted_rule");

    tester.get(ActivityService.class).write(dbSession, Activity.Type.QPROFILE,
      ActiveRuleChange.createFor(ActiveRuleChange.Type.ACTIVATED, ActiveRuleKey.of(XOO_P1_KEY, ruleKey))
        .setSeverity(Severity.MAJOR)
        .setParameter("max", "10")
View Full Code Here

      .setName("My custom")
      .setMarkdownDescription("Some description")
      .setSeverity(Severity.MAJOR)
      .setStatus(RuleStatus.READY)
      .setParameters(ImmutableMap.of("regex", "a.*"));
    RuleKey customRuleKey = creator.create(newRule);

    dbSession.clearCache();

    RuleDto rule = db.ruleDao().getNullableByKey(dbSession, customRuleKey);
    assertThat(rule).isNotNull();
View Full Code Here

TOP

Related Classes of org.sonar.api.rule.RuleKey

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.