use of org.sonar.server.developers.ws.SearchEventsAction.PARAM_FROM 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