package org.sonar.server.batch;
import com.google.common.base.Splitter;
-
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-
import org.sonar.api.resources.Scopes;
import org.sonar.api.rules.RuleType;
+import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
.setDescription("Return open issues")
.setResponseExample(getClass().getResource("issues-example.proto"))
.setSince("5.1")
+ .setChangelog(new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_KEY)))
.setInternal(true)
.setHandler(this);
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
+import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
.setDescription("Return project repository")
.setResponseExample(getClass().getResource("project-example.json"))
.setSince("4.5")
+ .setChangelog(new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_KEY)))
+ .setChangelog(new Change("7.6", "Stop returning settings"))
.setInternal(true)
.setHandler(this);
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
import static org.apache.commons.lang.StringUtils.defaultString;
+import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY;
import static org.sonar.api.utils.DateUtils.parseEndingDateOrDateTime;
import static org.sonar.api.utils.DateUtils.parseStartingDateOrDateTime;
import static org.sonar.core.util.stream.MoreCollectors.toList;
new Change("5.5", "it's no more possible to specify the page parameter."),
new Change("6.1", "field \"logs\" is deprecated and its value is always false"),
new Change("6.6", "fields \"branch\" and \"branchType\" added"),
- new Change("7.1", "field \"pullRequest\" added"))
+ new Change("7.1", "field \"pullRequest\" added"),
+ new Change("7.6", String.format("The use of module keys in parameters '%s' and '%s' is deprecated", TEXT_QUERY, PARAM_COMPONENT_QUERY)))
.setSince("5.2");
action.createParam(PARAM_COMPONENT_ID)
"<li>component keys that are exactly the same as the supplied string</li>" +
"</ul>" +
"Must not be set together with %s.<br />" +
- "Deprecated and replaced by '%s'", PARAM_COMPONENT_ID, Param.TEXT_QUERY))
+ "Deprecated and replaced by '%s'", PARAM_COMPONENT_ID, TEXT_QUERY))
.setExampleValue("Apache")
.setDeprecatedSince("5.5");
- action.createParam(Param.TEXT_QUERY)
+ action.createParam(TEXT_QUERY)
.setDescription(format("Limit search to: <ul>" +
"<li>component names that contain the supplied string</li>" +
"<li>component keys that are exactly the same as the supplied string</li>" +
private static Request toSearchWsRequest(org.sonar.api.server.ws.Request request) {
Request activityWsRequest = new Request()
.setComponentId(request.param(PARAM_COMPONENT_ID))
- .setQ(defaultString(request.param(Param.TEXT_QUERY), request.param(PARAM_COMPONENT_QUERY)))
+ .setQ(defaultString(request.param(TEXT_QUERY), request.param(PARAM_COMPONENT_QUERY)))
.setStatus(request.paramAsStrings(PARAM_STATUS))
.setType(request.param(PARAM_TYPE))
.setMinSubmittedAt(request.param(PARAM_MIN_SUBMITTED_AT))
import org.sonar.server.ws.KeyExamples;
import org.sonarqube.ws.Ce.ActivityStatusWsResponse;
-import static org.sonar.server.component.ComponentFinder.ParamNames.COMPONENT_ID_AND_KEY;
-import static org.sonar.server.ws.WsUtils.writeProtobuf;
import static org.sonar.server.ce.ws.CeWsParameters.DEPRECATED_PARAM_COMPONENT_KEY;
import static org.sonar.server.ce.ws.CeWsParameters.PARAM_COMPONENT_ID;
+import static org.sonar.server.component.ComponentFinder.ParamNames.COMPONENT_ID_AND_KEY;
+import static org.sonar.server.ws.WsUtils.writeProtobuf;
public class ActivityStatusAction implements CeWsAction {
private final UserSession userSession;
.setDescription("Id of the component (project) to filter on")
.setExampleValue(Uuids.UUID_EXAMPLE_03);
action.createParam(DEPRECATED_PARAM_COMPONENT_KEY)
+ .setDeprecatedSince("6.6")
.setDescription("Key of the component (project) to filter on")
.setExampleValue(KeyExamples.KEY_PROJECT_EXAMPLE_001);
action.createParam(PARAM_BRANCH)
.setDescription("Branch key")
- .setExampleValue(KEY_BRANCH_EXAMPLE_001)
- .setInternal(true);
+ .setExampleValue(KEY_BRANCH_EXAMPLE_001);
action.createParam(PARAM_PULL_REQUEST)
.setDescription("Pull request id")
- .setExampleValue(KEY_PULL_REQUEST_EXAMPLE_001)
- .setInternal(true);
+ .setExampleValue(KEY_PULL_REQUEST_EXAMPLE_001);
}
@Override
.setResponseExample(getClass().getResource("component-example.json"))
.setChangelog(
new Change("6.1", "field \"logs\" is deprecated and its value is always false"),
- new Change("6.6", "fields \"branch\" and \"branchType\" added"))
+ new Change("6.6", "fields \"branch\" and \"branchType\" added"),
+ new Change("7.6", String.format("The use of module keys in parameter \"%s\" is deprecated", PARAM_COMPONENT)))
.setHandler(this);
action.createParam(PARAM_COMPONENT_ID)
import javax.annotation.Nullable;
import org.apache.commons.lang.BooleanUtils;
import org.sonar.api.measures.Metric;
+import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
"Requires the following permission: 'Browse'.")
.setResponseExample(getClass().getResource("app-example.json"))
.setSince("4.4")
+ .setChangelog(new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT)))
.setInternal(true)
.setHandler(this);
import java.util.Map;
import java.util.Optional;
import java.util.Set;
+import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.sonar.api.i18n.I18n;
import org.sonar.api.resources.Languages;
+import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.ResourceTypes;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
private final DefaultOrganizationProvider defaultOrganizationProvider;
public SearchAction(ComponentIndex componentIndex, DbClient dbClient, ResourceTypes resourceTypes, I18n i18n, Languages languages,
- DefaultOrganizationProvider defaultOrganizationProvider) {
+ DefaultOrganizationProvider defaultOrganizationProvider) {
this.componentIndex = componentIndex;
this.dbClient = dbClient;
this.resourceTypes = resourceTypes;
Set<String> projectUuidsToSearch = components.stream()
.map(ComponentDto::projectUuid)
.collect(toHashSet());
- List<ComponentDto> projects = dbClient.componentDao().selectByUuids(dbSession, projectUuidsToSearch);
+ List<ComponentDto> projects = dbClient.componentDao()
+ .selectByUuids(dbSession, projectUuidsToSearch)
+ .stream()
+ .filter(c -> !c.qualifier().equals(Qualifiers.MODULE))
+ .collect(Collectors.toList());
return projects.stream().collect(toMap(ComponentDto::uuid, ComponentDto::getDbKey));
}
}
}
-
}
new Change("6.4", "The 'visibility' field is added to the response"),
new Change("6.5", "Leak period date is added to the response"),
new Change("6.6", "'branch' is added to the response"),
- new Change("6.6", "'version' is added to the response"))
+ new Change("6.6", "'version' is added to the response"),
+ new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT)))
.setHandler(this);
action.createParam(PARAM_COMPONENT_ID)
if (branch == null && pullRequest == null) {
return componentFinder.getByUuidOrKey(dbSession, componentId, componentKey, COMPONENT_ID_AND_COMPONENT);
}
- checkRequest(componentKey!=null, "The '%s' parameter is missing", PARAM_COMPONENT);
+ checkRequest(componentKey != null, "The '%s' parameter is missing", PARAM_COMPONENT);
return componentFinder.getByKeyAndOptionalBranchOrPullRequest(dbSession, componentKey, branch, pullRequest);
}
SUBVIEW(Qualifiers.SUBVIEW),
APP(Qualifiers.APP),
PROJECT(Qualifiers.PROJECT),
- MODULE(Qualifiers.MODULE),
FILE(Qualifiers.FILE),
UNIT_TEST_FILE(Qualifiers.UNIT_TEST_FILE),;
private static final int MAXIMUM_RECENTLY_BROWSED = 50;
private static final int EXTENDED_LIMIT = 20;
- private static final Set<String> QUALIFIERS_FOR_WHICH_TO_RETURN_PROJECT = Stream.of(Qualifiers.MODULE, Qualifiers.FILE, Qualifiers.UNIT_TEST_FILE).collect(Collectors.toSet());
+ private static final Set<String> QUALIFIERS_FOR_WHICH_TO_RETURN_PROJECT = Stream.of(Qualifiers.FILE, Qualifiers.UNIT_TEST_FILE).collect(Collectors.toSet());
private final ComponentIndex index;
private final FavoriteFinder favoriteFinder;
}
private List<String> getQualifiers(@Nullable String more) {
- Set<String> availableQualifiers = resourceTypes.getAll().stream().map(ResourceType::getQualifier).collect(MoreCollectors.toSet());
+ Set<String> availableQualifiers = resourceTypes.getAll().stream()
+ .map(ResourceType::getQualifier)
+ .filter(q -> !q.equals(Qualifiers.MODULE))
+ .collect(MoreCollectors.toSet());
if (more == null) {
return stream(SuggestionCategory.values())
.map(SuggestionCategory::getQualifier)
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
+import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import org.sonar.api.i18n.I18n;
+import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.ResourceTypes;
import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Response;
.setSince("5.4")
.setResponseExample(getClass().getResource("tree-example.json"))
.setChangelog(
- new Change("6.4", "The field 'id' is deprecated in the response"))
+ new Change("6.4", "The field 'id' is deprecated in the response"),
+ new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT)))
.setHandler(this)
.addPagingParams(100, MAX_SIZE);
OrganizationDto organizationDto = componentFinder.getOrganization(dbSession, baseComponent);
ComponentTreeQuery query = toComponentTreeQuery(treeRequest, baseComponent);
- List<ComponentDto> components = dbClient.componentDao().selectDescendants(dbSession, query);
+ List<ComponentDto> components = dbClient.componentDao().selectDescendants(dbSession, query)
+ .stream()
+ .filter(c -> !c.qualifier().equals(Qualifiers.MODULE))
+ .collect(Collectors.toList());
int total = components.size();
components = sortComponents(components, treeRequest);
components = paginateComponents(components, treeRequest);
package org.sonar.server.favorite.ws;
import java.util.function.Consumer;
+import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
.setDescription("Add a component (project, directory, file etc.) as favorite for the authenticated user.<br>" +
"Requires authentication and the following permission: 'Browse' on the project of the specified component.")
.setSince("6.3")
+ .setChangelog(new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT)))
.setPost(true)
.setHandler(this);
- action.createParam("component")
+ action.createParam(PARAM_COMPONENT)
.setDescription("Component key")
.setRequired(true)
.setExampleValue(KeyExamples.KEY_FILE_EXAMPLE_001);
package org.sonar.server.favorite.ws;
import java.util.function.Consumer;
+import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
.setDescription("Remove a component (project, directory, file etc.) as favorite for the authenticated user.<br>" +
"Requires authentication.")
.setSince("6.3")
+ .setChangelog(new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT)))
.setPost(true)
.setHandler(this);
- action.createParam("component")
+ action.createParam(PARAM_COMPONENT)
.setDescription("Component key")
.setRequired(true)
.setExampleValue(KeyExamples.KEY_PROJECT_EXAMPLE_001);
import static org.sonar.server.es.SearchOptions.MAX_LIMIT;
import static org.sonar.server.issue.index.IssueIndex.FACET_ASSIGNED_TO_ME;
import static org.sonar.server.issue.index.IssueIndex.FACET_PROJECTS;
+import static org.sonar.server.issue.index.IssueQuery.SORT_BY_ASSIGNEE;
+import static org.sonar.server.issue.index.IssueQueryFactory.UNKNOWN;
import static org.sonar.server.issue.index.SecurityStandardHelper.SANS_TOP_25_INSECURE_INTERACTION;
import static org.sonar.server.issue.index.SecurityStandardHelper.SANS_TOP_25_POROUS_DEFENSES;
import static org.sonar.server.issue.index.SecurityStandardHelper.SANS_TOP_25_RISKY_RESOURCE;
import static org.sonar.server.issue.index.SecurityStandardHelper.UNKNOWN_STANDARD;
-import static org.sonar.server.issue.index.IssueQuery.SORT_BY_ASSIGNEE;
-import static org.sonar.server.issue.index.IssueQueryFactory.UNKNOWN;
import static org.sonar.server.ws.KeyExamples.KEY_BRANCH_EXAMPLE_001;
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
import static org.sonar.server.ws.KeyExamples.KEY_PULL_REQUEST_EXAMPLE_001;
PARAM_COMPONENT_KEYS, PARAM_COMPONENT_UUIDS, PARAM_COMPONENTS, PARAM_COMPONENT_ROOT_UUIDS, PARAM_COMPONENT_ROOTS)
.setSince("3.6")
.setChangelog(
+ new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT_KEYS)),
new Change("7.4", "The facet 'projectUuids' is dropped in favour of the new facet 'projects'. " +
"Note that they are not strictly identical, the latter returns the project keys."),
new Change("7.4", format("Parameter '%s' does not accept anymore deprecated value 'debt'", FACET_MODE)),
.setDescription("To retrieve issues associated to a specific list of modules (comma-separated list of module IDs). " +
INTERNAL_PARAMETER_DISCLAIMER)
.setInternal(true)
+ .setDeprecatedSince("7.6")
.setExampleValue("7d8749e8-3070-4903-9188-bdd82933bb92");
action.createParam(PARAM_DIRECTORIES)
.setResponseExample(getClass().getResource("component-example.json"))
.setSince("5.4")
.setChangelog(
+ new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT)),
new Change("6.6", "the response field id is deprecated. Use key instead."),
new Change("6.6", "the response field refId is deprecated. Use refKey instead."))
.setHandler(this);
.setHandler(this)
.addPagingParams(100, MAX_SIZE)
.setChangelog(
+ new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT)),
new Change("7.2", "field 'bestValue' is added to the response"),
new Change("6.3", format("Number of metric keys is limited to %s", MAX_METRIC_KEYS)),
new Change("6.6", "the response field id is deprecated. Use key instead."),
import java.util.stream.Stream;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
+import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
"Requires the following permission: 'Browse' on the specified component")
.setResponseExample(getClass().getResource("search_history-example.json"))
.setSince("6.3")
+ .setChangelog(new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT)))
.setHandler(this);
action.createParam(PARAM_COMPONENT)
import org.sonar.api.config.PropertyDefinition;
import org.sonar.api.config.PropertyDefinitions;
import org.sonar.api.config.PropertyFieldDefinition;
+import org.sonar.api.server.ws.Change;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
.setDescription("List settings definitions.<br>" +
"Requires 'Browse' permission when a component is specified<br/>" +
"To access licensed settings, authentication is required<br/>" +
- "To access secured settings, one of the following permissions is required: " +
- "<ul>" +
- "<li>'Execute Analysis'</li>" +
- "<li>'Administer System'</li>" +
- "<li>'Administer' rights on the specified component</li>" +
- "</ul>")
+ "To access secured settings, one of the following permissions is required: " +
+ "<ul>" +
+ "<li>'Execute Analysis'</li>" +
+ "<li>'Administer System'</li>" +
+ "<li>'Administer' rights on the specified component</li>" +
+ "</ul>")
.setResponseExample(getClass().getResource("list_definitions-example.json"))
.setSince("6.3")
+ .setChangelog(new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT)))
.setHandler(this);
action.createParam(PARAM_COMPONENT)
.setDescription("Component key")
"<li>'Administer' rights on the specified component</li>" +
"</ul>")
.setSince("6.1")
- .setChangelog(new Change("7.1", "The settings defined in config/sonar.properties are read-only and can't be changed"))
+ .setChangelog(
+ new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT)),
+ new Change("7.1", "The settings defined in config/sonar.properties are read-only and can't be changed"))
.setPost(true)
.setHandler(this);
WebService.NewAction action = context.createAction("set")
.setDescription("Update a setting value.<br>" +
"Either '%s' or '%s' must be provided.<br> " +
- "The settings defined in config/sonar.properties are read-only and can't be changed.<br/>" +
+ "The settings defined in config/sonar.properties are read-only and can't be changed.<br/>" +
"Requires one of the following permissions: " +
"<ul>" +
"<li>'Administer System'</li>" +
"</ul>",
PARAM_VALUE, PARAM_VALUES)
.setSince("6.1")
- .setChangelog(new Change("7.1", "The settings defined in config/sonar.properties are read-only and can't be changed"))
+ .setChangelog(
+ new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT)),
+ new Change("7.1", "The settings defined in config/sonar.properties are read-only and can't be changed"))
.setPost(true)
.setHandler(this);
"</ul>")
.setResponseExample(getClass().getResource("values-example.json"))
.setSince("6.3")
- .setChangelog(new Change("7.1", "The settings from conf/sonar.properties are excluded from results."))
+ .setChangelog(
+ new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT)),
+ new Change("7.1", "The settings from conf/sonar.properties are excluded from results."))
.setHandler(this);
action.createParam(PARAM_KEYS)
.setDescription("List of setting keys")
import static org.sonar.server.ws.KeyExamples.KEY_BRANCH_EXAMPLE_001;
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
import static org.sonar.server.ws.KeyExamples.KEY_PULL_REQUEST_EXAMPLE_001;
+import static org.sonar.server.ws.WsUtils.checkComponentNotAModuleAndNotADirectory;
public class ComponentAction implements NavigationWsAction {
.setResponseExample(getClass().getResource("component-example.json"))
.setSince("5.2")
.setChangelog(
- new Change("6.4", "The 'visibility' field is added"),
- new Change("7.3", "The 'almRepoUrl' and 'almId' fields are added"));
+ new Change("7.6", String.format("The use of module keys in parameter '%s' is deprecated", PARAM_COMPONENT)),
+ new Change("7.3", "The 'almRepoUrl' and 'almId' fields are added"),
+ new Change("6.4", "The 'visibility' field is added"));
action.createParam(PARAM_COMPONENT)
.setDescription("A component key.")
action
.createParam(PARAM_BRANCH)
.setDescription("Branch key")
- .setInternal(true)
.setExampleValue(KEY_BRANCH_EXAMPLE_001);
action
.createParam(PARAM_PULL_REQUEST)
.setDescription("Pull request id")
- .setInternal(true)
.setExampleValue(KEY_PULL_REQUEST_EXAMPLE_001);
}
String branch = request.param(PARAM_BRANCH);
String pullRequest = request.param(PARAM_PULL_REQUEST);
ComponentDto component = componentFinder.getByKeyAndOptionalBranchOrPullRequest(session, componentKey, branch, pullRequest);
+ checkComponentNotAModuleAndNotADirectory(component);
ComponentDto rootProjectOrBranch = getRootProjectOrBranch(component, session);
ComponentDto rootProject = rootProjectOrBranch.getMainBranchProjectUuid() == null ? rootProjectOrBranch
: componentFinder.getByUuid(session, rootProjectOrBranch.getMainBranchProjectUuid());
package org.sonar.server.ws;
import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableSet;
import com.google.protobuf.Message;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.List;
+import java.util.Set;
import javax.annotation.Nullable;
import org.apache.commons.io.IOUtils;
+import org.sonar.api.resources.Qualifiers;
import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.Response;
import org.sonar.api.utils.text.JsonWriter;
import org.sonar.core.util.ProtobufJsonFormat;
+import org.sonar.db.component.ComponentDto;
import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.NotFoundException;
public class WsUtils {
+ private static final Set<String> MODULE_OR_DIR_QUALIFIERS = ImmutableSet.of(Qualifiers.MODULE, Qualifiers.DIRECTORY);
+
private WsUtils() {
// only statics
}
return value.get();
}
+
+ public static void checkComponentNotAModuleAndNotADirectory(ComponentDto component) {
+ checkRequest(!MODULE_OR_DIR_QUALIFIERS.contains(component.qualifier()), "Operation not supported for module or directory components");
+ }
}
"paging": {
"pageIndex": 1,
"pageSize": 100,
- "total": 4
+ "total": 3
},
"components": [
{
"language": "java",
"project": "project-key"
},
- {
- "organization": "my-org-1",
- "id": "module-uuid",
- "key": "module-key",
- "qualifier": "BRC",
- "name": "Module Name",
- "project": "project-key"
- },
{
"organization": "my-org-1",
"id": "project-uuid",
],
"more": 0
},
- {
- "q": "BRC",
- "items": [],
- "more": 0
- },
{
"q": "FIL",
"items": [],
String response = ws.newRequest()
.setMediaType(MediaTypes.JSON)
.setParam(PARAM_ORGANIZATION, organizationDto.getKey())
- .setParam(PARAM_QUALIFIERS, Joiner.on(",").join(PROJECT, MODULE, DIRECTORY, FILE))
+ .setParam(PARAM_QUALIFIERS, Joiner.on(",").join(PROJECT, DIRECTORY, FILE))
.execute().getInput();
assertJson(response).isSimilarTo(ws.getDef().responseExampleAsString());
}
tuple("6.4", "The 'visibility' field is added to the response"),
tuple("6.5", "Leak period date is added to the response"),
tuple("6.6", "'branch' is added to the response"),
- tuple("6.6", "'version' is added to the response"));
+ tuple("6.6", "'version' is added to the response"),
+ tuple("7.6", "The use of module keys in parameter 'component' is deprecated"));
assertThat(action.params()).extracting(WebService.Param::key).containsExactlyInAnyOrder("component", "componentId", "branch", "pullRequest");
WebService.Param componentId = action.param(PARAM_COMPONENT_ID);
assertThat(response.getResultsList())
.extracting(Category::getQ, Category::getItemsCount)
- .containsExactlyInAnyOrder(tuple("VW", 0), tuple("APP", 0), tuple("SVW", 0), tuple("TRK", 1), tuple("BRC", 0), tuple("FIL", 0), tuple("UTS", 0));
+ .containsExactlyInAnyOrder(tuple("VW", 0), tuple("APP", 0), tuple("SVW", 0), tuple("TRK", 1), tuple("FIL", 0), tuple("UTS", 0))
+ .doesNotContain(tuple("BRC", 0));
}
@Test
assertThat(response.getResultsList())
.extracting(Category::getQ)
- .containsExactlyInAnyOrder(PROJECT, MODULE, FILE);
+ .containsExactlyInAnyOrder(PROJECT, FILE).doesNotContain(MODULE);
}
@Test
}
@Test
- public void should_contain_project_names() {
- ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organization));
+ public void should_not_return_modules() {
+ ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organization).setName("ProjectWithModules"));
db.components().insertComponent(newModuleDto(project).setName("Module1"));
db.components().insertComponent(newModuleDto(project).setName("Module2"));
componentIndexer.indexOnAnalysis(project.projectUuid());
assertThat(response.getResultsList())
.flatExtracting(Category::getItemsList)
- .extracting(Suggestion::getProject)
+ .extracting(Suggestion::getKey)
.containsOnly(project.getDbKey());
-
- assertThat(response.getProjectsList())
- .extracting(Project::getKey, Project::getName)
- .containsExactlyInAnyOrder(
- tuple(project.getDbKey(), project.longName()));
}
@Test
public void should_mark_recently_browsed_items() {
- ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organization));
+ ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organization).setName("ProjectModule"));
ComponentDto module1 = newModuleDto(project).setName("Module1");
db.components().insertComponent(module1);
ComponentDto module2 = newModuleDto(project).setName("Module2");
SuggestionsWsResponse response = ws.newRequest()
.setMethod("POST")
.setParam(PARAM_QUERY, "Module")
- .setParam(PARAM_RECENTLY_BROWSED, Stream.of(module1.getDbKey()).collect(joining(",")))
+ .setParam(PARAM_RECENTLY_BROWSED, Stream.of(module1.getDbKey(), project.getDbKey()).collect(joining(",")))
.executeProtobuf(SuggestionsWsResponse.class);
assertThat(response.getResultsList())
.flatExtracting(Category::getItemsList)
.extracting(Suggestion::getIsRecentlyBrowsed)
- .containsExactly(true, false);
+ .containsExactly(true);
}
@Test
public void should_mark_favorite_items() {
- ComponentDto project = db.components().insertComponent(newPrivateProjectDto(organization));
- ComponentDto favorite = newModuleDto(project).setName("Module1");
- db.components().insertComponent(favorite);
- doReturn(singletonList(favorite)).when(favoriteFinder).list();
+ ComponentDto favouriteProject = db.components().insertComponent(newPrivateProjectDto(organization).setName("Project1"));
+ ComponentDto nonFavouriteProject = db.components().insertComponent(newPublicProjectDto(organization).setName("Project2"));
- ComponentDto nonFavorite = newModuleDto(project).setName("Module2");
- db.components().insertComponent(nonFavorite);
- componentIndexer.indexOnAnalysis(project.projectUuid());
- authorizationIndexerTester.allowOnlyAnyone(project);
+ doReturn(singletonList(favouriteProject)).when(favoriteFinder).list();
+ componentIndexer.indexOnAnalysis(favouriteProject.projectUuid());
+ componentIndexer.indexOnAnalysis(nonFavouriteProject.projectUuid());
+ authorizationIndexerTester.allowOnlyAnyone(favouriteProject, nonFavouriteProject);
SuggestionsWsResponse response = ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_QUERY, "Module")
+ .setParam(PARAM_QUERY, "Project")
.executeProtobuf(SuggestionsWsResponse.class);
assertThat(response.getResultsList())
.flatExtracting(Category::getItemsList)
.extracting(Suggestion::getKey, Suggestion::getIsFavorite)
- .containsExactly(tuple(favorite.getDbKey(), true), tuple(nonFavorite.getDbKey(), false));
+ .containsExactly(tuple(favouriteProject.getDbKey(), true), tuple(nonFavouriteProject.getDbKey(), false));
}
@Test
assertThat(response.getResultsList())
.extracting(Category::getQ, Category::getItemsCount)
- .containsExactlyInAnyOrder(tuple("VW", 0), tuple("SVW", 0), tuple("APP", 0), tuple("TRK", 1), tuple("BRC", 0), tuple("FIL", 0), tuple("UTS", 0));
+ .containsExactlyInAnyOrder(tuple("VW", 0), tuple("SVW", 0), tuple("APP", 0), tuple("TRK", 1), tuple("FIL", 0), tuple("UTS", 0));
}
@Test
tuple(SuggestionCategory.VIEW.getName(), false),
tuple(SuggestionCategory.SUBVIEW.getName(), false),
tuple(SuggestionCategory.PROJECT.getName(), false),
- tuple(SuggestionCategory.MODULE.getName(), true),
tuple(SuggestionCategory.FILE.getName(), true),
tuple(SuggestionCategory.UNIT_TEST_FILE.getName(), true));
}
}
private void check_proposal_to_show_more_results(int numberOfProjects, int expectedNumberOfResults, long expectedNumberOfMoreResults, @Nullable SuggestionCategory more,
- boolean useQuery) {
+ boolean useQuery) {
String namePrefix = "MyProject";
List<ComponentDto> projects = range(0, numberOfProjects)
assertThat(action.description()).isNotNull();
assertThat(action.responseExample()).isNotNull();
assertThat(action.changelog()).extracting(Change::getVersion, Change::getDescription).containsExactlyInAnyOrder(
- tuple("6.4", "The field 'id' is deprecated in the response"));
+ tuple("6.4", "The field 'id' is deprecated in the response"),
+ tuple("7.6", "The use of module keys in parameter 'component' is deprecated"));
assertThat(action.params()).extracting(Param::key).containsExactlyInAnyOrder("component", "componentId", "branch", "pullRequest", "qualifiers", "strategy",
"q", "s", "p", "asc", "ps");
.setParam(Param.SORT, "qualifier, name")
.setParam(PARAM_COMPONENT_ID, "project-uuid").executeProtobuf(TreeWsResponse.class);
- assertThat(response.getComponentsList()).extracting("id").containsExactly("module-uuid-1", "path/directory/", "file-uuid-1", "file-uuid-2");
+ assertThat(response.getComponentsList()).extracting("id")
+ .containsExactly("path/directory/", "file-uuid-1", "file-uuid-2")
+ .doesNotContain("module-uuid-1");
}
@Test
import org.sonar.db.component.BranchType;
import org.sonar.db.component.ComponentDbTester;
import org.sonar.db.component.ComponentDto;
-import org.sonar.db.component.ComponentTesting;
import org.sonar.db.component.SnapshotDto;
import org.sonar.db.metric.MetricDto;
import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.qualityprofile.QProfileDto;
import org.sonar.db.user.UserDto;
import org.sonar.server.component.ComponentFinder;
+import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.organization.BillingValidations;
executeAndVerify(project.getDbKey(), "return_configuration_with_all_properties.json");
}
- @Test
- public void return_breadcrumbs_on_module() {
- ComponentDto project = insertOrganizationAndProject();
- ComponentDto module = componentDbTester.insertComponent(newModuleDto("bcde", project).setDbKey("palap").setName("Palap"));
- userSession.anonymous()
- .addProjectPermission(UserRole.USER, project)
- .addProjectPermission(UserRole.ADMIN, project);
- init();
-
- executeAndVerify(module.getDbKey(), "return_breadcrumbs_on_module.json");
- }
-
@Test
public void return_configuration_for_quality_profile_admin() {
ComponentDto project = insertOrganizationAndProject();
assertJson(execute(project.getDbKey())).isSimilarTo("{\"visibility\": \"public\"}");
}
- @Test
- public void should_not_return_private_flag_for_module() {
- OrganizationDto org = db.organizations().insert();
- db.qualityGates().createDefaultQualityGate(org);
- ComponentDto project = db.components().insertPrivateProject(org);
- ComponentDto module = db.components().insertComponent(ComponentTesting.newModuleDto(project));
- init();
-
- userSession.logIn()
- .addProjectPermission(UserRole.ADMIN, project)
- .addPermission(OrganizationPermission.ADMINISTER, org);
- String json = execute(module.getDbKey());
- assertThat(json).doesNotContain("visibility");
- }
-
@Test
public void canApplyPermissionTemplate_is_true_if_logged_in_as_organization_administrator() {
OrganizationDto org = db.organizations().insert();
assertThat(action.responseExample()).isNotNull();
assertThat(action.changelog()).extracting(Change::getVersion, Change::getDescription).containsExactlyInAnyOrder(
tuple("6.4", "The 'visibility' field is added"),
- tuple("7.3", "The 'almRepoUrl' and 'almId' fields are added"));
+ tuple("7.3", "The 'almRepoUrl' and 'almId' fields are added"),
+ tuple("7.6", "The use of module keys in parameter 'component' is deprecated"));
WebService.Param componentId = action.param(PARAM_COMPONENT);
assertThat(componentId.isRequired()).isFalse();
"}\n");
}
- @Test
- public void return_alm_info_on_module() {
+ @Test(expected = BadRequestException.class)
+ public void fail_on_module_key_as_param() {
ComponentDto project = insertOrganizationAndProject();
ComponentDto module = componentDbTester.insertComponent(newModuleDto("bcde", project).setDbKey("palap").setName("Palap"));
- dbClient.projectAlmBindingsDao().insertOrUpdate(db.getSession(), ALM.BITBUCKETCLOUD, "{123456789}", project.uuid(), null, "http://bitbucket.org/foo/bar");
- db.getSession().commit();
- userSession.addProjectPermission(UserRole.USER, project);
init();
- String json = execute(module.getKey());
+ execute(module.getKey());
+ }
- assertJson(json).isSimilarTo("{\n" +
- " \"organization\": \"my-org\",\n" +
- " \"key\": \"palap\",\n" +
- " \"id\": \"bcde\",\n" +
- " \"name\": \"Palap\",\n" +
- " \"alm\": {\n" +
- " \"key\": \"bitbucketcloud\",\n" +
- " \"url\": \"http://bitbucket.org/foo/bar\"\n" +
- " }\n" +
- "}\n");
+ @Test(expected = BadRequestException.class)
+ public void fail_on_directory_key_as_param() {
+ ComponentDto project = insertOrganizationAndProject();
+ ComponentDto module = componentDbTester.insertComponent(newModuleDto("bcde", project).setDbKey("palap").setName("Palap"));
+ ComponentDto directory = componentDbTester.insertComponent(newDirectory(module, "src/main/xoo"));
+ userSession.addProjectPermission(UserRole.USER, project);
+ init();
+
+ execute(directory.getDbKey());
}
@Test
+++ /dev/null
-{
- "breadcrumbs": [
- {
- "key": "polop",
- "name": "Polop",
- "qualifier": "TRK"
- },
- {
- "key": "palap",
- "name": "Palap",
- "qualifier": "BRC"
- }
- ]
-}
*/
package org.sonarqube.ws.client.navigation;
-import java.util.List;
import javax.annotation.Generated;
/**