Package org.sonar.server.rule.RuleOperations

Examples of org.sonar.server.rule.RuleOperations.RuleChange


    when(characteristicDao.selectById(2, session)).thenReturn(subCharacteristic);
    CharacteristicDto characteristic = new CharacteristicDto().setId(1).setKey("PORTABILITY").setName("Portability").setOrder(2);
    when(characteristicDao.selectById(1, session)).thenReturn(characteristic);

    operations.updateRule(
      new RuleChange().setRuleKey(ruleKey).setDebtCharacteristicKey("COMPILER")
        .setDebtRemediationFunction("LINEAR_OFFSET").setDebtRemediationCoefficient("2h").setDebtRemediationOffset("20min"),
      authorizedUserSession
    );

    verify(ruleDao).update(eq(session), ruleCaptor.capture());
View Full Code Here


    CharacteristicDto characteristic = new CharacteristicDto().setId(1).setKey("PORTABILITY").setName("Portability").setOrder(2);
    when(characteristicDao.selectById(1, session)).thenReturn(characteristic);

    operations.updateRule(
      // Same value as default values -> overridden values will be set to null
      new RuleChange().setRuleKey(ruleKey).setDebtCharacteristicKey("COMPILER")
        .setDebtRemediationFunction("CONSTANT_ISSUE").setDebtRemediationOffset("10min"),
      authorizedUserSession
    );

    verify(ruleDao).update(eq(session), ruleCaptor.capture());
View Full Code Here

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

    operations.updateRule(
      new RuleChange().setRuleKey(ruleKey).setDebtCharacteristicKey("COMPILER")
        .setDebtRemediationFunction("CONSTANT_ISSUE").setDebtRemediationOffset("10min"),
      authorizedUserSession
    );

    verify(ruleDao, never()).update(eq(session), any(RuleDto.class));
View Full Code Here

    CharacteristicDto characteristic = new CharacteristicDto().setId(1).setKey("PORTABILITY").setName("Portability").setOrder(2);
    when(characteristicDao.selectById(1, session)).thenReturn(characteristic);

    operations.updateRule(
      // Remediation function is not the same as default one -> Overridden value should be set
      new RuleChange().setRuleKey(ruleKey).setDebtCharacteristicKey("COMPILER")
        .setDebtRemediationFunction("LINEAR_OFFSET").setDebtRemediationCoefficient("2h").setDebtRemediationOffset("20min"),
      authorizedUserSession
    );

    verify(ruleDao).update(eq(session), ruleCaptor.capture());
View Full Code Here

    CharacteristicDto characteristic = new CharacteristicDto().setId(1).setKey("PORTABILITY").setName("Portability").setOrder(2);
    when(characteristicDao.selectById(1, session)).thenReturn(characteristic);

    operations.updateRule(
      // Characteristic is the not same as the default one -> Overridden values should be set
      new RuleChange().setRuleKey(ruleKey).setDebtCharacteristicKey("COMPILER")
        .setDebtRemediationFunction("CONSTANT_ISSUE").setDebtRemediationOffset("10min"),
      authorizedUserSession
    );

    verify(ruleDao).update(eq(session), ruleCaptor.capture());
View Full Code Here

      .setRemediationOffset("10min");
    RuleKey ruleKey = RuleKey.of("squid", "UselessImportCheck");

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

    operations.updateRule(new RuleChange().setRuleKey(ruleKey).setDebtCharacteristicKey(null), authorizedUserSession);

    verify(ruleDao).update(eq(session), ruleCaptor.capture());
    verify(session).commit();

    RuleDto result = ruleCaptor.getValue();
View Full Code Here

    when(characteristicDao.selectByKey("COMPILER", session)).thenReturn(subCharacteristic);
    when(characteristicDao.selectById(2, session)).thenReturn(subCharacteristic);
    CharacteristicDto characteristic = new CharacteristicDto().setId(1).setKey("PORTABILITY").setName("Portability").setOrder(2);
    when(characteristicDao.selectById(1, session)).thenReturn(characteristic);

    operations.updateRule(new RuleChange().setRuleKey(ruleKey).setDebtCharacteristicKey("COMPILER"), authorizedUserSession);

    verify(ruleDao).update(eq(session), ruleCaptor.capture());
    verify(session).commit();

    RuleDto result = ruleCaptor.getValue();
View Full Code Here

    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);

    verify(ruleDao).update(eq(session), ruleCaptor.capture());
    verify(session).commit();

    RuleDto result = ruleCaptor.getValue();
View Full Code Here

    RuleKey ruleKey = RuleKey.of("squid", "UselessImportCheck");

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

    operations.updateRule(
      new RuleChange().setRuleKey(ruleKey).setDebtCharacteristicKey(null),
      authorizedUserSession
    );

    verify(ruleDao, never()).update(eq(session), any(RuleDto.class));
    verify(session, never()).commit();
View Full Code Here

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

    try {
      operations.updateRule(
        new RuleChange().setRuleKey(ruleKey).setDebtCharacteristicKey("COMPILER")
          .setDebtRemediationFunction("LINEAR_OFFSET").setDebtRemediationCoefficient("2h").setDebtRemediationOffset("20min"),
        authorizedUserSession
      );
    } catch (Exception e) {
      assertThat(e).isInstanceOf(NotFoundException.class);
View Full Code Here

TOP

Related Classes of org.sonar.server.rule.RuleOperations.RuleChange

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.