Search in sources :

Example 11 with RuleDebt

use of org.sonar.server.debt.DebtModelXMLExporter.RuleDebt in project sonarqube by SonarSource.

the class DebtRulesXMLImporterTest method import_linear_having_offset_to_zero.

@Test
public void import_linear_having_offset_to_zero() throws Exception {
    String xml = getFileContent("import_linear_having_offset_to_zero.xml");
    List<RuleDebt> results = underTest.importXML(xml, validationMessages);
    assertThat(results).hasSize(1);
    RuleDebt ruleDebt = results.get(0);
    assertThat(ruleDebt.ruleKey()).isEqualTo(RuleKey.of("checkstyle", "Regexp"));
    assertThat(ruleDebt.function()).isEqualTo(DebtRemediationFunction.Type.LINEAR.name());
    assertThat(ruleDebt.coefficient()).isEqualTo("3h");
    assertThat(ruleDebt.offset()).isNull();
}
Also used : RuleDebt(org.sonar.server.debt.DebtModelXMLExporter.RuleDebt) Test(org.junit.Test)

Example 12 with RuleDebt

use of org.sonar.server.debt.DebtModelXMLExporter.RuleDebt in project sonarqube by SonarSource.

the class DebtRulesXMLImporterTest method convert_deprecated_linear_with_threshold_function_by_linear_function.

@Test
public void convert_deprecated_linear_with_threshold_function_by_linear_function() throws Exception {
    String xml = getFileContent("convert_deprecated_linear_with_threshold_function_by_linear_function.xml");
    List<RuleDebt> results = underTest.importXML(xml, validationMessages);
    assertThat(results).hasSize(1);
    RuleDebt ruleDebt = results.get(0);
    assertThat(ruleDebt.function()).isEqualTo(DebtRemediationFunction.Type.LINEAR.name());
    assertThat(ruleDebt.coefficient()).isEqualTo("3h");
    assertThat(ruleDebt.offset()).isNull();
    assertThat(validationMessages.getWarnings()).isNotEmpty();
}
Also used : RuleDebt(org.sonar.server.debt.DebtModelXMLExporter.RuleDebt) Test(org.junit.Test)

Example 13 with RuleDebt

use of org.sonar.server.debt.DebtModelXMLExporter.RuleDebt in project sonarqube by SonarSource.

the class DebtRulesXMLImporterTest method import_linear_with_offset.

@Test
public void import_linear_with_offset() throws Exception {
    String xml = getFileContent("import_linear_with_offset.xml");
    List<RuleDebt> results = underTest.importXML(xml, validationMessages);
    assertThat(results).hasSize(1);
    RuleDebt ruleDebt = results.get(0);
    assertThat(ruleDebt.function()).isEqualTo(DebtRemediationFunction.Type.LINEAR_OFFSET.name());
    assertThat(ruleDebt.coefficient()).isEqualTo("3h");
    assertThat(ruleDebt.offset()).isEqualTo("1min");
}
Also used : RuleDebt(org.sonar.server.debt.DebtModelXMLExporter.RuleDebt) Test(org.junit.Test)

Example 14 with RuleDebt

use of org.sonar.server.debt.DebtModelXMLExporter.RuleDebt in project sonarqube by SonarSource.

the class DebtRulesXMLImporterTest method use_default_unit_when_no_unit.

@Test
public void use_default_unit_when_no_unit() throws Exception {
    String xml = getFileContent("use_default_unit_when_no_unit.xml");
    List<RuleDebt> results = underTest.importXML(xml, validationMessages);
    assertThat(results).hasSize(1);
    RuleDebt ruleDebt = results.get(0);
    assertThat(ruleDebt.function()).isEqualTo(DebtRemediationFunction.Type.LINEAR_OFFSET.name());
    assertThat(ruleDebt.coefficient()).isEqualTo("3d");
    assertThat(ruleDebt.offset()).isEqualTo("1d");
}
Also used : RuleDebt(org.sonar.server.debt.DebtModelXMLExporter.RuleDebt) Test(org.junit.Test)

Aggregations

RuleDebt (org.sonar.server.debt.DebtModelXMLExporter.RuleDebt)14 Test (org.junit.Test)11 Reader (java.io.Reader)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 SMInputFactory (org.codehaus.staxmate.SMInputFactory)1 SMHierarchicCursor (org.codehaus.staxmate.in.SMHierarchicCursor)1 SMInputCursor (org.codehaus.staxmate.in.SMInputCursor)1 RuleParam (org.sonar.api.rules.RuleParam)1 RuleRepository (org.sonar.api.rules.RuleRepository)1 RulesDefinition (org.sonar.api.server.rule.RulesDefinition)1 ValidationMessages (org.sonar.api.utils.ValidationMessages)1