Search in sources :

Example 1 with Measures

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"));
}
Also used : MetricDto(org.sonar.db.metric.MetricDto) Measures(org.sonarqube.ws.Measures) ComponentDto(org.sonar.db.component.ComponentDto) Measure(org.sonarqube.ws.Measures.Measure) SearchWsResponse(org.sonarqube.ws.Measures.SearchWsResponse) Test(org.junit.Test)

Example 2 with Measures

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;
}
Also used : Measures(org.sonarqube.ws.Measures) ComponentRequest(org.sonarqube.ws.client.measures.ComponentRequest)

Aggregations

Measures (org.sonarqube.ws.Measures)2 Test (org.junit.Test)1 ComponentDto (org.sonar.db.component.ComponentDto)1 MetricDto (org.sonar.db.metric.MetricDto)1 Measure (org.sonarqube.ws.Measures.Measure)1 SearchWsResponse (org.sonarqube.ws.Measures.SearchWsResponse)1 ComponentRequest (org.sonarqube.ws.client.measures.ComponentRequest)1