use of org.sonar.server.measure.ws.SearchHistoryAction.SearchHistoryRequest 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.sonar.server.measure.ws.SearchHistoryAction.SearchHistoryRequest 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.sonar.server.measure.ws.SearchHistoryAction.SearchHistoryRequest 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.sonar.server.measure.ws.SearchHistoryAction.SearchHistoryRequest 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();
}
use of org.sonar.server.measure.ws.SearchHistoryAction.SearchHistoryRequest in project sonarqube by SonarSource.
the class SearchHistoryActionTest method fail_if_unknown_component.
@Test
public void fail_if_unknown_component() {
SearchHistoryRequest request = SearchHistoryRequest.builder().setComponent("__UNKNOWN__").setMetrics(singletonList(complexityMetric.getKey())).build();
assertThatThrownBy(() -> call(request)).isInstanceOf(NotFoundException.class);
}
Aggregations