use of org.sonar.db.ce.CeTaskMessageDto in project sonarqube by SonarSource.
the class ActivityActionTest method insertMessages.
private void insertMessages(String taskUuid, int messageCount) {
IntStream.range(0, messageCount).forEach(i -> db.getDbClient().ceTaskMessageDao().insert(db.getSession(), new CeTaskMessageDto().setUuid("uuid_" + taskUuid + "_" + i).setTaskUuid(taskUuid).setMessage("m_" + taskUuid + "_" + i).setType(CeTaskMessageType.GENERIC).setCreatedAt(taskUuid.hashCode() + i)));
db.commit();
}
use of org.sonar.db.ce.CeTaskMessageDto in project sonarqube by SonarSource.
the class ComponentActionTest method populates_warning_count_of_activities_but_not_warnings.
@Test
public void populates_warning_count_of_activities_but_not_warnings() {
ComponentDto privateProject = db.components().insertPrivateProject();
userSession.addProjectPermission(UserRole.USER, privateProject);
SnapshotDto analysis = db.components().insertSnapshot(privateProject);
CeActivityDto activity = insertActivity("Branch", privateProject, SUCCESS, analysis);
int messageCount = 1 + new Random().nextInt(10);
IntStream.range(0, messageCount).forEach(i -> db.getDbClient().ceTaskMessageDao().insert(db.getSession(), new CeTaskMessageDto().setUuid("uuid_" + i).setTaskUuid(activity.getUuid()).setMessage("m_" + i).setType(CeTaskMessageType.GENERIC).setCreatedAt(i)));
db.commit();
Ce.ComponentResponse response = ws.newRequest().setParam(PARAM_COMPONENT, privateProject.getKey()).executeProtobuf(Ce.ComponentResponse.class);
assertThat(response.hasCurrent()).isTrue();
assertThat(response.getCurrent()).extracting(Ce.Task::getWarningCount, Ce.Task::getWarningsList).containsOnly(messageCount, emptyList());
}
use of org.sonar.db.ce.CeTaskMessageDto in project sonarqube by SonarSource.
the class TaskActionTest method insertWarning.
private CeTaskMessageDto insertWarning(CeActivityDto task, int i) {
CeTaskMessageDto res = new CeTaskMessageDto().setUuid(UuidFactoryFast.getInstance().create()).setTaskUuid(task.getUuid()).setMessage("msg_" + task.getUuid() + "_" + i).setType(CeTaskMessageType.GENERIC).setCreatedAt(task.getUuid().hashCode() + i);
db.getDbClient().ceTaskMessageDao().insert(db.getSession(), res);
db.getSession().commit();
return res;
}
use of org.sonar.db.ce.CeTaskMessageDto in project sonarqube by SonarSource.
the class TaskActionTest method no_warning_detail_on_task_in_queue.
@Test
public void no_warning_detail_on_task_in_queue() {
UserDto user = db.users().insertUser();
userSession.logIn(user).setRoot();
CeQueueDto queueDto = createAndPersistQueueTask(null, user);
IntStream.range(0, 1 + new Random().nextInt(5)).forEach(i -> db.getDbClient().ceTaskMessageDao().insert(db.getSession(), new CeTaskMessageDto().setUuid("u_" + i).setTaskUuid(queueDto.getUuid()).setMessage("m_" + i).setType(CeTaskMessageType.GENERIC).setCreatedAt(queueDto.getUuid().hashCode() + i)));
db.commit();
Ce.TaskResponse taskResponse = ws.newRequest().setParam("id", SOME_TASK_UUID).executeProtobuf(Ce.TaskResponse.class);
Ce.Task task = taskResponse.getTask();
assertThat(task.getWarningCount()).isZero();
assertThat(task.getWarningsList()).isEmpty();
}
use of org.sonar.db.ce.CeTaskMessageDto in project sonarqube by SonarSource.
the class AnalysisStatusActionTest method return_warnings_per_branch.
@Test
public void return_warnings_per_branch() {
ComponentDto project = db.components().insertPrivateProject();
userSession.logIn().setSystemAdministrator().addProjectPermission(UserRole.USER, project);
SnapshotDto analysis = db.components().insertSnapshot(project);
CeActivityDto activity = insertActivity("task-uuid" + counter++, project, SUCCESS, analysis, REPORT);
CeTaskMessageDto warningInMainMessage = createTaskMessage(activity, WARNING_IN_MAIN);
ComponentDto branchWithWarning = db.components().insertProjectBranch(project, b -> b.setKey(BRANCH_WITH_WARNING));
SnapshotDto branchAnalysis = db.components().insertSnapshot(branchWithWarning);
CeActivityDto branchActivity = insertActivity("task-uuid" + counter++, branchWithWarning, SUCCESS, branchAnalysis, REPORT);
CeTaskMessageDto warningInBranchMessage = createTaskMessage(branchActivity, WARNING_IN_BRANCH);
ComponentDto branchWithoutWarning = db.components().insertProjectBranch(project, b -> b.setKey(BRANCH_WITHOUT_WARNING));
SnapshotDto branchWithoutWarningAnalysis = db.components().insertSnapshot(branchWithoutWarning);
insertActivity("task-uuid" + counter++, branchWithoutWarning, SUCCESS, branchWithoutWarningAnalysis, REPORT);
ComponentDto pullRequest = db.components().insertProjectBranch(project, b -> {
b.setBranchType(BranchType.PULL_REQUEST);
b.setKey(PULL_REQUEST);
});
SnapshotDto prAnalysis = db.components().insertSnapshot(pullRequest);
CeActivityDto prActivity = insertActivity("task-uuid" + counter++, pullRequest, SUCCESS, prAnalysis, REPORT);
CeTaskMessageDto warningInPrMessage = createTaskMessage(prActivity, WARNING_IN_PR);
Ce.AnalysisStatusWsResponse responseForMain = ws.newRequest().setParam(PARAM_COMPONENT, project.getKey()).executeProtobuf(Ce.AnalysisStatusWsResponse.class);
assertThat(responseForMain.getComponent().getWarningsList()).extracting(Warning::getKey, Warning::getMessage, Warning::getDismissable).containsExactly(tuple(warningInMainMessage.getUuid(), WARNING_IN_MAIN, false));
Ce.AnalysisStatusWsResponse responseForBranchWithWarning = ws.newRequest().setParam(PARAM_COMPONENT, project.getKey()).setParam(PARAM_BRANCH, BRANCH_WITH_WARNING).executeProtobuf(Ce.AnalysisStatusWsResponse.class);
assertThat(responseForBranchWithWarning.getComponent().getWarningsList()).extracting(Warning::getKey, Warning::getMessage, Warning::getDismissable).containsExactly(tuple(warningInBranchMessage.getUuid(), WARNING_IN_BRANCH, false));
Ce.AnalysisStatusWsResponse responseForBranchWithoutWarning = ws.newRequest().setParam(PARAM_COMPONENT, project.getKey()).setParam(PARAM_BRANCH, BRANCH_WITHOUT_WARNING).executeProtobuf(Ce.AnalysisStatusWsResponse.class);
assertThat(responseForBranchWithoutWarning.getComponent().getWarningsList()).isEmpty();
Ce.AnalysisStatusWsResponse responseForPr = ws.newRequest().setParam(PARAM_COMPONENT, project.getKey()).setParam(PARAM_PULL_REQUEST, PULL_REQUEST).executeProtobuf(Ce.AnalysisStatusWsResponse.class);
assertThat(responseForPr.getComponent().getWarningsList()).extracting(Warning::getKey, Warning::getMessage, Warning::getDismissable).containsExactly(tuple(warningInPrMessage.getUuid(), WARNING_IN_PR, false));
}
Aggregations