use of org.sonarqube.ws.Measures in project sonarqube by SonarSource.
the class SearchActionTest method return_measures_on_new_code_period.
@Test
public void return_measures_on_new_code_period() {
ComponentDto project = db.components().insertPrivateProject();
userSession.addProjectPermission(UserRole.USER, project);
MetricDto coverage = db.measures().insertMetric(m -> m.setValueType(FLOAT.name()));
db.measures().insertLiveMeasure(project, coverage, m -> m.setValue(15.5d).setVariation(10d));
SearchWsResponse result = call(singletonList(project.getDbKey()), singletonList(coverage.getKey()));
List<Measure> measures = result.getMeasuresList();
assertThat(measures).hasSize(1);
Measure measure = measures.get(0);
assertThat(measure.getMetric()).isEqualTo(coverage.getKey());
assertThat(measure.getValue()).isEqualTo("15.5");
assertThat(measure.getPeriods().getPeriodsValueList()).extracting(Measures.PeriodValue::getIndex, Measures.PeriodValue::getValue).containsOnly(tuple(1, "10.0"));
}
use of org.sonarqube.ws.Measures in project sonar-web by SonarSource.
the class HtmlTestSuite method getMeasure.
static Measures.Measure getMeasure(Orchestrator orchestrator, String componentKey, String metricKey) {
Measures.ComponentWsResponse response = newWsClient(orchestrator).measures().component(new ComponentRequest().setComponent(componentKey).setMetricKeys(singletonList(metricKey)));
List<Measures.Measure> measures = response.getComponent().getMeasuresList();
return measures.size() == 1 ? measures.get(0) : null;
}
Aggregations