use of org.sonarqube.ws.WsMeasures.ComponentWsResponse in project sonarqube by SonarSource.
the class MeasuresWsTest method component.
@Test
public void component() {
scanXooSample();
ComponentWsResponse response = wsClient.measures().component(new ComponentWsRequest().setComponentKey("sample").setMetricKeys(singletonList("ncloc")).setAdditionalFields(newArrayList("metrics", "periods")));
WsMeasures.Component component = response.getComponent();
assertThat(component.getKey()).isEqualTo("sample");
assertThat(component.getMeasuresList()).isNotEmpty();
assertThat(response.getMetrics().getMetricsList()).extracting("key").containsOnly("ncloc");
}
use of org.sonarqube.ws.WsMeasures.ComponentWsResponse in project sonarqube by SonarSource.
the class ComponentAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
ComponentWsResponse componentWsResponse = doHandle(toComponentWsRequest(request));
writeProtobuf(componentWsResponse, request, response);
}
use of org.sonarqube.ws.WsMeasures.ComponentWsResponse in project sonarqube by SonarSource.
the class ComponentActionTest method reference_uuid_in_the_response.
@Test
public void reference_uuid_in_the_response() {
ComponentDto project = newProjectDto(db.getDefaultOrganization(), "project-uuid").setKey("project-key");
componentDb.insertProjectAndSnapshot(project);
ComponentDto view = newView(db.getDefaultOrganization(), "view-uuid");
componentDb.insertViewAndSnapshot(view);
componentDb.insertComponent(newProjectCopy("project-uuid-copy", project, view));
insertNclocMetric();
ComponentWsResponse response = newRequest("project-uuid-copy", "ncloc");
assertThat(response.getComponent().getId()).isEqualTo("project-uuid-copy");
assertThat(response.getComponent().getRefId()).isEqualTo("project-uuid");
assertThat(response.getComponent().getRefKey()).isEqualTo("project-key");
}
use of org.sonarqube.ws.WsMeasures.ComponentWsResponse in project sonarqube by SonarSource.
the class ComponentActionTest method developer_measure_by_developer_key.
@Test
public void developer_measure_by_developer_key() {
OrganizationDto organizationDto = db.organizations().insert();
ComponentDto developer = newDeveloper(organizationDto, "developer-name");
componentDb.insertDeveloperAndSnapshot(developer);
ComponentDto project = newProjectDto(organizationDto, PROJECT_UUID);
SnapshotDto projectSnapshot = componentDb.insertProjectAndSnapshot(project);
ComponentDto file = newFileDto(project, null, "file-uuid");
componentDb.insertComponent(file);
MetricDto ncloc = insertNclocMetric();
dbClient.measureDao().insert(dbSession, newMeasureDto(ncloc, file, projectSnapshot).setValue(42.0d).setDeveloperId(null), newMeasureDto(ncloc, file, projectSnapshot).setValue(1984.0d).setDeveloperId(developer.getId()));
db.commit();
ComponentWsResponse result = call(ws.newRequest().setParam(PARAM_COMPONENT_ID, "file-uuid").setParam(PARAM_DEVELOPER_KEY, developer.key()).setParam(PARAM_METRIC_KEYS, "ncloc"));
assertThat(result.getComponent().getMeasuresCount()).isEqualTo(1);
assertThat(result.getComponent().getMeasures(0).getValue()).isEqualTo("1984");
}
use of org.sonarqube.ws.WsMeasures.ComponentWsResponse in project sonarqube by SonarSource.
the class ComponentActionTest method provided_project.
@Test
public void provided_project() {
componentDb.insertComponent(newProjectDto(db.getDefaultOrganization(), PROJECT_UUID));
userSession.addProjectUuidPermissions(UserRole.USER, PROJECT_UUID);
insertNclocMetric();
ComponentWsResponse response = newRequest(PROJECT_UUID, "ncloc");
assertThat(response.getMetrics().getMetricsCount()).isEqualTo(1);
assertThat(response.getPeriods().getPeriodsCount()).isEqualTo(0);
assertThat(response.getComponent().getId()).isEqualTo(PROJECT_UUID);
}
Aggregations