use of org.sonar.api.measures.CoreMetrics.NEW_MINOR_VIOLATIONS_KEY in project sonarqube by SonarSource.
the class prMeasureFixTest method should_transform_measures.
@Test
public void should_transform_measures() {
Set<String> requestedKeys = new HashSet<>(Arrays.asList(NEW_BUGS_KEY, MINOR_VIOLATIONS_KEY, NEW_MINOR_VIOLATIONS_KEY));
MetricDto bugsMetric = new MetricDto().setKey(BUGS_KEY).setUuid("1");
MetricDto newBugsMetric = new MetricDto().setKey(NEW_BUGS_KEY).setUuid("2");
MetricDto violationsMetric = new MetricDto().setKey(MINOR_VIOLATIONS_KEY).setUuid("3");
MetricDto newViolationsMetric = new MetricDto().setKey(NEW_MINOR_VIOLATIONS_KEY).setUuid("4");
List<MetricDto> metricList = Arrays.asList(bugsMetric, newBugsMetric, violationsMetric, newViolationsMetric);
LiveMeasureDto bugs = createLiveMeasure(bugsMetric.getUuid(), 10.0, null);
LiveMeasureDto newBugs = createLiveMeasure(newBugsMetric.getUuid(), null, 5.0);
LiveMeasureDto violations = createLiveMeasure(violationsMetric.getUuid(), 20.0, null);
LiveMeasureDto newViolations = createLiveMeasure(newViolationsMetric.getUuid(), null, 3.0);
Map<MetricDto, LiveMeasureDto> measureByMetric = new HashMap<>();
measureByMetric.put(bugsMetric, bugs);
measureByMetric.put(newBugsMetric, newBugs);
measureByMetric.put(violationsMetric, violations);
measureByMetric.put(newViolationsMetric, newViolations);
PrMeasureFix.createReplacementMeasures(metricList, measureByMetric, requestedKeys);
assertThat(measureByMetric.entrySet()).extracting(e -> e.getKey().getKey(), e -> e.getValue().getValue(), e -> e.getValue().getVariation()).containsOnly(tuple(NEW_BUGS_KEY, null, 10.0), tuple(MINOR_VIOLATIONS_KEY, 20.0, null), tuple(NEW_MINOR_VIOLATIONS_KEY, null, 20.0));
}
Aggregations