Search in sources :

Example 21 with SearchEventsWsResponse

use of org.sonarqube.ws.Developers.SearchEventsWsResponse in project sonarqube by SonarSource.

the class SearchEventsActionNewIssuesTest method issue_event.

@Test
public void issue_event() {
    userSession.logIn().setRoot();
    when(server.getPublicRootUrl()).thenReturn("https://sonarcloud.io");
    ComponentDto project = db.components().insertPrivateProject();
    SnapshotDto analysis = insertAnalysis(project, 1_500_000_000_000L);
    insertIssue(project, analysis);
    insertIssue(project, analysis);
    // will be ignored
    insertSecurityHotspot(project, analysis);
    issueIndexer.indexAllIssues();
    long from = analysis.getCreatedAt() - 1_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'", project.name()), format("https://sonarcloud.io/project/issues?id=%s&createdAfter=%s&assignees=%s&resolved=false", project.getKey(), encode(formatDateTime(from + 1_000L)), userSession.getLogin()), formatDateTime(analysis.getCreatedAt())));
}
Also used : SnapshotDto(org.sonar.db.component.SnapshotDto) ComponentDto(org.sonar.db.component.ComponentDto) SearchEventsWsResponse(org.sonarqube.ws.Developers.SearchEventsWsResponse) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)21 SearchEventsWsResponse (org.sonarqube.ws.Developers.SearchEventsWsResponse)21 ComponentDto (org.sonar.db.component.ComponentDto)19 SnapshotDto (org.sonar.db.component.SnapshotDto)19 EventDto (org.sonar.db.event.EventDto)7 Date (java.util.Date)2 String.format (java.lang.String.format)1 IntStream (java.util.stream.IntStream)1 Stream (java.util.stream.Stream)1 RandomStringUtils.randomAlphanumeric (org.apache.commons.lang.RandomStringUtils.randomAlphanumeric)1 RandomUtils.nextInt (org.apache.commons.lang.math.RandomUtils.nextInt)1 RandomUtils.nextLong (org.apache.commons.lang.math.RandomUtils.nextLong)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)1 Assertions.tuple (org.assertj.core.api.Assertions.tuple)1 Rule (org.junit.Rule)1 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)1 ArgumentMatchers.argThat (org.mockito.ArgumentMatchers.argThat)1 Mockito.mock (org.mockito.Mockito.mock)1 Mockito.verify (org.mockito.Mockito.verify)1