Package org.sonar.api.server.debt.internal

Examples of org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction


  }

  @Test
  public void fail_if_bad_coefficient_format() {
    try {
      new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR, "foo", null);
      fail();
    } catch (IllegalArgumentException e) {
      assertThat(e).hasMessage("Invalid coefficient: foo (Duration 'foo' is invalid, it should use the following sample format : 2d 10h 15min)");
    }
View Full Code Here


public class DefaultDebtRemediationFunctionTest {

  @Test
  public void create_linear() {
    DebtRemediationFunction function = new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR, "10h", null);
    assertThat(function.type()).isEqualTo(DefaultDebtRemediationFunction.Type.LINEAR);
    assertThat(function.coefficient()).isEqualTo("10h");
    assertThat(function.offset()).isNull();
  }
View Full Code Here

    assertThat(function.offset()).isNull();
  }

  @Test
  public void create_linear_with_offset() {
    DebtRemediationFunction function = new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET, "10h", "5min");
    assertThat(function.type()).isEqualTo(DefaultDebtRemediationFunction.Type.LINEAR_OFFSET);
    assertThat(function.coefficient()).isEqualTo("10h");
    assertThat(function.offset()).isEqualTo("5min");
  }
View Full Code Here

    assertThat(function.offset()).isEqualTo("5min");
  }

  @Test
  public void create_constant_per_issue() {
    DebtRemediationFunction function = new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE, null, "10h");
    assertThat(function.type()).isEqualTo(DefaultDebtRemediationFunction.Type.CONSTANT_ISSUE);
    assertThat(function.coefficient()).isNull();
    assertThat(function.offset()).isEqualTo("10h");
  }
View Full Code Here

        // New values are not the same as the overridden values -> update overridden values with new values
      } else if (!isRuleDebtSameAsOverriddenValues(ruleDto, newSubCharacteristic, newFunction, newCoefficient, newOffset)) {
        ruleDto.setSubCharacteristicId(newSubCharacteristic.getId());

        DefaultDebtRemediationFunction debtRemediationFunction = new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.valueOf(newFunction), newCoefficient, newOffset);
        ruleDto.setRemediationFunction(debtRemediationFunction.type().name());
        ruleDto.setRemediationCoefficient(debtRemediationFunction.coefficient());
        ruleDto.setRemediationOffset(debtRemediationFunction.offset());
        needUpdate = true;
      }

      // No sub-characteristic is given -> disable rule debt if not already disabled
    } else {
View Full Code Here

    value = request.param(PARAM_DEBT_REMEDIATION_FN_TYPE);
    if (value != null) {
      if (StringUtils.isBlank(value)) {
        update.setDebtRemediationFunction(null);
      } else {
        DebtRemediationFunction fn = new DefaultDebtRemediationFunction(
          DebtRemediationFunction.Type.valueOf(value), request.param(PARAM_DEBT_REMEDIATION_FY_COEFF),
          request.param(PARAM_DEBT_REMEDIATION_FN_OFFSET));
        update.setDebtRemediationFunction(fn);
      }
    }
View Full Code Here

    update.setDebtSubCharacteristic(Strings.emptyToNull((String) params.get("debtCharacteristicKey")));
    String fn = (String) params.get("debtRemediationFunction");
    if (fn == null) {
      update.setDebtRemediationFunction(null);
    } else {
      update.setDebtRemediationFunction(new DefaultDebtRemediationFunction(
          DebtRemediationFunction.Type.valueOf(fn),
          Strings.emptyToNull((String) params.get("debtRemediationCoefficient")),
          Strings.emptyToNull((String) params.get("debtRemediationOffset")))
      );
    }
View Full Code Here

      .setRemediationFunction(null)
      .setRemediationCoefficient(null)
      .setRemediationOffset(null));
    dbSession.commit();

    DefaultDebtRemediationFunction fn = new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE, null, "1min");
    RuleUpdate update = RuleUpdate.createForPluginRule(RULE_KEY)
      .setDebtSubCharacteristic("SOFT_RELIABILITY")
      .setDebtRemediationFunction(fn);
    updater.update(update, UserSession.get());
    dbSession.clearCache();
View Full Code Here

      .setRemediationCoefficient(null)
      .setRemediationOffset(null));
    dbSession.commit();

    RuleUpdate update = RuleUpdate.createForPluginRule(RULE_KEY)
      .setDebtRemediationFunction(new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR, "2d", null));
    updater.update(update, UserSession.get());
    dbSession.clearCache();

    // verify debt is overridden
    Rule indexedRule = tester.get(RuleIndex.class).getByKey(RULE_KEY);
View Full Code Here

      .setRemediationCoefficient(null)
      .setRemediationOffset(null));
    dbSession.commit();

    RuleUpdate update = RuleUpdate.createForPluginRule(RULE_KEY)
      .setDebtRemediationFunction(new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE, null, "10min"));
    updater.update(update, UserSession.get());
    dbSession.clearCache();

    // verify debt is overridden
    Rule indexedRule = tester.get(RuleIndex.class).getByKey(RULE_KEY);
View Full Code Here

TOP

Related Classes of org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction

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.