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);
}
use of org.sonarqube.ws.WsMeasures.ComponentWsResponse in project sonarqube by SonarSource.
the class ComponentActionTest method developer_measure_by_developer_uuid.
@Test
public void developer_measure_by_developer_uuid() {
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_ID, developer.uuid()).setParam(PARAM_METRIC_KEYS, "ncloc"));
assertThat(result.getComponent().getMeasuresCount()).isEqualTo(1);
assertThat(result.getComponent().getMeasures(0).getValue()).isEqualTo("1984");
}
Aggregations