use of org.sonarqube.ws.Measures.SearchHistoryResponse in project sonarqube by SonarSource.
the class SearchHistoryActionTest method do_not_return_unprocessed_analyses.
@Test
public void do_not_return_unprocessed_analyses() {
dbClient.snapshotDao().insert(dbSession, newAnalysis(project).setStatus(STATUS_UNPROCESSED));
db.commit();
SearchHistoryRequest request = SearchHistoryRequest.builder().setComponent(project.getDbKey()).setMetrics(asList(complexityMetric.getKey(), nclocMetric.getKey(), newViolationMetric.getKey())).build();
SearchHistoryResponse result = call(request);
// one analysis in setUp method
assertThat(result.getPaging().getTotal()).isOne();
}
use of org.sonarqube.ws.Measures.SearchHistoryResponse in project sonarqube by SonarSource.
the class SearchHistoryActionTest method return_metrics.
@Test
public void return_metrics() {
dbClient.measureDao().insert(dbSession, newMeasureDto(complexityMetric, project, analysis).setValue(42.0d));
db.commit();
SearchHistoryRequest request = SearchHistoryRequest.builder().setComponent(project.getDbKey()).setMetrics(asList(complexityMetric.getKey(), nclocMetric.getKey(), newViolationMetric.getKey())).build();
SearchHistoryResponse result = call(request);
assertThat(result.getMeasuresList()).hasSize(3).extracting(HistoryMeasure::getMetric).containsExactly(complexityMetric.getKey(), nclocMetric.getKey(), newViolationMetric.getKey());
}
use of org.sonarqube.ws.Measures.SearchHistoryResponse in project sonarqube by SonarSource.
the class SearchHistoryActionTest method empty_response.
@Test
public void empty_response() {
project = db.components().insertPrivateProject();
userSession.addProjectPermission(UserRole.USER, project);
SearchHistoryRequest request = SearchHistoryRequest.builder().setComponent(project.getDbKey()).setMetrics(singletonList(complexityMetric.getKey())).build();
SearchHistoryResponse result = call(request);
assertThat(result.getMeasuresList()).hasSize(1);
assertThat(result.getMeasures(0).getHistoryCount()).isZero();
assertThat(result.getPaging()).extracting(Paging::getPageIndex, Paging::getPageSize, Paging::getTotal).containsExactly(1, 100, 0);
}
use of org.sonarqube.ws.Measures.SearchHistoryResponse 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());
}
use of org.sonarqube.ws.Measures.SearchHistoryResponse in project sonarqube by SonarSource.
the class SearchHistoryActionTest method measure_without_values.
@Test
public void measure_without_values() {
dbClient.measureDao().insert(dbSession, newMeasureDto(stringMetric, project, analysis).setValue(null).setData(null));
db.commit();
SearchHistoryRequest request = SearchHistoryRequest.builder().setComponent(project.getDbKey()).setMetrics(singletonList(stringMetric.getKey())).build();
SearchHistoryResponse result = call(request);
HistoryMeasure measure = result.getMeasuresList().stream().filter(m -> m.getMetric().equals(stringMetric.getKey())).findFirst().get();
assertThat(measure.getHistoryList()).hasSize(1);
assertThat(measure.getHistory(0).hasValue()).isFalse();
}
Aggregations