use of org.sonar.server.computation.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class NewMaintainabilityMeasuresVisitorTest method setupOneFileAloneInAProject.
private void setupOneFileAloneInAProject(int newDebt, Flag isUnitTest, Flag withNclocLines, Flag withChangeSets) {
checkArgument(isUnitTest == Flag.UT_FILE || isUnitTest == Flag.SRC_FILE);
checkArgument(withNclocLines == Flag.WITH_NCLOC || withNclocLines == Flag.NO_NCLOC || withNclocLines == Flag.MISSING_MEASURE_NCLOC);
checkArgument(withChangeSets == Flag.WITH_CHANGESET || withChangeSets == Flag.NO_CHANGESET);
treeRootHolder.setRoot(builder(PROJECT, ROOT_REF).addChildren(builder(FILE, LANGUAGE_1_FILE_REF).setFileAttributes(new FileAttributes(isUnitTest == Flag.UT_FILE, LANGUAGE_1_KEY, 1)).build()).build());
Measure newDebtMeasure = createNewDebtMeasure(newDebt);
measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NEW_TECHNICAL_DEBT_KEY, newDebtMeasure);
if (withNclocLines == Flag.WITH_NCLOC) {
// 4 lines file, only first one is not ncloc
measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NCLOC_DATA_KEY, createNclocDataMeasure(2, 3, 4));
} else if (withNclocLines == Flag.NO_NCLOC) {
// 4 lines file, none of which is ncloc
measureRepository.addRawMeasure(LANGUAGE_1_FILE_REF, NCLOC_DATA_KEY, createNoNclocDataMeasure(4));
}
if (withChangeSets == Flag.WITH_CHANGESET) {
// first 2 lines are before all snapshots, 2 last lines are after PERIOD 2's snapshot date
scmInfoRepository.setScmInfo(LANGUAGE_1_FILE_REF, createChangesets(PERIOD_SNAPSHOT_DATE - 100, 2, PERIOD_SNAPSHOT_DATE + 100, 2));
}
}
use of org.sonar.server.computation.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class ComputeQProfileMeasureStepTest method addMeasure.
private void addMeasure(int componentRef, QualityProfile... qps) {
Measure qualityProfileMeasure = newMeasureBuilder().create(toJson(qps));
measureRepository.addRawMeasure(componentRef, QUALITY_PROFILES_KEY, qualityProfileMeasure);
}
use of org.sonar.server.computation.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class ConditionEvaluatorTest method test_condition_on_rating.
@Test
public void test_condition_on_rating() throws Exception {
Metric metric = createMetric(RATING);
Measure measure = newMeasureBuilder().create(4, "D");
assertThat(underTest.evaluate(new Condition(metric, GREATER_THAN.getDbValue(), "4", null, false), measure)).hasLevel(OK).hasValue(4);
assertThat(underTest.evaluate(new Condition(metric, GREATER_THAN.getDbValue(), "2", null, false), measure)).hasLevel(ERROR).hasValue(4);
}
use of org.sonar.server.computation.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class ConditionEvaluatorTest method test_condition_on_rating_on_leak_period_when_variation_is_zero.
@Test
public void test_condition_on_rating_on_leak_period_when_variation_is_zero() throws Exception {
Metric metric = createMetric(RATING);
Measure measure = newMeasureBuilder().setVariation(0d).createNoValue();
assertThat(underTest.evaluate(new Condition(metric, GREATER_THAN.getDbValue(), "4", null, true), measure)).hasLevel(OK).hasValue(0);
}
use of org.sonar.server.computation.task.projectanalysis.measure.Measure in project sonarqube by SonarSource.
the class ConditionEvaluatorTest method testUnsupportedType.
@Test
public void testUnsupportedType() {
Metric metric = createMetric(DATA);
Measure measure = newMeasureBuilder().create("3.14159265358");
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Conditions on MetricType DATA are not supported");
underTest.evaluate(createErrorCondition(metric, EQUALS, "1.60217657"), measure);
}
Aggregations