Search in sources :

Example 6 with EventDto

use of org.sonar.db.event.EventDto in project sonarqube by SonarSource.

the class UpdateEventActionTest method update_name_in_db.

@Test
public void update_name_in_db() {
    SnapshotDto analysis = createAnalysisAndLogInAsProjectAdministrator("5.6");
    EventDto originalEvent = db.events().insertEvent(newEvent(analysis).setUuid("E1").setName("Original Name"));
    call("E1", "name");
    EventDto newEvent = dbClient.eventDao().selectByUuid(dbSession, "E1").get();
    assertThat(newEvent.getName()).isEqualTo("name");
    assertThat(newEvent.getDescription()).isNull();
    assertThat(newEvent.getCategory()).isEqualTo(originalEvent.getCategory());
    assertThat(newEvent.getDate()).isEqualTo(originalEvent.getDate());
    assertThat(newEvent.getCreatedAt()).isEqualTo(originalEvent.getCreatedAt());
}
Also used : SnapshotDto(org.sonar.db.component.SnapshotDto) EventDto(org.sonar.db.event.EventDto) Test(org.junit.Test)

Example 7 with EventDto

use of org.sonar.db.event.EventDto in project sonarqube by SonarSource.

the class UpdateEventActionTest method update_name_only_in_db.

@Test
public void update_name_only_in_db() {
    SnapshotDto analysis = createAnalysisAndLogInAsProjectAdministrator("5.6");
    EventDto originalEvent = db.events().insertEvent(newEvent(analysis).setUuid("E1").setName("Original Name").setDescription("Original Description"));
    call("E1", "name");
    EventDto newEvent = dbClient.eventDao().selectByUuid(dbSession, "E1").get();
    assertThat(newEvent.getName()).isEqualTo("name");
    assertThat(newEvent.getDescription()).isEqualTo(originalEvent.getDescription());
}
Also used : SnapshotDto(org.sonar.db.component.SnapshotDto) EventDto(org.sonar.db.event.EventDto) Test(org.junit.Test)

Example 8 with EventDto

use of org.sonar.db.event.EventDto in project sonarqube by SonarSource.

the class CreateEventActionTest method create_2_version_events_on_same_project.

@Test
public void create_2_version_events_on_same_project() {
    ComponentDto project = newProjectDto(db.organizations().insert());
    SnapshotDto firstAnalysis = db.components().insertProjectAndSnapshot(project);
    CreateEventRequest.Builder firstRequest = CreateEventRequest.builder().setAnalysis(firstAnalysis.getUuid()).setCategory(VERSION).setName("5.6.3");
    SnapshotDto secondAnalysis = dbClient.snapshotDao().insert(dbSession, newAnalysis(project));
    db.commit();
    CreateEventRequest.Builder secondRequest = CreateEventRequest.builder().setAnalysis(secondAnalysis.getUuid()).setCategory(VERSION).setName("6.3");
    logInAsProjectAdministrator(project);
    call(firstRequest);
    call(secondRequest);
    List<EventDto> events = dbClient.eventDao().selectByComponentUuid(dbSession, project.uuid());
    assertThat(events).hasSize(2);
}
Also used : CreateEventRequest(org.sonarqube.ws.client.projectanalysis.CreateEventRequest) SnapshotDto(org.sonar.db.component.SnapshotDto) ComponentDto(org.sonar.db.component.ComponentDto) EventDto(org.sonar.db.event.EventDto) Test(org.junit.Test)

Example 9 with EventDto

use of org.sonar.db.event.EventDto in project sonarqube by SonarSource.

the class DeleteEventActionTest method delete_event.

@Test
public void delete_event() {
    ComponentDto project = newProjectDto(db.organizations().insert());
    SnapshotDto analysis = db.components().insertProjectAndSnapshot(project);
    db.events().insertEvent(newEvent(analysis).setUuid("E1"));
    db.events().insertEvent(newEvent(analysis).setUuid("E2"));
    logInAsProjectAdministrator(project);
    call("E2");
    List<EventDto> events = db.getDbClient().eventDao().selectByAnalysisUuid(db.getSession(), analysis.getUuid());
    assertThat(events).extracting(EventDto::getUuid).containsExactly("E1");
}
Also used : SnapshotDto(org.sonar.db.component.SnapshotDto) ComponentDto(org.sonar.db.component.ComponentDto) EventDto(org.sonar.db.event.EventDto) Test(org.junit.Test)

Aggregations

EventDto (org.sonar.db.event.EventDto)9 SnapshotDto (org.sonar.db.component.SnapshotDto)8 Test (org.junit.Test)7 ComponentDto (org.sonar.db.component.ComponentDto)4 CreateEventRequest (org.sonarqube.ws.client.projectanalysis.CreateEventRequest)2 DbSession (org.sonar.db.DbSession)1 SnapshotTesting.newAnalysis (org.sonar.db.component.SnapshotTesting.newAnalysis)1 EventTesting.newEvent (org.sonar.db.event.EventTesting.newEvent)1 OrganizationDto (org.sonar.db.organization.OrganizationDto)1 ProjectAnalyses (org.sonarqube.ws.ProjectAnalyses)1 Analysis (org.sonarqube.ws.ProjectAnalyses.Analysis)1 CreateEventResponse (org.sonarqube.ws.ProjectAnalyses.CreateEventResponse)1 Event (org.sonarqube.ws.ProjectAnalyses.Event)1