use of org.sonar.api.resources.Qualifiers.SUBVIEW 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));
}
Aggregations