use of org.sonarqube.ws.WsMeasures.ComponentTreeWsResponse in project sonarqube by SonarSource.
the class ComponentTreeActionTest method empty_response.
@Test
public void empty_response() {
componentDb.insertComponent(newProjectDto(db.getDefaultOrganization(), "project-uuid"));
ComponentTreeWsResponse response = call(ws.newRequest().setParam(PARAM_BASE_COMPONENT_ID, "project-uuid").setParam(PARAM_METRIC_KEYS, "ncloc, complexity"));
assertThat(response.getBaseComponent().getId()).isEqualTo("project-uuid");
assertThat(response.getComponentsList()).isEmpty();
assertThat(response.getMetrics().getMetricsList()).isEmpty();
assertThat(response.getPeriods().getPeriodsList()).isEmpty();
}
use of org.sonarqube.ws.WsMeasures.ComponentTreeWsResponse in project sonarqube by SonarSource.
the class ComponentTreeActionTest method remove_components_without_measure_on_the_metric_sort.
@Test
public void remove_components_without_measure_on_the_metric_sort() {
ComponentDto project = newProjectDto(db.getDefaultOrganization(), "project-uuid");
SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(project);
ComponentDto file1 = newFileDto(project, null, "file-uuid-1");
ComponentDto file2 = newFileDto(project, null, "file-uuid-2");
ComponentDto file3 = newFileDto(project, null, "file-uuid-3");
ComponentDto file4 = newFileDto(project, null, "file-uuid-4");
componentDb.insertComponent(file1);
componentDb.insertComponent(file2);
componentDb.insertComponent(file3);
componentDb.insertComponent(file4);
MetricDto ncloc = newMetricDtoWithoutOptimization().setKey("ncloc").setValueType(ValueType.INT.name()).setDirection(1);
dbClient.metricDao().insert(dbSession, ncloc);
dbClient.measureDao().insert(dbSession, newMeasureDto(ncloc, file1, projectSnapshot).setValue(1.0d), newMeasureDto(ncloc, file2, projectSnapshot).setValue(2.0d), newMeasureDto(ncloc, file3, projectSnapshot).setValue(3.0d), // measure on period 1
newMeasureDto(ncloc, file4, projectSnapshot).setVariation(4.0d));
db.commit();
ComponentTreeWsResponse response = call(ws.newRequest().setParam(PARAM_BASE_COMPONENT_ID, project.uuid()).setParam(Param.SORT, METRIC_SORT).setParam(PARAM_METRIC_SORT, "ncloc").setParam(PARAM_METRIC_KEYS, "ncloc").setParam(PARAM_METRIC_SORT_FILTER, WITH_MEASURES_ONLY_METRIC_SORT_FILTER));
assertThat(response.getComponentsList()).extracting("id").containsExactly(file1.uuid(), file2.uuid(), file3.uuid()).doesNotContain(file4.uuid());
assertThat(response.getPaging().getTotal()).isEqualTo(3);
}
Aggregations