Search in sources :

Example 16 with CeTaskMessageDto

use of org.sonar.db.ce.CeTaskMessageDto in project sonarqube by SonarSource.

the class DismissAnalysisWarningActionTest method is_idempotent.

@Test
public void is_idempotent() {
    UserDto user = db.users().insertUser();
    ComponentDto project = db.components().insertPrivateProject();
    userSession.logIn(user).addProjectPermission(UserRole.USER, project);
    SnapshotDto analysis = db.components().insertSnapshot(project);
    CeActivityDto activity = insertActivity("task-uuid" + counter++, project, SUCCESS, analysis, REPORT);
    CeTaskMessageDto taskMessageDismissible = createTaskMessage(activity, "dismissable warning", CeTaskMessageType.SUGGEST_DEVELOPER_EDITION_UPGRADE);
    underTest.newRequest().setParam("component", project.getKey()).setParam("warning", taskMessageDismissible.getUuid()).execute();
    TestResponse response = underTest.newRequest().setParam("component", project.getKey()).setParam("warning", taskMessageDismissible.getUuid()).execute();
    assertThat(response.getStatus()).isEqualTo(204);
    assertThat(db.select("select * from user_dismissed_messages")).extracting("USER_UUID", "PROJECT_UUID", "MESSAGE_TYPE").containsExactly(tuple(userSession.getUuid(), project.uuid(), CeTaskMessageType.SUGGEST_DEVELOPER_EDITION_UPGRADE.name()));
}
Also used : CeActivityDto(org.sonar.db.ce.CeActivityDto) TestResponse(org.sonar.server.ws.TestResponse) UserDto(org.sonar.db.user.UserDto) SnapshotDto(org.sonar.db.component.SnapshotDto) CeTaskMessageDto(org.sonar.db.ce.CeTaskMessageDto) ComponentDto(org.sonar.db.component.ComponentDto) Test(org.junit.Test)

Example 17 with CeTaskMessageDto

use of org.sonar.db.ce.CeTaskMessageDto in project sonarqube by SonarSource.

the class DismissAnalysisWarningActionTest method createTaskMessage.

private CeTaskMessageDto createTaskMessage(CeActivityDto activity, String warning, CeTaskMessageType messageType) {
    CeTaskMessageDto ceTaskMessageDto = new CeTaskMessageDto().setUuid("m-uuid-" + counter++).setTaskUuid(activity.getUuid()).setMessage(warning).setType(messageType).setCreatedAt(counter);
    db.getDbClient().ceTaskMessageDao().insert(db.getSession(), ceTaskMessageDto);
    db.commit();
    return ceTaskMessageDto;
}
Also used : CeTaskMessageDto(org.sonar.db.ce.CeTaskMessageDto)

Aggregations

CeTaskMessageDto (org.sonar.db.ce.CeTaskMessageDto)17 Test (org.junit.Test)11 CeActivityDto (org.sonar.db.ce.CeActivityDto)10 ComponentDto (org.sonar.db.component.ComponentDto)10 SnapshotDto (org.sonar.db.component.SnapshotDto)10 UserDto (org.sonar.db.user.UserDto)6 Ce (org.sonarqube.ws.Ce)6 Random (java.util.Random)3 DbSession (org.sonar.db.DbSession)2 ProjectDto (org.sonar.db.project.ProjectDto)2 UserDismissedMessageDto (org.sonar.db.user.UserDismissedMessageDto)2 MoreObjects.firstNonNull (com.google.common.base.MoreObjects.firstNonNull)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 LocalDateTime (java.time.LocalDateTime)1 ZoneOffset (java.time.ZoneOffset)1 UTC (java.time.ZoneOffset.UTC)1 Arrays (java.util.Arrays)1 Arrays.asList (java.util.Arrays.asList)1 Collection (java.util.Collection)1