use of org.sonarqube.ws.Measures.SearchHistoryResponse.HistoryValue in project sonarqube by SonarSource.
the class SearchHistoryActionTest method inclusive_from_and_to_dates.
@Test
public void inclusive_from_and_to_dates() {
project = db.components().insertPrivateProject();
userSession.addProjectPermission(UserRole.USER, project);
List<String> analysisDates = LongStream.rangeClosed(1, 9).mapToObj(i -> dbClient.snapshotDao().insert(dbSession, newAnalysis(project).setCreatedAt(System2.INSTANCE.now() + i * 1_000_000_000L))).peek(a -> dbClient.measureDao().insert(dbSession, newMeasureDto(complexityMetric, project, a).setValue(Double.valueOf(a.getCreatedAt())))).map(a -> formatDateTime(a.getCreatedAt())).collect(MoreCollectors.toList());
db.commit();
SearchHistoryRequest request = SearchHistoryRequest.builder().setComponent(project.getDbKey()).setMetrics(asList(complexityMetric.getKey(), nclocMetric.getKey(), newViolationMetric.getKey())).setFrom(analysisDates.get(1)).setTo(analysisDates.get(3)).build();
SearchHistoryResponse result = call(request);
assertThat(result.getPaging()).extracting(Paging::getPageIndex, Paging::getPageSize, Paging::getTotal).containsExactly(1, 100, 3);
assertThat(result.getMeasures(0).getHistoryList()).extracting(HistoryValue::getDate).containsExactly(analysisDates.get(1), analysisDates.get(2), analysisDates.get(3));
}
use of org.sonarqube.ws.Measures.SearchHistoryResponse.HistoryValue in project sonarqube by SonarSource.
the class SearchHistoryActionTest method pagination_applies_to_analyses.
@Test
public void pagination_applies_to_analyses() {
project = db.components().insertPrivateProject();
userSession.addProjectPermission(UserRole.USER, project);
List<String> analysisDates = LongStream.rangeClosed(1, 9).mapToObj(i -> dbClient.snapshotDao().insert(dbSession, newAnalysis(project).setCreatedAt(i * 1_000_000_000))).peek(a -> dbClient.measureDao().insert(dbSession, newMeasureDto(complexityMetric, project, a).setValue(101d))).map(a -> formatDateTime(a.getCreatedAt())).collect(MoreCollectors.toList());
db.commit();
SearchHistoryRequest request = SearchHistoryRequest.builder().setComponent(project.getDbKey()).setMetrics(asList(complexityMetric.getKey(), nclocMetric.getKey(), newViolationMetric.getKey())).setPage(2).setPageSize(3).build();
SearchHistoryResponse result = call(request);
assertThat(result.getPaging()).extracting(Paging::getPageIndex, Paging::getPageSize, Paging::getTotal).containsExactly(2, 3, 9);
assertThat(result.getMeasures(0).getHistoryList()).extracting(HistoryValue::getDate).containsExactly(analysisDates.get(3), analysisDates.get(4), analysisDates.get(5));
}
Aggregations