use of org.sonarqube.ws.Developers.SearchEventsWsResponse in project sonarqube by SonarSource.
the class SearchEventsActionNewIssuesTest method encode_link.
@Test
public void encode_link() {
userSession.logIn("rågnar").setRoot();
long from = 1_500_000_000_000L;
ComponentDto project = db.components().insertPrivateProject(p -> p.setDbKey("M&M's"));
SnapshotDto analysis = insertAnalysis(project, from);
insertIssue(project, analysis);
issueIndexer.indexAllIssues();
when(server.getPublicRootUrl()).thenReturn("http://sonarcloud.io");
String fromDate = formatDateTime(from - 1_000L);
SearchEventsWsResponse result = ws.newRequest().setParam(PARAM_PROJECTS, project.getKey()).setParam(PARAM_FROM, fromDate).executeProtobuf(SearchEventsWsResponse.class);
assertThat(result.getEventsList()).extracting(Event::getLink).containsExactly("http://sonarcloud.io/project/issues?id=M%26M%27s&createdAfter=" + encode(formatDateTime(from)) + "&assignees=r%C3%A5gnar&resolved=false");
}
use of org.sonarqube.ws.Developers.SearchEventsWsResponse in project sonarqube by SonarSource.
the class SearchEventsActionTest method does_not_return_events_of_project_for_which_the_current_user_has_no_browse_permission.
@Test
public void does_not_return_events_of_project_for_which_the_current_user_has_no_browse_permission() {
userSession.logIn();
ComponentDto project1 = db.components().insertPrivateProject();
userSession.addProjectPermission(UserRole.CODEVIEWER, project1);
userSession.addProjectPermission(UserRole.ISSUE_ADMIN, project1);
ComponentDto project2 = db.components().insertPrivateProject();
userSession.addProjectPermission(UserRole.USER, project2);
SnapshotDto a1 = insertAnalysis(project1, 1_500_000_000_000L);
EventDto e1 = db.events().insertEvent(newQualityGateEvent(a1).setDate(a1.getCreatedAt()));
insertIssue(project1, a1);
SnapshotDto a2 = insertAnalysis(project2, 1_500_000_000_000L);
EventDto e2 = db.events().insertEvent(newQualityGateEvent(a2).setDate(a2.getCreatedAt()));
insertIssue(project2, a2);
issueIndexer.indexAllIssues();
String stringFrom = formatDateTime(a1.getCreatedAt() - 1_000L);
SearchEventsWsResponse result = ws.newRequest().setParam(PARAM_PROJECTS, String.join(",", project1.getKey(), project2.getKey())).setParam(PARAM_FROM, String.join(",", stringFrom, stringFrom)).executeProtobuf(SearchEventsWsResponse.class);
assertThat(result.getEventsList()).extracting(Event::getCategory, Event::getProject).containsOnly(tuple("NEW_ISSUES", project2.getKey()), tuple(EventCategory.QUALITY_GATE.name(), project2.getKey()));
}
use of org.sonarqube.ws.Developers.SearchEventsWsResponse in project sonarqube by SonarSource.
the class SearchEventsActionTest method empty_response_for_empty_list_of_projects.
@Test
public void empty_response_for_empty_list_of_projects() {
userSession.logIn().setRoot();
SearchEventsWsResponse result = ws.newRequest().setParam(PARAM_PROJECTS, "").setParam(PARAM_FROM, "").executeProtobuf(SearchEventsWsResponse.class);
assertThat(result.getEventsList()).isEmpty();
}
use of org.sonarqube.ws.Developers.SearchEventsWsResponse in project sonarqube by SonarSource.
the class SearchEventsActionTest method does_not_return_old_events.
@Test
public void does_not_return_old_events() {
userSession.logIn().setRoot();
ComponentDto project = db.components().insertPrivateProject();
SnapshotDto analysis = insertAnalysis(project, 1_500_000_000_000L);
insertIssue(project, analysis);
db.events().insertEvent(newQualityGateEvent(analysis).setDate(analysis.getCreatedAt()).setName("Passed"));
SnapshotDto oldAnalysis = insertAnalysis(project, 1_400_000_000_000L);
insertIssue(project, oldAnalysis);
db.events().insertEvent(newQualityGateEvent(oldAnalysis).setDate(oldAnalysis.getCreatedAt()).setName("Failed"));
issueIndexer.indexAllIssues();
SearchEventsWsResponse result = ws.newRequest().setParam(PARAM_PROJECTS, project.getKey()).setParam(PARAM_FROM, formatDateTime(analysis.getCreatedAt() - 1450_000_000_000L)).executeProtobuf(SearchEventsWsResponse.class);
assertThat(result.getEventsList()).extracting(Event::getCategory, Event::getDate).containsOnly(tuple("NEW_ISSUES", formatDateTime(analysis.getCreatedAt())), tuple("QUALITY_GATE", formatDateTime(analysis.getCreatedAt())));
}
use of org.sonarqube.ws.Developers.SearchEventsWsResponse in project sonarqube by SonarSource.
the class SearchEventsActionTest method events.
@Test
public void events() {
userSession.logIn().setRoot();
when(server.getPublicRootUrl()).thenReturn("https://sonarcloud.io");
ComponentDto project = db.components().insertPrivateProject();
ComponentDto branch = db.components().insertProjectBranch(project);
SnapshotDto projectAnalysis = insertAnalysis(project, 1_500_000_000_000L);
db.events().insertEvent(newQualityGateEvent(projectAnalysis).setDate(projectAnalysis.getCreatedAt()).setName("Passed"));
insertIssue(project, projectAnalysis);
insertIssue(project, projectAnalysis);
SnapshotDto branchAnalysis = insertAnalysis(branch, 1_501_000_000_000L);
db.events().insertEvent(newQualityGateEvent(branchAnalysis).setDate(branchAnalysis.getCreatedAt()).setName("Failed"));
insertIssue(branch, branchAnalysis);
issueIndexer.indexAllIssues();
SearchEventsWsResponse result = ws.newRequest().setParam(PARAM_PROJECTS, project.getKey()).setParam(PARAM_FROM, formatDateTime(1_499_000_000_000L)).executeProtobuf(SearchEventsWsResponse.class);
assertThat(result.getEventsList()).extracting(Event::getCategory, Event::getProject, Event::getMessage).containsOnly(tuple("QUALITY_GATE", project.getKey(), format("Quality Gate status of project '%s' changed to 'Passed'", project.name())), tuple("QUALITY_GATE", project.getKey(), format("Quality Gate status of project '%s' on branch '%s' changed to 'Failed'", project.name(), branch.getBranch())), tuple("NEW_ISSUES", project.getKey(), format("You have 2 new issues on project '%s'", project.name())), tuple("NEW_ISSUES", project.getKey(), format("You have 1 new issue on project '%s' on branch '%s'", project.name(), branch.getBranch())));
verify(issueIndexSyncProgressChecker).checkIfAnyComponentsNeedIssueSync(any(), argThat(arg -> arg.contains(project.getKey())));
}
Aggregations