use of org.sonar.server.project.Project in project sonarqube by SonarSource.
the class BulkDeleteAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
SearchRequest searchRequest = toSearchWsRequest(request);
userSession.checkLoggedIn();
try (DbSession dbSession = dbClient.openSession(false)) {
userSession.checkPermission(GlobalPermission.ADMINISTER);
checkAtLeastOneParameterIsPresent(searchRequest);
ComponentQuery query = buildDbQuery(searchRequest);
Set<ComponentDto> componentDtos = new HashSet<>(dbClient.componentDao().selectByQuery(dbSession, query, 0, Integer.MAX_VALUE));
try {
componentDtos.forEach(p -> componentCleanerService.delete(dbSession, p));
} finally {
projectLifeCycleListeners.onProjectsDeleted(componentDtos.stream().map(Project::from).collect(MoreCollectors.toSet(componentDtos.size())));
}
}
response.noContent();
}
use of org.sonar.server.project.Project in project sonarqube by SonarSource.
the class SiblingsIssueMergerTest method setUp.
@Before
public void setUp() {
DbClient dbClient = db.getDbClient();
ComponentIssuesLoader componentIssuesLoader = new ComponentIssuesLoader(dbClient, null, null, new MapSettings().asConfig(), System2.INSTANCE);
copier = new SiblingsIssueMerger(new SiblingsIssuesLoader(new SiblingComponentsWithOpenIssues(treeRootHolder, metadataHolder, dbClient), dbClient, componentIssuesLoader), tracker, issueLifecycle);
projectDto = db.components().insertPublicProject(p -> p.setDbKey(PROJECT_KEY).setUuid(PROJECT_UUID));
branch1Dto = db.components().insertProjectBranch(projectDto, b -> b.setKey("myBranch1").setBranchType(BranchType.PULL_REQUEST).setMergeBranchUuid(projectDto.uuid()));
branch2Dto = db.components().insertProjectBranch(projectDto, b -> b.setKey("myBranch2").setBranchType(BranchType.PULL_REQUEST).setMergeBranchUuid(projectDto.uuid()));
branch3Dto = db.components().insertProjectBranch(projectDto, b -> b.setKey("myBranch3").setBranchType(BranchType.PULL_REQUEST).setMergeBranchUuid(projectDto.uuid()));
fileOnBranch1Dto = db.components().insertComponent(newFileDto(branch1Dto).setDbKey(FILE_1_KEY + ":PULL_REQUEST:myBranch1"));
fileOnBranch2Dto = db.components().insertComponent(newFileDto(branch2Dto).setDbKey(FILE_1_KEY + ":PULL_REQUEST:myBranch2"));
fileOnBranch3Dto = db.components().insertComponent(newFileDto(branch3Dto).setDbKey(FILE_1_KEY + ":PULL_REQUEST:myBranch3"));
rule = db.rules().insert();
when(branch.getReferenceBranchUuid()).thenReturn(projectDto.uuid());
metadataHolder.setBranch(branch);
metadataHolder.setProject(new Project(projectDto.uuid(), projectDto.getKey(), projectDto.name(), projectDto.description(), Collections.emptyList()));
}
use of org.sonar.server.project.Project in project sonarqube by SonarSource.
the class SourceBranchComponentUuidsTest method setup.
@Before
public void setup() {
underTest = new SourceBranchComponentUuids(analysisMetadataHolder, db.getDbClient());
Project project = mock(Project.class);
analysisMetadataHolder.setProject(project);
analysisMetadataHolder.setBranch(branch);
ComponentDto projectDto = db.components().insertPublicProject();
when(project.getUuid()).thenReturn(projectDto.uuid());
branch1 = db.components().insertProjectBranch(projectDto, b -> b.setKey(BRANCH_KEY));
ComponentDto pr1branch = db.components().insertProjectBranch(projectDto, b -> b.setKey(PR_KEY).setBranchType(BranchType.PULL_REQUEST).setPullRequestData(DbProjectBranches.PullRequestData.newBuilder().setBranch(BRANCH_KEY).build()).setMergeBranchUuid(projectDto.getMainBranchProjectUuid()));
branch1File = ComponentTesting.newFileDto(branch1, null, "file").setUuid("branch1File");
pr1File = ComponentTesting.newFileDto(pr1branch, null, "file").setUuid("file1");
db.components().insertComponents(branch1File, pr1File);
}
use of org.sonar.server.project.Project in project sonarqube by SonarSource.
the class NewCodeReferenceBranchComponentUuidsTest method setUp.
@Before
public void setUp() {
analysisMetadataHolder.setProject(project);
ComponentDto projectDto = db.components().insertPublicProject();
when(project.getUuid()).thenReturn(projectDto.uuid());
branch1 = db.components().insertProjectBranch(projectDto, b -> b.setKey("branch1"));
branch2 = db.components().insertProjectBranch(projectDto, b -> b.setKey("branch2"));
pr1 = db.components().insertProjectBranch(projectDto, b -> b.setKey("pr1").setBranchType(BranchType.PULL_REQUEST).setMergeBranchUuid(branch1.uuid()));
pr2 = db.components().insertProjectBranch(projectDto, b -> b.setKey("pr2").setBranchType(BranchType.PULL_REQUEST).setMergeBranchUuid(branch1.uuid()));
branch1File = ComponentTesting.newFileDto(branch1, null, "file").setUuid("branch1File");
branch2File = ComponentTesting.newFileDto(branch2, null, "file").setUuid("branch2File");
pr1File = ComponentTesting.newFileDto(pr1, null, "file").setUuid("file1");
pr2File = ComponentTesting.newFileDto(pr2, null, "file").setUuid("file2");
db.components().insertComponents(branch1File, pr1File, pr2File, branch2File);
}
use of org.sonar.server.project.Project in project sonarqube by SonarSource.
the class LoadReportAnalysisMetadataHolderStepTest method set_project_from_dto.
@Test
public void set_project_from_dto() {
reportReader.setMetadata(newBatchReportBuilder().setRootComponentRef(1).build());
underTest.execute(new TestComputationStepContext());
Project project = analysisMetadataHolder.getProject();
assertThat(project.getUuid()).isEqualTo(this.project.uuid());
assertThat(project.getKey()).isEqualTo(this.project.getDbKey());
assertThat(project.getName()).isEqualTo(this.project.name());
assertThat(project.getDescription()).isEqualTo(this.project.description());
}
Aggregations