use of org.sonar.api.resources.Qualifiers.APP in project sonarqube by SonarSource.
the class SuggestionsActionTest method should_only_provide_project_for_certain_qualifiers.
@Test
public void should_only_provide_project_for_certain_qualifiers() {
String query = randomAlphabetic(10);
ComponentDto app = db.components().insertPublicApplication(v -> v.setName(query));
ComponentDto view = db.components().insertPublicPortfolio(v -> v.setName(query));
ComponentDto subView = db.components().insertComponent(ComponentTesting.newSubPortfolio(view).setName(query));
ComponentDto project = db.components().insertPrivateProject(p -> p.setName(query));
ComponentDto module = db.components().insertComponent(ComponentTesting.newModuleDto(project).setName(query));
ComponentDto file = db.components().insertComponent(ComponentTesting.newFileDto(module).setName(query));
ComponentDto test = db.components().insertComponent(ComponentTesting.newFileDto(module).setName(query).setQualifier(UNIT_TEST_FILE));
componentIndexer.indexAll();
authorizationIndexerTester.allowOnlyAnyone(project);
authorizationIndexerTester.allowOnlyAnyone(view);
authorizationIndexerTester.allowOnlyAnyone(app);
SuggestionsWsResponse response = ws.newRequest().setMethod("POST").setParam(PARAM_QUERY, project.name()).executeProtobuf(SuggestionsWsResponse.class);
assertThat(response.getResultsList()).extracting(Category::getQ, c -> c.getItemsList().stream().map(Suggestion::hasProject).findFirst().orElse(null)).containsExactlyInAnyOrder(tuple(SuggestionCategory.APP.getName(), false), tuple(SuggestionCategory.VIEW.getName(), false), tuple(SuggestionCategory.SUBVIEW.getName(), false), tuple(SuggestionCategory.PROJECT.getName(), false));
}
use of org.sonar.api.resources.Qualifiers.APP in project sonarqube by SonarSource.
the class IssueQueryFactoryTest method search_by_application_key_and_branch.
@Test
public void search_by_application_key_and_branch() {
ComponentDto application = db.components().insertPublicProject(c -> c.setQualifier(APP).setDbKey("app"));
ComponentDto applicationBranch1 = db.components().insertProjectBranch(application, a -> a.setKey("app-branch1"));
ComponentDto applicationBranch2 = db.components().insertProjectBranch(application, a -> a.setKey("app-branch2"));
ComponentDto project1 = db.components().insertPrivateProject(p -> p.setDbKey("prj1"));
ComponentDto project1Branch1 = db.components().insertProjectBranch(project1);
ComponentDto fileOnProject1Branch1 = db.components().insertComponent(newFileDto(project1Branch1));
ComponentDto project1Branch2 = db.components().insertProjectBranch(project1);
ComponentDto project2 = db.components().insertPrivateProject(p -> p.setDbKey("prj2"));
db.components().insertComponents(newProjectCopy(project1Branch1, applicationBranch1));
db.components().insertComponents(newProjectCopy(project2, applicationBranch1));
db.components().insertComponents(newProjectCopy(project1Branch2, applicationBranch2));
// Search on applicationBranch1
assertThat(underTest.create(new SearchRequest().setComponents(singletonList(applicationBranch1.getKey())).setBranch(applicationBranch1.getBranch()))).extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.projectUuids()), IssueQuery::isMainBranch).containsOnly(applicationBranch1.uuid(), Collections.emptyList(), false);
// Search on project1Branch1
assertThat(underTest.create(new SearchRequest().setComponents(singletonList(applicationBranch1.getKey())).setProjects(singletonList(project1.getKey())).setBranch(applicationBranch1.getBranch()))).extracting(IssueQuery::branchUuid, query -> new ArrayList<>(query.projectUuids()), IssueQuery::isMainBranch).containsOnly(applicationBranch1.uuid(), singletonList(project1.uuid()), false);
}
Aggregations