diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2017-10-12 13:38:17 +0200 |
---|---|---|
committer | Teryk Bellahsene <teryk@users.noreply.github.com> | 2017-10-16 09:27:14 +0200 |
commit | 7ee2cc6372f66afc24e0fd4f780bab8dfcdb4409 (patch) | |
tree | 7f4f0a37f4c4478305f65a559b08ba7907b26b07 | |
parent | 61c8a63a9cd8a04c2bc9fd228d12e7d6544ded13 (diff) | |
download | sonarqube-7ee2cc6372f66afc24e0fd4f780bab8dfcdb4409.tar.gz sonarqube-7ee2cc6372f66afc24e0fd4f780bab8dfcdb4409.zip |
SONAR-7734 Clarify message when one of several parameters is required
24 files changed, 48 insertions, 54 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/ce/ws/ComponentAction.java b/server/sonar-server/src/main/java/org/sonar/server/ce/ws/ComponentAction.java index 0f109ec370a..289b0cd480e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/ce/ws/ComponentAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/ce/ws/ComponentAction.java @@ -40,7 +40,6 @@ import org.sonarqube.ws.WsCe.ProjectResponse; import static org.sonar.db.Pagination.forPage; import static org.sonar.server.component.ComponentFinder.ParamNames.COMPONENT_ID_AND_COMPONENT; import static org.sonar.server.ws.WsUtils.writeProtobuf; -import static org.sonarqube.ws.client.ce.CeWsParameters.DEPRECATED_PARAM_COMPONENT_KEY; import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT; import static org.sonarqube.ws.client.ce.CeWsParameters.PARAM_COMPONENT_ID; @@ -63,8 +62,8 @@ public class ComponentAction implements CeWsAction { WebService.NewAction action = controller.createAction("component") .setDescription("Get the pending tasks, in-progress tasks and the last executed task of a given component (usually a project).<br>" + "Requires the following permission: 'Browse' on the specified component.<br>" + - "Either '%s' or '%s' must be provided, not both.", - PARAM_COMPONENT_ID, DEPRECATED_PARAM_COMPONENT_KEY) + "Either '%s' or '%s' must be provided.", + PARAM_COMPONENT_ID, PARAM_COMPONENT) .setSince("5.2") .setResponseExample(getClass().getResource("component-example.json")) .setChangelog( diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ComponentFinder.java b/server/sonar-server/src/main/java/org/sonar/server/component/ComponentFinder.java index cb191f65287..384aa88a2e8 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ComponentFinder.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ComponentFinder.java @@ -40,7 +40,7 @@ import static org.sonar.server.ws.WsUtils.checkFoundWithOptional; import static org.sonar.server.ws.WsUtils.checkRequest; public class ComponentFinder { - private static final String MSG_COMPONENT_ID_OR_KEY_TEMPLATE = "Either '%s' or '%s' must be provided, not both"; + private static final String MSG_COMPONENT_ID_OR_KEY_TEMPLATE = "Either '%s' or '%s' must be provided"; private static final String MSG_PARAMETER_MUST_NOT_BE_EMPTY = "The '%s' parameter must not be empty"; private static final String LABEL_PROJECT = "Project"; private static final String LABEL_COMPONENT = "Component"; diff --git a/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/CreateAction.java b/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/CreateAction.java index 568b92490af..0453dfcc850 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/CreateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/measure/custom/ws/CreateAction.java @@ -147,7 +147,7 @@ public class CreateAction implements CustomMeasuresWsAction { private MetricDto searchMetric(DbSession dbSession, Request request) { Integer metricId = request.paramAsInt(PARAM_METRIC_ID); String metricKey = request.param(PARAM_METRIC_KEY); - checkArgument(metricId != null ^ metricKey != null, "The metric id or the metric key must be provided, not both."); + checkArgument(metricId != null ^ metricKey != null, "Either the metric id or the metric key must be provided"); if (metricId != null) { return dbClient.metricDao().selectOrFailById(dbSession, metricId); diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/ProjectWsRef.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/ProjectWsRef.java index 02bcb3d3025..5a3cad31e6a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/ProjectWsRef.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/ProjectWsRef.java @@ -51,7 +51,6 @@ public class ProjectWsRef { } public static ProjectWsRef newWsProjectRef(@Nullable String uuid, @Nullable String key) { - checkRequest(uuid == null ^ key == null, MSG_ID_OR_KEY_MUST_BE_PROVIDED); return new ProjectWsRef(uuid, key); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/project/ws/BulkUpdateKeyAction.java b/server/sonar-server/src/main/java/org/sonar/server/project/ws/BulkUpdateKeyAction.java index 106a9db3a6c..017a6ec373b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/project/ws/BulkUpdateKeyAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/project/ws/BulkUpdateKeyAction.java @@ -80,7 +80,7 @@ public class BulkUpdateKeyAction implements ProjectsWsAction { " <li>%s: my_</li>" + " <li>%s: my_new_</li>" + "</ul>" + - "Either '%s' or '%s' must be provided, not both.<br> " + + "Either '%s' or '%s' must be provided.<br> " + "Requires one of the following permissions: " + "<ul>" + "<li>'Administer System'</li>" + diff --git a/server/sonar-server/src/main/java/org/sonar/server/project/ws/UpdateKeyAction.java b/server/sonar-server/src/main/java/org/sonar/server/project/ws/UpdateKeyAction.java index 4364f3c1cac..4f14b4793e8 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/project/ws/UpdateKeyAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/project/ws/UpdateKeyAction.java @@ -57,7 +57,7 @@ public class UpdateKeyAction implements ProjectsWsAction { public WebService.NewAction doDefine(WebService.NewController context) { WebService.NewAction action = context.createAction(ACTION_UPDATE_KEY) .setDescription("Update a project or module key and all its sub-components keys.<br>" + - "Either '%s' or '%s' must be provided, not both.<br> " + + "Either '%s' or '%s' must be provided.<br> " + "Requires one of the following permissions: " + "<ul>" + "<li>'Administer System'</li>" + diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/ProjectStatusAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/ProjectStatusAction.java index 37b98e830a6..e8838d5769a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/ProjectStatusAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/ProjectStatusAction.java @@ -60,8 +60,7 @@ public class ProjectStatusAction implements QualityGatesWsAction { private static final String QG_STATUSES_ONE_LINE = Arrays.stream(ProjectStatusWsResponse.Status.values()) .map(Enum::toString) .collect(Collectors.joining(", ")); - private static final String MSG_ONE_PARAMETER_ONLY = String.format("One (and only one) of the following parameters must be provided '%s', '%s', '%s'", - PARAM_ANALYSIS_ID, PARAM_PROJECT_ID, PARAM_PROJECT_KEY); + private static final String MSG_ONE_PARAMETER_ONLY = String.format("Either '%s', '%s' or '%s' must be provided", PARAM_ANALYSIS_ID, PARAM_PROJECT_ID, PARAM_PROJECT_KEY); private final DbClient dbClient; private final ComponentFinder componentFinder; diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/ShowAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/ShowAction.java index 20b4e52d1bc..185941ae266 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/ShowAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/ShowAction.java @@ -28,9 +28,11 @@ import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.text.JsonWriter; import org.sonar.db.qualitygate.QualityGateConditionDto; import org.sonar.db.qualitygate.QualityGateDto; -import org.sonar.server.exceptions.BadRequestException; import org.sonar.server.qualitygate.QualityGates; -import org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters; + +import static org.sonar.server.ws.WsUtils.checkRequest; +import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_ID; +import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_NAME; public class ShowAction implements QualityGatesWsAction { @@ -48,19 +50,19 @@ public class ShowAction implements QualityGatesWsAction { .setResponseExample(Resources.getResource(this.getClass(), "example-show.json")) .setHandler(this); - action.createParam(QualityGatesWsParameters.PARAM_ID) + action.createParam(PARAM_ID) .setDescription("ID of the quality gate. Either id or name must be set") .setExampleValue("1"); - action.createParam(QualityGatesWsParameters.PARAM_NAME) + action.createParam(PARAM_NAME) .setDescription("Name of the quality gate. Either id or name must be set") .setExampleValue("My Quality Gate"); } @Override public void handle(Request request, Response response) { - Long qGateId = request.paramAsLong(QualityGatesWsParameters.PARAM_ID); - String qGateName = request.param(QualityGatesWsParameters.PARAM_NAME); + Long qGateId = request.paramAsLong(PARAM_ID); + String qGateName = request.param(PARAM_NAME); checkOneOfIdOrNamePresent(qGateId, qGateName); QualityGateDto qGate = qGateId == null ? qualityGates.get(qGateName) : qualityGates.get(qGateId); @@ -68,8 +70,8 @@ public class ShowAction implements QualityGatesWsAction { try (JsonWriter writer = response.newJsonWriter()) { writer.beginObject() - .prop(QualityGatesWsParameters.PARAM_ID, qGate.getId()) - .prop(QualityGatesWsParameters.PARAM_NAME, qGate.getName()); + .prop(PARAM_ID, qGate.getId()) + .prop(PARAM_NAME, qGate.getName()); Collection<QualityGateConditionDto> conditions = qualityGates.listConditions(qGateId); if (!conditions.isEmpty()) { writer.name("conditions").beginArray(); @@ -83,11 +85,6 @@ public class ShowAction implements QualityGatesWsAction { } private static void checkOneOfIdOrNamePresent(@Nullable Long qGateId, @Nullable String qGateName) { - if (qGateId == null && qGateName == null) { - throw BadRequestException.create("Either one of 'id' or 'name' is required."); - } else if (qGateId != null && qGateName != null) { - throw BadRequestException.create("Only one of 'id' or 'name' must be provided."); - } + checkRequest(qGateId == null ^ qGateName == null, "Either '%s' or '%s' must be provided", PARAM_ID, PARAM_NAME); } - } diff --git a/server/sonar-server/src/main/java/org/sonar/server/setting/ws/SetAction.java b/server/sonar-server/src/main/java/org/sonar/server/setting/ws/SetAction.java index f4386026588..b255d1ecafe 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/setting/ws/SetAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/setting/ws/SetAction.java @@ -97,7 +97,7 @@ public class SetAction implements SettingsWsAction { public void define(WebService.NewController context) { WebService.NewAction action = context.createAction(ACTION_SET) .setDescription("Update a setting value.<br>" + - "Either '%s' or '%s' must be provided, not both.<br> " + + "Either '%s' or '%s' must be provided.<br> " + "Requires one of the following permissions: " + "<ul>" + "<li>'Administer System'</li>" + @@ -251,7 +251,7 @@ public class SetAction implements SettingsWsAction { request.getValue() != null ^ !request.getValues().isEmpty() ^ !request.getFieldValues().isEmpty(), - "One and only one of '%s', '%s', '%s' must be provided", PARAM_VALUE, PARAM_VALUES, PARAM_FIELD_VALUES); + "Either '%s', '%s' or '%s' must be provided", PARAM_VALUE, PARAM_VALUES, PARAM_FIELD_VALUES); checkRequest(request.getValues().stream().allMatch(StringUtils::isNotBlank), MSG_NO_EMPTY_VALUE); checkRequest(request.getValue() == null || StringUtils.isNotBlank(request.getValue()), MSG_NO_EMPTY_VALUE); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/test/ws/ListAction.java b/server/sonar-server/src/main/java/org/sonar/server/test/ws/ListAction.java index 41d40efd5dc..57afa5ad572 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/test/ws/ListAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/test/ws/ListAction.java @@ -83,7 +83,7 @@ public class ListAction implements TestsWsAction { .createAction("list") .setDescription(String.format( "Get the list of tests either in a test file or that test a given line of source code.<br /> " + - "Require Browse permission on the file's project.<br /> " + + "Requires 'Browse' permission on the file's project.<br /> " + "One (and only one) of the following combination of parameters must be provided: " + "<ul>" + "<li>%s - get a specific test</li>" + diff --git a/server/sonar-server/src/main/java/org/sonar/server/webhook/ws/WebhookDeliveriesAction.java b/server/sonar-server/src/main/java/org/sonar/server/webhook/ws/WebhookDeliveriesAction.java index 08562c8f600..372f1011c7a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/webhook/ws/WebhookDeliveriesAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/webhook/ws/WebhookDeliveriesAction.java @@ -43,8 +43,8 @@ import static org.sonar.server.ws.WsUtils.writeProtobuf; public class WebhookDeliveriesAction implements WebhooksWsAction { - private static final String COMPONENT_PARAM = "componentKey"; - private static final String TASK_PARAM = "ceTaskId"; + private static final String PARAM_COMPONENT = "componentKey"; + private static final String PARAM_TASK = "ceTaskId"; private final DbClient dbClient; private final UserSession userSession; @@ -66,11 +66,11 @@ public class WebhookDeliveriesAction implements WebhooksWsAction { .setResponseExample(Resources.getResource(this.getClass(), "example-deliveries.json")) .setHandler(this); - action.createParam(COMPONENT_PARAM) + action.createParam(PARAM_COMPONENT) .setDescription("Key of the project") .setExampleValue("my-project"); - action.createParam(TASK_PARAM) + action.createParam(PARAM_TASK) .setDescription("Id of the Compute Engine task") .setExampleValue(Uuids.UUID_EXAMPLE_01); } @@ -80,9 +80,9 @@ public class WebhookDeliveriesAction implements WebhooksWsAction { // fail-fast if not logged in userSession.checkLoggedIn(); - String ceTaskId = request.param(TASK_PARAM); - String componentKey = request.param(COMPONENT_PARAM); - checkArgument(ceTaskId != null ^ componentKey != null, "Either parameter '%s' or '%s' must be defined", TASK_PARAM, COMPONENT_PARAM); + String ceTaskId = request.param(PARAM_TASK); + String componentKey = request.param(PARAM_COMPONENT); + checkArgument(ceTaskId != null ^ componentKey != null, "Either '%s' or '%s' must be provided", PARAM_TASK, PARAM_COMPONENT); Data data = loadFromDatabase(ceTaskId, componentKey); data.ensureAdminPermission(userSession); diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ComponentFinderTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ComponentFinderTest.java index ea314a825d8..0082df50de5 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/component/ComponentFinderTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/component/ComponentFinderTest.java @@ -49,7 +49,7 @@ public class ComponentFinderTest { @Test public void fail_when_the_uuid_and_key_are_null() { expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Either 'id' or 'key' must be provided, not both"); + expectedException.expectMessage("Either 'id' or 'key' must be provided"); underTest.getByUuidOrKey(dbSession, null, null, ID_AND_KEY); } @@ -57,7 +57,7 @@ public class ComponentFinderTest { @Test public void fail_when_the_uuid_and_key_are_provided() { expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Either 'id' or 'key' must be provided, not both"); + expectedException.expectMessage("Either 'id' or 'key' must be provided"); underTest.getByUuidOrKey(dbSession, "project-uuid", "project-key", ID_AND_KEY); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ws/AppActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ws/AppActionTest.java index 8eaf43d42c3..7eb2c50a074 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/component/ws/AppActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/component/ws/AppActionTest.java @@ -291,7 +291,7 @@ public class AppActionTest { @Test public void fail_if_no_parameter_provided() { expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Either 'componentId' or 'component' must be provided, not both"); + expectedException.expectMessage("Either 'componentId' or 'component' must be provided"); ws.newRequest().execute(); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ws/TreeActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ws/TreeActionTest.java index 2e74d63376a..dc8ffbf335d 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/component/ws/TreeActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/component/ws/TreeActionTest.java @@ -460,7 +460,7 @@ public class TreeActionTest { @Test public void fail_when_no_base_component_parameter() { expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Either 'componentId' or 'component' must be provided, not both"); + expectedException.expectMessage("Either 'componentId' or 'component' must be provided"); ws.newRequest().execute(); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/ShowActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/ShowActionTest.java index 79dac8f08d1..c00e6f7f18b 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/ShowActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/duplication/ws/ShowActionTest.java @@ -181,7 +181,7 @@ public class ShowActionTest { @Test public void fail_if_no_parameter_provided() { expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Either 'uuid' or 'key' must be provided, not both"); + expectedException.expectMessage("Either 'uuid' or 'key' must be provided"); newBaseRequest().execute(); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/CreateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/CreateActionTest.java index 9ac22c0300f..a88e7b02db7 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/CreateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/CreateActionTest.java @@ -315,7 +315,7 @@ public class CreateActionTest { @Test public void fail_when_project_id_nor_project_key_provided() throws Exception { expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Either 'projectId' or 'projectKey' must be provided, not both"); + expectedException.expectMessage("Either 'projectId' or 'projectKey' must be provided"); MetricDto metric = insertMetric(STRING); newRequest() @@ -327,7 +327,7 @@ public class CreateActionTest { @Test public void fail_when_project_id_and_project_key_are_provided() throws Exception { expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Either 'projectId' or 'projectKey' must be provided, not both"); + expectedException.expectMessage("Either 'projectId' or 'projectKey' must be provided"); MetricDto metric = insertMetric(STRING); newRequest() @@ -367,7 +367,7 @@ public class CreateActionTest { @Test public void fail_when_metric_id_nor_metric_key_is_provided() throws Exception { expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("The metric id or the metric key must be provided, not both."); + expectedException.expectMessage("Either the metric id or the metric key must be provided"); insertMetric(STRING); newRequest() @@ -379,7 +379,7 @@ public class CreateActionTest { @Test public void fail_when_metric_id_and_metric_key_are_provided() throws Exception { expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("The metric id or the metric key must be provided, not both."); + expectedException.expectMessage("Either the metric id or the metric key must be provided"); MetricDto metric = insertMetric(STRING); newRequest() diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/SearchActionTest.java index ff61bf57a16..5188cbffe8f 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/SearchActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/measure/custom/ws/SearchActionTest.java @@ -220,7 +220,7 @@ public class SearchActionTest { @Test public void fail_when_project_id_and_project_key_provided() throws Exception { expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Either 'projectId' or 'projectKey' must be provided, not both"); + expectedException.expectMessage("Either 'projectId' or 'projectKey' must be provided"); newRequest() .setParam(SearchAction.PARAM_PROJECT_ID, DEFAULT_PROJECT_UUID) @@ -231,7 +231,7 @@ public class SearchActionTest { @Test public void fail_when_project_id_nor_project_key_provided() throws Exception { expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Either 'projectId' or 'projectKey' must be provided, not both"); + expectedException.expectMessage("Either 'projectId' or 'projectKey' must be provided"); newRequest().execute(); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java index 8e96d3fd2d5..05b5ad04eba 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java @@ -230,7 +230,7 @@ public class ProjectStatusActionTest { logInAsSystemAdministrator(); expectedException.expect(BadRequestException.class); - expectedException.expectMessage("One (and only one) of the following parameters must be provided 'analysisId', 'projectId', 'projectKey'"); + expectedException.expectMessage("Either 'analysisId', 'projectId' or 'projectKey' must be provided"); ws.newRequest() .setParam(PARAM_ANALYSIS_ID, "analysis-id") @@ -243,7 +243,7 @@ public class ProjectStatusActionTest { logInAsSystemAdministrator(); expectedException.expect(BadRequestException.class); - expectedException.expectMessage("One (and only one) of the following parameters must be provided 'analysisId', 'projectId', 'projectKey'"); + expectedException.expectMessage("Either 'analysisId', 'projectId' or 'projectKey' must be provided"); ws.newRequest().execute().getInput(); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java index 04774a842f2..55f46efe64e 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/ExportActionTest.java @@ -130,7 +130,7 @@ public class ExportActionTest { QProfileDto profile = createProfile(db.getDefaultOrganization(), false); expectedException.expect(BadRequestException.class); - expectedException.expectMessage("Either 'key' or 'language' must be provided."); + expectedException.expectMessage("Either 'key' or 'language' must be provided"); WsActionTester ws = newWsActionTester(newExporter("polop"), newExporter("palap")); ws.newRequest() diff --git a/server/sonar-server/src/test/java/org/sonar/server/setting/ws/SetActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/setting/ws/SetActionTest.java index 1b18dce0a2b..38922d51ff7 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/setting/ws/SetActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/setting/ws/SetActionTest.java @@ -441,7 +441,7 @@ public class SetActionTest { @Test public void fail_when_no_value() { expectedException.expect(BadRequestException.class); - expectedException.expectMessage("One and only one of 'value', 'values', 'fieldValues' must be provided"); + expectedException.expectMessage("Either 'value', 'values' or 'fieldValues' must be provided"); callForGlobalSetting("my.key", null); } @@ -682,7 +682,7 @@ public class SetActionTest { @Test public void fail_when_single_and_multi_value_provided() { expectedException.expect(BadRequestException.class); - expectedException.expectMessage("One and only one of 'value', 'values', 'fieldValues' must be provided"); + expectedException.expectMessage("Either 'value', 'values' or 'fieldValues' must be provided"); call("my.key", "My Value", newArrayList("Another Value"), null, null); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/source/ws/LinesActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/source/ws/LinesActionTest.java index 9cebc9d452a..f79b6cc1095 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/source/ws/LinesActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/source/ws/LinesActionTest.java @@ -144,7 +144,7 @@ public class LinesActionTest { @Test public void fail_when_no_uuid_or_key_param() throws Exception { expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Either 'uuid' or 'key' must be provided, not both"); + expectedException.expectMessage("Either 'uuid' or 'key' must be provided"); WsTester.TestRequest request = wsTester.newGetRequest("api/sources", "lines"); request.execute(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/test/ws/ListActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/test/ws/ListActionTest.java index 48ff6b83a57..53b07b273f5 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/test/ws/ListActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/test/ws/ListActionTest.java @@ -100,7 +100,7 @@ public class ListActionTest { assertThat(action.responseExampleAsString()).isNotEmpty(); assertThat(action.params()).hasSize(9); assertThat(action.description()).isEqualTo("Get the list of tests either in a test file or that test a given line of source code.<br /> " + - "Require Browse permission on the file's project.<br /> " + + "Requires 'Browse' permission on the file's project.<br /> " + "One (and only one) of the following combination of parameters must be provided: " + "<ul>" + "<li>testId - get a specific test</li>" + diff --git a/server/sonar-server/src/test/java/org/sonar/server/webhook/ws/WebhookDeliveriesActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/webhook/ws/WebhookDeliveriesActionTest.java index 750a7ca9665..d213a842369 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/webhook/ws/WebhookDeliveriesActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/webhook/ws/WebhookDeliveriesActionTest.java @@ -182,7 +182,7 @@ public class WebhookDeliveriesActionTest { userSession.logIn(); expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Either parameter 'ceTaskId' or 'componentKey' must be defined"); + expectedException.expectMessage("Either 'ceTaskId' or 'componentKey' must be provided"); ws.newRequest() .setParam("componentKey", project.getDbKey()) diff --git a/tests/src/test/java/org/sonarqube/tests/duplication/DuplicationsTest.java b/tests/src/test/java/org/sonarqube/tests/duplication/DuplicationsTest.java index 710fd8de0d5..a8124972636 100644 --- a/tests/src/test/java/org/sonarqube/tests/duplication/DuplicationsTest.java +++ b/tests/src/test/java/org/sonarqube/tests/duplication/DuplicationsTest.java @@ -183,7 +183,7 @@ public class DuplicationsTest { WsResponse result = adminWsClient.wsConnector().call(new GetRequest("api/duplications/show")); assertThat(result.code()).isEqualTo(HTTP_BAD_REQUEST); - assertThat(result.content()).contains("Either 'uuid' or 'key' must be provided, not both"); + assertThat(result.content()).contains("Either 'uuid' or 'key' must be provided"); } } |