use of org.sonarqube.ws.WsMeasures.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().insertProject();
userSession.addProjectUuidPermissions(UserRole.USER, project.uuid());
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(Collectors.toList());
db.commit();
wsRequest.setComponent(project.getKey()).setFrom(analysisDates.get(1)).setTo(analysisDates.get(3));
SearchHistoryResponse result = call();
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.WsMeasures.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().insertProject();
userSession.addProjectUuidPermissions(UserRole.USER, project.uuid());
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(Collectors.toList());
db.commit();
wsRequest.setComponent(project.getKey()).setPage(2).setPageSize(3);
SearchHistoryResponse result = call();
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