use of org.sonar.db.ce.CeTaskMessageDto in project sonarqube by SonarSource.
the class AnalysisStatusActionTest 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;
}
use of org.sonar.db.ce.CeTaskMessageDto in project sonarqube by SonarSource.
the class AnalysisStatusActionTest method return_warnings_for_last_analysis_of_branch.
@Test
public void return_warnings_for_last_analysis_of_branch() {
ComponentDto project = db.components().insertPrivateProject();
userSession.logIn().setSystemAdministrator().addProjectPermission(UserRole.USER, project);
ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setKey(BRANCH_WITH_WARNING));
SnapshotDto analysis = db.components().insertSnapshot(branch);
CeActivityDto activity = insertActivity("task-uuid" + counter++, branch, SUCCESS, analysis, REPORT);
CeTaskMessageDto taskMessage = createTaskMessage(activity, WARNING_IN_BRANCH);
Ce.AnalysisStatusWsResponse response = ws.newRequest().setParam(PARAM_COMPONENT, project.getKey()).setParam(PARAM_BRANCH, BRANCH_WITH_WARNING).executeProtobuf(Ce.AnalysisStatusWsResponse.class);
assertThat(response.getComponent().getWarningsList()).extracting(Warning::getKey, Warning::getMessage, Warning::getDismissable).containsExactly(tuple(taskMessage.getUuid(), WARNING_IN_BRANCH, false));
SnapshotDto analysis2 = db.components().insertSnapshot(branch);
insertActivity("task-uuid" + counter++, branch, SUCCESS, analysis2, REPORT);
insertActivity("task-uuid" + counter++, branch, SUCCESS, null, "PROJECT_EXPORT");
Ce.AnalysisStatusWsResponse response2 = ws.newRequest().setParam(PARAM_COMPONENT, project.getKey()).setParam(PARAM_BRANCH, BRANCH_WITH_WARNING).executeProtobuf(Ce.AnalysisStatusWsResponse.class);
assertThat(response2.getComponent().getWarningsList()).isEmpty();
}
use of org.sonar.db.ce.CeTaskMessageDto in project sonarqube by SonarSource.
the class DismissAnalysisWarningActionTest method returns_400_if_warning_is_not_dismissable.
@Test
public void returns_400_if_warning_is_not_dismissable() {
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 taskMessage = createTaskMessage(activity, "generic warning");
TestRequest request = underTest.newRequest().setParam("component", project.getKey()).setParam("warning", taskMessage.getUuid());
assertThrows(format("Message '%s' cannot be dismissed.", taskMessage.getUuid()), IllegalArgumentException.class, request::execute);
assertThat(db.countRowsOfTable("USER_DISMISSED_MESSAGES")).isZero();
}
use of org.sonar.db.ce.CeTaskMessageDto in project sonarqube by SonarSource.
the class DismissAnalysisWarningActionTest method return_204_on_success.
@Test
public void return_204_on_success() {
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);
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()));
}
use of org.sonar.db.ce.CeTaskMessageDto in project sonarqube by SonarSource.
the class UpgradeSuggestionsCleanerTest method insertCeTaskMessage.
private void insertCeTaskMessage(String uuid, CeTaskMessageType messageType, String msg) {
CeTaskMessageDto dto = new CeTaskMessageDto().setUuid(uuid).setMessage(msg).setType(messageType).setTaskUuid(TASK_UUID);
dbTester.getDbClient().ceTaskMessageDao().insert(dbTester.getSession(), dto);
dbTester.getSession().commit();
}
Aggregations