use of org.sonarqube.ws.Developers.SearchEventsWsResponse in project sonarqube by SonarSource.
the class SearchEventsActionQualityGateTest method does_not_return_quality_gate_events_on_pull_request.
@Test
public void does_not_return_quality_gate_events_on_pull_request() {
userSession.logIn().setRoot();
when(server.getPublicRootUrl()).thenReturn("https://sonarcloud.io");
ComponentDto project = db.components().insertPrivateProject();
ComponentDto pr = db.components().insertProjectBranch(project, b -> b.setBranchType(PULL_REQUEST));
SnapshotDto prAnalysis = insertSuccessfulActivity(pr, 1_500_000_000_000L);
insertActivity(pr, prAnalysis, CeActivityDto.Status.SUCCESS);
db.events().insertEvent(newQualityGateEvent(prAnalysis).setDate(prAnalysis.getCreatedAt()).setName("Failed"));
SearchEventsWsResponse result = ws.newRequest().setParam(PARAM_PROJECTS, project.getKey()).setParam(PARAM_FROM, formatDateTime(prAnalysis.getCreatedAt() - 1_000L)).executeProtobuf(SearchEventsWsResponse.class);
assertThat(result.getEventsList()).isEmpty();
}
use of org.sonarqube.ws.Developers.SearchEventsWsResponse in project sonarqube by SonarSource.
the class SearchEventsActionQualityGateTest method filter_by_from_date_inclusive.
@Test
public void filter_by_from_date_inclusive() {
userSession.logIn().setRoot();
ComponentDto project1 = db.components().insertPrivateProject();
ComponentDto project2 = db.components().insertPrivateProject();
ComponentDto project3 = db.components().insertPrivateProject();
long from1 = 1_500_000_000_000L;
long from2 = 1_400_000_000_000L;
long from3 = 1_300_000_000_000L;
SnapshotDto a1 = insertSuccessfulActivity(project1, from1 - 1L);
db.events().insertEvent(newQualityGateEvent(a1).setDate(a1.getCreatedAt()));
SnapshotDto a2 = insertSuccessfulActivity(project2, from2);
db.events().insertEvent(newQualityGateEvent(a2).setDate(from2));
SnapshotDto a3 = insertSuccessfulActivity(project3, from3 + 1L);
db.events().insertEvent(newQualityGateEvent(a3).setDate(from3 + 1L));
SearchEventsWsResponse result = ws.newRequest().setParam(PARAM_PROJECTS, join(",", project1.getKey(), project2.getKey(), project3.getKey())).setParam(PARAM_FROM, join(",", formatDateTime(from1 - 1_000L), formatDateTime(from2 - 1_000L), formatDateTime(from3 - 1_000L))).executeProtobuf(SearchEventsWsResponse.class);
assertThat(result.getEventsList()).extracting(Event::getProject).containsExactlyInAnyOrder(project2.getKey(), project3.getKey());
}
use of org.sonarqube.ws.Developers.SearchEventsWsResponse in project sonarqube by SonarSource.
the class SearchEventsActionQualityGateTest method branch_quality_gate_events.
@Test
public void branch_quality_gate_events() {
userSession.logIn().setRoot();
when(server.getPublicRootUrl()).thenReturn("https://sonarcloud.io");
ComponentDto project = db.components().insertPrivateProject();
ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setBranchType(BRANCH));
SnapshotDto projectAnalysis = insertSuccessfulActivity(project, 1_500_000_000_000L);
SnapshotDto branchAnalysis = insertSuccessfulActivity(branch, 1_500_000_000_000L);
insertActivity(branch, branchAnalysis, CeActivityDto.Status.SUCCESS);
db.events().insertEvent(newQualityGateEvent(branchAnalysis).setDate(branchAnalysis.getCreatedAt()).setName("Failed"));
SearchEventsWsResponse result = ws.newRequest().setParam(PARAM_PROJECTS, project.getKey()).setParam(PARAM_FROM, formatDateTime(branchAnalysis.getCreatedAt() - 1_000L)).executeProtobuf(SearchEventsWsResponse.class);
assertThat(result.getEventsList()).extracting(Event::getCategory, Event::getProject, Event::getMessage, Event::getLink).containsOnly(tuple("QUALITY_GATE", project.getKey(), format("Quality Gate status of project '%s' on branch '%s' changed to 'Failed'", project.name(), branch.getBranch()), format("https://sonarcloud.io/dashboard?id=%s&branch=%s", project.getKey(), branch.getBranch())));
}
use of org.sonarqube.ws.Developers.SearchEventsWsResponse in project sonarqube by SonarSource.
the class SearchEventsActionNewIssuesTest method return_link_to_issue_search_for_new_issues_event.
@Test
public void return_link_to_issue_search_for_new_issues_event() {
userSession.logIn("my_login").setRoot();
ComponentDto project = db.components().insertPrivateProject(p -> p.setDbKey("my_project"));
SnapshotDto analysis = insertAnalysis(project, 1_400_000_000_000L);
insertIssue(project, analysis);
issueIndexer.indexAllIssues();
when(server.getPublicRootUrl()).thenReturn("https://sonarcloud.io");
SearchEventsWsResponse result = ws.newRequest().setParam(PARAM_PROJECTS, project.getKey()).setParam(PARAM_FROM, formatDateTime(analysis.getCreatedAt() - 1_000L)).executeProtobuf(SearchEventsWsResponse.class);
assertThat(result.getEventsList()).extracting(Event::getLink).containsExactly("https://sonarcloud.io/project/issues?id=my_project&createdAfter=" + encode(formatDateTime(analysis.getCreatedAt())) + "&assignees=my_login&resolved=false");
}
use of org.sonarqube.ws.Developers.SearchEventsWsResponse in project sonarqube by SonarSource.
the class SearchEventsActionQualityGateTest method quality_gate_events.
@Test
public void quality_gate_events() {
userSession.logIn().setRoot();
when(server.getPublicRootUrl()).thenReturn("https://sonarcloud.io");
ComponentDto project = db.components().insertPrivateProject();
SnapshotDto projectAnalysis = insertSuccessfulActivity(project, 1_500_000_000_000L);
db.events().insertEvent(newQualityGateEvent(projectAnalysis).setDate(projectAnalysis.getCreatedAt()).setName("Failed"));
long from = 1_000_000_000_000L;
SearchEventsWsResponse result = ws.newRequest().setParam(PARAM_PROJECTS, project.getKey()).setParam(PARAM_FROM, formatDateTime(from)).executeProtobuf(SearchEventsWsResponse.class);
assertThat(result.getEventsList()).extracting(Event::getCategory, Event::getProject, Event::getMessage, Event::getLink, Event::getDate).containsOnly(tuple("QUALITY_GATE", project.getKey(), format("Quality Gate status of project '%s' changed to 'Failed'", project.name()), format("https://sonarcloud.io/dashboard?id=%s", project.getKey()), formatDateTime(projectAnalysis.getCreatedAt())));
}
Aggregations