use of org.sonarqube.ws.ProjectAnalyses.SearchResponse in project sonarqube by SonarSource.
the class SearchActionTest method paginate_with_filter_on_category.
@Test
public void paginate_with_filter_on_category() {
ComponentDto project = db.components().insertComponent(newProjectDto(db.organizations().insert()).setKey("P1"));
userSession.addProjectUuidPermissions(UserRole.USER, project.uuid());
SnapshotDto a1 = db.components().insertSnapshot(newAnalysis(project).setUuid("A1").setCreatedAt(1_000_000L));
SnapshotDto a2 = db.components().insertSnapshot(newAnalysis(project).setUuid("A2").setCreatedAt(2_000_000L));
SnapshotDto a3 = db.components().insertSnapshot(newAnalysis(project).setUuid("A3").setCreatedAt(3_000_000L));
SnapshotDto a42 = db.components().insertSnapshot(newAnalysis(project).setUuid("A42"));
db.events().insertEvent(newEvent(a1).setUuid("E11").setCategory(VERSION.getLabel()));
db.events().insertEvent(newEvent(a1).setUuid("E12").setCategory(QUALITY_GATE.getLabel()));
db.events().insertEvent(newEvent(a2).setUuid("E21").setCategory(QUALITY_GATE.getLabel()));
db.events().insertEvent(newEvent(a3).setUuid("E31").setCategory(QUALITY_GATE.getLabel()));
// Analysis A42 doesn't have a quality gate event
db.events().insertEvent(newEvent(a42).setCategory(OTHER.getLabel()));
SearchResponse result = call(SearchRequest.builder().setProject("P1").setCategory(QUALITY_GATE).setPage(2).setPageSize(1).build());
assertThat(result.getAnalysesList()).extracting(Analysis::getKey).containsOnly("A2");
assertThat(result.getPaging()).extracting(Paging::getPageIndex, Paging::getPageSize, Paging::getTotal).containsExactly(2, 1, 3);
}
use of org.sonarqube.ws.ProjectAnalyses.SearchResponse in project sonarqube by SonarSource.
the class SearchActionTest method paginate_analyses.
@Test
public void paginate_analyses() {
ComponentDto project = db.components().insertProject();
userSession.addProjectUuidPermissions(UserRole.USER, project.uuid());
IntStream.rangeClosed(1, 9).forEach(i -> db.components().insertSnapshot(newAnalysis(project).setCreatedAt(1_000_000L * i).setUuid("A" + i)));
SearchResponse result = call(SearchRequest.builder().setProject(project.key()).setPage(2).setPageSize(3).build());
assertThat(result.getAnalysesList()).extracting(Analysis::getKey).containsExactly("A6", "A5", "A4");
}
Aggregations