use of org.sonarqube.ws.ProjectAnalyses.CreateEventResponse in project sonarqube by SonarSource.
the class CreateEventActionTest method create_event_in_db.
@Test
public void create_event_in_db() {
ComponentDto project = newProjectDto(db.organizations().insert());
SnapshotDto analysis = db.components().insertProjectAndSnapshot(project);
CreateEventRequest.Builder request = CreateEventRequest.builder().setAnalysis(analysis.getUuid()).setCategory(VERSION).setName("5.6.3");
when(system.now()).thenReturn(123_456_789L);
logInAsProjectAdministrator(project);
CreateEventResponse result = call(request);
List<EventDto> dbEvents = dbClient.eventDao().selectByComponentUuid(dbSession, analysis.getComponentUuid());
assertThat(dbEvents).hasSize(1);
EventDto dbEvent = dbEvents.get(0);
assertThat(dbEvent.getName()).isEqualTo("5.6.3");
assertThat(dbEvent.getCategory()).isEqualTo(VERSION.getLabel());
assertThat(dbEvent.getDescription()).isNull();
assertThat(dbEvent.getAnalysisUuid()).isEqualTo(analysis.getUuid());
assertThat(dbEvent.getComponentUuid()).isEqualTo(analysis.getComponentUuid());
assertThat(dbEvent.getUuid()).isEqualTo(result.getEvent().getKey());
assertThat(dbEvent.getCreatedAt()).isEqualTo(123_456_789L);
assertThat(dbEvent.getDate()).isEqualTo(analysis.getCreatedAt());
}
use of org.sonarqube.ws.ProjectAnalyses.CreateEventResponse in project sonarqube by SonarSource.
the class CreateEventAction method handle.
@Override
public void handle(Request httpRequest, Response httpResponse) throws Exception {
CreateEventRequest request = toAddEventRequest(httpRequest);
CreateEventResponse response = doHandle(request);
writeProtobuf(response, httpRequest, httpResponse);
}
use of org.sonarqube.ws.ProjectAnalyses.CreateEventResponse in project sonarqube by SonarSource.
the class CreateEventActionTest method create_event_without_description.
@Test
public void create_event_without_description() {
ComponentDto project = newProjectDto(db.getDefaultOrganization());
SnapshotDto analysis = db.components().insertProjectAndSnapshot(project);
CreateEventRequest.Builder request = CreateEventRequest.builder().setAnalysis(analysis.getUuid()).setCategory(OTHER).setName("Project Import");
logInAsProjectAdministrator(project);
CreateEventResponse result = call(request);
ProjectAnalyses.Event event = result.getEvent();
assertThat(event.getKey()).isNotEmpty();
assertThat(event.hasDescription()).isFalse();
}
use of org.sonarqube.ws.ProjectAnalyses.CreateEventResponse in project sonarqube by SonarSource.
the class CreateEventActionTest method create_other_event_with_ws_response.
@Test
public void create_other_event_with_ws_response() {
ComponentDto project = newProjectDto(db.organizations().insert());
SnapshotDto analysis = db.components().insertProjectAndSnapshot(project);
CreateEventRequest.Builder request = CreateEventRequest.builder().setAnalysis(analysis.getUuid()).setName("Project Import");
logInAsProjectAdministrator(project);
CreateEventResponse result = call(request);
SnapshotDto newAnalysis = dbClient.snapshotDao().selectByUuid(dbSession, analysis.getUuid()).get();
assertThat(analysis.getVersion()).isEqualTo(newAnalysis.getVersion());
ProjectAnalyses.Event wsEvent = result.getEvent();
assertThat(wsEvent.getKey()).isNotEmpty();
assertThat(wsEvent.getCategory()).isEqualTo(OTHER.name());
assertThat(wsEvent.getName()).isEqualTo("Project Import");
assertThat(wsEvent.hasDescription()).isFalse();
assertThat(wsEvent.getAnalysis()).isEqualTo(analysis.getUuid());
}
use of org.sonarqube.ws.ProjectAnalyses.CreateEventResponse in project sonarqube by SonarSource.
the class CreateEventActionTest method create_event_as_project_admin.
@Test
public void create_event_as_project_admin() {
ComponentDto project = newProjectDto(db.getDefaultOrganization(), "P1");
SnapshotDto analysis = db.components().insertProjectAndSnapshot(project);
CreateEventRequest.Builder request = CreateEventRequest.builder().setAnalysis(analysis.getUuid()).setCategory(VERSION).setName("5.6.3");
logInAsProjectAdministrator(project);
CreateEventResponse result = call(request);
assertThat(result.getEvent().getKey()).isNotEmpty();
}
Aggregations