use of org.sonarqube.ws.Developers.SearchEventsWsResponse in project sonarqube by SonarSource.
the class SearchEventsActionQualityGateTest method encode_link.
@Test
public void encode_link() {
userSession.logIn().setRoot();
ComponentDto project = db.components().insertPrivateProject(p -> p.setDbKey("M&M's"));
SnapshotDto analysis = insertSuccessfulActivity(project, 1_500_000_000_000L);
EventDto event = db.events().insertEvent(newQualityGateEvent(analysis).setName("Failed").setDate(analysis.getCreatedAt()));
when(server.getPublicRootUrl()).thenReturn("http://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("http://sonarcloud.io/dashboard?id=M%26M%27s");
}
use of org.sonarqube.ws.Developers.SearchEventsWsResponse in project sonarqube by SonarSource.
the class SearchEventsActionQualityGateTest method return_link_to_dashboard_for_quality_gate_event.
@Test
public void return_link_to_dashboard_for_quality_gate_event() {
userSession.logIn().setRoot();
ComponentDto project = db.components().insertPrivateProject();
SnapshotDto analysis = insertSuccessfulActivity(project, 1_500_000_000_000L);
EventDto e1 = db.events().insertEvent(newQualityGateEvent(analysis).setName("Failed").setDate(analysis.getCreatedAt()));
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/dashboard?id=" + project.getKey());
}
use of org.sonarqube.ws.Developers.SearchEventsWsResponse in project sonarqube by SonarSource.
the class SearchEventsActionQualityGateTest method return_one_quality_gate_change_per_project.
@Test
public void return_one_quality_gate_change_per_project() {
userSession.logIn().setRoot();
ComponentDto project1 = db.components().insertPrivateProject(p -> p.setName("p1"));
ComponentDto project2 = db.components().insertPrivateProject(p -> p.setName("p2"));
long from = 1_500_000_000_000L;
SnapshotDto a11 = insertSuccessfulActivity(project1, from);
SnapshotDto a12 = insertSuccessfulActivity(project1, from + 1L);
SnapshotDto a21 = insertSuccessfulActivity(project2, from);
SnapshotDto a22 = insertSuccessfulActivity(project2, from + 1L);
EventDto e11 = db.events().insertEvent(newQualityGateEvent(a11).setName("e11").setDate(from));
EventDto e12 = db.events().insertEvent(newQualityGateEvent(a12).setName("e12").setDate(from + 1L));
EventDto e21 = db.events().insertEvent(newQualityGateEvent(a21).setName("e21").setDate(from));
EventDto e22 = db.events().insertEvent(newQualityGateEvent(a22).setName("e22").setDate(from + 1L));
String fromDate = formatDateTime(from - 1_000L);
SearchEventsWsResponse result = ws.newRequest().setParam(PARAM_PROJECTS, join(",", project1.getKey(), project2.getKey())).setParam(PARAM_FROM, join(",", fromDate, fromDate)).executeProtobuf(SearchEventsWsResponse.class);
assertThat(result.getEventsList()).extracting(Event::getProject, Event::getMessage).containsExactlyInAnyOrder(tuple(project1.getKey(), "Quality Gate status of project 'p1' changed to 'e12'"), tuple(project2.getKey(), "Quality Gate status of project 'p2' changed to 'e22'"));
}
use of org.sonarqube.ws.Developers.SearchEventsWsResponse in project sonarqube by SonarSource.
the class SearchEventsActionQualityGateTest method return_only_latest_quality_gate_event.
@Test
public void return_only_latest_quality_gate_event() {
userSession.logIn().setRoot();
ComponentDto project = db.components().insertPrivateProject(p -> p.setName("My Project"));
SnapshotDto a1 = insertSuccessfulActivity(project, 1_500_000_000_000L);
EventDto e1 = db.events().insertEvent(newQualityGateEvent(a1).setName("Failed").setDate(a1.getCreatedAt()));
SnapshotDto a2 = insertSuccessfulActivity(project, 1_500_000_000_001L);
EventDto e2 = db.events().insertEvent(newQualityGateEvent(a2).setName("Passed").setDate(a2.getCreatedAt() + 1L));
SearchEventsWsResponse result = ws.newRequest().setParam(PARAM_PROJECTS, project.getKey()).setParam(PARAM_FROM, formatDateTime(a1.getCreatedAt() - 1_000L)).executeProtobuf(SearchEventsWsResponse.class);
assertThat(result.getEventsList()).extracting(Event::getMessage).containsExactly("Quality Gate status of project 'My Project' changed to 'Passed'");
}
use of org.sonarqube.ws.Developers.SearchEventsWsResponse in project sonarqube by SonarSource.
the class SearchEventsActionQualityGateTest method filter_quality_gate_event.
@Test
public void filter_quality_gate_event() {
userSession.logIn().setRoot();
ComponentDto project = db.components().insertPrivateProject();
SnapshotDto analysis = insertSuccessfulActivity(project, 1_500_000_000_000L);
EventDto qualityGateEvent = db.events().insertEvent(newQualityGateEvent(analysis).setDate(analysis.getCreatedAt()));
EventDto versionEvent = db.events().insertEvent(newEvent(analysis).setCategory(EventCategory.VERSION.getLabel()).setDate(analysis.getCreatedAt()));
EventDto qualityProfileEvent = db.events().insertEvent(newEvent(analysis).setCategory(EventCategory.QUALITY_PROFILE.getLabel()).setDate(analysis.getCreatedAt()));
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::getCategory).containsExactly("QUALITY_GATE");
}
Aggregations