use of org.sonar.db.component.SnapshotDto in project sonarqube by SonarSource.
the class ActivityActionTest method branch_in_past_activity.
@Test
public void branch_in_past_activity() {
logInAsSystemAdministrator();
ComponentDto project = db.components().insertPrivateProject();
userSession.addProjectPermission(UserRole.USER, project);
ComponentDto branch = db.components().insertProjectBranch(project, b -> b.setBranchType(BRANCH));
SnapshotDto analysis = db.components().insertSnapshot(branch);
CeActivityDto activity = insertActivity("T1", project, SUCCESS, analysis);
insertCharacteristic(activity, BRANCH_KEY, branch.getBranch());
insertCharacteristic(activity, BRANCH_TYPE_KEY, BRANCH.name());
ActivityResponse response = ws.newRequest().executeProtobuf(ActivityResponse.class);
assertThat(response.getTasksList()).extracting(Task::getId, Ce.Task::getBranch, Ce.Task::getBranchType, Ce.Task::getStatus, Ce.Task::getComponentKey).containsExactlyInAnyOrder(tuple("T1", branch.getBranch(), Common.BranchType.BRANCH, Ce.TaskStatus.SUCCESS, branch.getKey()));
}
use of org.sonar.db.component.SnapshotDto in project sonarqube by SonarSource.
the class ComponentActionTest method search_tasks_by_component_key.
@Test
public void search_tasks_by_component_key() {
ComponentDto project = db.components().insertPrivateProject();
logInWithBrowsePermission(project);
SnapshotDto analysis = db.components().insertSnapshot(project);
insertActivity("T1", project, CeActivityDto.Status.SUCCESS, analysis);
Ce.ComponentResponse response = ws.newRequest().setParam(PARAM_COMPONENT, project.getDbKey()).executeProtobuf(Ce.ComponentResponse.class);
assertThat(response.hasCurrent()).isTrue();
Ce.Task current = response.getCurrent();
assertThat(current.getId()).isEqualTo("T1");
assertThat(current.getAnalysisId()).isEqualTo(analysis.getUuid());
assertThat(current.getWarningCount()).isZero();
assertThat(current.getWarningsList()).isEmpty();
}
use of org.sonar.db.component.SnapshotDto in project sonarqube by SonarSource.
the class ComponentActionTest method search_tasks_by_component.
@Test
public void search_tasks_by_component() {
ComponentDto project = db.components().insertPrivateProject();
logInWithBrowsePermission(project);
SnapshotDto analysis = db.components().insertSnapshot(project);
insertActivity("T1", project, CeActivityDto.Status.SUCCESS, analysis);
Ce.ComponentResponse response = ws.newRequest().setParam(PARAM_COMPONENT, project.getKey()).executeProtobuf(Ce.ComponentResponse.class);
assertThat(response.hasCurrent()).isTrue();
Ce.Task current = response.getCurrent();
assertThat(current.getId()).isEqualTo("T1");
assertThat(current.getAnalysisId()).isEqualTo(analysis.getUuid());
assertThat(current.getWarningCount()).isZero();
assertThat(current.getWarningsList()).isEmpty();
}
use of org.sonar.db.component.SnapshotDto in project sonarqube by SonarSource.
the class ComponentActionTest method project_tasks.
@Test
public void project_tasks() {
ComponentDto project1 = db.components().insertPrivateProject();
SnapshotDto analysisProject1 = db.components().insertSnapshot(project1);
ComponentDto project2 = db.components().insertPrivateProject();
userSession.addProjectPermission(UserRole.USER, project1);
insertActivity("T1", project1, CeActivityDto.Status.SUCCESS, analysisProject1);
insertActivity("T2", project2, CeActivityDto.Status.FAILED, null);
insertActivity("T3", project1, CeActivityDto.Status.FAILED, null);
insertQueue("T4", project1, IN_PROGRESS);
insertQueue("T5", project1, PENDING);
Ce.ComponentResponse response = ws.newRequest().setParam(PARAM_COMPONENT, project1.getKey()).executeProtobuf(Ce.ComponentResponse.class);
assertThat(response.getQueueCount()).isEqualTo(2);
assertThat(response.getQueue(0).getId()).isEqualTo("T4");
assertThat(response.getQueue(1).getId()).isEqualTo("T5");
// T3 is the latest task executed on PROJECT_1
assertThat(response.hasCurrent()).isTrue();
Ce.Task current = response.getCurrent();
assertThat(current.getId()).isEqualTo("T3");
assertThat(current.hasAnalysisId()).isFalse();
assertThat(current.getWarningCount()).isZero();
assertThat(current.getWarningsList()).isEmpty();
}
use of org.sonar.db.component.SnapshotDto 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());
}
Aggregations