use of org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRICS in project sonarqube by SonarSource.
the class SearchHistoryActionTest method branch.
@Test
public void branch() {
ComponentDto project = db.components().insertPrivateProject();
userSession.addProjectPermission(UserRole.USER, project);
ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey("my_branch"));
ComponentDto file = db.components().insertComponent(newFileDto(branch));
SnapshotDto analysis = db.components().insertSnapshot(branch);
MeasureDto measure = db.measures().insertMeasure(file, analysis, nclocMetric, m -> m.setValue(2d));
SearchHistoryResponse result = ws.newRequest().setParam(PARAM_COMPONENT, file.getKey()).setParam(PARAM_BRANCH, "my_branch").setParam(PARAM_METRICS, "ncloc").executeProtobuf(SearchHistoryResponse.class);
assertThat(result.getMeasuresList()).extracting(HistoryMeasure::getMetric).hasSize(1);
HistoryMeasure historyMeasure = result.getMeasures(0);
assertThat(historyMeasure.getMetric()).isEqualTo(nclocMetric.getKey());
assertThat(historyMeasure.getHistoryList()).extracting(m -> parseDouble(m.getValue())).containsExactlyInAnyOrder(measure.getValue());
}
use of org.sonar.server.component.ws.MeasuresWsParameters.PARAM_METRICS in project sonarqube by SonarSource.
the class SearchHistoryActionTest method pull_request.
@Test
public void pull_request() {
ComponentDto project = db.components().insertPrivateProject();
userSession.addProjectPermission(UserRole.USER, project);
ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey("pr-123").setBranchType(PULL_REQUEST));
ComponentDto file = db.components().insertComponent(newFileDto(branch));
SnapshotDto analysis = db.components().insertSnapshot(branch);
MeasureDto measure = db.measures().insertMeasure(file, analysis, nclocMetric, m -> m.setValue(2d));
SearchHistoryResponse result = ws.newRequest().setParam(PARAM_COMPONENT, file.getKey()).setParam(PARAM_PULL_REQUEST, "pr-123").setParam(PARAM_METRICS, "ncloc").executeProtobuf(SearchHistoryResponse.class);
assertThat(result.getMeasuresList()).extracting(HistoryMeasure::getMetric).hasSize(1);
HistoryMeasure historyMeasure = result.getMeasures(0);
assertThat(historyMeasure.getMetric()).isEqualTo(nclocMetric.getKey());
assertThat(historyMeasure.getHistoryList()).extracting(m -> parseDouble(m.getValue())).containsExactlyInAnyOrder(measure.getValue());
}
Aggregations