Search in sources :

Example 11 with DefaultDebtRemediationFunction

use of org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction in project sonarqube by SonarSource.

the class RuleUpdaterMediumTest method override_debt_from_linear_with_offset_to_constant.

@Test
public void override_debt_from_linear_with_offset_to_constant() {
    ruleDao.insert(dbSession, RuleTesting.newDto(RULE_KEY).setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name()).setDefaultRemediationGapMultiplier("1d").setDefaultRemediationBaseEffort("5min").setRemediationFunction(null).setRemediationGapMultiplier(null).setRemediationBaseEffort(null));
    dbSession.commit();
    RuleUpdate update = RuleUpdate.createForPluginRule(RULE_KEY).setDebtRemediationFunction(new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE, null, "10min"));
    underTest.update(update, userSessionRule);
    dbSession.clearCache();
    // verify debt is overridden
    RuleDto rule = ruleDao.selectOrFailByKey(dbSession, RULE_KEY);
    assertThat(rule.getRemediationFunction()).isEqualTo(DebtRemediationFunction.Type.CONSTANT_ISSUE.name());
    assertThat(rule.getRemediationGapMultiplier()).isNull();
    assertThat(rule.getRemediationBaseEffort()).isEqualTo("10min");
    assertThat(rule.getDefaultRemediationFunction()).isEqualTo(DebtRemediationFunction.Type.LINEAR_OFFSET.name());
    assertThat(rule.getDefaultRemediationGapMultiplier()).isEqualTo("1d");
    assertThat(rule.getDefaultRemediationBaseEffort()).isEqualTo("5min");
}
Also used : ActiveRuleDto(org.sonar.db.qualityprofile.ActiveRuleDto) RuleDto(org.sonar.db.rule.RuleDto) DefaultDebtRemediationFunction(org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction) Test(org.junit.Test)

Example 12 with DefaultDebtRemediationFunction

use of org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction in project sonarqube by SonarSource.

the class RuleUpdaterMediumTest method override_debt.

@Test
public void override_debt() {
    ruleDao.insert(dbSession, RuleTesting.newDto(RULE_KEY).setDefaultRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET.name()).setDefaultRemediationGapMultiplier("1d").setDefaultRemediationBaseEffort("5min").setRemediationFunction(null).setRemediationGapMultiplier(null).setRemediationBaseEffort(null));
    dbSession.commit();
    DefaultDebtRemediationFunction fn = new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.CONSTANT_ISSUE, null, "1min");
    RuleUpdate update = RuleUpdate.createForPluginRule(RULE_KEY).setDebtRemediationFunction(fn);
    underTest.update(update, userSessionRule);
    dbSession.clearCache();
    // verify debt is overridden
    RuleDto rule = ruleDao.selectOrFailByKey(dbSession, RULE_KEY);
    assertThat(rule.getRemediationFunction()).isEqualTo(DebtRemediationFunction.Type.CONSTANT_ISSUE.name());
    assertThat(rule.getRemediationGapMultiplier()).isNull();
    assertThat(rule.getRemediationBaseEffort()).isEqualTo("1min");
    assertThat(rule.getDefaultRemediationFunction()).isEqualTo(DebtRemediationFunction.Type.LINEAR_OFFSET.name());
    assertThat(rule.getDefaultRemediationGapMultiplier()).isEqualTo("1d");
    assertThat(rule.getDefaultRemediationBaseEffort()).isEqualTo("5min");
}
Also used : ActiveRuleDto(org.sonar.db.qualityprofile.ActiveRuleDto) RuleDto(org.sonar.db.rule.RuleDto) DefaultDebtRemediationFunction(org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction) Test(org.junit.Test)

Example 13 with DefaultDebtRemediationFunction

use of org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction in project sonarqube by SonarSource.

the class DefaultDebtRemediationFunctionTest method create_linear.

@Test
public void create_linear() {
    DebtRemediationFunction function = new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR, "10h", null);
    assertThat(function.type()).isEqualTo(DefaultDebtRemediationFunction.Type.LINEAR);
    assertThat(function.gapMultiplier()).isEqualTo("10h");
    assertThat(function.baseEffort()).isNull();
}
Also used : DefaultDebtRemediationFunction(org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction) DefaultDebtRemediationFunction(org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction) Test(org.junit.Test)

Example 14 with DefaultDebtRemediationFunction

use of org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction in project sonarqube by SonarSource.

the class DefaultDebtRemediationFunctionTest method create_linear_with_offset.

@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.gapMultiplier()).isEqualTo("10h");
    assertThat(function.baseEffort()).isEqualTo("5min");
}
Also used : DefaultDebtRemediationFunction(org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction) DefaultDebtRemediationFunction(org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction) Test(org.junit.Test)

Example 15 with DefaultDebtRemediationFunction

use of org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction in project sonarqube by SonarSource.

the class DefaultDebtRemediationFunctionTest method sanitize_remediation_coefficient_and_offset.

@Test
public void sanitize_remediation_coefficient_and_offset() {
    DebtRemediationFunction function = new DefaultDebtRemediationFunction(DebtRemediationFunction.Type.LINEAR_OFFSET, "  1  h   ", "  10   min");
    assertThat(function.gapMultiplier()).isEqualTo("1h");
    assertThat(function.baseEffort()).isEqualTo("10min");
}
Also used : DefaultDebtRemediationFunction(org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction) DefaultDebtRemediationFunction(org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction) Test(org.junit.Test)

Aggregations

DefaultDebtRemediationFunction (org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction)15 Test (org.junit.Test)13 ActiveRuleDto (org.sonar.db.qualityprofile.ActiveRuleDto)3 RuleDto (org.sonar.db.rule.RuleDto)3 DebtRemediationFunction (org.sonar.api.server.debt.DebtRemediationFunction)2