import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_ACTIVATE_RULE;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARAMS;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_RESET;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_RULE;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_SEVERITY;
.setPost(true)
.setSince("4.4");
- activate.createParam(PARAM_PROFILE)
+ activate.createParam(PARAM_KEY)
.setDescription("Quality Profile key. Can be obtained through <code>api/qualityprofiles/search</code>")
.setDeprecatedKey("profile_key", "6.5")
.setRequired(true)
public void handle(Request request, Response response) throws Exception {
userSession.checkLoggedIn();
try (DbSession dbSession = dbClient.openSession(false)) {
- String profileKey = request.mandatoryParam(PARAM_PROFILE);
+ String profileKey = request.mandatoryParam(PARAM_KEY);
QProfileDto profile = wsSupport.getProfile(dbSession, QProfileReference.fromKey(profileKey));
wsSupport.checkPermission(dbSession, profile);
wsSupport.checkNotBuiltInt(profile);
import static org.sonar.server.qualityprofile.ws.QProfileReference.fromKey;
import static org.sonar.server.rule.ws.SearchAction.defineRuleSearchParameters;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_ACTIVATE_RULES;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_PROFILE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_KEY;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_SEVERITY;
public class ActivateRulesAction implements QProfileWsAction {
defineRuleSearchParameters(activate);
- activate.createParam(PARAM_TARGET_PROFILE)
- .setDescription("Quality Profile key on which the rule activation is done. To retrieve a profile key please see <code>api/qualityprofiles/search</code>")
+ activate.createParam(PARAM_TARGET_KEY)
+ .setDescription("Quality Profile key on which the rule activation is done. To retrieve a quality profile key please see <code>api/qualityprofiles/search</code>")
.setDeprecatedKey("profile_key", "6.5")
.setRequired(true)
.setExampleValue(UUID_EXAMPLE_03);
@Override
public void handle(Request request, Response response) throws Exception {
- String qualityProfileKey = request.mandatoryParam(PARAM_TARGET_PROFILE);
+ String qualityProfileKey = request.mandatoryParam(PARAM_TARGET_KEY);
userSession.checkLoggedIn();
BulkChangeResult result;
try (DbSession dbSession = dbClient.openSession(false)) {
import org.sonar.db.qualityprofile.QProfileDto;
import org.sonar.server.qualityprofile.RuleActivator;
import org.sonar.server.user.UserSession;
+import org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters;
import static org.apache.commons.lang.StringUtils.isEmpty;
import static org.sonar.core.util.Uuids.UUID_EXAMPLE_02;
import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_PROFILES;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_PROFILE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_KEY;
public class ChangeParentAction implements QProfileWsAction {
- private static final String PARAM_PARENT_NAME = "parentName";
-
- private DbClient dbClient;
+ private final DbClient dbClient;
private final RuleActivator ruleActivator;
private final Languages languages;
private final QProfileWsSupport wsSupport;
.setSince("6.4");
QProfileReference.defineParams(inheritance, languages);
- inheritance.createParam(PARAM_PARENT_PROFILE)
+ inheritance.createParam(PARAM_PARENT_KEY)
.setDescription("New parent profile key.<br> " +
"If no profile is provided, the inheritance link with current parent profile (if any) is broken, which deactivates all rules " +
"which come from the parent and are not overridden.")
- .setDeprecatedKey("parentKey", "6.5")
+ .setDeprecatedSince("6.6")
.setExampleValue(UUID_EXAMPLE_02);
- inheritance.createParam(PARAM_PARENT_NAME)
- .setDescription("Quality profile name. If this parameter is set, '%s' must not be set and '%s' must be set to disambiguate.", PARAM_PARENT_PROFILE, PARAM_LANGUAGE)
- .setDeprecatedSince("6.5")
+ inheritance.createParam(QualityProfileWsParameters.PARAM_PARENT_QUALITY_PROFILE)
+ .setDescription("Quality profile name. If this parameter is set, '%s' must not be set and '%s' must be set to disambiguate.", PARAM_PARENT_KEY, PARAM_LANGUAGE)
.setExampleValue("Sonar way");
}
userSession.checkPermission(ADMINISTER_QUALITY_PROFILES, organization);
wsSupport.checkNotBuiltInt(profile);
- String parentKey = request.param(PARAM_PARENT_PROFILE);
- String parentName = request.param(PARAM_PARENT_NAME);
+ String parentKey = request.param(PARAM_PARENT_KEY);
+ String parentName = request.param(QualityProfileWsParameters.PARAM_PARENT_QUALITY_PROFILE);
if (isEmpty(parentKey) && isEmpty(parentName)) {
ruleActivator.setParentAndCommit(dbSession, profile, null);
} else {
import static org.sonar.server.ws.WsUtils.writeProtobuf;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_CREATE;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_NAME;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_ORGANIZATION;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE_NAME;
public class CreateAction implements QProfileWsAction {
createOrganizationParam(create)
.setSince("6.4");
- create.createParam(PARAM_PROFILE_NAME)
- .setDescription("Name for the new quality profile")
+ create.createParam(PARAM_NAME)
+ .setDescription("Quality profile name")
.setExampleValue("My Sonar way")
- .setDeprecatedKey("name", "6.1")
+ .setDeprecatedKey("profileName", "6.6")
.setRequired(true);
create.createParam(PARAM_LANGUAGE)
- .setDescription("The language for the quality profile.")
+ .setDescription("Quality profile language")
.setExampleValue("js")
.setPossibleValues(LanguageParamUtils.getLanguageKeys(languages))
.setRequired(true);
private CreateWsResponse doHandle(DbSession dbSession, CreateRequest createRequest, Request request, OrganizationDto organization) {
QProfileResult result = new QProfileResult();
QProfileDto profile = profileFactory.checkAndCreateCustom(dbSession, organization,
- QProfileName.createFor(createRequest.getLanguage(), createRequest.getProfileName()));
+ QProfileName.createFor(createRequest.getLanguage(), createRequest.getName()));
result.setProfile(profile);
for (ProfileImporter importer : importers) {
String importerKey = importer.getKey();
CreateRequest.Builder builder = CreateRequest.builder()
.setOrganizationKey(organization.getKey())
.setLanguage(request.mandatoryParam(PARAM_LANGUAGE))
- .setProfileName(request.mandatoryParam(PARAM_PROFILE_NAME));
+ .setName(request.mandatoryParam(PARAM_NAME));
return builder.build();
}
import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_DEACTIVATE_RULE;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_RULE;
public class DeactivateRuleAction implements QProfileWsAction {
.setPost(true)
.setSince("4.4");
- deactivate.createParam(PARAM_PROFILE)
+ deactivate.createParam(PARAM_KEY)
.setDescription("Quality Profile key. Can be obtained through <code>api/qualityprofiles/search</code>")
.setDeprecatedKey("profile_key", "6.5")
.setRequired(true)
@Override
public void handle(Request request, Response response) throws Exception {
RuleKey ruleKey = RuleKey.parse(request.mandatoryParam(PARAM_RULE));
- String qualityProfileKey = request.mandatoryParam(PARAM_PROFILE);
+ String qualityProfileKey = request.mandatoryParam(PARAM_KEY);
userSession.checkLoggedIn();
try (DbSession dbSession = dbClient.openSession(false)) {
QProfileDto profile = wsSupport.getProfile(dbSession, QProfileReference.fromKey(qualityProfileKey));
import static org.sonar.server.qualityprofile.ws.BulkChangeWsResponse.writeResponse;
import static org.sonar.server.rule.ws.SearchAction.defineRuleSearchParameters;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_DEACTIVATE_RULES;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_PROFILE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_KEY;
public class DeactivateRulesAction implements QProfileWsAction {
public static final String SEVERITY = "activation_severity";
defineRuleSearchParameters(deactivate);
- deactivate.createParam(PARAM_TARGET_PROFILE)
+ deactivate.createParam(PARAM_TARGET_KEY)
.setDescription("Quality Profile key on which the rule deactivation is done. To retrieve a profile key please see <code>api/qualityprofiles/search</code>")
.setDeprecatedKey("profile_key", "6.5")
.setRequired(true)
@Override
public void handle(Request request, Response response) throws Exception {
- String qualityProfileKey = request.mandatoryParam(PARAM_TARGET_PROFILE);
+ String qualityProfileKey = request.mandatoryParam(PARAM_TARGET_KEY);
userSession.checkLoggedIn();
BulkChangeResult result;
try (DbSession dbSession = dbClient.openSession(false)) {
import static org.sonar.server.ws.WsUtils.checkFound;
import static org.sonar.server.ws.WsUtils.checkRequest;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_ORGANIZATION;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE;
public class ExportAction implements QProfileWsAction {
- private static final String PARAM_NAME = "name";
private static final String PARAM_EXPORTER_KEY = "exporterKey";
private final DbClient dbClient;
.setResponseExample(getClass().getResource("export-example.xml"))
.setHandler(this);
- action.createParam(PARAM_PROFILE)
+ action.createParam(PARAM_KEY)
.setDescription("Quality profile key")
.setSince("6.5")
+ .setDeprecatedSince("6.6")
.setExampleValue(UUID_EXAMPLE_01);
- action.createParam(PARAM_NAME)
+ action.createParam(PARAM_QUALITY_PROFILE)
.setDescription("Quality profile name to export. If left empty, the default profile for the language is exported. If this parameter is set, '%s' must not be set.",
- PARAM_PROFILE)
- .setDeprecatedSince("6.5")
+ PARAM_KEY)
+ .setDeprecatedKey("profileName", "6.6")
.setExampleValue("My Sonar way");
action.createParam(PARAM_LANGUAGE)
- .setDescription("Quality profile language. If this parameter is set, '%s' must not be set.", PARAM_PROFILE)
- .setDeprecatedSince("6.5")
+ .setDescription("Quality profile language. If this parameter is set, '%s' must not be set.", PARAM_KEY)
.setExampleValue(LanguageParamUtils.getExampleValue(languages))
.setPossibleValues(LanguageParamUtils.getLanguageKeys(languages));
@Override
public void handle(Request request, Response response) throws Exception {
- String key = request.param(PARAM_PROFILE);
- String name = request.param(PARAM_NAME);
+ String key = request.param(PARAM_KEY);
+ String name = request.param(PARAM_QUALITY_PROFILE);
String language = request.param(PARAM_LANGUAGE);
- checkRequest(key != null ^ language != null, "Either '%s' or '%s' must be provided.", PARAM_PROFILE, PARAM_LANGUAGE);
+ checkRequest(key != null ^ language != null, "Either '%s' or '%s' must be provided.", PARAM_KEY, PARAM_LANGUAGE);
try (DbSession dbSession = dbClient.openSession(false)) {
OrganizationDto organization = wsSupport.getOrganizationByKey(dbSession, request.param(PARAM_ORGANIZATION));
import static java.util.Comparator.comparing;
import static org.sonar.api.utils.Paging.forPageIndex;
import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
public class ProjectsAction implements QProfileWsAction {
new Change("6.0", "'uuid' response field is deprecated and replaced by 'id'"),
new Change("6.0", "'key' response field has been added to return the project key"));
- action.createParam(PARAM_PROFILE)
- .setDescription("Quality profile key.")
- .setDeprecatedKey("key", "6.5")
+ action.createParam(PARAM_KEY)
+ .setDescription("Quality profile key")
.setRequired(true)
.setExampleValue(UUID_EXAMPLE_01);
action.addSelectionModeParam();
@Override
public void handle(Request request, Response response) throws Exception {
- String profileKey = request.mandatoryParam(PARAM_PROFILE);
+ String profileKey = request.mandatoryParam(PARAM_KEY);
try (DbSession session = dbClient.openSession(false)) {
checkProfileExists(profileKey, session);
import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_ORGANIZATION;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE_NAME;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE;
/**
* Reference to a Quality profile as defined by requests to web services api/qualityprofiles.
}
public static QProfileReference from(Request request) {
- String key = request.param(PARAM_PROFILE);
+ String key = request.param(PARAM_KEY);
String organizationKey = request.param(PARAM_ORGANIZATION);
String lang = request.param(PARAM_LANGUAGE);
- String name = request.param(PARAM_PROFILE_NAME);
+ String name = request.param(PARAM_QUALITY_PROFILE);
return from(key, organizationKey, lang, name);
}
}
public static void defineParams(WebService.NewAction action, Languages languages) {
- action.createParam(PARAM_PROFILE)
+ action.createParam(PARAM_KEY)
.setDescription("Quality profile key")
.setDeprecatedKey("profileKey", "6.5")
+ .setDeprecatedSince("6.6")
.setExampleValue(UUID_EXAMPLE_01);
- action.createParam(PARAM_PROFILE_NAME)
- .setDescription("Quality profile name. If this parameter is set, '%s' must not be set and '%s' must be set to disambiguate.", PARAM_PROFILE, PARAM_LANGUAGE)
- .setDeprecatedSince("6.5")
+ action.createParam(PARAM_QUALITY_PROFILE)
+ .setDescription("Quality profile name. If this parameter is set, '%s' must not be set and '%s' must be set to disambiguate.", PARAM_KEY, PARAM_LANGUAGE)
+ .setDeprecatedKey("profileName", "6.6")
.setExampleValue("Sonar way");
action.createParam(PARAM_LANGUAGE)
- .setDescription("Quality profile language. If this parameter is set, '%s' must not be set and '%s' must be set to disambiguate.", PARAM_PROFILE, PARAM_LANGUAGE)
- .setDeprecatedSince("6.5")
+ .setDescription("Quality profile language. If this parameter is set, '%s' must not be set and '%s' must be set to disambiguate.", PARAM_KEY, PARAM_LANGUAGE)
.setPossibleValues(Arrays.stream(languages.all()).map(Language::getKey).collect(MoreCollectors.toSet()));
}
}
import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_PROFILES;
import static org.sonar.server.ws.WsUtils.checkRequest;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_NAME;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
public class RenameAction implements QProfileWsAction {
.setPost(true)
.setHandler(this);
+ setDefault.createParam(PARAM_KEY)
+ .setDescription("Quality profile key")
+ .setExampleValue(UUID_EXAMPLE_01)
+ .setRequired(true);
+
setDefault.createParam(PARAM_NAME)
.setDescription("New quality profile name")
.setExampleValue("My Sonar way")
.setRequired(true);
- setDefault.createParam(PARAM_PROFILE)
- .setDescription("Quality profile key")
- .setDeprecatedKey("key", "6.5")
- .setExampleValue(UUID_EXAMPLE_01)
- .setRequired(true);
}
@Override
public void handle(Request request, Response response) throws Exception {
String newName = request.mandatoryParam(PARAM_NAME);
- String profileKey = request.mandatoryParam(PARAM_PROFILE);
+ String profileKey = request.mandatoryParam(PARAM_KEY);
doHandle(newName, profileKey);
response.noContent();
}
*/
package org.sonar.server.qualityprofile.ws;
-import com.google.common.annotations.VisibleForTesting;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_DEFAULTS;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_ORGANIZATION;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE_NAME;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE;
public class SearchAction implements QProfileWsAction {
private static final Comparator<QProfileDto> Q_PROFILE_COMPARATOR = Comparator
.setDescription("Language key. If provided, only profiles for the given language are returned.")
.setPossibleValues(LanguageParamUtils.getLanguageKeys(languages));
- action.createParam(PARAM_PROFILE_NAME)
- .setDescription("Profile name")
+ action.createParam(PARAM_QUALITY_PROFILE)
+ .setDescription("Quality profile name")
+ .setDeprecatedKey("profileName", "6.6")
.setExampleValue("SonarQube Way");
}
return new SearchWsRequest()
.setOrganizationKey(request.param(PARAM_ORGANIZATION))
.setProjectKey(request.param(PARAM_PROJECT))
- .setProfileName(request.param(PARAM_PROFILE_NAME))
+ .setQualityProfile(request.param(PARAM_QUALITY_PROFILE))
.setDefaults(request.paramAsBoolean(PARAM_DEFAULTS))
.setLanguage(request.param(PARAM_LANGUAGE));
}
- @VisibleForTesting
- SearchWsResponse doHandle(SearchWsRequest request) {
+ private SearchWsResponse doHandle(SearchWsRequest request) {
SearchData data = load(request);
return buildResponse(data);
}
}
private static Predicate<QProfileDto> byName(SearchWsRequest request) {
- return p -> request.getProfileName() == null || Objects.equals(p.getName(), request.getProfileName());
+ return p -> request.getQualityProfile() == null || Objects.equals(p.getName(), request.getQualityProfile());
}
private static Predicate<QProfileDto> byLanguage(SearchWsRequest request) {
import static org.sonar.server.ws.WsUtils.writeProtobuf;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_SHOW;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_COMPARE_TO_SONAR_WAY;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
public class ShowAction implements QProfileWsAction {
@Override
public void define(WebService.NewController controller) {
NewAction show = controller.createAction(ACTION_SHOW)
- .setSince("6.5")
.setDescription("Show a quality profile")
+ .setSince("6.5")
.setResponseExample(getClass().getResource("show-example.json"))
.setInternal(true)
.setHandler(this);
- show.createParam(PARAM_PROFILE)
+ show.createParam(PARAM_KEY)
.setDescription("Quality profile key")
.setExampleValue(UUID_EXAMPLE_01)
+ .setDeprecatedKey("profile", "6.6")
.setRequired(true);
show.createParam(PARAM_COMPARE_TO_SONAR_WAY)
@Override
public void handle(Request request, Response response) throws Exception {
try (DbSession dbSession = dbClient.openSession(false)) {
- QProfileDto profile = qProfileWsSupport.getProfile(dbSession, QProfileReference.fromKey(request.mandatoryParam(PARAM_PROFILE)));
+ QProfileDto profile = qProfileWsSupport.getProfile(dbSession, QProfileReference.fromKey(request.mandatoryParam(PARAM_KEY)));
OrganizationDto organization = qProfileWsSupport.getOrganization(dbSession, profile);
boolean isDefault = dbClient.defaultQProfileDao().isDefault(dbSession, profile.getOrganizationUuid(), profile.getKee());
ActiveRuleCountQuery.Builder builder = ActiveRuleCountQuery.builder().setOrganization(organization);
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_RULE;
public class ActivateRuleActionTest {
WebService.Action definition = ws.getDef();
assertThat(definition).isNotNull();
assertThat(definition.isPost()).isTrue();
- assertThat(definition.params()).extracting(WebService.Param::key).containsExactlyInAnyOrder("severity", "profile", "reset", "rule", "params");
- WebService.Param profileKey = definition.param("profile");
+ assertThat(definition.params()).extracting(WebService.Param::key).containsExactlyInAnyOrder("severity", "key", "reset", "rule", "params");
+ WebService.Param profileKey = definition.param("key");
assertThat(profileKey.deprecatedKey()).isEqualTo("profile_key");
WebService.Param ruleKey = definition.param("rule");
assertThat(ruleKey.deprecatedKey()).isEqualTo("rule_key");
TestRequest request = ws.newRequest()
.setMethod("POST")
.setParam(PARAM_RULE, RuleTesting.newRule().getKey().toString())
- .setParam(PARAM_PROFILE, randomAlphanumeric(UUID_SIZE));
+ .setParam(PARAM_KEY, randomAlphanumeric(UUID_SIZE));
expectedException.expect(UnauthorizedException.class);
TestRequest request = ws.newRequest()
.setMethod("POST")
.setParam(PARAM_RULE, RuleTesting.newRuleDto().getKey().toString())
- .setParam(PARAM_PROFILE, qualityProfile.getKee());
+ .setParam(PARAM_KEY, qualityProfile.getKee());
expectedException.expect(ForbiddenException.class);
TestRequest request = ws.newRequest()
.setMethod("POST")
.setParam(PARAM_RULE, RuleTesting.newRuleDto().getKey().toString())
- .setParam(PARAM_PROFILE, qualityProfile.getKee());
+ .setParam(PARAM_KEY, qualityProfile.getKee());
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("Operation forbidden for built-in Quality Profile 'Xoo profile' with language 'xoo'");
TestRequest request = ws.newRequest()
.setMethod("POST")
.setParam(PARAM_RULE, ruleKey.toString())
- .setParam(PARAM_PROFILE, qualityProfile.getKee())
+ .setParam(PARAM_KEY, qualityProfile.getKee())
.setParam("severity", "BLOCKER")
.setParam("params", "key1=v1;key2=v2")
.setParam("reset", "false");
TestRequest request = ws.newRequest()
.setMethod("POST")
.setParam(PARAM_RULE, ruleKey.toString())
- .setParam(PARAM_PROFILE, qualityProfile.getKee())
+ .setParam(PARAM_KEY, qualityProfile.getKee())
.setParam("severity", "BLOCKER")
.setParam("params", "key1=v1;key2=v2")
.setParam("reset", "false");
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_PROFILE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_KEY;
public class ActivateRulesActionTest {
"active_severities",
"s",
"repositories",
- "targetProfile",
+ "targetKey",
"statuses",
"rule_key",
"available_since",
"activation",
"severities",
"organization");
- WebService.Param targetProfile = definition.param("targetProfile");
+ WebService.Param targetProfile = definition.param("targetKey");
assertThat(targetProfile.deprecatedKey()).isEqualTo("profile_key");
WebService.Param targetSeverity = definition.param("targetSeverity");
assertThat(targetSeverity.deprecatedKey()).isEqualTo("activation_severity");
public void should_fail_if_not_logged_in() {
TestRequest request = ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_TARGET_PROFILE, randomAlphanumeric(UUID_SIZE));
+ .setParam(PARAM_TARGET_KEY, randomAlphanumeric(UUID_SIZE));
expectedException.expect(UnauthorizedException.class);
QProfileDto qualityProfile = db.qualityProfiles().insert(defaultOrganization, p -> p.setIsBuiltIn(true));
TestRequest request = ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_TARGET_PROFILE, qualityProfile.getKee());
+ .setParam(PARAM_TARGET_KEY, qualityProfile.getKee());
expectedException.expect(BadRequestException.class);
QProfileDto qualityProfile = db.qualityProfiles().insert(organization);
TestRequest request = ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_TARGET_PROFILE, qualityProfile.getKee());
+ .setParam(PARAM_TARGET_KEY, qualityProfile.getKee());
expectedException.expect(ForbiddenException.class);
// parameters
assertThat(definition.params()).extracting(WebService.Param::key)
- .containsExactlyInAnyOrder("profile", "profileName", "project", "language", "projectUuid", "organization");
- WebService.Param profile = definition.param("profile");
+ .containsExactlyInAnyOrder("key", "qualityProfile", "project", "language", "projectUuid", "organization");
+ WebService.Param profile = definition.param("key");
assertThat(profile.deprecatedKey()).isEqualTo("profileKey");
- WebService.Param profileName = definition.param("profileName");
- assertThat(profileName.deprecatedSince()).isEqualTo("6.5");
+ assertThat(profile.deprecatedSince()).isEqualTo("6.6");
WebService.Param languageParam = definition.param("language");
assertThat(languageParam.possibleValues()).containsOnly(LANGUAGE_1, LANGUAGE_2);
assertThat(languageParam.exampleValue()).isNull();
- assertThat(languageParam.deprecatedSince()).isEqualTo("6.5");
WebService.Param project = definition.param("project");
assertThat(project.deprecatedKey()).isEqualTo("projectKey");
WebService.Param projectUuid = definition.param("projectUuid");
private TestResponse call(ComponentDto project, QProfileDto qualityProfile) {
TestRequest request = tester.newRequest()
.setParam("projectUuid", project.uuid())
- .setParam("profile", qualityProfile.getKee());
+ .setParam("key", qualityProfile.getKee());
return request.execute();
}
.setParam("organization", organization.getKey())
.setParam("projectUuid", project.uuid())
.setParam("language", qualityProfile.getLanguage())
- .setParam("profileName", qualityProfile.getName());
+ .setParam("qualityProfile", qualityProfile.getName());
return request.execute();
}
}
import org.sonar.server.ws.WsActionTester;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
public class BackupActionTest {
assertThat(definition.isPost()).isFalse();
// parameters
- assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("profile", "organization", "profileName", "language");
- Param profile = definition.param("profile");
- assertThat(profile.deprecatedKey()).isEqualTo("profileKey");
+ assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("key", "organization", "qualityProfile", "language");
+ Param key = definition.param("key");
+ assertThat(key.deprecatedKey()).isEqualTo("profileKey");
+ assertThat(key.deprecatedSince()).isEqualTo("6.6");
Param language = definition.param("language");
- assertThat(language.deprecatedSince()).isEqualTo("6.5");
- Param profileName = definition.param("profileName");
- assertThat(profileName.deprecatedSince()).isEqualTo("6.5");
+ assertThat(language.deprecatedSince()).isNullOrEmpty();
+ Param profileName = definition.param("qualityProfile");
Param orgParam = definition.param("organization");
assertThat(orgParam.since()).isEqualTo("6.4");
}
public void returns_backup_of_profile_with_specified_key() throws Exception {
QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
- TestResponse response = tester.newRequest().setParam(PARAM_PROFILE, profile.getKee()).execute();
+ TestResponse response = tester.newRequest().setParam(PARAM_KEY, profile.getKee()).execute();
assertThat(response.getMediaType()).isEqualTo("application/xml");
assertThat(response.getInput()).isXmlEqualTo(xmlForProfileWithoutRules(profile));
assertThat(response.getHeader("Content-Disposition")).isEqualTo("attachment; filename=" + profile.getKee() + ".xml");
TestResponse response = tester.newRequest()
.setParam("language", profile.getLanguage())
- .setParam("profileName", profile.getName())
+ .setParam("qualityProfile", profile.getName())
.execute();
assertThat(response.getInput()).isXmlEqualTo(xmlForProfileWithoutRules(profile));
}
TestResponse response = tester.newRequest()
.setParam("organization", org.getKey())
.setParam("language", profile.getLanguage())
- .setParam("profileName", profile.getName())
+ .setParam("qualityProfile", profile.getName())
.execute();
assertThat(response.getInput()).isXmlEqualTo(xmlForProfileWithoutRules(profile));
}
expectedException.expect(NotFoundException.class);
expectedException.expectMessage("Quality Profile with key 'missing' does not exist");
- tester.newRequest().setParam(PARAM_PROFILE, "missing").execute();
+ tester.newRequest().setParam(PARAM_KEY, "missing").execute();
}
@Test
tester.newRequest()
.setParam("organization", "the-missing-org")
.setParam("language", A_LANGUAGE)
- .setParam("profileName", "the-name")
+ .setParam("qualityProfile", "the-name")
.execute();
}
tester.newRequest()
.setParam("organization", org2.getKey())
.setParam("language", profileInOrg1.getLanguage())
- .setParam("profileName", profileInOrg1.getName())
+ .setParam("qualityProfile", profileInOrg1.getName())
.execute();
}
import org.sonar.api.rule.RuleStatus;
import org.sonar.api.rule.Severity;
import org.sonar.api.server.ws.WebService;
+import org.sonar.api.server.ws.WebService.Param;
import org.sonar.api.utils.System2;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.server.util.TypeValidations;
import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
+import org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters;
import static java.util.Arrays.asList;
import static java.util.Collections.emptySet;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_PROFILES;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_ORGANIZATION;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_NAME;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_PROFILE;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE_NAME;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_KEY;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_QUALITY_PROFILE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE;
public class ChangeParentActionTest {
public void definition() {
WebService.Action definition = ws.getDef();
assertThat(definition.isPost()).isTrue();
- assertThat(definition.params()).extracting("key").containsExactlyInAnyOrder(
- "organization", "profile", "profileName", "language", "parentProfile", "parentName");
+ assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder(
+ "organization", "key", "qualityProfile", "language", "parentKey", "parentQualityProfile");
assertThat(definition.param("organization").since()).isEqualTo("6.4");
- WebService.Param profile = definition.param("profile");
+ Param profile = definition.param("key");
assertThat(profile.deprecatedKey()).isEqualTo("profileKey");
- WebService.Param parentProfile = definition.param("parentProfile");
- assertThat(parentProfile.deprecatedKey()).isEqualTo("parentKey");
- WebService.Param profileName = definition.param("profileName");
- assertThat(profileName.deprecatedSince()).isEqualTo("6.5");
- WebService.Param language = definition.param("language");
- assertThat(language.deprecatedSince()).isEqualTo("6.5");
- WebService.Param parentName = definition.param("parentName");
- assertThat(parentName.deprecatedSince()).isEqualTo("6.5");
+ assertThat(profile.deprecatedSince()).isEqualTo("6.6");
+ Param parentProfile = definition.param("parentKey");
+ assertThat(parentProfile.deprecatedKey()).isNullOrEmpty();
}
@Test
// Set parent
ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_PROFILE, child.getKee())
- .setParam(PARAM_PARENT_PROFILE, parent1.getKee())
+ .setParam(PARAM_KEY, child.getKee())
+ .setParam(PARAM_PARENT_KEY, parent1.getKee())
.execute();
// Check rule 1 enabled
// Set parent 2 through WS
ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_PROFILE, child.getKee())
- .setParam(PARAM_PARENT_PROFILE, parent2.getKee())
+ .setParam(PARAM_KEY, child.getKee())
+ .setParam(PARAM_PARENT_KEY, parent2.getKee())
.execute();
// Check rule 2 enabled
// Remove parent through WS
ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_PROFILE, child.getKee())
+ .setParam(PARAM_KEY, child.getKee())
.execute();
// Check no rule enabled
ws.newRequest()
.setMethod("POST")
.setParam(PARAM_LANGUAGE, child.getLanguage())
- .setParam(PARAM_PROFILE_NAME, child.getName())
+ .setParam(PARAM_QUALITY_PROFILE, child.getName())
.setParam(PARAM_ORGANIZATION, organization.getKey())
- .setParam(PARAM_PARENT_NAME, parent1.getName())
+ .setParam(PARAM_PARENT_QUALITY_PROFILE, parent1.getName())
.execute();
// 1. check rule 1 enabled
ws.newRequest()
.setMethod("POST")
.setParam(PARAM_LANGUAGE, child.getLanguage())
- .setParam(PARAM_PROFILE_NAME, child.getName())
+ .setParam(PARAM_QUALITY_PROFILE, child.getName())
.setParam(PARAM_ORGANIZATION, organization.getKey())
- .setParam(PARAM_PARENT_NAME, parent2.getName())
+ .setParam(QualityProfileWsParameters.PARAM_PARENT_QUALITY_PROFILE, parent2.getName())
.execute();
// 2. check rule 2 enabled
ws.newRequest()
.setMethod("POST")
.setParam(PARAM_LANGUAGE, child.getLanguage())
- .setParam(PARAM_PROFILE_NAME, child.getName())
+ .setParam(PARAM_QUALITY_PROFILE, child.getName())
.setParam(PARAM_ORGANIZATION, organization.getKey())
- .setParam(PARAM_PARENT_NAME, "")
+ .setParam(QualityProfileWsParameters.PARAM_PARENT_QUALITY_PROFILE, "")
.execute();
// 3. check no rule enabled
// Remove parent
ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_PROFILE, child.getKee())
- .setParam(PARAM_PARENT_PROFILE, "")
+ .setParam(PARAM_KEY, child.getKee())
+ .setParam(PARAM_PARENT_KEY, "")
.execute();
// Check no rule enabled
TestRequest request = ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_PROFILE, child.getKee())
- .setParam(PARAM_PARENT_PROFILE, "palap");
+ .setParam(PARAM_KEY, child.getKee())
+ .setParam(PARAM_PARENT_KEY, "palap");
thrown.expect(BadRequestException.class);
TestRequest request = ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_PROFILE, child.getKee())
- .setParam(PARAM_PARENT_NAME, "polop")
- .setParam(PARAM_PARENT_PROFILE, "palap");
+ .setParam(PARAM_KEY, child.getKee())
+ .setParam(PARAM_PARENT_QUALITY_PROFILE, "polop")
+ .setParam(PARAM_PARENT_KEY, "palap");
thrown.expect(IllegalArgumentException.class);
request
.execute();
TestRequest request = ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_PROFILE, child.getKee())
- .setParam(PARAM_PROFILE_NAME, child.getName())
+ .setParam(PARAM_KEY, child.getKee())
+ .setParam(PARAM_QUALITY_PROFILE, child.getName())
.setParam(PARAM_ORGANIZATION, organization.getKey())
- .setParam(PARAM_PARENT_PROFILE, "palap");
+ .setParam(PARAM_PARENT_KEY, "palap");
thrown.expect(IllegalArgumentException.class);
request.execute();
TestRequest request = ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_PROFILE, child.getKee());
+ .setParam(PARAM_KEY, child.getKee());
thrown.expect(ForbiddenException.class);
thrown.expectMessage("Insufficient privileges");
TestRequest request = ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_PROFILE, child.getKee());
+ .setParam(PARAM_KEY, child.getKee());
thrown.expect(ForbiddenException.class);
thrown.expectMessage("Insufficient privileges");
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_ORGANIZATION;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE_NAME;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE;
public class ChangelogActionDatabaseTest {
assertThat(definition.responseExampleAsString()).isNotEmpty();
assertThat(definition.params()).extracting(WebService.Param::key)
- .containsExactlyInAnyOrder("profile", "profileName", "language", "organization", "since", "to", "p", "ps");
- WebService.Param profile = definition.param("profile");
- assertThat(profile.deprecatedKey()).isEqualTo("profileKey");
- WebService.Param profileName = definition.param("profileName");
- assertThat(profileName.deprecatedSince()).isEqualTo("6.5");
+ .containsExactlyInAnyOrder("key", "qualityProfile", "language", "organization", "since", "to", "p", "ps");
+ WebService.Param profileName = definition.param("qualityProfile");
+ assertThat(profileName.deprecatedSince()).isNullOrEmpty();
WebService.Param language = definition.param("language");
- assertThat(language.deprecatedSince()).isEqualTo("6.5");
+ assertThat(language.deprecatedSince()).isNullOrEmpty();
}
@Test
String response = ws.newRequest()
.setMethod("GET")
- .setParam(PARAM_PROFILE, profile.getKee())
+ .setParam(PARAM_KEY, profile.getKee())
.execute()
.getInput();
String response = ws.newRequest()
.setMethod("GET")
.setParam(PARAM_LANGUAGE, qualityProfile.getLanguage())
- .setParam(PARAM_PROFILE_NAME, qualityProfile.getName())
+ .setParam(PARAM_QUALITY_PROFILE, qualityProfile.getName())
.execute()
.getInput();
String response = ws.newRequest()
.setMethod("GET")
.setParam(PARAM_LANGUAGE, qualityProfile.getLanguage())
- .setParam(PARAM_PROFILE_NAME, qualityProfile.getName())
+ .setParam(PARAM_QUALITY_PROFILE, qualityProfile.getName())
.setParam(PARAM_ORGANIZATION, organization.getKey())
.execute()
.getInput();
TestRequest request = ws.newRequest()
.setMethod("GET")
.setParam(PARAM_LANGUAGE, qualityProfile.getLanguage())
- .setParam(PARAM_PROFILE_NAME, qualityProfile.getName())
+ .setParam(PARAM_QUALITY_PROFILE, qualityProfile.getName())
.setParam(PARAM_ORGANIZATION, organization2.getKey());
thrown.expect(NotFoundException.class);
String response = ws.newRequest()
.setMethod("GET")
- .setParam(PARAM_PROFILE, qualityProfile.getKee())
+ .setParam(PARAM_KEY, qualityProfile.getKee())
.execute()
.getInput();
String response = ws.newRequest()
.setMethod("GET")
- .setParam(PARAM_PROFILE, qualityProfile.getKee())
+ .setParam(PARAM_KEY, qualityProfile.getKee())
.execute()
.getInput();
import static org.mockito.Mockito.when;
import static org.sonar.api.utils.DateUtils.parseDate;
import static org.sonar.server.qualityprofile.QProfileTesting.XOO_P1_KEY;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_SINCE;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TO;
when(wsSupport.getProfile(any(DbSession.class), eq(QProfileReference.fromKey(XOO_P1_KEY)))).thenReturn(QProfileTesting.newXooP1(organization));
when(changelogLoader.load(any(DbSession.class), any(QProfileChangeQuery.class))).thenReturn(new ChangelogLoader.Changelog(0, Collections.emptyList()));
- ws.newGetRequest(QProfilesWs.API_ENDPOINT, "changelog").setParam(PARAM_PROFILE, XOO_P1_KEY)
+ ws.newGetRequest(QProfilesWs.API_ENDPOINT, "changelog").setParam(PARAM_KEY, XOO_P1_KEY)
.execute().assertJson(getClass(), "changelog_empty.json");
}
List<ChangelogLoader.Change> changes = asList(change1, change2);
when(changelogLoader.load(any(DbSession.class), any(QProfileChangeQuery.class))).thenReturn(new ChangelogLoader.Changelog(10, changes));
- ws.newGetRequest(QProfilesWs.API_ENDPOINT, "changelog").setParam(PARAM_PROFILE, XOO_P1_KEY)
+ ws.newGetRequest(QProfilesWs.API_ENDPOINT, "changelog").setParam(PARAM_KEY, XOO_P1_KEY)
.execute().assertJson(getClass(), "changelog_nominal.json");
}
List<ChangelogLoader.Change> changes = asList(change1);
when(changelogLoader.load(any(DbSession.class), any(QProfileChangeQuery.class))).thenReturn(new ChangelogLoader.Changelog(10, changes));
- ws.newGetRequest(QProfilesWs.API_ENDPOINT, "changelog").setParam(PARAM_PROFILE, XOO_P1_KEY)
+ ws.newGetRequest(QProfilesWs.API_ENDPOINT, "changelog").setParam(PARAM_KEY, XOO_P1_KEY)
.execute().assertJson(getClass(), "changelog_full.json");
}
when(changelogLoader.load(any(DbSession.class), any(QProfileChangeQuery.class))).thenReturn(new ChangelogLoader.Changelog(0, Collections.emptyList()));
ws.newGetRequest(QProfilesWs.API_ENDPOINT, "changelog")
- .setParam(PARAM_PROFILE, XOO_P1_KEY)
+ .setParam(PARAM_KEY, XOO_P1_KEY)
.setParam(PARAM_SINCE, "2016-09-01")
.setParam(PARAM_TO, "2016-09-01")
.execute();
public void fail_on_unknown_profile() throws Exception {
when(wsSupport.getProfile(any(DbSession.class), eq(QProfileReference.fromKey(XOO_P1_KEY)))).thenThrow(new NotFoundException("Profile not found"));
- ws.newGetRequest(QProfilesWs.API_ENDPOINT, "changelog").setParam(PARAM_PROFILE, XOO_P1_KEY).execute();
+ ws.newGetRequest(QProfilesWs.API_ENDPOINT, "changelog").setParam(PARAM_KEY, XOO_P1_KEY).execute();
}
}
assertThat(definition.responseExampleAsString()).isNotEmpty();
assertThat(definition.params()).extracting(Param::key)
- .containsExactlyInAnyOrder("language", "organization", "profileName", "backup_with_messages", "backup_with_errors", "backup_xoo_lint");
- Param profileName = definition.param("profileName");
- assertThat(profileName.deprecatedKey()).isEqualTo("name");
- assertThat(profileName.deprecatedKeySince()).isEqualTo("6.1");
+ .containsExactlyInAnyOrder("language", "organization", "name", "backup_with_messages", "backup_with_errors", "backup_xoo_lint");
+ Param name = definition.param("name");
+ assertThat(name.deprecatedKey()).isEqualTo("profileName");
+ assertThat(name.deprecatedKeySince()).isEqualTo("6.6");
}
@Test
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_RULE;
public class DeactivateRuleActionTest {
WebService.Action definition = wsActionTester.getDef();
assertThat(definition).isNotNull();
assertThat(definition.isPost()).isTrue();
- assertThat(definition.params()).extracting(WebService.Param::key).containsExactlyInAnyOrder("profile", "rule");
- WebService.Param profileKey = definition.param("profile");
+ assertThat(definition.params()).extracting(WebService.Param::key).containsExactlyInAnyOrder("key", "rule");
+ WebService.Param profileKey = definition.param("key");
assertThat(profileKey.deprecatedKey()).isEqualTo("profile_key");
WebService.Param ruleKey = definition.param("rule");
assertThat(ruleKey.deprecatedKey()).isEqualTo("rule_key");
TestRequest request = wsActionTester.newRequest()
.setMethod("POST")
.setParam(PARAM_RULE, RuleTesting.newRuleDto().getKey().toString())
- .setParam(PARAM_PROFILE, randomAlphanumeric(UUID_SIZE));
+ .setParam(PARAM_KEY, randomAlphanumeric(UUID_SIZE));
expectedException.expect(UnauthorizedException.class);
TestRequest request = wsActionTester.newRequest()
.setMethod("POST")
.setParam(PARAM_RULE, RuleTesting.newRuleDto().getKey().toString())
- .setParam(PARAM_PROFILE, qualityProfile.getKee());
+ .setParam(PARAM_KEY, qualityProfile.getKee());
expectedException.expect(ForbiddenException.class);
TestRequest request = wsActionTester.newRequest()
.setMethod("POST")
.setParam(PARAM_RULE, RuleTesting.newRuleDto().getKey().toString())
- .setParam(PARAM_PROFILE, qualityProfile.getKee());
+ .setParam(PARAM_KEY, qualityProfile.getKee());
expectedException.expect(BadRequestException.class);
TestRequest request = wsActionTester.newRequest()
.setMethod("POST")
.setParam(PARAM_RULE, ruleKey.toString())
- .setParam(PARAM_PROFILE, qualityProfile.getKee());
+ .setParam(PARAM_KEY, qualityProfile.getKee());
TestResponse response = request.execute();
.setMethod("POST")
.setParam("organization", organization.getKey())
.setParam(PARAM_RULE, ruleKey.toString())
- .setParam(PARAM_PROFILE, qualityProfile.getKee());
+ .setParam(PARAM_KEY, qualityProfile.getKee());
TestResponse response = request.execute();
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.sonar.server.platform.db.migration.def.VarcharColumnDef.UUID_SIZE;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_PROFILE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_KEY;
public class DeactivateRulesActionTest {
"active_severities",
"s",
"repositories",
- "targetProfile",
+ "targetKey",
"statuses",
"rule_key",
"available_since",
"activation",
"severities",
"organization");
- WebService.Param targetProfile = definition.param("targetProfile");
+ WebService.Param targetProfile = definition.param("targetKey");
assertThat(targetProfile.deprecatedKey()).isEqualTo("profile_key");
}
public void should_fail_if_not_logged_in() {
TestRequest request = wsActionTester.newRequest()
.setMethod("POST")
- .setParam(PARAM_TARGET_PROFILE, randomAlphanumeric(UUID_SIZE));
+ .setParam(PARAM_TARGET_KEY, randomAlphanumeric(UUID_SIZE));
thrown.expect(UnauthorizedException.class);
request.execute();
QProfileDto qualityProfile = dbTester.qualityProfiles().insert(defaultOrganization, p -> p.setIsBuiltIn(true));
TestRequest request = wsActionTester.newRequest()
.setMethod("POST")
- .setParam(PARAM_TARGET_PROFILE, qualityProfile.getKee());
+ .setParam(PARAM_TARGET_KEY, qualityProfile.getKee());
thrown.expect(BadRequestException.class);
QProfileDto qualityProfile = dbTester.qualityProfiles().insert(organization);
TestRequest request = wsActionTester.newRequest()
.setMethod("POST")
- .setParam(PARAM_TARGET_PROFILE, qualityProfile.getKee());
+ .setParam(PARAM_TARGET_KEY, qualityProfile.getKee());
thrown.expect(ForbiddenException.class);
request.execute();
TestResponse response = ws.newRequest()
.setMethod("POST")
.setParam("language", profile1.getLanguage())
- .setParam("profileName", profile1.getName())
+ .setParam("qualityProfile", profile1.getName())
.execute();
assertThat(response.getStatus()).isEqualTo(HttpURLConnection.HTTP_NO_CONTENT);
.setMethod("POST")
.setParam("organization", organization.getKey())
.setParam("language", profile1.getLanguage())
- .setParam("profileName", profile1.getName())
+ .setParam("qualityProfile", profile1.getName())
.execute();
assertThat(response.getStatus()).isEqualTo(HttpURLConnection.HTTP_NO_CONTENT);
public void definition() {
WebService.Action definition = ws.getDef();
- assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("language", "organization", "profile", "profileName");
- Param profile = definition.param("profile");
- assertThat(profile.deprecatedKey()).isEqualTo("profileKey");
- Param profileName = definition.param("profileName");
- assertThat(profileName.deprecatedSince()).isEqualTo("6.5");
+ assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("language", "organization", "key", "qualityProfile");
+ Param key = definition.param("key");
+ assertThat(key.deprecatedKey()).isEqualTo("profileKey");
+ assertThat(key.deprecatedSince()).isEqualTo("6.6");
+ Param profileName = definition.param("qualityProfile");
+ assertThat(profileName.deprecatedSince()).isNullOrEmpty();
Param language = definition.param("language");
- assertThat(language.deprecatedSince()).isEqualTo("6.5");
+ assertThat(language.deprecatedSince()).isNullOrEmpty();
}
private void logInAsQProfileAdministrator(OrganizationDto organization) {
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
public class ExportActionTest {
assertThat(definition.isPost()).isFalse();
assertThat(definition.isInternal()).isFalse();
- assertThat(definition.params()).extracting(WebService.Param::key).containsExactlyInAnyOrder("profile", "language", "name", "organization");
+ assertThat(definition.params()).extracting(WebService.Param::key).containsExactlyInAnyOrder("key", "language", "qualityProfile", "organization");
WebService.Param organizationParam = definition.param("organization");
assertThat(organizationParam.since()).isEqualTo("6.4");
assertThat(organizationParam.isInternal()).isTrue();
- WebService.Param profile = definition.param("profile");
- assertThat(profile.since()).isEqualTo("6.5");
- WebService.Param name = definition.param("name");
- assertThat(name.deprecatedSince()).isEqualTo("6.5");
+ WebService.Param key = definition.param("key");
+ assertThat(key.since()).isEqualTo("6.5");
+ assertThat(key.deprecatedSince()).isEqualTo("6.6");
+ WebService.Param name = definition.param("qualityProfile");
+ assertThat(name.deprecatedSince()).isNullOrEmpty();
WebService.Param language = definition.param("language");
- assertThat(language.deprecatedSince()).isEqualTo("6.5");
+ assertThat(language.deprecatedSince()).isNullOrEmpty();
}
@Test
assertThat(definition.isPost()).isFalse();
assertThat(definition.isInternal()).isFalse();
- assertThat(definition.params()).extracting("key").containsExactlyInAnyOrder("profile", "language", "name", "organization", "exporterKey");
+ assertThat(definition.params()).extracting("key").containsExactlyInAnyOrder("key", "language", "qualityProfile", "organization", "exporterKey");
WebService.Param exportersParam = definition.param("exporterKey");
assertThat(exportersParam.possibleValues()).containsOnly("polop", "palap");
assertThat(exportersParam.deprecatedKey()).isEqualTo("format");
WsActionTester tester = newWsActionTester(newExporter("polop"), newExporter("palap"));
String result = tester.newRequest()
- .setParam(PARAM_PROFILE, profile.getKee())
+ .setParam(PARAM_KEY, profile.getKee())
.setParam("exporterKey", "polop").execute()
.getInput();
WsActionTester ws = newWsActionTester(newExporter("polop"), newExporter("palap"));
ws.newRequest()
- .setParam(PARAM_PROFILE, "PROFILE-KEY-404")
+ .setParam(PARAM_KEY, "PROFILE-KEY-404")
.setParam("exporterKey", "polop").execute()
.getInput();
}
QProfileDto profile = createProfile(db.getDefaultOrganization(), false);
expectedException.expect(BadRequestException.class);
- expectedException.expectMessage("Either 'profile' or 'language' must be provided.");
+ expectedException.expectMessage("Either 'key' or 'language' must be provided.");
WsActionTester ws = newWsActionTester(newExporter("polop"), newExporter("palap"));
ws.newRequest()
- .setParam(PARAM_PROFILE, profile.getKee())
+ .setParam(PARAM_KEY, profile.getKee())
.setParam(PARAM_LANGUAGE, profile.getLanguage())
.setParam("exporterKey", "polop").execute()
.getInput();
WsActionTester tester = newWsActionTester(newExporter("polop"), newExporter("palap"));
String result = tester.newRequest()
.setParam("language", profile.getLanguage())
- .setParam("name", profile.getName())
+ .setParam("qualityProfile", profile.getName())
.setParam("exporterKey", "polop").execute()
.getInput();
String result = tester.newRequest()
.setParam("organization", organization.getKey())
.setParam("language", profile.getLanguage())
- .setParam("name", profile.getName())
+ .setParam("qualityProfile", profile.getName())
.setParam("exporterKey", "polop").execute()
.getInput();
String result = newWsActionTester(newExporter("polop")).newRequest()
.setParam("language", profile.getLanguage())
- .setParam("name", profile.getName())
+ .setParam("qualityProfile", profile.getName())
.execute()
.getInput();
import static org.sonar.server.qualityprofile.QProfileTesting.newQProfileDto;
import static org.sonar.test.JsonAssert.assertJson;
import static org.sonarqube.ws.MediaTypes.PROTOBUF;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
public class InheritanceActionTest {
String response = ws.newRequest()
.setMethod("GET")
- .setParam(PARAM_PROFILE, buWide.getKee())
+ .setParam(PARAM_KEY, buWide.getKee())
.execute()
.getInput();
InputStream response = ws.newRequest()
.setMethod("GET")
.setMediaType(PROTOBUF)
- .setParam(PARAM_PROFILE, child.getKee())
+ .setParam(PARAM_KEY, child.getKee())
.execute()
.getInputStream();
InputStream response = ws.newRequest()
.setMethod("GET")
.setMediaType(PROTOBUF)
- .setParam(PARAM_PROFILE, profile.getKee())
+ .setParam(PARAM_KEY, profile.getKee())
.execute()
.getInputStream();
String response = ws.newRequest()
.setMethod("GET")
- .setParam(PARAM_PROFILE, remi.getKee())
+ .setParam(PARAM_KEY, remi.getKee())
.execute()
.getInput();
@Test(expected = NotFoundException.class)
public void fail_if_not_found() throws Exception {
ws.newRequest()
- .setMethod("GET").setParam(PARAM_PROFILE, "polop").execute();
+ .setMethod("GET").setParam(PARAM_KEY, "polop").execute();
}
@Test
WebService.Action definition = ws.getDef();
assertThat(definition.key()).isEqualTo("inheritance");
- assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("profile", "language", "profileName", "organization");
- Param profile = definition.param("profile");
- assertThat(profile.deprecatedKey()).isEqualTo("profileKey");
- Param profileName = definition.param("profileName");
- assertThat(profileName.deprecatedSince()).isEqualTo("6.5");
+ assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("key", "language", "qualityProfile", "organization");
+ Param key = definition.param("key");
+ assertThat(key.deprecatedKey()).isEqualTo("profileKey");
+ assertThat(key.deprecatedSince()).isEqualTo("6.6");
+ Param profileName = definition.param("qualityProfile");
+ assertThat(profileName.deprecatedSince()).isNullOrEmpty();
Param language = definition.param("language");
- assertThat(language.deprecatedSince()).isEqualTo("6.5");
+ assertThat(language.deprecatedSince()).isNullOrEmpty();
}
private QProfileDto createProfile(String lang, String name, String key) {
import org.sonar.server.ws.WsTester.TestRequest;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
public class ProjectsActionTest {
dbSession.commit();
- newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam("selected", "selected").execute().assertJson(this.getClass(), "authorized_selected.json");
+ newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam("selected", "selected").execute().assertJson(this.getClass(), "authorized_selected.json");
}
@Test
dbSession.commit();
- newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "2")
+ newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "2")
.execute().assertJson(this.getClass(), "selected_page1.json");
- newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "2").setParam(Param.PAGE, "2")
+ newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "2").setParam(Param.PAGE, "2")
.execute().assertJson(this.getClass(), "selected_page2.json");
- newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "2").setParam(Param.PAGE, "3")
+ newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "2").setParam(Param.PAGE, "3")
.execute().assertJson(this.getClass(), "empty.json");
- newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "2").setParam(Param.PAGE, "4")
+ newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "2").setParam(Param.PAGE, "4")
.execute().assertJson(this.getClass(), "empty.json");
- newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "3").setParam(Param.PAGE, "1")
+ newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "3").setParam(Param.PAGE, "1")
.execute().assertJson(this.getClass(), "selected_ps3_page1.json");
- newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "3").setParam(Param.PAGE, "2")
+ newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "3").setParam(Param.PAGE, "2")
.execute().assertJson(this.getClass(), "selected_ps3_page2.json");
- newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "3").setParam(Param.PAGE, "3")
+ newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam("selected", "selected").setParam(Param.PAGE_SIZE, "3").setParam(Param.PAGE, "3")
.execute().assertJson(this.getClass(), "empty.json");
}
dbSession.commit();
- newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam("selected", "deselected").execute().assertJson(this.getClass(), "deselected.json");
+ newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam("selected", "deselected").execute().assertJson(this.getClass(), "deselected.json");
}
@Test
dbSession.commit();
- newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam("selected", "all").execute().assertJson(this.getClass(), "all.json");
+ newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam("selected", "all").execute().assertJson(this.getClass(), "all.json");
}
@Test
dbSession.commit();
- newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam("selected", "all").setParam(Param.TEXT_QUERY, "project t").execute().assertJson(this.getClass(), "all_filtered.json");
+ newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam("selected", "all").setParam(Param.TEXT_QUERY, "project t").execute().assertJson(this.getClass(), "all_filtered.json");
}
@Test
public void should_fail_on_nonexistent_profile() throws Exception {
expectedException.expect(NotFoundException.class);
- newRequest().setParam(PARAM_PROFILE, "unknown").setParam("selected", "all").execute();
+ newRequest().setParam(PARAM_KEY, "unknown").setParam("selected", "all").execute();
}
@Test
dbSession.commit();
- newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam("selected", "all").execute().assertJson(this.getClass(), "return_deprecated_uuid_field.json");
+ newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam("selected", "all").execute().assertJson(this.getClass(), "return_deprecated_uuid_field.json");
}
@Test
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("The 'ps' parameter must be less than 500");
- newRequest().setParam(PARAM_PROFILE, xooP1.getKee()).setParam(Param.PAGE_SIZE, "501").execute();
+ newRequest().setParam(PARAM_KEY, xooP1.getKee()).setParam(Param.PAGE_SIZE, "501").execute();
}
@Test
assertThat(definition.key()).isEqualTo("projects");
assertThat(definition.responseExampleAsString()).isNotEmpty();
- assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("profile", "p", "ps", "q", "selected");
- Param profile = definition.param("profile");
- assertThat(profile.deprecatedKey()).isEqualTo("key");
+ assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("key", "p", "ps", "q", "selected");
+ Param profile = definition.param("key");
+ assertThat(profile.deprecatedKey()).isNullOrEmpty();
Param page = definition.param("p");
assertThat(page.deprecatedKey()).isEqualTo("page");
Param pageSize = definition.param("ps");
@Test
public void from_reads_request_parameters_and_creates_reference_by_key() {
SimpleGetRequest req = new SimpleGetRequest();
- req.setParam("profile", "foo");
+ req.setParam("key", "foo");
QProfileReference ref = QProfileReference.from(req);
assertThat(ref.getKey()).isEqualTo("foo");
public void from_reads_request_parameters_and_creates_reference_by_name_on_default_organization() {
SimpleGetRequest req = new SimpleGetRequest();
req.setParam("language", "js");
- req.setParam("profileName", "Sonar way");
+ req.setParam("qualityProfile", "Sonar way");
QProfileReference ref = QProfileReference.from(req);
assertThat(ref.getOrganizationKey()).isEmpty();
SimpleGetRequest req = new SimpleGetRequest();
req.setParam("organization", "my-org");
req.setParam("language", "js");
- req.setParam("profileName", "Sonar way");
+ req.setParam("qualityProfile", "Sonar way");
QProfileReference ref = QProfileReference.from(req);
assertThat(ref.getOrganizationKey()).hasValue("my-org");
WebService.Action action = wsTester.controller("api/qualityprofiles").action("do");
assertThat(action.param("language")).isNotNull();
assertThat(action.param("language").possibleValues()).containsOnly("java", "js");
- assertThat(action.param("profile")).isNotNull();
- assertThat(action.param("profileName")).isNotNull();
+ assertThat(action.param("key")).isNotNull();
+ assertThat(action.param("qualityProfile")).isNotNull();
}
@Test
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_RESET;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_RULE;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_SEVERITY;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_PROFILE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_KEY;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_TARGET_SEVERITY;
import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_LANGUAGES;
import static org.sonarqube.ws.client.rule.RulesWsParameters.PARAM_QPROFILE;
// 1. Deactivate Rule
wsDeactivateRule.newRequest().setMethod("POST")
- .setParam(PARAM_PROFILE, profile.getKee())
+ .setParam(PARAM_KEY, profile.getKee())
.setParam(PARAM_RULE, rule.getKey().toString())
.execute();
dbSession.clearCache();
// 1. Deactivate Rule
wsDeactivateRules.newRequest().setMethod("POST")
- .setParam(PARAM_TARGET_PROFILE, profile.getKee())
+ .setParam(PARAM_TARGET_KEY, profile.getKee())
.execute();
dbSession.clearCache();
// 1. Deactivate Rule
wsDeactivateRules.newRequest().setMethod("POST")
- .setParam(PARAM_TARGET_PROFILE, profile.getKee())
+ .setParam(PARAM_TARGET_KEY, profile.getKee())
.execute();
dbSession.clearCache();
// 1. Deactivate Rule
wsDeactivateRules.newRequest().setMethod("POST")
- .setParam(PARAM_TARGET_PROFILE, profile.getKee())
+ .setParam(PARAM_TARGET_KEY, profile.getKee())
.setParam(Param.TEXT_QUERY, "hello")
.execute();
dbSession.clearCache();
// 1. Activate Rule
wsActivateRule.newRequest().setMethod("POST")
- .setParam(PARAM_PROFILE, profile.getKee())
+ .setParam(PARAM_KEY, profile.getKee())
.setParam(PARAM_RULE, rule.getKey().toString())
.execute();
dbSession.clearCache();
try {
// 1. Activate Rule
wsActivateRule.newRequest().setMethod("POST")
- .setParam(PARAM_PROFILE, profile.getKee())
+ .setParam(PARAM_KEY, profile.getKee())
.setParam(PARAM_RULE, rule.getKey().toString())
.execute();
dbSession.clearCache();
// 1. Activate Rule
wsActivateRule.newRequest().setMethod("POST")
- .setParam(PARAM_PROFILE, profile.getKee())
+ .setParam(PARAM_KEY, profile.getKee())
.setParam(PARAM_RULE, rule.getKey().toString())
.setParam(PARAM_SEVERITY, "MINOR")
.execute();
// 1. Activate Rule
wsActivateRules.newRequest().setMethod("POST")
- .setParam(PARAM_TARGET_PROFILE, profile.getKee())
+ .setParam(PARAM_TARGET_KEY, profile.getKee())
.setParam(PARAM_LANGUAGES, "java")
.execute()
.assertJson(getClass(), "bulk_activate_rule.json");
// 1. Activate Rule
wsActivateRules.newRequest().setMethod("POST")
- .setParam(PARAM_TARGET_PROFILE, php.getKee())
+ .setParam(PARAM_TARGET_KEY, php.getKee())
.setParam(PARAM_LANGUAGES, "php")
.execute()
.assertJson(getClass(), "bulk_activate_rule_not_all.json");
// 1. Activate Rule with query returning 0 hits
wsActivateRules.newRequest().setMethod("POST")
- .setParam(PARAM_TARGET_PROFILE, profile.getKee())
+ .setParam(PARAM_TARGET_KEY, profile.getKee())
.setParam(Param.TEXT_QUERY, "php")
.execute();
dbSession.clearCache();
// 1. Activate Rule with query returning 1 hits
wsActivateRules.newRequest().setMethod("POST")
- .setParam(PARAM_TARGET_PROFILE, profile.getKee())
+ .setParam(PARAM_TARGET_KEY, profile.getKee())
.setParam(Param.TEXT_QUERY, "world")
.execute();
dbSession.commit();
// 1. Activate Rule with query returning 2 hits
wsActivateRules.newRequest().setMethod("POST")
- .setParam(PARAM_TARGET_PROFILE, profile.getKee())
+ .setParam(PARAM_TARGET_KEY, profile.getKee())
.setParam(PARAM_TARGET_SEVERITY, "MINOR")
.execute();
dbSession.commit();
// 1. Activate Rule
wsActivateRules.newRequest().setMethod("POST")
- .setParam(PARAM_TARGET_PROFILE, javaProfile.getKee())
+ .setParam(PARAM_TARGET_KEY, javaProfile.getKee())
.setParam(PARAM_QPROFILE, javaProfile.getKee())
.setParam("activation", "false")
.execute()
// 1. reset child rule
wsActivateRule.newRequest().setMethod("POST")
- .setParam(PARAM_PROFILE, subProfile.getKee())
+ .setParam(PARAM_KEY, subProfile.getKee())
.setParam(PARAM_RULE, rule.getKey().toString())
.setParam(PARAM_RESET, "true")
.execute();
import org.sonar.api.resources.Language;
import org.sonar.api.resources.Languages;
import org.sonar.api.server.ws.WebService;
+import org.sonar.api.server.ws.WebService.Param;
import org.sonar.api.utils.ValidationMessages;
import org.sonar.db.DbClient;
import org.sonar.server.language.LanguageTesting;
assertThat(create.param("organization")).isNotNull();
assertThat(create.param("organization").isRequired()).isFalse();
assertThat(create.param("organization").isInternal()).isTrue();
- assertThat(create.param("profileName")).isNotNull();
- assertThat(create.param("profileName").isRequired()).isTrue();
+ assertThat(create.param("name")).isNotNull();
+ assertThat(create.param("name").isRequired()).isTrue();
assertThat(create.param("language").possibleValues()).containsOnly(xoo1Key, xoo2Key);
assertThat(create.param("language").isRequired()).isTrue();
assertThat(create.param("backup_" + xoo1Key)).isNotNull();
WebService.Action delete = controller.action("delete");
assertThat(delete).isNotNull();
assertThat(delete.isPost()).isTrue();
- assertThat(delete.params()).hasSize(4).extracting("key").containsOnly(
- "organization", "profile", "language", "profileName");
+ assertThat(delete.params()).hasSize(4).extracting(Param::key).containsOnly(
+ "organization", "key", "language", "qualityProfile");
}
@Test
WebService.Action inheritance = controller.action("inheritance");
assertThat(inheritance).isNotNull();
assertThat(inheritance.isPost()).isFalse();
- assertThat(inheritance.params()).hasSize(4).extracting("key").containsExactlyInAnyOrder(
- "organization", "profile", "language", "profileName");
+ assertThat(inheritance.params()).hasSize(4).extracting(Param::key).containsExactlyInAnyOrder(
+ "organization", "key", "language", "qualityProfile");
assertThat(inheritance.responseExampleAsString()).isNotEmpty();
}
}
assertThat(definition.isPost()).isTrue();
assertThat(definition.key()).isEqualTo("remove_project");
- assertThat(definition.params()).extracting(WebService.Param::key).containsOnly("profile", "profileName", "project", "language", "projectUuid", "organization");
+ assertThat(definition.params()).extracting(WebService.Param::key).containsOnly("key", "qualityProfile", "project", "language", "projectUuid", "organization");
WebService.Param languageParam = definition.param("language");
assertThat(languageParam.possibleValues()).containsOnly(LANGUAGE_1, LANGUAGE_2);
assertThat(languageParam.exampleValue()).isNull();
- assertThat(languageParam.deprecatedSince()).isEqualTo("6.5");
+ assertThat(languageParam.deprecatedSince()).isNullOrEmpty();
WebService.Param organizationParam = definition.param("organization");
assertThat(organizationParam.since()).isEqualTo("6.4");
assertThat(organizationParam.isInternal()).isTrue();
- WebService.Param profile = definition.param("profile");
+ WebService.Param profile = definition.param("key");
assertThat(profile.deprecatedKey()).isEqualTo("profileKey");
- WebService.Param profileName = definition.param("profileName");
- assertThat(profileName.deprecatedSince()).isEqualTo("6.5");
+ WebService.Param profileName = definition.param("qualityProfile");
+ assertThat(profileName.deprecatedSince()).isNullOrEmpty();
WebService.Param project = definition.param("project");
assertThat(project.deprecatedKey()).isEqualTo("projectKey");
WebService.Param projectUuid = definition.param("projectUuid");
logInAsQProfileAdministrator();
expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("The 'profile' parameter is missing");
+ expectedException.expectMessage("The 'key' parameter is missing");
call(null, "Other Sonar Way");
}
assertThat(definition.key()).isEqualTo("rename");
assertThat(definition.isPost()).isTrue();
- assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("profile", "name");
- Param profile = definition.param("profile");
- assertThat(profile.deprecatedKey()).isEqualTo("key");
+ assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("key", "name");
+ Param profile = definition.param("key");
+ assertThat(profile.deprecatedKey()).isNullOrEmpty();
}
private String createNewValidQualityProfileKey() {
TestRequest request = ws.newRequest()
.setMethod("POST");
- setNullable(key, k -> request.setParam("profile", k));
+ setNullable(key, k -> request.setParam("key", k));
setNullable(name, n -> request.setParam("name", n));
request.execute();
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_DEFAULTS;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_ORGANIZATION;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE_NAME;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT_KEY;
public class SearchActionTest {
assertThat(language.deprecatedSince()).isNull();
assertThat(language.description()).isEqualTo("Language key. If provided, only profiles for the given language are returned.");
- WebService.Param profileName = definition.param("profileName");
+ WebService.Param profileName = definition.param("qualityProfile");
assertThat(profileName.deprecatedSince()).isNull();
- assertThat(profileName.description()).isEqualTo("Profile name");
+ assertThat(profileName.description()).isEqualTo("Quality profile name");
}
@Test
QProfileDto sonarWayInCamelCase = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setName("Sonar Way").setLanguage(XOO2.getKey()));
QProfileDto anotherProfile = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setName("Another").setLanguage(XOO2.getKey()));
- SearchWsResponse result = call(ws.newRequest().setParam(PARAM_PROFILE_NAME, "Sonar way"));
+ SearchWsResponse result = call(ws.newRequest().setParam(PARAM_QUALITY_PROFILE, "Sonar way"));
assertThat(result.getProfilesList()).extracting(QualityProfile::getKey)
.containsExactlyInAnyOrder(sonarWayOnXoo1.getKee(), sonarWayOnXoo2.getKee())
SearchWsResponse result = call(ws.newRequest()
.setParam(PARAM_DEFAULTS, "true")
- .setParam(PARAM_PROFILE_NAME, "Sonar way"));
+ .setParam(PARAM_QUALITY_PROFILE, "Sonar way"));
assertThat(result.getProfilesList()).extracting(QualityProfile::getKey)
.containsExactlyInAnyOrder(sonarWayOnXoo1.getKee())
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_PROFILES;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
public class SetDefaultActionTest {
assertThat(definition).isNotNull();
assertThat(definition.isPost()).isTrue();
- assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("profile", "profileName", "language", "organization");
+ assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("key", "qualityProfile", "language", "organization");
assertThat(definition.param("organization").since()).isEqualTo("6.4");
- Param profile = definition.param("profile");
+ Param profile = definition.param("key");
assertThat(profile.deprecatedKey()).isEqualTo("profileKey");
- assertThat(definition.param("profileName").deprecatedSince()).isEqualTo("6.5");
- assertThat(definition.param("language").deprecatedSince()).isEqualTo("6.5");
+ assertThat(definition.param("qualityProfile").deprecatedSince()).isNullOrEmpty();
+ assertThat(definition.param("language").deprecatedSince()).isNullOrEmpty();
}
@Test
TestResponse response = ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_PROFILE, xoo2Profile.getKee()).execute();
+ .setParam(PARAM_KEY, xoo2Profile.getKee()).execute();
assertThat(response.getInput()).isEmpty();
// One more time!
TestResponse response2 = ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_PROFILE, xoo2Profile.getKee()).execute();
+ .setParam(PARAM_KEY, xoo2Profile.getKee()).execute();
assertThat(response2.getInput()).isEmpty();
checkDefaultProfile(organization, XOO_1_KEY, xoo1Profile.getKee());
TestResponse response = ws.newRequest().setMethod("POST")
.setParam("language", xoo2Profile.getLanguage())
- .setParam("profileName", xoo2Profile.getName())
+ .setParam("qualityProfile", xoo2Profile.getName())
.setParam("organization", organization.getKey())
.execute();
TestResponse response = ws.newRequest().setMethod("POST")
.setParam("language", profileOrg1New.getLanguage())
- .setParam("profileName", profileOrg1New.getName())
+ .setParam("qualityProfile", profileOrg1New.getName())
.setParam("organization", organization1.getKey())
.execute();
expectedException.expectMessage("Quality Profile with key 'unknown-profile-666' does not exist");
ws.newRequest().setMethod("POST")
- .setParam(PARAM_PROFILE, "unknown-profile-666")
+ .setParam(PARAM_KEY, "unknown-profile-666")
.execute();
checkDefaultProfile(organization, XOO_1_KEY, xoo1Profile.getKee());
try {
TestResponse response = ws.newRequest().setMethod("POST")
.setParam("language", XOO_2_KEY)
- .setParam("profileName", "Unknown")
+ .setParam("qualityProfile", "Unknown")
.execute();
Fail.failBecauseExceptionWasNotThrown(NotFoundException.class);
} catch (NotFoundException nfe) {
expectedException.expectMessage("When providing a quality profile key, neither of organization/language/name must be set");
ws.newRequest().setMethod("POST")
- .setParam(PARAM_PROFILE, xoo2Profile.getKee())
+ .setParam(PARAM_KEY, xoo2Profile.getKee())
.setParam("organization", organization.getKey())
.execute();
}
expectedException.expectMessage("Insufficient privileges");
ws.newRequest().setMethod("POST")
- .setParam(PARAM_PROFILE, xoo2Profile.getKee())
+ .setParam(PARAM_KEY, xoo2Profile.getKee())
.execute();
}
expectedException.expectMessage("Authentication is required");
ws.newRequest().setMethod("POST")
- .setParam(PARAM_PROFILE, xoo2Profile.getKee())
+ .setParam(PARAM_KEY, xoo2Profile.getKee())
.execute();
}
import static org.sonar.server.language.LanguageTesting.newLanguage;
import static org.sonar.test.JsonAssert.assertJson;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_COMPARE_TO_SONAR_WAY;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
public class ShowActionTest {
assertThat(action.isPost()).isFalse();
assertThat(action.since()).isEqualTo("6.5");
- WebService.Param profile = action.param("profile");
+ WebService.Param profile = action.param("key");
assertThat(profile.isRequired()).isTrue();
assertThat(profile.isInternal()).isFalse();
assertThat(profile.description()).isNotEmpty();
public void profile_info() {
QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage(XOO1.getKey()));
- QualityProfiles.ShowResponse result = call(ws.newRequest().setParam(PARAM_PROFILE, profile.getKee()));
+ QualityProfiles.ShowResponse result = call(ws.newRequest().setParam(PARAM_KEY, profile.getKee()));
assertThat(result.getProfile())
.extracting(QualityProfile::getKey, QualityProfile::getName, QualityProfile::getIsBuiltIn, QualityProfile::getLanguage, QualityProfile::getLanguageName,
QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage(XOO1.getKey()));
db.qualityProfiles().setAsDefault(profile);
- QualityProfiles.ShowResponse result = call(ws.newRequest().setParam(PARAM_PROFILE, profile.getKee()));
+ QualityProfiles.ShowResponse result = call(ws.newRequest().setParam(PARAM_KEY, profile.getKee()));
assertThat(result.getProfile().getIsDefault()).isTrue();
}
QProfileDto defaultProfile = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage(XOO1.getKey()));
db.qualityProfiles().setAsDefault(defaultProfile);
- ShowResponse result = call(ws.newRequest().setParam(PARAM_PROFILE, profile.getKee()));
+ ShowResponse result = call(ws.newRequest().setParam(PARAM_KEY, profile.getKee()));
assertThat(result.getProfile().getIsDefault()).isFalse();
}
.setLastUsed(time)
.setUserUpdatedAt(time));
- QualityProfiles.ShowResponse result = call(ws.newRequest().setParam(PARAM_PROFILE, profile.getKee()));
+ QualityProfiles.ShowResponse result = call(ws.newRequest().setParam(PARAM_KEY, profile.getKee()));
assertThat(result.getProfile().getRulesUpdatedAt()).isEqualTo("2016-12-21T19:10:03+0100");
assertThat(parseDateTime(result.getProfile().getLastUsed()).getTime()).isEqualTo(time);
.mapToObj(i -> db.components().insertPrivateProject())
.forEach(project -> db.qualityProfiles().associateWithProject(project, profile));
- QualityProfiles.ShowResponse result = call(ws.newRequest().setParam(PARAM_PROFILE, profile.getKee()));
+ QualityProfiles.ShowResponse result = call(ws.newRequest().setParam(PARAM_KEY, profile.getKee()));
assertThat(result.getProfile())
.extracting(QualityProfile::getActiveRuleCount, QualityProfile::getActiveDeprecatedRuleCount, QualityProfile::getProjectCount)
activeRuleIndexer.indexOnStartup(activeRuleIndexer.getIndexTypes());
CompareToSonarWay result = call(ws.newRequest()
- .setParam(PARAM_PROFILE, profile.getKee())
+ .setParam(PARAM_KEY, profile.getKee())
.setParam(PARAM_COMPARE_TO_SONAR_WAY, "true"))
.getCompareToSonarWay();
activeRuleIndexer.indexOnStartup(activeRuleIndexer.getIndexTypes());
CompareToSonarWay result = call(ws.newRequest()
- .setParam(PARAM_PROFILE, profile.getKee())
+ .setParam(PARAM_KEY, profile.getKee())
.setParam(PARAM_COMPARE_TO_SONAR_WAY, "true"))
.getCompareToSonarWay();
QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage(XOO1.getKey()));
ShowResponse result = call(ws.newRequest()
- .setParam(PARAM_PROFILE, profile.getKee())
+ .setParam(PARAM_KEY, profile.getKee())
.setParam(PARAM_COMPARE_TO_SONAR_WAY, "true"));
assertThat(result.hasCompareToSonarWay()).isFalse();
QProfileDto anotherBuiltInProfile = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setIsBuiltIn(true).setLanguage(XOO1.getKey()));
QualityProfiles.ShowResponse result = call(ws.newRequest()
- .setParam(PARAM_PROFILE, anotherBuiltInProfile.getKee())
+ .setParam(PARAM_KEY, anotherBuiltInProfile.getKee())
.setParam(PARAM_COMPARE_TO_SONAR_WAY, "true"));
assertThat(result.hasCompareToSonarWay()).isFalse();
QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage(XOO1.getKey()));
QualityProfiles.ShowResponse result = call(ws.newRequest()
- .setParam(PARAM_PROFILE, profile.getKee())
+ .setParam(PARAM_KEY, profile.getKee())
.setParam(PARAM_COMPARE_TO_SONAR_WAY, "true"));
assertThat(result.hasCompareToSonarWay()).isFalse();
QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage(XOO1.getKey()));
QualityProfiles.ShowResponse result = call(ws.newRequest()
- .setParam(PARAM_PROFILE, profile.getKee())
+ .setParam(PARAM_KEY, profile.getKee())
.setParam(PARAM_COMPARE_TO_SONAR_WAY, "false"));
assertThat(result.hasCompareToSonarWay()).isFalse();
QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage(XOO1.getKey()));
CompareToSonarWay result = call(ws.newRequest()
- .setParam(PARAM_PROFILE, profile.getKee())
+ .setParam(PARAM_KEY, profile.getKee())
.setParam(PARAM_COMPARE_TO_SONAR_WAY, "true"))
.getCompareToSonarWay();
QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), p -> p.setLanguage(XOO1.getKey()));
CompareToSonarWay result = call(ws.newRequest()
- .setParam(PARAM_PROFILE, profile.getKee())
+ .setParam(PARAM_KEY, profile.getKee())
.setParam(PARAM_COMPARE_TO_SONAR_WAY, "true"))
.getCompareToSonarWay();
expectedException.expect(NotFoundException.class);
expectedException.expectMessage("Quality Profile with key 'unknown-profile' does not exist");
- call(ws.newRequest().setParam(PARAM_PROFILE, profile.getKee()));
+ call(ws.newRequest().setParam(PARAM_KEY, profile.getKee()));
}
@Test
expectedException.expect(NotFoundException.class);
expectedException.expectMessage("Quality Profile with key 'unknown-profile' does not exist");
- call(ws.newRequest().setParam(PARAM_PROFILE, "unknown-profile"));
+ call(ws.newRequest().setParam(PARAM_KEY, "unknown-profile"));
}
@Test
ws = new WsActionTester(
new ShowAction(db.getDbClient(), new QProfileWsSupport(db.getDbClient(), userSession, TestDefaultOrganizationProvider.from(db)), new Languages(cs), ruleIndex));
- String result = ws.newRequest().setParam(PARAM_PROFILE, profile.getKee()).execute().getInput();
+ String result = ws.newRequest().setParam(PARAM_KEY, profile.getKee()).execute().getInput();
assertJson(result).ignoreFields("rulesUpdatedAt", "lastUsed", "userUpdatedAt").isSimilarTo(ws.getDef().responseExampleAsString());
}
public class ActivateRuleWsRequest {
private final Optional<String> params;
- private final String profileKey;
+ private final String key;
private final Optional<Boolean> reset;
private final String ruleKey;
private final Optional<Severity> severity;
private ActivateRuleWsRequest(Builder builder) {
organization = requireNonNull(builder.organization);
params = requireNonNull(builder.params);
- profileKey = requireNonNull(builder.profileKey);
+ key = requireNonNull(builder.key);
reset = requireNonNull(builder.reset);
ruleKey = requireNonNull(builder.ruleKey);
severity = requireNonNull(builder.severity);
return params;
}
- public String getProfileKey() {
- return profileKey;
+ public String getKey() {
+ return key;
}
public Optional<Boolean> getReset() {
public static class Builder {
private Optional<String> organization = Optional.empty();
private Optional<String> params = Optional.empty();
- private String profileKey;
+ private String key;
private Optional<Boolean> reset = Optional.empty();
private String ruleKey;
private Optional<Severity> severity = Optional.empty();
return this;
}
- public Builder setProfileKey(String profileKey) {
- this.profileKey = profileKey;
+ public Builder setKey(String key) {
+ this.key = key;
return this;
}
private final String language;
private final Optional<String> organization;
- private final String profileName;
- private final String profileKey;
+ private final String qualityProfile;
+ private final String key;
private final String projectKey;
private final String projectUuid;
private AddProjectRequest(Builder builder) {
this.language = builder.language;
this.organization = requireNonNull(builder.organization);
- this.profileName = builder.profileName;
- this.profileKey = builder.profileKey;
+ this.qualityProfile = builder.qualityProfile;
+ this.key = builder.key;
this.projectKey = builder.projectKey;
this.projectUuid = builder.projectUuid;
}
}
@CheckForNull
- public String getProfileName() {
- return profileName;
+ public String getQualityProfile() {
+ return qualityProfile;
}
@CheckForNull
- public String getProfileKey() {
- return profileKey;
+ public String getKey() {
+ return key;
}
@CheckForNull
public static class Builder {
private String language;
private Optional<String> organization = Optional.empty();
- private String profileName;
- private String profileKey;
+ private String qualityProfile;
+ private String key;
private String projectKey;
private String projectUuid;
return this;
}
- public Builder setProfileName(@Nullable String profileName) {
- this.profileName = profileName;
+ public Builder setQualityProfile(@Nullable String qualityProfile) {
+ this.qualityProfile = qualityProfile;
return this;
}
- public Builder setProfileKey(@Nullable String profileKey) {
- this.profileKey = profileKey;
+ public Builder setKey(@Nullable String key) {
+ this.key = key;
return this;
}
public class ChangeParentRequest {
private final String language;
private final String parentKey;
- private final String parentName;
- private final String profileKey;
- private final String profileName;
+ private final String parentQualityProfile;
+ private final String key;
+ private final String qualityProfile;
private final String organization;
public ChangeParentRequest(Builder builder) {
this.language = builder.language;
this.parentKey = builder.parentKey;
- this.parentName = builder.parentName;
- this.profileKey = builder.profileKey;
- this.profileName = builder.profileName;
+ this.parentQualityProfile = builder.parentName;
+ this.key = builder.profileKey;
+ this.qualityProfile = builder.profileName;
this.organization = builder.organization;
}
return parentKey;
}
- public String getParentName() {
- return parentName;
+ public String getParentQualityProfile() {
+ return parentQualityProfile;
}
- public String getProfileKey() {
- return profileKey;
+ public String getKey() {
+ return key;
}
- public String getProfileName() {
- return profileName;
+ public String getQualityProfile() {
+ return qualityProfile;
}
public String getOrganization() {
@Immutable
public class CreateRequest {
- private final String profileName;
+ private final String name;
private final String language;
private final String organizationKey;
private CreateRequest(Builder builder) {
- this.profileName = builder.profileName;
+ this.name = builder.name;
this.language = builder.language;
this.organizationKey = builder.organizationKey;
}
return language;
}
- public String getProfileName() {
- return profileName;
+ public String getName() {
+ return name;
}
public String getOrganizationKey() {
public static class Builder {
private String language;
- private String profileName;
+ private String name;
private String organizationKey;
private Builder() {
return this;
}
- public Builder setProfileName(@Nullable String profileName) {
- this.profileName = profileName;
+ public Builder setName(@Nullable String profileName) {
+ this.name = profileName;
return this;
}
public CreateRequest build() {
checkArgument(language != null && !language.isEmpty(), "Language is mandatory and must not be empty.");
- checkArgument(profileName != null && !profileName.isEmpty(), "Profile name is mandatory and must not be empty.");
+ checkArgument(name != null && !name.isEmpty(), "Profile name is mandatory and must not be empty.");
checkArgument(organizationKey == null || !organizationKey.isEmpty(), "Organization key may be either null or not empty. Empty organization key is invalid.");
return new CreateRequest(this);
}
public class QualityProfileWsParameters {
public static final String CONTROLLER_QUALITY_PROFILES = "api/qualityprofiles";
+
public interface RestoreActionParameters {
String PARAM_BACKUP = "backup";
public static final String PARAM_LANGUAGE = "language";
public static final String PARAM_NAME = "name";
public static final String PARAM_PARAMS = "params";
- public static final String PARAM_PARENT_NAME = "parentName";
- public static final String PARAM_PARENT_PROFILE = "parentProfile";
- public static final String PARAM_PROFILE = "profile";
- public static final String PARAM_PROFILE_KEY = "profileKey";
- public static final String PARAM_PROFILE_NAME = "profileName";
+ public static final String PARAM_PARENT_KEY = "parentKey";
+ public static final String PARAM_PARENT_QUALITY_PROFILE = "parentQualityProfile";
+ public static final String PARAM_KEY = "key";
+ public static final String PARAM_QUALITY_PROFILE = "qualityProfile";
public static final String PARAM_PROJECT = "project";
public static final String PARAM_PROJECT_KEY = "projectKey";
public static final String PARAM_PROJECT_UUID = "projectUuid";
public static final String PARAM_RULE = "rule";
public static final String PARAM_SEVERITY = "severity";
public static final String PARAM_SINCE = "since";
- public static final String PARAM_TARGET_PROFILE = "targetProfile";
+ public static final String PARAM_TARGET_KEY = "targetKey";
public static final String PARAM_TARGET_SEVERITY = "targetSeverity";
public static final String PARAM_TO = "to";
public static final String PARAM_TO_NAME = "toName";
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_DEFAULTS;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_FROM_KEY;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_NAME;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_ORGANIZATION;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARAMS;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_NAME;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_PROFILE;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE_KEY;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE_NAME;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_QUALITY_PROFILE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_KEY;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT_KEY;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT_UUID;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_RESET;
PostRequest httpRequest = new PostRequest(path(ACTION_ACTIVATE_RULE));
httpRequest.setParam(PARAM_ORGANIZATION, request.getOrganization().orElse(null));
httpRequest.setParam(PARAM_PARAMS, request.getParams().orElse(null));
- httpRequest.setParam(PARAM_PROFILE, request.getProfileKey());
+ httpRequest.setParam(PARAM_KEY, request.getKey());
httpRequest.setParam(PARAM_RESET, request.getReset().orElse(null));
httpRequest.setParam(PARAM_RULE, request.getRuleKey());
httpRequest.setParam(PARAM_SEVERITY, request.getSeverity().map(Enum::name).orElse(null));
public void deactivateRule(String profileKey, String ruleKey) {
PostRequest httpRequest = new PostRequest(path(ACTION_DEACTIVATE_RULE));
- httpRequest.setParam(PARAM_PROFILE, profileKey);
+ httpRequest.setParam(PARAM_KEY, profileKey);
httpRequest.setParam(PARAM_RULE, ruleKey);
call(httpRequest);
}
new GetRequest(path(ACTION_SEARCH))
.setParam(PARAM_DEFAULTS, request.getDefaults())
.setParam(PARAM_LANGUAGE, request.getLanguage())
- .setParam(PARAM_PROFILE_NAME, request.getProfileName())
+ .setParam(PARAM_QUALITY_PROFILE, request.getQualityProfile())
.setParam(PARAM_PROJECT_KEY, request.getProjectKey())
.setParam(PARAM_ORGANIZATION, request.getOrganizationKey()),
SearchWsResponse.parser());
public QualityProfiles.ShowResponse show(ShowRequest request) {
return call(
new GetRequest(path(ACTION_SHOW))
- .setParam(PARAM_PROFILE, request.getProfile())
+ .setParam(PARAM_KEY, request.getKey())
.setParam(PARAM_COMPARE_TO_SONAR_WAY, request.getCompareToSonarWay()),
ShowResponse.parser());
}
call(new PostRequest(path(ACTION_ADD_PROJECT))
.setParam(PARAM_LANGUAGE, request.getLanguage())
.setParam(PARAM_ORGANIZATION, request.getOrganization().orElse(null))
- .setParam(PARAM_PROFILE_NAME, request.getProfileName())
- .setParam(PARAM_PROFILE_KEY, request.getProfileKey())
+ .setParam(PARAM_QUALITY_PROFILE, request.getQualityProfile())
+ .setParam(QualityProfileWsParameters.PARAM_KEY, request.getKey())
.setParam(PARAM_PROJECT_KEY, request.getProjectKey())
.setParam(PARAM_PROJECT_UUID, request.getProjectUuid()));
}
public void removeProject(RemoveProjectRequest request) {
call(new PostRequest(path(ACTION_REMOVE_PROJECT))
.setParam(PARAM_LANGUAGE, request.getLanguage())
- .setParam(PARAM_PROFILE_NAME, request.getProfileName())
- .setParam(PARAM_PROFILE_KEY, request.getProfileKey())
+ .setParam(PARAM_QUALITY_PROFILE, request.getQualityProfile())
+ .setParam(QualityProfileWsParameters.PARAM_KEY, request.getKey())
.setParam(PARAM_PROJECT_KEY, request.getProjectKey())
.setParam(PARAM_PROJECT_UUID, request.getProjectUuid()));
}
PostRequest postRequest = new PostRequest(path(ACTION_CREATE))
.setParam(PARAM_ORGANIZATION, request.getOrganizationKey())
.setParam(PARAM_LANGUAGE, request.getLanguage())
- .setParam(PARAM_PROFILE_NAME, request.getProfileName());
+ .setParam(PARAM_NAME, request.getName());
return call(postRequest, CreateWsResponse.parser());
}
public void changeParent(ChangeParentRequest request) {
call(new PostRequest(path(ACTION_CHANGE_PARENT))
.setParam(PARAM_LANGUAGE, request.getLanguage())
- .setParam(PARAM_PARENT_PROFILE, request.getParentKey())
- .setParam(PARAM_PARENT_NAME, request.getParentName())
- .setParam(PARAM_PROFILE, request.getProfileKey())
- .setParam(PARAM_PROFILE_NAME, request.getProfileName())
+ .setParam(PARAM_PARENT_KEY, request.getParentKey())
+ .setParam(PARAM_PARENT_QUALITY_PROFILE, request.getParentQualityProfile())
+ .setParam(PARAM_KEY, request.getKey())
+ .setParam(PARAM_QUALITY_PROFILE, request.getQualityProfile())
.setParam(PARAM_ORGANIZATION, request.getOrganization()));
}
public void setDefault(SetDefaultRequest request) {
PostRequest postRequest = new PostRequest(path(ACTION_SET_DEFAULT))
- .setParam(PARAM_PROFILE_KEY, request.getProfileKey());
+ .setParam(QualityProfileWsParameters.PARAM_KEY, request.getKey());
call(postRequest);
}
public void delete(String profileKey) {
PostRequest postRequest = new PostRequest(path(ACTION_DELETE))
- .setParam(PARAM_PROFILE_KEY, profileKey);
+ .setParam(QualityProfileWsParameters.PARAM_KEY, profileKey);
call(postRequest);
}
public class RemoveProjectRequest {
private final String language;
- private final String profileName;
- private final String profileKey;
+ private final String qualityProfile;
+ private final String key;
private final String projectKey;
private final String projectUuid;
private RemoveProjectRequest(Builder builder) {
this.language = builder.language;
- this.profileName = builder.profileName;
- this.profileKey = builder.profileKey;
+ this.qualityProfile = builder.qualityProfile;
+ this.key = builder.key;
this.projectKey = builder.projectKey;
this.projectUuid = builder.projectUuid;
}
}
@CheckForNull
- public String getProfileName() {
- return profileName;
+ public String getQualityProfile() {
+ return qualityProfile;
}
@CheckForNull
- public String getProfileKey() {
- return profileKey;
+ public String getKey() {
+ return key;
}
@CheckForNull
public static class Builder {
private String language;
- private String profileName;
- private String profileKey;
+ private String qualityProfile;
+ private String key;
private String projectKey;
private String projectUuid;
return this;
}
- public Builder setProfileName(@Nullable String profileName) {
- this.profileName = profileName;
+ public Builder setQualityProfile(@Nullable String qualityProfile) {
+ this.qualityProfile = qualityProfile;
return this;
}
- public Builder setProfileKey(@Nullable String profileKey) {
- this.profileKey = profileKey;
+ public Builder setKey(@Nullable String key) {
+ this.key = key;
return this;
}
private String organizationKey;
private boolean defaults;
private String language;
- private String profileName;
+ private String qualityProfile;
private String projectKey;
public String getOrganizationKey() {
}
@CheckForNull
- public String getProfileName() {
- return profileName;
+ public String getQualityProfile() {
+ return qualityProfile;
}
- public SearchWsRequest setProfileName(@Nullable String profileName) {
- this.profileName = profileName;
+ public SearchWsRequest setQualityProfile(@Nullable String qualityProfile) {
+ this.qualityProfile = qualityProfile;
return this;
}
package org.sonarqube.ws.client.qualityprofile;
public class SetDefaultRequest {
- private final String profileKey;
+ private final String key;
- public SetDefaultRequest(String profileKey) {
- this.profileKey = profileKey;
+ public SetDefaultRequest(String key) {
+ this.key = key;
}
- public String getProfileKey() {
- return profileKey;
+ public String getKey() {
+ return key;
}
}
import javax.annotation.Nullable;
public class ShowRequest {
- private String profile;
+ private String key;
private Boolean compareToSonarWay;
@CheckForNull
- public String getProfile() {
- return profile;
+ public String getKey() {
+ return key;
}
- public ShowRequest setProfile(@Nullable String profile) {
- this.profile = profile;
+ public ShowRequest setKey(@Nullable String key) {
+ this.key = key;
return this;
}
@Test
public void create_request_from_profile_key_and_project_key() {
- AddProjectRequest result = underTest.setProfileKey("SonarWay").setProjectKey("sample").build();
+ AddProjectRequest result = underTest.setKey("SonarWay").setProjectKey("sample").build();
assertThat(result.getLanguage()).isNull();
- assertThat(result.getProfileKey()).isEqualTo("SonarWay");
- assertThat(result.getProfileName()).isNull();
+ assertThat(result.getKey()).isEqualTo("SonarWay");
+ assertThat(result.getQualityProfile()).isNull();
assertThat(result.getProjectKey()).isEqualTo("sample");
assertThat(result.getProjectUuid()).isNull();
}
@Test
public void create_request_from_profile_name_and_language_and_project_key() {
- AddProjectRequest result = underTest.setLanguage("xoo").setProfileName("Sonar Way").setProjectKey("sample").build();
+ AddProjectRequest result = underTest.setLanguage("xoo").setQualityProfile("Sonar Way").setProjectKey("sample").build();
assertThat(result.getLanguage()).isEqualTo("xoo");
- assertThat(result.getProfileKey()).isNull();
- assertThat(result.getProfileName()).isEqualTo("Sonar Way");
+ assertThat(result.getKey()).isNull();
+ assertThat(result.getQualityProfile()).isEqualTo("Sonar Way");
assertThat(result.getProjectKey()).isEqualTo("sample");
assertThat(result.getProjectUuid()).isNull();
}
@Test
public void create_request_from_profile_key_and_project_uuid() {
- AddProjectRequest result = underTest.setProfileKey("SonarWay").setProjectUuid("123").build();
+ AddProjectRequest result = underTest.setKey("SonarWay").setProjectUuid("123").build();
assertThat(result.getLanguage()).isNull();
- assertThat(result.getProfileKey()).isEqualTo("SonarWay");
- assertThat(result.getProfileName()).isNull();
+ assertThat(result.getKey()).isEqualTo("SonarWay");
+ assertThat(result.getQualityProfile()).isNull();
assertThat(result.getProjectKey()).isNull();
assertThat(result.getProjectUuid()).isEqualTo("123");
}
public void create_set_request() {
CreateRequest result = underTest
.setLanguage("java")
- .setProfileName("Sonar way")
+ .setName("Sonar way")
.build();
assertThat(result.getLanguage()).isEqualTo("java");
- assertThat(result.getProfileName()).isEqualTo("Sonar way");
+ assertThat(result.getName()).isEqualTo("Sonar way");
}
@Test
public void fail_when_no_language() {
expectedException.expect(IllegalArgumentException.class);
- underTest.setProfileName("Sonar way").build();
+ underTest.setName("Sonar way").build();
}
@Test
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_DEFAULTS;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_FROM_KEY;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_NAME;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_ORGANIZATION;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARAMS;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE_KEY;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROFILE_NAME;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT_KEY;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_RULE;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_SEVERITY;
.setDefaults(true)
.setProjectKey("project")
.setLanguage("language")
- .setProfileName("profile"));
+ .setQualityProfile("profile"));
GetRequest getRequest = serviceTester.getGetRequest();
assertThat(serviceTester.getGetParser()).isSameAs(SearchWsResponse.parser());
.hasParam(PARAM_DEFAULTS, true)
.hasParam(PARAM_PROJECT_KEY, "project")
.hasParam(PARAM_LANGUAGE, "language")
- .hasParam(PARAM_PROFILE_NAME, "profile")
+ .hasParam(PARAM_QUALITY_PROFILE, "profile")
.andNoOtherParam();
}
@Test
public void show() {
underTest.show(new ShowRequest()
- .setProfile("profile")
+ .setKey("profile")
.setCompareToSonarWay(true));
GetRequest getRequest = serviceTester.getGetRequest();
assertThat(serviceTester.getGetParser()).isSameAs(ShowResponse.parser());
serviceTester.assertThat(getRequest)
.hasPath("show")
- .hasParam(PARAM_PROFILE, "profile")
+ .hasParam(PARAM_KEY, "profile")
.hasParam(PARAM_COMPARE_TO_SONAR_WAY, true)
.andNoOtherParam();
}
public void add_project() throws Exception {
underTest.addProject(AddProjectRequest.builder()
.setLanguage("xoo")
- .setProfileName("Sonar Way")
+ .setQualityProfile("Sonar Way")
.setProjectKey("sample")
.build());
serviceTester.assertThat(serviceTester.getPostRequest())
.hasPath("add_project")
.hasParam(PARAM_LANGUAGE, "xoo")
- .hasParam(PARAM_PROFILE_NAME, "Sonar Way")
+ .hasParam(PARAM_QUALITY_PROFILE, "Sonar Way")
.hasParam(PARAM_PROJECT_KEY, "sample")
.andNoOtherParam();
}
public void remove_project() throws Exception {
underTest.removeProject(RemoveProjectRequest.builder()
.setLanguage("xoo")
- .setProfileName("Sonar Way")
+ .setQualityProfile("Sonar Way")
.setProjectKey("sample")
.build());
serviceTester.assertThat(serviceTester.getPostRequest())
.hasPath("remove_project")
.hasParam(PARAM_LANGUAGE, "xoo")
- .hasParam(PARAM_PROFILE_NAME, "Sonar Way")
+ .hasParam(PARAM_QUALITY_PROFILE, "Sonar Way")
.hasParam(PARAM_PROJECT_KEY, "sample")
.andNoOtherParam();
}
public void create() throws Exception {
underTest.create(CreateRequest.builder()
.setLanguage("xoo")
- .setProfileName("Sonar Way")
+ .setName("Sonar Way")
.build());
serviceTester.assertThat(serviceTester.getPostRequest())
.hasPath("create")
.hasParam(PARAM_LANGUAGE, "xoo")
- .hasParam(PARAM_PROFILE_NAME, "Sonar Way")
+ .hasParam(PARAM_NAME, "Sonar Way")
.andNoOtherParam();
}
serviceTester.assertThat(serviceTester.getPostRequest())
.hasPath("set_default")
- .hasParam(PARAM_PROFILE_KEY, "sample")
+ .hasParam(QualityProfileWsParameters.PARAM_KEY, "sample")
.andNoOtherParam();
}
serviceTester.assertThat(serviceTester.getPostRequest())
.hasPath("delete")
- .hasParam(PARAM_PROFILE_KEY, "sample")
+ .hasParam(QualityProfileWsParameters.PARAM_KEY, "sample")
.andNoOtherParam();
}
serviceTester.assertThat(request)
.hasPath("deactivate_rule")
- .hasParam(PARAM_PROFILE, "P1")
+ .hasParam(PARAM_KEY, "P1")
.hasParam(PARAM_RULE, "R1")
.andNoOtherParam();
}
public void activate_rule() {
underTest.activateRule(ActivateRuleWsRequest.builder()
.setRuleKey("R1")
- .setProfileKey("P1")
+ .setKey("P1")
.setOrganization("O1")
.setParams("PS1")
.setSeverity(Severity.INFO)
serviceTester.assertThat(request)
.hasPath("activate_rule")
- .hasParam(PARAM_PROFILE, "P1")
+ .hasParam(PARAM_KEY, "P1")
.hasParam(PARAM_RULE, "R1")
.hasParam(PARAM_ORGANIZATION, "O1")
.hasParam(PARAM_PARAMS, "PS1")
@Test
public void create_request_from_profile_key_and_project_key() {
- RemoveProjectRequest result = underTest.setProfileKey("SonarWay").setProjectKey("sample").build();
+ RemoveProjectRequest result = underTest.setKey("SonarWay").setProjectKey("sample").build();
assertThat(result.getLanguage()).isNull();
- assertThat(result.getProfileKey()).isEqualTo("SonarWay");
- assertThat(result.getProfileName()).isNull();
+ assertThat(result.getKey()).isEqualTo("SonarWay");
+ assertThat(result.getQualityProfile()).isNull();
assertThat(result.getProjectKey()).isEqualTo("sample");
assertThat(result.getProjectUuid()).isNull();
}
@Test
public void create_request_from_profile_name_and_language_and_project_key() {
- RemoveProjectRequest result = underTest.setLanguage("xoo").setProfileName("Sonar Way").setProjectKey("sample").build();
+ RemoveProjectRequest result = underTest.setLanguage("xoo").setQualityProfile("Sonar Way").setProjectKey("sample").build();
assertThat(result.getLanguage()).isEqualTo("xoo");
- assertThat(result.getProfileKey()).isNull();
- assertThat(result.getProfileName()).isEqualTo("Sonar Way");
+ assertThat(result.getKey()).isNull();
+ assertThat(result.getQualityProfile()).isEqualTo("Sonar Way");
assertThat(result.getProjectKey()).isEqualTo("sample");
assertThat(result.getProjectUuid()).isNull();
}
@Test
public void create_request_from_profile_key_and_project_uuid() {
- RemoveProjectRequest result = underTest.setProfileKey("SonarWay").setProjectUuid("123").build();
+ RemoveProjectRequest result = underTest.setKey("SonarWay").setProjectUuid("123").build();
assertThat(result.getLanguage()).isNull();
- assertThat(result.getProfileKey()).isEqualTo("SonarWay");
- assertThat(result.getProfileName()).isNull();
+ assertThat(result.getKey()).isEqualTo("SonarWay");
+ assertThat(result.getQualityProfile()).isNull();
assertThat(result.getProjectKey()).isNull();
assertThat(result.getProjectUuid()).isEqualTo("123");
}
CreateRequest.Builder request = CreateRequest.builder()
.setOrganizationKey(organization.getKey())
.setLanguage("xoo")
- .setProfileName("Profile" + id);
+ .setName("Profile" + id);
stream(populators).forEach(p -> p.accept(request));
return service().create(request.build()).getProfile();
}
public QProfileTester activateRule(String profileKey, String ruleKey) {
ActivateRuleWsRequest request = ActivateRuleWsRequest.builder()
- .setProfileKey(profileKey)
+ .setKey(profileKey)
.setRuleKey(ruleKey)
.build();
service().activateRule(request);
public QProfileTester assignQProfileToProject(QualityProfile profile, Project project) {
service().addProject(AddProjectRequest.builder()
.setProjectKey(project.getKey())
- .setProfileKey(profile.getKey())
+ .setKey(profile.getKey())
.build());
return this;
}
private void createProfile(String language, String name) {
tester.wsClient().qualityProfiles().create(CreateRequest.builder()
.setLanguage(language)
- .setProfileName(name)
+ .setName(name)
.build());
}
.setProjectKey(projectKey)
.setOrganization(organization)
.setLanguage("xoo")
- .setProfileName("one-issue-per-file-profile")
+ .setQualityProfile("one-issue-per-file-profile")
.build());
}
WsUsers.CreateWsResponse.User noProfileAdmin = userRule.generate();
// Create a child profile on the built-in profile => The notification should not take into account updates of this profile
- wsClient.qualityProfiles().create(CreateRequest.builder().setLanguage("foo").setProfileName("child").build());
+ wsClient.qualityProfiles().create(CreateRequest.builder().setLanguage("foo").setName("child").build());
wsClient.qualityProfiles().changeParent(ChangeParentRequest.builder().setProfileName("child").setParentName("Basic").setLanguage("foo").build());
// uninstall plugin V1
// create two profiles with same names in two organizations
Organization org1 = tester.organizations().generate();
Organization org2 = tester.organizations().generate();
- QualityProfile profileInOrg1 = tester.qProfiles().createXooProfile(org1, p -> p.setProfileName("foo"));
- QualityProfile profileInOrg2 = tester.qProfiles().createXooProfile(org2, p -> p.setProfileName("foo"));
+ QualityProfile profileInOrg1 = tester.qProfiles().createXooProfile(org1, p -> p.setName("foo"));
+ QualityProfile profileInOrg2 = tester.qProfiles().createXooProfile(org2, p -> p.setName("foo"));
tester.qProfiles()
.assertThatNumberOfActiveRulesEqualsTo(profileInOrg1, 0)
CreateRequest.builder()
.setLanguage(parentProfile.getLanguage())
.setOrganizationKey(org.getKey())
- .setProfileName("inherited_profile")
+ .setName("inherited_profile")
.build())
.getProfile();
CreateRequest.builder()
.setLanguage(parentProfile.getLanguage())
.setOrganizationKey(org.getKey())
- .setProfileName("inherited_profile2")
+ .setName("inherited_profile2")
.build())
.getProfile();
CreateRequest.builder()
.setLanguage(parentProfile.getLanguage())
.setOrganizationKey(org.getKey())
- .setProfileName("inherited_profile")
+ .setName("inherited_profile")
.build())
.getProfile();
.setParam("organization", org.getKey()));
adminSession.qProfiles().service().addProject(AddProjectRequest.builder()
- .setProfileKey(newXooProfile.getKey())
+ .setKey(newXooProfile.getKey())
.setProjectKey(projectKey)
.build());
private void addProfileToProject(String language, String profileName, String projectKey) {
tester.wsClient().qualityProfiles().addProject(AddProjectRequest.builder()
.setLanguage(language)
- .setProfileName(profileName)
+ .setQualityProfile(profileName)
.setProjectKey(projectKey)
.setOrganization(organization.getKey())
.build());
private void createProfile(String language, String name) {
tester.wsClient().qualityProfiles().create(CreateRequest.builder()
.setLanguage(language)
- .setProfileName(name)
+ .setName(name)
.build());
}
private void addProfileToProject(String language, String profileName, String projectKey) {
tester.wsClient().qualityProfiles().addProject(AddProjectRequest.builder()
.setLanguage(language)
- .setProfileName(profileName)
+ .setQualityProfile(profileName)
.setProjectKey(projectKey)
.build());
}
tester.qProfiles().activateRule(xooProfile, RULE_ONE_BUG_PER_LINE);
tester.qProfiles().activateRule(xooProfile, RULE_ONE_ISSUE_PER_LINE);
- ShowResponse result = tester.qProfiles().service().show(new ShowRequest().setProfile(xooProfile.getKey()));
+ ShowResponse result = tester.qProfiles().service().show(new ShowRequest().setKey(xooProfile.getKey()));
assertThat(result.getProfile())
.extracting(QualityProfile::getName, QualityProfile::getLanguage, QualityProfile::getIsBuiltIn, QualityProfile::getIsDefault,
SearchWsResponse.QualityProfile sonarWay = getProfile(org, p -> "Sonar way".equals(p.getName()) && "xoo".equals(p.getLanguage()) && p.getIsBuiltIn());
CompareToSonarWay result = tester.qProfiles().service().show(new ShowRequest()
- .setProfile(xooProfile.getKey())
+ .setKey(xooProfile.getKey())
.setCompareToSonarWay(true)).getCompareToSonarWay();
assertThat(result)
// Bulk activate missing rules from the Sonar way profile
tester.wsClient().wsConnector().call(new PostRequest("api/qualityprofiles/activate_rules")
- .setParam("targetProfile", xooProfile.getKey())
+ .setParam("targetKey", xooProfile.getKey())
.setParam("qprofile", xooProfile.getKey())
.setParam("activation", "false")
.setParam("compareToProfile", sonarWay.getKey())).failIfNotSuccessful();
// Check that the profile has no missing rule from the Sonar way profile
assertThat(tester.qProfiles().service().show(new ShowRequest()
- .setProfile(xooProfile.getKey())
+ .setKey(xooProfile.getKey())
.setCompareToSonarWay(true)).getCompareToSonarWay())
.extracting(CompareToSonarWay::getProfile, CompareToSonarWay::getProfileName, CompareToSonarWay::getMissingRuleCount)
.containsExactly(sonarWay.getKey(), sonarWay.getName(), 0L);
assertThat(response.content()).isEqualTo("xoo -> Basic -> 1");
// Check 'name' parameter is taken into account
- assertThat(tester.wsClient().wsConnector().call(new GetRequest("profiles/export?language=xoo&name=empty&format=XooFakeExporter")).content()).isEqualTo("xoo -> empty -> 0");
+ assertThat(tester.wsClient().wsConnector()
+ .call(new GetRequest("profiles/export?language=xoo&qualityProfile=empty&format=XooFakeExporter")).content())
+ .isEqualTo("xoo -> empty -> 0");
}
private SearchWsResponse.QualityProfile getProfile(Organization organization, Predicate<SearchWsResponse.QualityProfile> filter) {