use of org.sonarqube.ws.Measures.SearchWsResponse in project sonarqube by SonarSource.
the class SearchAction method handle.
@Override
public void handle(Request httpRequest, Response httpResponse) throws Exception {
try (DbSession dbSession = dbClient.openSession(false)) {
SearchWsResponse response = new ResponseBuilder(httpRequest, dbSession).build();
writeProtobuf(response, httpRequest, httpResponse);
}
}
use of org.sonarqube.ws.Measures.SearchWsResponse in project sonarqube by SonarSource.
the class SearchActionTest method return_best_value.
@Test
public void return_best_value() {
ComponentDto project = db.components().insertPrivateProject();
userSession.addProjectPermission(UserRole.USER, project);
MetricDto matchBestValue = db.measures().insertMetric(m -> m.setValueType(FLOAT.name()).setBestValue(15.5d));
db.measures().insertLiveMeasure(project, matchBestValue, m -> m.setValue(15.5d));
MetricDto doesNotMatchBestValue = db.measures().insertMetric(m -> m.setValueType(INT.name()).setBestValue(50d));
db.measures().insertLiveMeasure(project, doesNotMatchBestValue, m -> m.setValue(40d));
MetricDto noBestValue = db.measures().insertMetric(m -> m.setValueType(INT.name()).setBestValue(null));
db.measures().insertLiveMeasure(project, noBestValue, m -> m.setValue(123d));
SearchWsResponse result = call(singletonList(project.getDbKey()), asList(matchBestValue.getKey(), doesNotMatchBestValue.getKey(), noBestValue.getKey()));
List<Measure> measures = result.getMeasuresList();
assertThat(measures).extracting(Measure::getMetric, Measure::getValue, Measure::getBestValue, Measure::hasBestValue).containsExactlyInAnyOrder(tuple(matchBestValue.getKey(), "15.5", true, true), tuple(doesNotMatchBestValue.getKey(), "40", false, true), tuple(noBestValue.getKey(), "123", false, false));
}
use of org.sonarqube.ws.Measures.SearchWsResponse 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.SearchWsResponse in project sonarqube by SonarSource.
the class SearchActionTest method return_measures.
@Test
public void return_measures() {
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));
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");
}
use of org.sonarqube.ws.Measures.SearchWsResponse in project sonarqube by SonarSource.
the class SearchActionTest method return_measures_on_view.
@Test
public void return_measures_on_view() {
ComponentDto view = db.components().insertPrivatePortfolio();
userSession.addProjectPermission(UserRole.USER, view);
MetricDto coverage = db.measures().insertMetric(m -> m.setValueType(FLOAT.name()));
db.measures().insertLiveMeasure(view, coverage, m -> m.setValue(15.5d));
SearchWsResponse result = call(singletonList(view.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");
}
Aggregations