use of org.sonarqube.ws.Components.SuggestionsWsResponse in project sonarqube by SonarSource.
the class SuggestionsActionTest method suggestions_without_query_should_contain_recently_browsed_public_project.
@Test
public void suggestions_without_query_should_contain_recently_browsed_public_project() {
ComponentDto project = db.components().insertComponent(newPublicProjectDto());
componentIndexer.indexAll();
SuggestionsWsResponse response = ws.newRequest().setMethod("POST").setParam(PARAM_RECENTLY_BROWSED, project.getDbKey()).executeProtobuf(SuggestionsWsResponse.class);
// assert match in qualifier "TRK"
assertThat(response.getResultsList()).filteredOn(q -> q.getItemsCount() > 0).extracting(Category::getQ).containsExactly(PROJECT);
// assert correct id to be found
assertThat(response.getResultsList()).flatExtracting(Category::getItemsList).extracting(Suggestion::getKey, Suggestion::getIsRecentlyBrowsed).containsExactly(tuple(project.getDbKey(), true));
}
use of org.sonarqube.ws.Components.SuggestionsWsResponse in project sonarqube by SonarSource.
the class SuggestionsActionTest method suggestions_without_query_should_return_empty_qualifiers.
@Test
public void suggestions_without_query_should_return_empty_qualifiers() {
ComponentDto project = db.components().insertComponent(newPrivateProjectDto());
componentIndexer.indexOnAnalysis(project.projectUuid());
userSessionRule.addProjectPermission(USER, project);
SuggestionsWsResponse response = ws.newRequest().setMethod("POST").setParam(PARAM_RECENTLY_BROWSED, project.getDbKey()).executeProtobuf(SuggestionsWsResponse.class);
assertThat(response.getResultsList()).extracting(Category::getQ, Category::getItemsCount).containsExactlyInAnyOrder(tuple("VW", 0), tuple("APP", 0), tuple("SVW", 0), tuple("TRK", 1)).doesNotContain(tuple("BRC", 0), tuple("FIL", 0), tuple("UTS", 0));
}
use of org.sonarqube.ws.Components.SuggestionsWsResponse in project sonarqube by SonarSource.
the class SuggestionsActionTest method should_warn_about_short_inputs.
@Test
public void should_warn_about_short_inputs() {
SuggestionsWsResponse response = ws.newRequest().setMethod("POST").setParam(PARAM_QUERY, "validLongToken x").executeProtobuf(SuggestionsWsResponse.class);
assertThat(response.getWarning()).contains(SHORT_INPUT_WARNING);
}
use of org.sonarqube.ws.Components.SuggestionsWsResponse in project sonarqube by SonarSource.
the class SuggestionsActionTest method should_return_empty_qualifiers.
@Test
public void should_return_empty_qualifiers() {
ComponentDto project = db.components().insertComponent(newPrivateProjectDto());
componentIndexer.indexOnAnalysis(project.projectUuid());
authorizationIndexerTester.allowOnlyAnyone(project);
SuggestionsWsResponse response = ws.newRequest().setMethod("POST").setParam(PARAM_QUERY, project.name()).executeProtobuf(SuggestionsWsResponse.class);
assertThat(response.getResultsList()).extracting(Category::getQ, Category::getItemsCount).containsExactlyInAnyOrder(tuple("VW", 0), tuple("SVW", 0), tuple("APP", 0), tuple("TRK", 1));
}
use of org.sonarqube.ws.Components.SuggestionsWsResponse in project sonarqube by SonarSource.
the class SuggestionsActionTest method suggestions_without_query_should_not_contain_favorites_without_permission.
@Test
public void suggestions_without_query_should_not_contain_favorites_without_permission() {
ComponentDto project = db.components().insertComponent(newPrivateProjectDto());
doReturn(singletonList(project)).when(favoriteFinder).list();
componentIndexer.indexAll();
SuggestionsWsResponse response = ws.newRequest().setMethod("POST").executeProtobuf(SuggestionsWsResponse.class);
assertThat(response.getResultsList()).flatExtracting(Category::getItemsList).isEmpty();
}
Aggregations