use of org.sonar.db.component.SnapshotDto in project sonarqube by SonarSource.
the class ComponentActionTest method branch_in_activity.
@Test
public void branch_in_activity() {
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());
Ce.ComponentResponse response = ws.newRequest().setParam(PARAM_COMPONENT, project.getKey()).executeProtobuf(Ce.ComponentResponse.class);
assertThat(response.getCurrent()).extracting(Ce.Task::getId, Ce.Task::getBranch, Ce.Task::getBranchType, Ce.Task::getStatus, Ce.Task::getComponentKey, Ce.Task::getWarningCount, Ce.Task::getWarningsList).containsOnly("T1", branch.getBranch(), Common.BranchType.BRANCH, Ce.TaskStatus.SUCCESS, project.getKey(), 0, emptyList());
}
use of org.sonar.db.component.SnapshotDto in project sonarqube by SonarSource.
the class ComponentCleanerServiceTest method insertProjectData.
private DbData insertProjectData() {
ComponentDto componentDto = db.components().insertPublicProject();
ProjectDto project = dbClient.projectDao().selectByUuid(dbSession, componentDto.uuid()).get();
BranchDto branch = dbClient.branchDao().selectByUuid(dbSession, project.getUuid()).get();
RuleDefinitionDto rule = db.rules().insert();
IssueDto issue = db.issues().insert(rule, project, componentDto);
SnapshotDto analysis = db.components().insertSnapshot(componentDto);
mockResourceTypeAsValidProject();
return new DbData(project, branch, analysis, issue);
}
use of org.sonar.db.component.SnapshotDto 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));
}
use of org.sonar.db.component.SnapshotDto 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.component.SnapshotDto in project sonarqube by SonarSource.
the class AnalysisStatusActionTest method allows_unauthenticated_access.
@Test
public void allows_unauthenticated_access() {
ComponentDto project = db.components().insertPublicProject();
userSession.registerComponents(project);
SnapshotDto analysis = db.components().insertSnapshot(project);
CeActivityDto activity = insertActivity("task-uuid" + counter++, project, SUCCESS, analysis, REPORT);
createTaskMessage(activity, WARNING_IN_MAIN);
createTaskMessage(activity, "Dismissible warning", CeTaskMessageType.SUGGEST_DEVELOPER_EDITION_UPGRADE);
Ce.AnalysisStatusWsResponse response = ws.newRequest().setParam(PARAM_COMPONENT, project.getKey()).executeProtobuf(Ce.AnalysisStatusWsResponse.class);
assertThat(response.getComponent().getWarningsList()).hasSize(2);
}
Aggregations