private String generateRating(MetricDto metric, LiveMeasureDto measure) { Rating rating = valueOf(getNonNullValue(measure, LiveMeasureDto::getValue).intValue()); return generateBadge(metric, rating.name(), COLOR_BY_RATING.get(rating)); }
private void computeAndSaveMeasures(Component component, Path<Counter> path) { processIssues(component, path); path.current().ratingValueByMetric.forEach((key, value) -> { Rating rating = value.getValue(); measureRepository.add(component, metricsByKey.get(key), newMeasureBuilder().create(rating.getIndex(), rating.name())); }); if (!path.isRoot()) { path.parent().add(path.current()); } }
private void addMaintainabilityRatingMeasure(Component component, double density) { Rating rating = ratingSettings.getDebtRatingGrid().getRatingForDensity(density); measureRepository.add(component, maintainabilityRatingMetric, newMeasureBuilder().create(rating.getIndex(), rating.name())); }
private static Measure createRatingMeasure(Rating rating) { return newMeasureBuilder().create(rating.getIndex(), rating.name()); }
private static Measure createMaintainabilityRatingMeasure(Rating rating) { return newMeasureBuilder().create(rating.getIndex(), rating.name()); }
void setValue(ComponentDto component, String metricKey, Rating value) { changeCell(component, metricKey, m -> { Double initialValue = m.getValue(); if (initialValue != null && Double.compare(initialValue, (double) value.getIndex()) == 0) { return false; } m.setData(value.name()); m.setValue((double) value.getIndex()); Double initialVariation = m.getVariation(); if (initialValue != null && initialVariation != null) { double leakInitialValue = initialValue - initialVariation; m.setVariation(value.getIndex() - leakInitialValue); } return true; }); }
private LiveMeasureDto assertThatRatingMeasureHasValue(ComponentDto component, Rating expectedRating) { LiveMeasureDto measure = db.getDbClient().liveMeasureDao().selectMeasure(db.getSession(), component.uuid(), ratingMetric.getKey()).get(); assertThat(measure.getComponentUuid()).isEqualTo(component.uuid()); assertThat(measure.getProjectUuid()).isEqualTo(component.projectUuid()); assertThat(measure.getMetricId()).isEqualTo(ratingMetric.getId()); assertThat(measure.getValue()).isEqualTo(expectedRating.getIndex()); assertThat(measure.getDataAsString()).isEqualTo(expectedRating.name()); return measure; }
private void verifyAddedRawMeasure(int componentRef, String metricKey, Rating rating) { assertThat(toEntries(measureRepository.getAddedRawMeasures(componentRef))).contains(entryOf(metricKey, newMeasureBuilder().create(rating.getIndex(), rating.name()))); }
private void verifyAddedRawMeasure(int componentRef, String metricKey, Rating rating) { assertThat(toEntries(measureRepository.getAddedRawMeasures(componentRef))).contains(entryOf(metricKey, newMeasureBuilder().create(rating.getIndex(), rating.name()))); }
@Test @UseDataProvider("ratings") public void rating_measure(Rating rating, Color color) { ComponentDto project = db.components().insertPublicProject(); userSession.registerComponents(project); MetricDto metric = db.measures().insertMetric(m -> m.setKey(SQALE_RATING_KEY).setValueType(RATING.name())); db.measures().insertLiveMeasure(project, metric, m -> m.setValue((double) rating.getIndex()).setData(rating.name())); TestResponse response = ws.newRequest() .setParam("project", project.getKey()) .setParam("metric", metric.getKey()) .execute(); checkSvg(response, "maintainability", rating.name(), color); // Second call with If-None-Match must return 304 checkWithIfNoneMatchHeader(project, metric, response); }