use of org.sonarqube.ws.Developers.SearchEventsWsResponse in project sonarqube by SonarSource.
the class SearchEventsActionNewIssuesTest method pull_request_issues_events.
@Test
public void pull_request_issues_events() {
userSession.logIn().setRoot();
when(server.getPublicRootUrl()).thenReturn("https://sonarcloud.io");
ComponentDto project = db.components().insertPrivateProject();
ComponentDto nonMainBranch = db.components().insertProjectBranch(project, b -> b.setBranchType(BRANCH).setKey("nonMain"));
SnapshotDto nonMainBranchAnalysis = insertAnalysis(nonMainBranch, 1_500_000_000_000L);
insertIssue(nonMainBranch, nonMainBranchAnalysis);
insertIssue(nonMainBranch, nonMainBranchAnalysis);
ComponentDto pullRequest = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.PULL_REQUEST).setKey("42"));
SnapshotDto pullRequestAnalysis = insertAnalysis(pullRequest, 1_300_000_000_000L);
insertIssue(pullRequest, pullRequestAnalysis);
issueIndexer.indexAllIssues();
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("NEW_ISSUES", project.getKey(), format("You have 2 new issues on project '%s' on branch '%s'", project.name(), nonMainBranch.getBranch()), format("https://sonarcloud.io/project/issues?id=%s&createdAfter=%s&assignees=%s&resolved=false&branch=%s", nonMainBranch.getKey(), encode(formatDateTime(from + 1_000L)), userSession.getLogin(), nonMainBranch.getBranch()), formatDateTime(nonMainBranchAnalysis.getCreatedAt())), tuple("NEW_ISSUES", project.getKey(), format("You have 1 new issue on project '%s' on pull request '%s'", project.name(), pullRequest.getPullRequest()), format("https://sonarcloud.io/project/issues?id=%s&createdAfter=%s&assignees=%s&resolved=false&pullRequest=%s", pullRequest.getKey(), encode(formatDateTime(from + 1_000L)), userSession.getLogin(), pullRequest.getPullRequest()), formatDateTime(pullRequestAnalysis.getCreatedAt())));
}
use of org.sonarqube.ws.Developers.SearchEventsWsResponse in project sonarqube by SonarSource.
the class SearchEventsActionNewIssuesTest method does_not_return_old_issue.
@Test
public void does_not_return_old_issue() {
userSession.logIn().setRoot();
ComponentDto project = db.components().insertPrivateProject();
SnapshotDto analysis = insertAnalysis(project, 1_500_000_000_000L);
db.issues().insert(db.rules().insert(), project, project, i -> i.setIssueCreationDate(new Date(analysis.getCreatedAt() - 10_000L)));
issueIndexer.indexAllIssues();
SearchEventsWsResponse result = ws.newRequest().setParam(PARAM_PROJECTS, project.getKey()).setParam(PARAM_FROM, formatDateTime(analysis.getCreatedAt() - 1_000L)).executeProtobuf(SearchEventsWsResponse.class);
assertThat(result.getEventsList()).isEmpty();
}
use of org.sonarqube.ws.Developers.SearchEventsWsResponse in project sonarqube by SonarSource.
the class SearchEventsActionTest method empty_response_if_project_key_is_unknown.
@Test
public void empty_response_if_project_key_is_unknown() {
userSession.logIn().setRoot();
long from = 1_500_000_000_000L;
SearchEventsWsResponse result = ws.newRequest().setParam(PARAM_PROJECTS, "unknown").setParam(PARAM_FROM, formatDateTime(from - 1_000L)).executeProtobuf(SearchEventsWsResponse.class);
assertThat(result.getEventsList()).isEmpty();
}
use of org.sonarqube.ws.Developers.SearchEventsWsResponse in project sonarqube by SonarSource.
the class SearchEventsActionNewIssuesTest method many_issues_events.
@Test
public void many_issues_events() {
userSession.logIn().setRoot();
long from = 1_500_000_000_000L;
ComponentDto project = db.components().insertPrivateProject(p -> p.setName("SonarQube"));
SnapshotDto analysis = insertAnalysis(project, from);
insertIssue(project, analysis);
insertIssue(project, analysis);
issueIndexer.indexAllIssues();
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::getCategory, Event::getMessage, Event::getProject, Event::getDate).containsExactly(tuple("NEW_ISSUES", "You have 2 new issues on project 'SonarQube'", project.getKey(), formatDateTime(from)));
}
use of org.sonarqube.ws.Developers.SearchEventsWsResponse in project sonarqube by SonarSource.
the class SearchEventsActionNewIssuesTest method branch_issues_events.
@Test
public void branch_issues_events() {
userSession.logIn().setRoot();
when(server.getPublicRootUrl()).thenReturn("https://sonarcloud.io");
ComponentDto project = db.components().insertPrivateProject();
ComponentDto branch1 = db.components().insertProjectBranch(project, b -> b.setBranchType(BRANCH).setKey("branch1"));
SnapshotDto branch1Analysis = insertAnalysis(branch1, 1_500_000_000_000L);
insertIssue(branch1, branch1Analysis);
insertIssue(branch1, branch1Analysis);
ComponentDto branch2 = db.components().insertProjectBranch(project, b -> b.setBranchType(BranchType.BRANCH).setKey("branch"));
SnapshotDto branch2Analysis = insertAnalysis(branch2, 1_300_000_000_000L);
insertIssue(branch2, branch2Analysis);
issueIndexer.indexAllIssues();
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("NEW_ISSUES", project.getKey(), format("You have 2 new issues on project '%s' on branch '%s'", project.name(), branch1.getBranch()), format("https://sonarcloud.io/project/issues?id=%s&createdAfter=%s&assignees=%s&resolved=false&branch=%s", branch1.getKey(), encode(formatDateTime(from + 1_000L)), userSession.getLogin(), branch1.getBranch()), formatDateTime(branch1Analysis.getCreatedAt())), tuple("NEW_ISSUES", project.getKey(), format("You have 1 new issue on project '%s' on branch '%s'", project.name(), branch2.getBranch()), format("https://sonarcloud.io/project/issues?id=%s&createdAfter=%s&assignees=%s&resolved=false&branch=%s", branch2.getKey(), encode(formatDateTime(from + 1_000L)), userSession.getLogin(), branch2.getBranch()), formatDateTime(branch2Analysis.getCreatedAt())));
}
Aggregations