aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/batch/ProjectActionTest.java5
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/ce/ws/ActivityActionTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/ce/ws/ActivityStatusActionTest.java7
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/ce/ws/ComponentActionTest.java28
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/ce/ws/SubmitActionTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/ce/ws/TaskActionTest.java57
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchActionTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java5
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/component/ws/ShowActionTest.java8
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/component/ws/TreeActionTest.java41
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/favorite/ws/SearchActionTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/ws/BulkChangeActionTest.java5
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/ws/ChangelogActionTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsMediumTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/license/ws/ListActionTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java25
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java123
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/measure/ws/SearchActionTest.java8
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/measure/ws/SearchHistoryActionTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/notification/ws/ListActionTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/organization/ws/AddMemberActionTest.java5
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/organization/ws/CreateActionTest.java5
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/organization/ws/SearchActionTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/organization/ws/SearchMembersActionTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/organization/ws/UpdateActionTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchGlobalPermissionsActionTest.java9
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest.java5
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SearchTemplatesActionTest.java5
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/TemplateGroupsActionTest.java28
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/TemplateUsersActionTest.java24
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkUpdateKeyActionTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/project/ws/CreateActionTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/project/ws/SearchActionTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/project/ws/SearchMyProjectsActionTest.java16
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/CreateEventActionTest.java5
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/SearchActionTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/UpdateEventActionTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/projectlink/ws/CreateActionTest.java87
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/projectlink/ws/SearchActionTest.java8
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/projecttag/ws/SearchActionTest.java5
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/AppActionTest.java3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/CreateActionTest.java5
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/CreateConditionActionTest.java3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/GetByProjectActionTest.java5
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java8
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/UpdateConditionActionTest.java3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java15
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/root/ws/SearchActionTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/ws/ListActionTest.java9
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionTest.java29
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/ws/ShowActionTest.java12
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/rule/ws/UpdateActionTest.java35
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/serverid/ws/GenerateActionTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/serverid/ws/ShowActionTest.java5
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/setting/ws/CheckSecretKeyActionTest.java5
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/setting/ws/EncryptActionTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/setting/ws/GenerateSecretKeyActionTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/setting/ws/ListDefinitionsActionTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/setting/ws/ValuesActionTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/test/ws/ListActionTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/user/ws/CreateActionTest.java6
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/user/ws/GroupsActionTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/usergroups/ws/SearchActionTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/usertoken/ws/GenerateActionTest.java5
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/usertoken/ws/SearchActionTest.java5
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/webhook/ws/WebhookDeliveriesActionTest.java13
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/webhook/ws/WebhookDeliveryActionTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/ws/TestRequest.java5
69 files changed, 294 insertions, 539 deletions
diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectActionTest.java
index ab0fe658dbf..685ecc062d0 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/batch/ProjectActionTest.java
@@ -26,7 +26,6 @@ import org.sonar.scanner.protocol.input.FileData;
import org.sonar.scanner.protocol.input.ProjectRepositories;
import org.sonar.server.ws.TestResponse;
import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.WsBatch.WsProjectResponse;
import static org.assertj.core.api.Assertions.assertThat;
@@ -78,11 +77,9 @@ public class ProjectActionTest {
when(projectDataLoader.load(any(ProjectDataQuery.class))).thenReturn(projectRepositories);
WsProjectResponse wsProjectResponse = ws.newRequest()
- .setMediaType(MediaTypes.PROTOBUF)
.setParam("key", projectKey)
.setParam("profile", "Default")
- .execute()
- .getInputObject(WsProjectResponse.class);
+ .executeProtobuf(WsProjectResponse.class);
assertThat(wsProjectResponse.getFileDataByModuleAndPath()).isEmpty();
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/ce/ws/ActivityActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/ce/ws/ActivityActionTest.java
index 6dedecfa79d..7a738a8ac51 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/ce/ws/ActivityActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/ce/ws/ActivityActionTest.java
@@ -404,8 +404,6 @@ public class ActivityActionTest {
}
private static ActivityResponse call(TestRequest request) {
- return request
- .setMediaType(MediaTypes.PROTOBUF)
- .execute().getInputObject(ActivityResponse.class);
+ return request.executeProtobuf(ActivityResponse.class);
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/ce/ws/ActivityStatusActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/ce/ws/ActivityStatusActionTest.java
index 9258fb366cd..1fab7fc1069 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/ce/ws/ActivityStatusActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/ce/ws/ActivityStatusActionTest.java
@@ -39,7 +39,6 @@ import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.WsCe;
import static org.assertj.core.api.Assertions.assertThat;
@@ -185,15 +184,13 @@ public class ActivityStatusActionTest {
}
private WsCe.ActivityStatusWsResponse callByComponentUuidOrComponentKey(@Nullable String componentUuid, @Nullable String componentKey) {
- TestRequest request = ws.newRequest()
- .setMediaType(MediaTypes.PROTOBUF);
+ TestRequest request = ws.newRequest();
if (componentUuid != null) {
request.setParam(PARAM_COMPONENT_ID, componentUuid);
}
if (componentKey != null) {
request.setParam(PARAM_COMPONENT_KEY, componentKey);
}
-
- return request.execute().getInputObject(WsCe.ActivityStatusWsResponse.class);
+ return request.executeProtobuf(WsCe.ActivityStatusWsResponse.class);
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/ce/ws/ComponentActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/ce/ws/ComponentActionTest.java
index 08bf98a3b72..03c3dc02dc3 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/ce/ws/ComponentActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/ce/ws/ComponentActionTest.java
@@ -34,7 +34,6 @@ import org.sonar.server.component.ComponentFinder;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.tester.UserSessionRule;
-import org.sonar.server.ws.TestResponse;
import org.sonar.server.ws.WsActionTester;
import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.WsCe;
@@ -64,12 +63,10 @@ public class ComponentActionTest {
dbTester.components().insertComponent(newProjectDto(dbTester.organizations().insert(), "PROJECT_1"));
userSession.addComponentUuidPermission(UserRole.USER, "PROJECT_1", "PROJECT_1");
- TestResponse wsResponse = ws.newRequest()
+ WsCe.ProjectResponse response = ws.newRequest()
.setParam("componentId", "PROJECT_1")
- .setMediaType(MediaTypes.PROTOBUF)
- .execute();
+ .executeProtobuf(WsCe.ProjectResponse.class);
- WsCe.ProjectResponse response = wsResponse.getInputObject(WsCe.ProjectResponse.class);
assertThat(response.getQueueCount()).isEqualTo(0);
assertThat(response.hasCurrent()).isFalse();
}
@@ -85,12 +82,9 @@ public class ComponentActionTest {
insertQueue("T4", "PROJECT_1", CeQueueDto.Status.IN_PROGRESS);
insertQueue("T5", "PROJECT_1", CeQueueDto.Status.PENDING);
- TestResponse wsResponse = ws.newRequest()
+ WsCe.ProjectResponse response = ws.newRequest()
.setParam("componentId", "PROJECT_1")
- .setMediaType(MediaTypes.PROTOBUF)
- .execute();
-
- WsCe.ProjectResponse response = wsResponse.getInputObject(WsCe.ProjectResponse.class);
+ .executeProtobuf(WsCe.ProjectResponse.class);
assertThat(response.getQueueCount()).isEqualTo(2);
assertThat(response.getQueue(0).getId()).isEqualTo("T4");
assertThat(response.getQueue(1).getId()).isEqualTo("T5");
@@ -109,12 +103,9 @@ public class ComponentActionTest {
logInWithBrowsePermission(project);
insertActivity("T1", project.uuid(), CeActivityDto.Status.SUCCESS);
- TestResponse wsResponse = ws.newRequest()
+ WsCe.ProjectResponse response = ws.newRequest()
.setParam(PARAM_COMPONENT_KEY, project.key())
- .setMediaType(MediaTypes.PROTOBUF)
- .execute();
-
- WsCe.ProjectResponse response = wsResponse.getInputObject(WsCe.ProjectResponse.class);
+ .executeProtobuf(WsCe.ProjectResponse.class);
assertThat(response.hasCurrent()).isTrue();
}
@@ -128,12 +119,9 @@ public class ComponentActionTest {
insertActivity("T4", "PROJECT_1", CeActivityDto.Status.CANCELED);
insertActivity("T5", "PROJECT_1", CeActivityDto.Status.CANCELED);
- TestResponse wsResponse = ws.newRequest()
+ WsCe.ProjectResponse response = ws.newRequest()
.setParam("componentId", "PROJECT_1")
- .setMediaType(MediaTypes.PROTOBUF)
- .execute();
-
- WsCe.ProjectResponse response = wsResponse.getInputObject(WsCe.ProjectResponse.class);
+ .executeProtobuf(WsCe.ProjectResponse.class);
assertThat(response.getQueueCount()).isEqualTo(0);
// T3 is the latest task executed on PROJECT_1 ignoring Canceled ones
assertThat(response.hasCurrent()).isTrue();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/ce/ws/SubmitActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/ce/ws/SubmitActionTest.java
index 77af58f44e5..e719bf738ea 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/ce/ws/SubmitActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/ce/ws/SubmitActionTest.java
@@ -60,17 +60,15 @@ public class SubmitActionTest {
when(reportSubmitter.submit(eq(organizationKey), eq("my_project"), Matchers.isNull(String.class), eq("My Project"), any(InputStream.class)))
.thenReturn(A_CE_TASK);
- TestResponse wsResponse = tester.newRequest()
+ WsCe.SubmitResponse submitResponse = tester.newRequest()
.setParam("projectKey", "my_project")
.setParam("projectName", "My Project")
.setParam("report", "{binary}")
- .setMediaType(MediaTypes.PROTOBUF)
.setMethod("POST")
- .execute();
+ .executeProtobuf(WsCe.SubmitResponse.class);
verify(reportSubmitter).submit(eq(organizationKey), eq("my_project"), Matchers.isNull(String.class), eq("My Project"), any(InputStream.class));
- WsCe.SubmitResponse submitResponse = wsResponse.getInputObject(WsCe.SubmitResponse.class);
assertThat(submitResponse.getTaskId()).isEqualTo("TASK_1");
assertThat(submitResponse.getProjectId()).isEqualTo("PROJECT_1");
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/ce/ws/TaskActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/ce/ws/TaskActionTest.java
index ea32ae59691..99aa93b072a 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/ce/ws/TaskActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/ce/ws/TaskActionTest.java
@@ -36,14 +36,12 @@ import org.sonar.db.organization.OrganizationDto;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.tester.UserSessionRule;
-import org.sonar.server.ws.TestResponse;
import org.sonar.server.ws.WsActionTester;
import org.sonarqube.ws.WsCe;
import static java.util.Collections.singleton;
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.db.permission.OrganizationPermission.SCAN;
-import static org.sonarqube.ws.MediaTypes.PROTOBUF;
public class TaskActionTest {
@@ -82,12 +80,9 @@ public class TaskActionTest {
queueDto.setSubmitterLogin("john");
persist(queueDto);
- TestResponse wsResponse = ws.newRequest()
- .setMediaType(PROTOBUF)
+ WsCe.TaskResponse taskResponse = ws.newRequest()
.setParam("id", SOME_TASK_UUID)
- .execute();
-
- WsCe.TaskResponse taskResponse = wsResponse.getInputObject(WsCe.TaskResponse.class);
+ .executeProtobuf(WsCe.TaskResponse.class);
assertThat(taskResponse.getTask().getOrganization()).isEqualTo(organizationDto.getKey());
assertThat(taskResponse.getTask().getId()).isEqualTo(SOME_TASK_UUID);
assertThat(taskResponse.getTask().getStatus()).isEqualTo(WsCe.TaskStatus.PENDING);
@@ -106,12 +101,9 @@ public class TaskActionTest {
CeActivityDto activityDto = createActivityDto(SOME_TASK_UUID);
persist(activityDto);
- TestResponse wsResponse = ws.newRequest()
- .setMediaType(PROTOBUF)
+ WsCe.TaskResponse taskResponse = ws.newRequest()
.setParam("id", SOME_TASK_UUID)
- .execute();
-
- WsCe.TaskResponse taskResponse = wsResponse.getInputObject(WsCe.TaskResponse.class);
+ .executeProtobuf(WsCe.TaskResponse.class);
WsCe.Task task = taskResponse.getTask();
assertThat(task.getOrganization()).isEqualTo(organizationDto.getKey());
assertThat(task.getId()).isEqualTo(SOME_TASK_UUID);
@@ -133,13 +125,10 @@ public class TaskActionTest {
.setErrorStacktrace("error stack");
persist(activityDto);
- TestResponse wsResponse = ws.newRequest()
- .setMediaType(PROTOBUF)
+ WsCe.TaskResponse taskResponse = ws.newRequest()
.setParam("id", SOME_TASK_UUID)
.setParam("additionalFields", "stacktrace")
- .execute();
-
- WsCe.TaskResponse taskResponse = wsResponse.getInputObject(WsCe.TaskResponse.class);
+ .executeProtobuf(WsCe.TaskResponse.class);
WsCe.Task task = taskResponse.getTask();
assertThat(task.getId()).isEqualTo(SOME_TASK_UUID);
assertThat(task.getErrorMessage()).isEqualTo(activityDto.getErrorMessage());
@@ -156,12 +145,9 @@ public class TaskActionTest {
.setErrorStacktrace("error stack");
persist(activityDto);
- TestResponse wsResponse = ws.newRequest()
- .setMediaType(PROTOBUF)
+ WsCe.TaskResponse taskResponse = ws.newRequest()
.setParam("id", SOME_TASK_UUID)
- .execute();
-
- WsCe.TaskResponse taskResponse = wsResponse.getInputObject(WsCe.TaskResponse.class);
+ .executeProtobuf(WsCe.TaskResponse.class);
WsCe.Task task = taskResponse.getTask();
assertThat(task.getId()).isEqualTo(SOME_TASK_UUID);
assertThat(task.getErrorMessage()).isEqualTo(activityDto.getErrorMessage());
@@ -176,13 +162,10 @@ public class TaskActionTest {
persist(createActivityDto(SOME_TASK_UUID));
persistScannerContext(SOME_TASK_UUID, scannerContext);
- TestResponse wsResponse = ws.newRequest()
- .setMediaType(PROTOBUF)
+ WsCe.TaskResponse taskResponse = ws.newRequest()
.setParam("id", SOME_TASK_UUID)
.setParam("additionalFields", "scannerContext")
- .execute();
-
- WsCe.TaskResponse taskResponse = wsResponse.getInputObject(WsCe.TaskResponse.class);
+ .executeProtobuf(WsCe.TaskResponse.class);
WsCe.Task task = taskResponse.getTask();
assertThat(task.getId()).isEqualTo(SOME_TASK_UUID);
assertThat(task.getScannerContext()).isEqualTo(scannerContext);
@@ -196,13 +179,10 @@ public class TaskActionTest {
persist(createActivityDto(SOME_TASK_UUID));
persistScannerContext(SOME_TASK_UUID, scannerContext);
- TestResponse wsResponse = ws.newRequest()
- .setMediaType(PROTOBUF)
+ WsCe.TaskResponse taskResponse = ws.newRequest()
.setParam("id", SOME_TASK_UUID)
.setParam("additionalFields", "stacktrace")
- .execute();
-
- WsCe.TaskResponse taskResponse = wsResponse.getInputObject(WsCe.TaskResponse.class);
+ .executeProtobuf(WsCe.TaskResponse.class);
WsCe.Task task = taskResponse.getTask();
assertThat(task.getId()).isEqualTo(SOME_TASK_UUID);
assertThat(task.hasScannerContext()).isFalse();
@@ -216,12 +196,9 @@ public class TaskActionTest {
.setErrorMessage("error msg");
persist(activityDto);
- TestResponse wsResponse = ws.newRequest()
- .setMediaType(PROTOBUF)
+ WsCe.TaskResponse taskResponse = ws.newRequest()
.setParam("id", SOME_TASK_UUID)
- .execute();
-
- WsCe.TaskResponse taskResponse = wsResponse.getInputObject(WsCe.TaskResponse.class);
+ .executeProtobuf(WsCe.TaskResponse.class);
WsCe.Task task = taskResponse.getTask();
assertThat(task.getId()).isEqualTo(SOME_TASK_UUID);
assertThat(task.getErrorMessage()).isEqualTo(activityDto.getErrorMessage());
@@ -392,11 +369,9 @@ public class TaskActionTest {
}
private void call(String taskUuid) {
- TestResponse response = ws.newRequest()
- .setMediaType(PROTOBUF)
+ WsCe.TaskResponse taskResponse = ws.newRequest()
.setParam("id", taskUuid)
- .execute();
- WsCe.TaskResponse taskResponse = response.getInputObject(WsCe.TaskResponse.class);
+ .executeProtobuf(WsCe.TaskResponse.class);
WsCe.Task task = taskResponse.getTask();
assertThat(task.getId()).isEqualTo(taskUuid);
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchActionTest.java
index b2fc71af4f3..8d04e0fe4c7 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchActionTest.java
@@ -65,7 +65,6 @@ import static org.sonar.db.component.ComponentTesting.newModuleDto;
import static org.sonar.db.component.ComponentTesting.newProjectDto;
import static org.sonar.db.component.ComponentTesting.newView;
import static org.sonar.test.JsonAssert.assertJson;
-import static org.sonarqube.ws.MediaTypes.PROTOBUF;
import static org.sonarqube.ws.WsComponents.Component;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_LANGUAGE;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_ORGANIZATION;
@@ -250,15 +249,14 @@ public class SearchActionTest {
}
private SearchWsResponse call(SearchWsRequest wsRequest) {
- TestRequest request = ws.newRequest()
- .setMediaType(PROTOBUF);
+ TestRequest request = ws.newRequest();
setNullable(wsRequest.getOrganization(), p -> request.setParam(PARAM_ORGANIZATION, p));
setNullable(wsRequest.getLanguage(), p -> request.setParam(PARAM_LANGUAGE, p));
setNullable(wsRequest.getQualifiers(), p -> request.setParam(PARAM_QUALIFIERS, Joiner.on(",").join(p)));
setNullable(wsRequest.getQuery(), p -> request.setParam(TEXT_QUERY, p));
setNullable(wsRequest.getPage(), page -> request.setParam(PAGE, String.valueOf(page)));
setNullable(wsRequest.getPageSize(), pageSize -> request.setParam(PAGE_SIZE, String.valueOf(pageSize)));
- return request.execute().getInputObject(SearchWsResponse.class);
+ return request.executeProtobuf(SearchWsResponse.class);
}
private static Language[] javaLanguage() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java
index 75cca7a02cb..447a6bc61a6 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/component/ws/SearchProjectsActionTest.java
@@ -639,8 +639,7 @@ public class SearchProjectsActionTest {
private SearchProjectsWsResponse call(SearchProjectsRequest.Builder requestBuilder) {
SearchProjectsRequest wsRequest = requestBuilder.build();
- TestRequest httpRequest = ws.newRequest()
- .setMediaType(MediaTypes.PROTOBUF);
+ TestRequest httpRequest = ws.newRequest();
ofNullable(wsRequest.getOrganization()).ifPresent(organization -> httpRequest.setParam(PARAM_ORGANIZATION, organization));
ofNullable(wsRequest.getFilter()).ifPresent(filter -> httpRequest.setParam(PARAM_FILTER, filter));
ofNullable(wsRequest.getSort()).ifPresent(sort -> httpRequest.setParam(SORT, sort));
@@ -649,7 +648,7 @@ public class SearchProjectsActionTest {
httpRequest.setParam(PAGE_SIZE, String.valueOf(wsRequest.getPageSize()));
httpRequest.setParam(FACETS, Joiner.on(",").join(wsRequest.getFacets()));
httpRequest.setParam(FIELDS, Joiner.on(",").join(wsRequest.getAdditionalFields()));
- return httpRequest.execute().getInputObject(SearchProjectsWsResponse.class);
+ return httpRequest.executeProtobuf(SearchProjectsWsResponse.class);
}
private ComponentDto insertProjectInDbAndEs(ComponentDto project) {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/component/ws/ShowActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/component/ws/ShowActionTest.java
index 3804ef8cb2e..c431c791837 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/component/ws/ShowActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/component/ws/ShowActionTest.java
@@ -38,7 +38,6 @@ import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.WsComponents;
import org.sonarqube.ws.WsComponents.ShowWsResponse;
@@ -187,17 +186,14 @@ public class ShowActionTest {
}
private ShowWsResponse newRequest(@Nullable String uuid, @Nullable String key) {
- TestRequest request = ws.newRequest()
- .setMediaType(MediaTypes.PROTOBUF);
-
+ TestRequest request = ws.newRequest();
if (uuid != null) {
request.setParam(PARAM_COMPONENT_ID, uuid);
}
if (key != null) {
request.setParam(PARAM_COMPONENT, key);
}
-
- return request.execute().getInputObject(ShowWsResponse.class);
+ return request.executeProtobuf(ShowWsResponse.class);
}
private void insertJsonExampleComponentsAndSnapshots() {
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 1dda1358272..1518d9ed220 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
@@ -51,10 +51,8 @@ import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.tester.UserSessionRule;
-import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
import org.sonar.test.JsonAssert;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.WsComponents.TreeWsResponse;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -122,14 +120,14 @@ public class TreeActionTest {
db.commit();
logInWithBrowsePermission(project);
- TreeWsResponse response = call(ws.newRequest()
+ TreeWsResponse response = ws.newRequest()
.setParam(PARAM_STRATEGY, "children")
.setParam(PARAM_COMPONENT_ID, "module-uuid-1")
.setParam(Param.PAGE, "2")
.setParam(Param.PAGE_SIZE, "3")
.setParam(Param.TEXT_QUERY, "file-name")
.setParam(Param.ASCENDING, "false")
- .setParam(Param.SORT, "name"));
+ .setParam(Param.SORT, "name").executeProtobuf(TreeWsResponse.class);
assertThat(response.getComponentsCount()).isEqualTo(3);
assertThat(response.getPaging().getTotal()).isEqualTo(8);
@@ -152,14 +150,14 @@ public class TreeActionTest {
db.commit();
logInWithBrowsePermission(project);
- TreeWsResponse response = call(ws.newRequest()
+ TreeWsResponse response = ws.newRequest()
.setParam(PARAM_STRATEGY, "all")
.setParam(PARAM_COMPONENT_ID, "module-uuid-1")
.setParam(Param.PAGE, "2")
.setParam(Param.PAGE_SIZE, "3")
.setParam(Param.TEXT_QUERY, "file-name")
.setParam(Param.ASCENDING, "true")
- .setParam(Param.SORT, "path"));
+ .setParam(Param.SORT, "path").executeProtobuf(TreeWsResponse.class);
assertThat(response.getComponentsCount()).isEqualTo(3);
assertThat(response.getPaging().getTotal()).isEqualTo(9);
@@ -176,10 +174,10 @@ public class TreeActionTest {
db.commit();
logInWithBrowsePermission(project);
- TreeWsResponse response = call(ws.newRequest()
+ TreeWsResponse response = ws.newRequest()
.setParam(PARAM_STRATEGY, "all")
.setParam(PARAM_QUALIFIERS, Qualifiers.FILE)
- .setParam(PARAM_COMPONENT_ID, "project-uuid"));
+ .setParam(PARAM_COMPONENT_ID, "project-uuid").executeProtobuf(TreeWsResponse.class);
assertThat(response.getComponentsList()).extracting("id").containsExactly("file-uuid-1", "file-uuid-2");
}
@@ -198,10 +196,10 @@ public class TreeActionTest {
db.commit();
logInWithBrowsePermission(project);
- TreeWsResponse response = call(ws.newRequest()
+ TreeWsResponse response = ws.newRequest()
.setParam(PARAM_STRATEGY, "leaves")
.setParam(PARAM_COMPONENT_ID, "project-uuid")
- .setParam(PARAM_QUALIFIERS, Qualifiers.FILE));
+ .setParam(PARAM_QUALIFIERS, Qualifiers.FILE).executeProtobuf(TreeWsResponse.class);
assertThat(response.getComponentsCount()).isEqualTo(3);
assertThat(response.getPaging().getTotal()).isEqualTo(3);
@@ -220,10 +218,10 @@ public class TreeActionTest {
db.commit();
logInWithBrowsePermission(project);
- TreeWsResponse response = call(ws.newRequest()
+ TreeWsResponse response = ws.newRequest()
.setParam(PARAM_STRATEGY, "all")
.setParam(Param.SORT, "qualifier, name")
- .setParam(PARAM_COMPONENT_ID, "project-uuid"));
+ .setParam(PARAM_COMPONENT_ID, "project-uuid").executeProtobuf(TreeWsResponse.class);
assertThat(response.getComponentsList()).extracting("id").containsExactly("module-uuid-1", "path/directory/", "file-uuid-1", "file-uuid-2");
}
@@ -240,10 +238,10 @@ public class TreeActionTest {
db.commit();
logInWithBrowsePermission(view);
- TreeWsResponse response = call(ws.newRequest()
+ TreeWsResponse response = ws.newRequest()
.setParam(PARAM_STRATEGY, "children")
.setParam(PARAM_COMPONENT_ID, "view-uuid")
- .setParam(Param.TEXT_QUERY, "name"));
+ .setParam(Param.TEXT_QUERY, "name").executeProtobuf(TreeWsResponse.class);
assertThat(response.getComponentsList()).extracting("id").containsExactly("project-uuid-1-copy", "sub-view-uuid");
assertThat(response.getComponentsList()).extracting("refId").containsExactly("project-uuid-1", "");
@@ -255,8 +253,8 @@ public class TreeActionTest {
ComponentDto project = componentDb.insertComponent(newProjectDto(db.getDefaultOrganization(), "project-uuid"));
logInWithBrowsePermission(project);
- TreeWsResponse response = call(ws.newRequest()
- .setParam(PARAM_COMPONENT_ID, "project-uuid"));
+ TreeWsResponse response = ws.newRequest()
+ .setParam(PARAM_COMPONENT_ID, "project-uuid").executeProtobuf(TreeWsResponse.class);
assertThat(response.getBaseComponent().getId()).isEqualTo("project-uuid");
assertThat(response.getComponentsList()).isEmpty();
@@ -275,7 +273,7 @@ public class TreeActionTest {
db.commit();
logInWithBrowsePermission(developer);
- TreeWsResponse response = call(ws.newRequest().setParam(PARAM_COMPONENT_ID, developer.uuid()));
+ TreeWsResponse response = ws.newRequest().setParam(PARAM_COMPONENT_ID, developer.uuid()).executeProtobuf(TreeWsResponse.class);
assertThat(response.getBaseComponent().getId()).isEqualTo(developer.uuid());
assertThat(response.getComponentsCount()).isEqualTo(1);
@@ -292,7 +290,7 @@ public class TreeActionTest {
componentDb.insertComponent(newProjectCopy("project-copy-uuid", project, view));
logInWithBrowsePermission(view);
- TreeWsResponse response = call(ws.newRequest().setParam(PARAM_COMPONENT_ID, view.uuid()));
+ TreeWsResponse response = ws.newRequest().setParam(PARAM_COMPONENT_ID, view.uuid()).executeProtobuf(TreeWsResponse.class);
assertThat(response.getBaseComponent().getId()).isEqualTo(view.uuid());
assertThat(response.getComponentsCount()).isEqualTo(1);
@@ -381,13 +379,6 @@ public class TreeActionTest {
ws.newRequest().execute();
}
- private TreeWsResponse call(TestRequest request) {
- return request
- .setMediaType(MediaTypes.PROTOBUF)
- .execute()
- .getInputObject(TreeWsResponse.class);
- }
-
private static ComponentDto newFileDto(ComponentDto moduleOrProject, @Nullable ComponentDto directory, int i) {
return ComponentTesting.newFileDto(moduleOrProject, directory, "file-uuid-" + i)
.setName("file-name-" + i)
diff --git a/server/sonar-server/src/test/java/org/sonar/server/favorite/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/favorite/ws/SearchActionTest.java
index ea1b5fc68c1..08559dcdc96 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/favorite/ws/SearchActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/favorite/ws/SearchActionTest.java
@@ -41,7 +41,6 @@ import org.sonar.server.ws.WsActionTester;
import org.sonarqube.ws.Common.Paging;
import org.sonarqube.ws.Favorites.Favorite;
import org.sonarqube.ws.Favorites.SearchResponse;
-import org.sonarqube.ws.MediaTypes;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.tuple;
@@ -192,12 +191,11 @@ public class SearchActionTest {
private SearchResponse call(@Nullable Integer page, @Nullable Integer pageSize) {
TestRequest request = ws.newRequest()
- .setMediaType(MediaTypes.PROTOBUF)
.setMethod(POST.name());
setNullable(page, p -> request.setParam(Param.PAGE, p.toString()));
setNullable(pageSize, ps -> request.setParam(Param.PAGE_SIZE, ps.toString()));
- return request.setMediaType(MediaTypes.PROTOBUF).execute().getInputObject(SearchResponse.class);
+ return request.executeProtobuf(SearchResponse.class);
}
private SearchResponse call() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/BulkChangeActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/BulkChangeActionTest.java
index 389a01c7bee..009b960bee8 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/BulkChangeActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/BulkChangeActionTest.java
@@ -61,7 +61,6 @@ import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
import org.sonarqube.ws.Issues.BulkChangeWsResponse;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.client.issue.BulkChangeRequest;
import static java.util.Arrays.asList;
@@ -463,7 +462,7 @@ public class BulkChangeActionTest {
}
private BulkChangeWsResponse call(BulkChangeRequest bulkChangeRequest) {
- TestRequest request = tester.newRequest().setMediaType(MediaTypes.PROTOBUF);
+ TestRequest request = tester.newRequest();
setNullable(bulkChangeRequest.getIssues(), value -> request.setParam("issues", String.join(",", value)));
setNullable(bulkChangeRequest.getAssign(), value -> request.setParam("assign", value));
setNullable(bulkChangeRequest.getSetSeverity(), value -> request.setParam("set_severity", value));
@@ -477,7 +476,7 @@ public class BulkChangeActionTest {
if (!bulkChangeRequest.getRemoveTags().isEmpty()) {
request.setParam("remove_tags", String.join(",", bulkChangeRequest.getRemoveTags()));
}
- return request.execute().getInputObject(BulkChangeWsResponse.class);
+ return request.executeProtobuf(BulkChangeWsResponse.class);
}
private void setUserProjectPermissions(String... permissions) {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/ChangelogActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/ChangelogActionTest.java
index b268d8f70d0..792059432fb 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/ChangelogActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/ChangelogActionTest.java
@@ -40,7 +40,6 @@ import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
import org.sonarqube.ws.Issues.ChangelogWsResponse;
import org.sonarqube.ws.Issues.ChangelogWsResponse.Changelog.Diff;
-import org.sonarqube.ws.MediaTypes;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.groups.Tuple.tuple;
@@ -272,10 +271,9 @@ public class ChangelogActionTest {
}
private ChangelogWsResponse call(@Nullable String issueKey) {
- TestRequest request = tester.newRequest()
- .setMediaType(MediaTypes.PROTOBUF);
+ TestRequest request = tester.newRequest();
setNullable(issueKey, e -> request.setParam("issue", e));
- return request.execute().getInputObject(ChangelogWsResponse.class);
+ return request.executeProtobuf(ChangelogWsResponse.class);
}
private IssueDto newIssue() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsMediumTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsMediumTest.java
index e9703994733..43c46a306ec 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsMediumTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsMediumTest.java
@@ -59,7 +59,6 @@ import org.sonar.server.ws.WsActionTester;
import org.sonar.server.ws.WsTester;
import org.sonarqube.ws.Issues;
import org.sonarqube.ws.Issues.SearchWsResponse;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.client.issue.IssuesWsParameters;
import static com.google.common.collect.Lists.newArrayList;
@@ -155,10 +154,7 @@ public class SearchActionComponentsMediumTest {
indexIssues();
WsActionTester actionTester = new WsActionTester(tester.get(SearchAction.class));
- SearchWsResponse searchResponse = actionTester.newRequest()
- .setMediaType(MediaTypes.PROTOBUF)
- .execute()
- .getInputObject(SearchWsResponse.class);
+ SearchWsResponse searchResponse = actionTester.newRequest().executeProtobuf(SearchWsResponse.class);
assertThat(searchResponse.getIssuesCount()).isEqualTo(2);
for (Issues.Issue issue : searchResponse.getIssuesList()) {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/license/ws/ListActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/license/ws/ListActionTest.java
index 3f909bb12b9..53256165c48 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/license/ws/ListActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/license/ws/ListActionTest.java
@@ -41,7 +41,6 @@ import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.WsActionTester;
import org.sonarqube.ws.Licenses;
import org.sonarqube.ws.Licenses.ListWsResponse;
-import org.sonarqube.ws.MediaTypes;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Java6Assertions.entry;
@@ -273,10 +272,7 @@ public class ListActionTest {
}
private ListWsResponse executeRequest() {
- return ws.newRequest()
- .setMediaType(MediaTypes.PROTOBUF)
- .execute()
- .getInputObject(ListWsResponse.class);
+ return ws.newRequest().executeProtobuf(ListWsResponse.class);
}
private void logInAsSystemAdministrator() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java
index 6428d1ac32e..93dce596cd1 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentActionTest.java
@@ -40,9 +40,7 @@ import org.sonar.server.exceptions.BadRequestException;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.tester.UserSessionRule;
-import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.WsMeasures.ComponentWsResponse;
import static org.assertj.core.api.Assertions.assertThat;
@@ -155,10 +153,10 @@ public class ComponentActionTest {
newMeasureDto(ncloc, file, projectSnapshot).setValue(1984.0d).setDeveloperId(developer.getId()));
db.commit();
- ComponentWsResponse result = call(ws.newRequest()
+ ComponentWsResponse result = ws.newRequest()
.setParam(PARAM_COMPONENT_ID, "file-uuid")
.setParam(PARAM_DEVELOPER_ID, developer.uuid())
- .setParam(PARAM_METRIC_KEYS, "ncloc"));
+ .setParam(PARAM_METRIC_KEYS, "ncloc").executeProtobuf(ComponentWsResponse.class);
assertThat(result.getComponent().getMeasuresCount()).isEqualTo(1);
assertThat(result.getComponent().getMeasures(0).getValue()).isEqualTo("1984");
@@ -179,10 +177,10 @@ public class ComponentActionTest {
newMeasureDto(ncloc, file, projectSnapshot).setValue(1984.0d).setDeveloperId(developer.getId()));
db.commit();
- ComponentWsResponse result = call(ws.newRequest()
+ ComponentWsResponse result = ws.newRequest()
.setParam(PARAM_COMPONENT_ID, "file-uuid")
.setParam(PARAM_DEVELOPER_KEY, developer.key())
- .setParam(PARAM_METRIC_KEYS, "ncloc"));
+ .setParam(PARAM_METRIC_KEYS, "ncloc").executeProtobuf(ComponentWsResponse.class);
assertThat(result.getComponent().getMeasuresCount()).isEqualTo(1);
assertThat(result.getComponent().getMeasures(0).getValue()).isEqualTo("1984");
@@ -196,10 +194,10 @@ public class ComponentActionTest {
componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), PROJECT_UUID));
insertNclocMetric();
- call(ws.newRequest()
+ ws.newRequest()
.setParam(PARAM_COMPONENT_ID, PROJECT_UUID)
.setParam(PARAM_METRIC_KEYS, "ncloc")
- .setParam(PARAM_DEVELOPER_ID, "unknown-developer-id"));
+ .setParam(PARAM_DEVELOPER_ID, "unknown-developer-id").executeProtobuf(ComponentWsResponse.class);
}
@Test
@@ -236,17 +234,10 @@ public class ComponentActionTest {
}
private ComponentWsResponse newRequest(String componentUuid, String metricKeys) {
- return call(ws.newRequest()
+ return ws.newRequest()
.setParam(PARAM_COMPONENT_ID, componentUuid)
.setParam(PARAM_METRIC_KEYS, metricKeys)
- .setParam(PARAM_ADDITIONAL_FIELDS, "metrics,periods"));
- }
-
- private ComponentWsResponse call(TestRequest request) {
- return request
- .setMediaType(MediaTypes.PROTOBUF)
- .execute()
- .getInputObject(ComponentWsResponse.class);
+ .setParam(PARAM_ADDITIONAL_FIELDS, "metrics,periods").executeProtobuf(ComponentWsResponse.class);
}
private static MetricDto newMetricDtoWithoutOptimization() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java
index 2bb97f95d43..01d56fdfe18 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/ComponentTreeActionTest.java
@@ -43,10 +43,8 @@ import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.i18n.I18nRule;
import org.sonar.server.tester.UserSessionRule;
-import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
import org.sonarqube.ws.Common;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.WsMeasures;
import org.sonarqube.ws.WsMeasures.ComponentTreeWsResponse;
@@ -124,9 +122,10 @@ public class ComponentTreeActionTest {
public void empty_response() {
componentDb.insertComponent(newProjectDto(db.getDefaultOrganization(), "project-uuid"));
- ComponentTreeWsResponse response = call(ws.newRequest()
+ ComponentTreeWsResponse response = ws.newRequest()
.setParam(PARAM_BASE_COMPONENT_ID, "project-uuid")
- .setParam(PARAM_METRIC_KEYS, "ncloc, complexity"));
+ .setParam(PARAM_METRIC_KEYS, "ncloc, complexity")
+ .executeProtobuf(ComponentTreeWsResponse.class);
assertThat(response.getBaseComponent().getId()).isEqualTo("project-uuid");
assertThat(response.getComponentsList()).isEmpty();
@@ -156,10 +155,11 @@ public class ComponentTreeActionTest {
newMeasureDto(coverage, directoryDto, projectSnapshot).setValue(15.0d));
db.commit();
- ComponentTreeWsResponse response = call(ws.newRequest()
+ ComponentTreeWsResponse response = ws.newRequest()
.setParam(PARAM_BASE_COMPONENT_ID, "project-uuid")
.setParam(PARAM_METRIC_KEYS, "ncloc,coverage")
- .setParam(PARAM_ADDITIONAL_FIELDS, ADDITIONAL_PERIODS));
+ .setParam(PARAM_ADDITIONAL_FIELDS, ADDITIONAL_PERIODS)
+ .executeProtobuf(ComponentTreeWsResponse.class);
assertThat(response.getComponentsList().get(0).getMeasuresList()).extracting("metric").containsOnly("coverage");
// file measures
@@ -195,10 +195,11 @@ public class ComponentTreeActionTest {
newMeasureDto(coverage, directoryDto, projectSnapshot).setValue(42.0d));
db.commit();
- ComponentTreeWsResponse response = call(ws.newRequest()
+ ComponentTreeWsResponse response = ws.newRequest()
.setParam(PARAM_BASE_COMPONENT_ID, "project-uuid")
.setParam(PARAM_METRIC_KEYS, "ncloc,coverage,new_violations")
- .setParam(PARAM_ADDITIONAL_FIELDS, "metrics"));
+ .setParam(PARAM_ADDITIONAL_FIELDS, "metrics")
+ .executeProtobuf(ComponentTreeWsResponse.class);
// directory measures
assertThat(response.getComponentsList().get(0).getMeasuresList()).extracting("metric").containsOnly("coverage");
@@ -233,10 +234,11 @@ public class ComponentTreeActionTest {
dbClient.measureDao().insert(dbSession, newMeasureDto(metric, directoryDto, projectSnapshot).setVariation(2d));
db.commit();
- ComponentTreeWsResponse response = call(ws.newRequest()
+ ComponentTreeWsResponse response = ws.newRequest()
.setParam(PARAM_BASE_COMPONENT_ID, "project-uuid")
.setParam(PARAM_METRIC_KEYS, NEW_SECURITY_RATING_KEY)
- .setParam(PARAM_ADDITIONAL_FIELDS, "metrics"));
+ .setParam(PARAM_ADDITIONAL_FIELDS, "metrics")
+ .executeProtobuf(ComponentTreeWsResponse.class);
// directory
assertThat(response.getComponentsList().get(0).getMeasuresList().get(0).getPeriods().getPeriodsValue(0).getValue()).isEqualTo("2.0");
@@ -270,7 +272,7 @@ public class ComponentTreeActionTest {
newMeasureDto(coverage, file9, projectSnapshot).setValue(9.0d));
db.commit();
- ComponentTreeWsResponse response = call(ws.newRequest()
+ ComponentTreeWsResponse response = ws.newRequest()
.setParam(PARAM_BASE_COMPONENT_ID, "project-uuid")
.setParam(Param.SORT, NAME_SORT + ", " + METRIC_SORT)
.setParam(PARAM_METRIC_SORT, "coverage")
@@ -278,7 +280,8 @@ public class ComponentTreeActionTest {
.setParam(PARAM_STRATEGY, "leaves")
.setParam(PARAM_QUALIFIERS, "FIL,UTS")
.setParam(Param.PAGE, "2")
- .setParam(Param.PAGE_SIZE, "3"));
+ .setParam(Param.PAGE_SIZE, "3")
+ .executeProtobuf(ComponentTreeWsResponse.class);
assertThat(response.getComponentsList()).extracting("id").containsExactly("file-uuid-4", "file-uuid-5", "file-uuid-6");
assertThat(response.getPaging().getPageIndex()).isEqualTo(2);
@@ -302,11 +305,12 @@ public class ComponentTreeActionTest {
newMeasureDto(ncloc, file3, projectSnapshot).setValue(3.0d));
db.commit();
- ComponentTreeWsResponse response = call(ws.newRequest()
+ ComponentTreeWsResponse response = ws.newRequest()
.setParam(PARAM_BASE_COMPONENT_ID, "project-uuid")
.setParam(Param.SORT, METRIC_SORT)
.setParam(PARAM_METRIC_SORT, "ncloc")
- .setParam(PARAM_METRIC_KEYS, "ncloc"));
+ .setParam(PARAM_METRIC_KEYS, "ncloc")
+ .executeProtobuf(ComponentTreeWsResponse.class);
assertThat(response.getComponentsList()).extracting("id").containsExactly("file-uuid-1", "file-uuid-2", "file-uuid-3", "file-uuid-4");
assertThat(response.getPaging().getTotal()).isEqualTo(4);
@@ -334,12 +338,13 @@ public class ComponentTreeActionTest {
newMeasureDto(ncloc, file4, projectSnapshot).setVariation(4.0d));
db.commit();
- ComponentTreeWsResponse response = call(ws.newRequest()
+ ComponentTreeWsResponse response = ws.newRequest()
.setParam(PARAM_BASE_COMPONENT_ID, project.uuid())
.setParam(Param.SORT, METRIC_SORT)
.setParam(PARAM_METRIC_SORT, "ncloc")
.setParam(PARAM_METRIC_KEYS, "ncloc")
- .setParam(PARAM_METRIC_SORT_FILTER, WITH_MEASURES_ONLY_METRIC_SORT_FILTER));
+ .setParam(PARAM_METRIC_SORT_FILTER, WITH_MEASURES_ONLY_METRIC_SORT_FILTER)
+ .executeProtobuf(ComponentTreeWsResponse.class);
assertThat(response.getComponentsList()).extracting("id")
.containsExactly(file1.uuid(), file2.uuid(), file3.uuid())
@@ -362,12 +367,13 @@ public class ComponentTreeActionTest {
newMeasureDto(ncloc, file3, projectSnapshot).setVariation(3.0d));
db.commit();
- ComponentTreeWsResponse response = call(ws.newRequest()
+ ComponentTreeWsResponse response = ws.newRequest()
.setParam(PARAM_BASE_COMPONENT_ID, "project-uuid")
.setParam(Param.SORT, METRIC_PERIOD_SORT)
.setParam(PARAM_METRIC_SORT, "ncloc")
.setParam(PARAM_METRIC_KEYS, "ncloc")
- .setParam(PARAM_METRIC_PERIOD_SORT, "1"));
+ .setParam(PARAM_METRIC_PERIOD_SORT, "1")
+ .executeProtobuf(ComponentTreeWsResponse.class);
assertThat(response.getComponentsList()).extracting("id").containsExactly("file-uuid-1", "file-uuid-2", "file-uuid-3");
}
@@ -390,13 +396,14 @@ public class ComponentTreeActionTest {
newMeasureDto(ncloc, file4, projectSnapshot).setValue(4.0d));
db.commit();
- ComponentTreeWsResponse response = call(ws.newRequest()
+ ComponentTreeWsResponse response = ws.newRequest()
.setParam(PARAM_BASE_COMPONENT_ID, "project-uuid")
.setParam(Param.SORT, METRIC_PERIOD_SORT + "," + NAME_SORT)
.setParam(PARAM_METRIC_SORT, "new_ncloc")
.setParam(PARAM_METRIC_KEYS, "new_ncloc")
.setParam(PARAM_METRIC_PERIOD_SORT, "1")
- .setParam(PARAM_METRIC_SORT_FILTER, WITH_MEASURES_ONLY_METRIC_SORT_FILTER));
+ .setParam(PARAM_METRIC_SORT_FILTER, WITH_MEASURES_ONLY_METRIC_SORT_FILTER)
+ .executeProtobuf(ComponentTreeWsResponse.class);
assertThat(response.getComponentsList()).extracting("id")
.containsExactly("file-uuid-1", "file-uuid-2", "file-uuid-3")
@@ -413,9 +420,10 @@ public class ComponentTreeActionTest {
insertNclocMetric();
db.commit();
- ComponentTreeWsResponse response = call(ws.newRequest()
+ ComponentTreeWsResponse response = ws.newRequest()
.setParam(PARAM_BASE_COMPONENT_ID, developer.uuid())
- .setParam(PARAM_METRIC_KEYS, "ncloc"));
+ .setParam(PARAM_METRIC_KEYS, "ncloc")
+ .executeProtobuf(ComponentTreeWsResponse.class);
assertThat(response.getComponentsCount()).isEqualTo(1);
WsMeasures.Component projectCopy = response.getComponents(0);
@@ -444,11 +452,12 @@ public class ComponentTreeActionTest {
newMeasureDto(ncloc, file2, projectSnapshot).setDeveloperId(null));
db.commit();
- ComponentTreeWsResponse response = call(ws.newRequest()
+ ComponentTreeWsResponse response = ws.newRequest()
.setParam(PARAM_BASE_COMPONENT_ID, "project-uuid")
.setParam(PARAM_DEVELOPER_ID, "developer-uuid")
.setParam(PARAM_STRATEGY, CHILDREN_STRATEGY)
- .setParam(PARAM_METRIC_KEYS, "ncloc"));
+ .setParam(PARAM_METRIC_KEYS, "ncloc")
+ .executeProtobuf(ComponentTreeWsResponse.class);
assertThat(response.getComponentsCount()).isEqualTo(2);
WsMeasures.Component file = response.getComponents(0);
@@ -472,10 +481,11 @@ public class ComponentTreeActionTest {
.setDeveloperId(developer.getId()));
db.commit();
- ComponentTreeWsResponse response = call(ws.newRequest()
+ ComponentTreeWsResponse response = ws.newRequest()
.setParam(PARAM_BASE_COMPONENT_ID, "project-uuid")
.setParam(PARAM_DEVELOPER_KEY, developer.key())
- .setParam(PARAM_METRIC_KEYS, "ncloc"));
+ .setParam(PARAM_METRIC_KEYS, "ncloc")
+ .executeProtobuf(ComponentTreeWsResponse.class);
assertThat(response.getComponentsCount()).isEqualTo(1);
WsMeasures.Component file = response.getComponents(0);
@@ -493,10 +503,11 @@ public class ComponentTreeActionTest {
componentDb.insertComponent(newFileDto(project, null));
insertNclocMetric();
- ComponentTreeWsResponse result = call(ws.newRequest()
+ ComponentTreeWsResponse result = ws.newRequest()
.setParam(PARAM_BASE_COMPONENT_ID, projectUuid)
.setParam(PARAM_STRATEGY, LEAVES_STRATEGY)
- .setParam(PARAM_METRIC_KEYS, "ncloc"));
+ .setParam(PARAM_METRIC_KEYS, "ncloc")
+ .executeProtobuf(ComponentTreeWsResponse.class);
assertThat(result.getBaseComponent().getId()).isEqualTo(projectUuid);
assertThat(result.getComponentsCount()).isEqualTo(0);
@@ -519,10 +530,11 @@ public class ComponentTreeActionTest {
.setDeveloperId(developer.getId()));
db.commit();
- call(ws.newRequest()
+ ws.newRequest()
.setParam(PARAM_BASE_COMPONENT_ID, "project-uuid")
.setParam(PARAM_DEVELOPER_KEY, "unknown-developer-key")
- .setParam(PARAM_METRIC_KEYS, "ncloc"));
+ .setParam(PARAM_METRIC_KEYS, "ncloc")
+ .executeProtobuf(ComponentTreeWsResponse.class);
}
@Test
@@ -532,9 +544,10 @@ public class ComponentTreeActionTest {
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("The 'metricKeys' parameter must contain at least one metric key");
- call(ws.newRequest()
+ ws.newRequest()
.setParam(PARAM_BASE_COMPONENT_ID, "project-uuid")
- .setParam(PARAM_METRIC_KEYS, ""));
+ .setParam(PARAM_METRIC_KEYS, "")
+ .executeProtobuf(ComponentTreeWsResponse.class);
}
@Test
@@ -545,9 +558,9 @@ public class ComponentTreeActionTest {
expectedException.expect(NotFoundException.class);
expectedException.expectMessage("The following metric keys are not found: unknown-metric, another-unknown-metric");
- call(ws.newRequest()
+ ws.newRequest()
.setParam(PARAM_BASE_COMPONENT_ID, "project-uuid")
- .setParam(PARAM_METRIC_KEYS, "ncloc, new_violations, unknown-metric, another-unknown-metric"));
+ .setParam(PARAM_METRIC_KEYS, "ncloc, new_violations, unknown-metric, another-unknown-metric").executeProtobuf(ComponentTreeWsResponse.class);
}
@Test
@@ -558,10 +571,11 @@ public class ComponentTreeActionTest {
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("The 'q' parameter must have at least 3 characters");
- call(ws.newRequest()
+ ws.newRequest()
.setParam(PARAM_BASE_COMPONENT_ID, "project-uuid")
.setParam(PARAM_METRIC_KEYS, "ncloc, new_violations")
- .setParam(Param.TEXT_QUERY, "fi"));
+ .setParam(Param.TEXT_QUERY, "fi")
+ .executeProtobuf(ComponentTreeWsResponse.class);
}
@Test
@@ -570,9 +584,10 @@ public class ComponentTreeActionTest {
componentDb.insertProjectAndSnapshot(newProjectDto(db.getDefaultOrganization(), "project-uuid"));
expectedException.expect(ForbiddenException.class);
- call(ws.newRequest()
+ ws.newRequest()
.setParam(PARAM_BASE_COMPONENT_ID, "project-uuid")
- .setParam(PARAM_METRIC_KEYS, "ncloc"));
+ .setParam(PARAM_METRIC_KEYS, "ncloc")
+ .executeProtobuf(ComponentTreeWsResponse.class);
}
@Test
@@ -582,11 +597,12 @@ public class ComponentTreeActionTest {
expectedException
.expectMessage("To sort by a metric, the 's' parameter must contain 'metric' or 'metricPeriod', and a metric key must be provided in the 'metricSort' parameter");
- call(ws.newRequest()
+ ws.newRequest()
.setParam(PARAM_BASE_COMPONENT_ID, "project-uuid")
.setParam(PARAM_METRIC_KEYS, "ncloc")
// PARAM_METRIC_SORT is not set
- .setParam(Param.SORT, METRIC_SORT));
+ .setParam(Param.SORT, METRIC_SORT)
+ .executeProtobuf(ComponentTreeWsResponse.class);
}
@Test
@@ -595,11 +611,12 @@ public class ComponentTreeActionTest {
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("To sort by the 'complexity' metric, it must be in the list of metric keys in the 'metricKeys' parameter");
- call(ws.newRequest()
+ ws.newRequest()
.setParam(PARAM_BASE_COMPONENT_ID, "project-uuid")
.setParam(PARAM_METRIC_KEYS, "ncloc,violations")
.setParam(PARAM_METRIC_SORT, "complexity")
- .setParam(Param.SORT, METRIC_SORT));
+ .setParam(Param.SORT, METRIC_SORT)
+ .executeProtobuf(ComponentTreeWsResponse.class);
}
@Test
@@ -608,12 +625,13 @@ public class ComponentTreeActionTest {
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("To sort by a metric period, the 's' parameter must contain 'metricPeriod' and the 'metricPeriodSort' must be provided.");
- call(ws.newRequest()
+ ws.newRequest()
.setParam(PARAM_BASE_COMPONENT_ID, "project-uuid")
.setParam(PARAM_METRIC_KEYS, "ncloc")
.setParam(PARAM_METRIC_SORT, "ncloc")
// PARAM_METRIC_PERIOD_SORT_IS_NOT_SET
- .setParam(Param.SORT, METRIC_PERIOD_SORT));
+ .setParam(Param.SORT, METRIC_PERIOD_SORT)
+ .executeProtobuf(ComponentTreeWsResponse.class);
}
@Test
@@ -623,10 +641,11 @@ public class ComponentTreeActionTest {
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("The 'ps' parameter must be less than 500");
- call(ws.newRequest()
+ ws.newRequest()
.setParam(PARAM_BASE_COMPONENT_ID, "project-uuid")
.setParam(PARAM_METRIC_KEYS, "ncloc")
- .setParam(Param.PAGE_SIZE, "2540"));
+ .setParam(Param.PAGE_SIZE, "2540")
+ .executeProtobuf(ComponentTreeWsResponse.class);
}
@Test
@@ -637,17 +656,11 @@ public class ComponentTreeActionTest {
expectedException
.expectMessage("To filter components based on the sort metric, the 's' parameter must contain 'metric' or 'metricPeriod' and the 'metricSort' parameter must be provided");
- call(ws.newRequest()
+ ws.newRequest()
.setParam(PARAM_BASE_COMPONENT_ID, "project-uuid")
.setParam(PARAM_METRIC_KEYS, "ncloc")
- .setParam(PARAM_METRIC_SORT_FILTER, WITH_MEASURES_ONLY_METRIC_SORT_FILTER));
- }
-
- private static ComponentTreeWsResponse call(TestRequest request) {
- return request
- .setMediaType(MediaTypes.PROTOBUF)
- .execute()
- .getInputObject(ComponentTreeWsResponse.class);
+ .setParam(PARAM_METRIC_SORT_FILTER, WITH_MEASURES_ONLY_METRIC_SORT_FILTER)
+ .executeProtobuf(ComponentTreeWsResponse.class);
}
private static MetricDto newMetricDtoWithoutOptimization() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/SearchActionTest.java
index 97a627211b5..50fc5ea2d69 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/SearchActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/SearchActionTest.java
@@ -66,7 +66,6 @@ import static org.sonar.db.component.SnapshotTesting.newAnalysis;
import static org.sonar.db.measure.MeasureTesting.newMeasureDto;
import static org.sonar.db.metric.MetricTesting.newMetricDto;
import static org.sonar.test.JsonAssert.assertJson;
-import static org.sonarqube.ws.MediaTypes.PROTOBUF;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_METRIC_KEYS;
import static org.sonarqube.ws.client.measure.MeasuresWsParameters.PARAM_PROJECT_KEYS;
@@ -378,17 +377,14 @@ public class SearchActionTest {
}
private SearchWsResponse call(@Nullable List<String> keys, @Nullable List<String> metrics) {
- TestRequest request = ws.newRequest()
- .setMediaType(PROTOBUF);
-
+ TestRequest request = ws.newRequest();
if (keys != null) {
request.setParam(PARAM_PROJECT_KEYS, String.join(",", keys));
}
if (metrics != null) {
request.setParam(PARAM_METRIC_KEYS, String.join(",", metrics));
}
-
- return request.execute().getInputObject(SearchWsResponse.class);
+ return request.executeProtobuf(SearchWsResponse.class);
}
private static MetricDto newMetricDtoWithoutOptimization() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/SearchHistoryActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/SearchHistoryActionTest.java
index e7f8f415f94..24e464f9190 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/measure/ws/SearchHistoryActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/measure/ws/SearchHistoryActionTest.java
@@ -45,7 +45,6 @@ import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
import org.sonarqube.ws.Common.Paging;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.WsMeasures.SearchHistoryResponse;
import org.sonarqube.ws.WsMeasures.SearchHistoryResponse.HistoryMeasure;
import org.sonarqube.ws.WsMeasures.SearchHistoryResponse.HistoryValue;
@@ -315,8 +314,7 @@ public class SearchHistoryActionTest {
private SearchHistoryResponse call() {
SearchHistoryRequest wsRequest = this.wsRequest.build();
- TestRequest request = ws.newRequest()
- .setMediaType(MediaTypes.PROTOBUF);
+ TestRequest request = ws.newRequest();
request.setParam(PARAM_COMPONENT, wsRequest.getComponent());
request.setParam(PARAM_METRICS, String.join(",", wsRequest.getMetrics()));
@@ -325,7 +323,7 @@ public class SearchHistoryActionTest {
setNullable(wsRequest.getPage(), p -> request.setParam(Param.PAGE, String.valueOf(p)));
setNullable(wsRequest.getPageSize(), ps -> request.setParam(Param.PAGE_SIZE, String.valueOf(ps)));
- return request.execute().getInputObject(SearchHistoryResponse.class);
+ return request.executeProtobuf(SearchHistoryResponse.class);
}
private static MetricDto newMetricDtoWithoutOptimization() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/notification/ws/ListActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/notification/ws/ListActionTest.java
index b7e8d15d7d8..254a71e135e 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/notification/ws/ListActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/notification/ws/ListActionTest.java
@@ -48,7 +48,6 @@ import static org.sonar.server.notification.NotificationDispatcherMetadata.GLOBA
import static org.sonar.server.notification.NotificationDispatcherMetadata.PER_PROJECT_NOTIFICATION;
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
import static org.sonar.test.JsonAssert.assertJson;
-import static org.sonarqube.ws.MediaTypes.PROTOBUF;
public class ListActionTest {
private static final String NOTIF_MY_NEW_ISSUES = "MyNewIssues";
@@ -225,10 +224,7 @@ public class ListActionTest {
}
private ListResponse call() {
- return ws.newRequest()
- .setMediaType(PROTOBUF)
- .execute()
- .getInputObject(ListResponse.class);
+ return ws.newRequest().executeProtobuf(ListResponse.class);
}
private ComponentDto addComponent(ComponentDto component) {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/AddMemberActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/AddMemberActionTest.java
index b7913a97041..5eefc948b33 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/AddMemberActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/AddMemberActionTest.java
@@ -50,7 +50,6 @@ import org.sonar.server.user.index.UserQuery;
import org.sonar.server.usergroups.DefaultGroupFinder;
import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.Organizations.AddMemberWsResponse;
import static java.lang.String.format;
@@ -258,10 +257,10 @@ public class AddMemberActionTest {
}
private AddMemberWsResponse call(@Nullable String organizationKey, @Nullable String login) {
- TestRequest request = ws.newRequest().setMediaType(MediaTypes.PROTOBUF);
+ TestRequest request = ws.newRequest();
setNullable(organizationKey, o -> request.setParam(PARAM_ORGANIZATION, o));
setNullable(login, l -> request.setParam("login", l));
- return request.execute().getInputObject(AddMemberWsResponse.class);
+ return request.executeProtobuf(AddMemberWsResponse.class);
}
private void assertMember(String organizationUuid, int userId) {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/CreateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/CreateActionTest.java
index a675ef9ede6..6276a91bdf5 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/CreateActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/CreateActionTest.java
@@ -585,10 +585,9 @@ public class CreateActionTest {
}
private CreateWsResponse executeRequest(@Nullable String name, @Nullable String key, @Nullable String description, @Nullable String url, @Nullable String avatar) {
- TestRequest request = wsTester.newRequest()
- .setMediaType(MediaTypes.PROTOBUF);
+ TestRequest request = wsTester.newRequest();
populateRequest(name, key, description, url, avatar, request);
- return request.execute().getInputObject(CreateWsResponse.class);
+ return request.executeProtobuf(CreateWsResponse.class);
}
private String executeJsonRequest(@Nullable String name, @Nullable String key, @Nullable String description, @Nullable String url, @Nullable String avatar) {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/SearchActionTest.java
index ae50a7a3888..e7f238b583b 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/SearchActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/SearchActionTest.java
@@ -228,11 +228,9 @@ public class SearchActionTest {
}
private List<Organization> executeRequest(@Nullable Integer page, @Nullable Integer pageSize, String... keys) {
- TestRequest request = wsTester.newRequest()
- .setMediaType(MediaTypes.PROTOBUF);
+ TestRequest request = wsTester.newRequest();
populateRequest(request, page, pageSize, keys);
- return request.execute()
- .getInputObject(Organizations.SearchWsResponse.class)
+ return request.executeProtobuf(Organizations.SearchWsResponse.class)
.getOrganizationsList();
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/SearchMembersActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/SearchMembersActionTest.java
index 8e1c758d15a..7dbe1c79356 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/SearchMembersActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/SearchMembersActionTest.java
@@ -45,7 +45,6 @@ import org.sonar.server.user.index.UserIndexer;
import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
import org.sonarqube.ws.Common.Paging;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.Organizations.SearchMembersWsResponse;
import org.sonarqube.ws.Organizations.User;
import org.sonarqube.ws.client.organization.SearchMembersWsRequest;
@@ -324,14 +323,13 @@ public class SearchMembersActionTest {
}
private SearchMembersWsResponse call() {
- TestRequest wsRequest = ws.newRequest()
- .setMediaType(MediaTypes.PROTOBUF);
+ TestRequest wsRequest = ws.newRequest();
setNullable(request.getOrganization(), o -> wsRequest.setParam("organization", o));
setNullable(request.getQuery(), q -> wsRequest.setParam(Param.TEXT_QUERY, q));
setNullable(request.getPage(), p -> wsRequest.setParam(Param.PAGE, String.valueOf(p)));
setNullable(request.getPageSize(), ps -> wsRequest.setParam(Param.PAGE_SIZE, String.valueOf(ps)));
setNullable(request.getSelected(), s -> wsRequest.setParam(Param.SELECTED, s));
- return wsRequest.execute().getInputObject(SearchMembersWsResponse.class);
+ return wsRequest.executeProtobuf(SearchMembersWsResponse.class);
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/UpdateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/UpdateActionTest.java
index d966ed608a6..382dd302cf7 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/organization/ws/UpdateActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/organization/ws/UpdateActionTest.java
@@ -34,7 +34,6 @@ import org.sonar.server.organization.TestOrganizationFlags;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.Organizations;
import static org.assertj.core.api.Assertions.assertThat;
@@ -322,14 +321,13 @@ public class UpdateActionTest {
private Organizations.UpdateWsResponse executeRequest(@Nullable String key,
@Nullable String name, @Nullable String description, @Nullable String url, @Nullable String avatar) {
- TestRequest request = wsTester.newRequest()
- .setMediaType(MediaTypes.PROTOBUF);
+ TestRequest request = wsTester.newRequest();
setParam(request, "key", key);
setParam(request, "name", name);
setParam(request, "description", description);
setParam(request, "url", url);
setParam(request, "avatar", avatar);
- return request.execute().getInputObject(Organizations.UpdateWsResponse.class);
+ return request.executeProtobuf(Organizations.UpdateWsResponse.class);
}
private void verifyResponseAndDb(Organizations.UpdateWsResponse response, OrganizationDto dto, String name, long updateAt) {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchGlobalPermissionsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchGlobalPermissionsActionTest.java
index 2982124f7e1..1782763fcc4 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchGlobalPermissionsActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchGlobalPermissionsActionTest.java
@@ -31,7 +31,6 @@ import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.exceptions.UnauthorizedException;
import org.sonar.server.i18n.I18nRule;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.WsPermissions;
import static org.assertj.core.api.Assertions.assertThat;
@@ -103,9 +102,7 @@ public class SearchGlobalPermissionsActionTest extends BasePermissionWsTest<Sear
db.organizations().addMember(org, user);
WsPermissions.WsSearchGlobalPermissionsResponse result = newRequest()
- .setMediaType(MediaTypes.PROTOBUF)
- .execute()
- .getInputObject(WsPermissions.WsSearchGlobalPermissionsResponse.class);
+ .executeProtobuf(WsPermissions.WsSearchGlobalPermissionsResponse.class);
assertThat(result.getPermissionsCount()).isEqualTo(GlobalPermissions.ALL.size());
for (WsPermissions.Permission permission : result.getPermissionsList()) {
@@ -122,9 +119,7 @@ public class SearchGlobalPermissionsActionTest extends BasePermissionWsTest<Sear
loginAsAdmin(db.getDefaultOrganization());
WsPermissions.WsSearchGlobalPermissionsResponse result = newRequest()
- .setMediaType(MediaTypes.PROTOBUF)
- .execute()
- .getInputObject(WsPermissions.WsSearchGlobalPermissionsResponse.class);
+ .executeProtobuf(WsPermissions.WsSearchGlobalPermissionsResponse.class);
assertThat(result).isNotNull();
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest.java
index 4aee6fed232..4c2996e7ba3 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest.java
@@ -32,7 +32,6 @@ import org.sonar.db.user.UserDto;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.UnauthorizedException;
import org.sonar.server.i18n.I18nRule;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.WsPermissions;
import static org.assertj.core.api.Assertions.assertThat;
@@ -200,10 +199,8 @@ public class SearchProjectPermissionsActionTest extends BasePermissionWsTest<Sea
db.components().insertComponent(newProjectDto(organizationDto, "project-uuid"));
WsPermissions.SearchProjectPermissionsWsResponse result = newRequest()
- .setMediaType(MediaTypes.PROTOBUF)
.setParam(PARAM_QUALIFIER, Qualifiers.PROJECT)
- .execute()
- .getInputObject(WsPermissions.SearchProjectPermissionsWsResponse.class);
+ .executeProtobuf(WsPermissions.SearchProjectPermissionsWsResponse.class);
assertThat(result.getProjectsList())
.extracting("id")
diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SearchTemplatesActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SearchTemplatesActionTest.java
index d924e1fd026..0268173ccec 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SearchTemplatesActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SearchTemplatesActionTest.java
@@ -38,7 +38,6 @@ import org.sonar.server.i18n.I18nRule;
import org.sonar.server.permission.ws.BasePermissionWsTest;
import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.WsPermissions;
import static org.assertj.core.api.Assertions.assertThat;
@@ -182,9 +181,7 @@ public class SearchTemplatesActionTest extends BasePermissionWsTest<SearchTempla
WsPermissions.SearchTemplatesWsResponse result = newRequest(underTestWithoutViews)
.setParam("organization", org.getKey())
- .setMediaType(MediaTypes.PROTOBUF)
- .execute()
- .getInputObject(WsPermissions.SearchTemplatesWsResponse.class);
+ .executeProtobuf(WsPermissions.SearchTemplatesWsResponse.class);
assertThat(result.getPermissionTemplatesCount()).isEqualTo(2);
assertThat(result.getPermissionTemplatesList())
diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/TemplateGroupsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/TemplateGroupsActionTest.java
index ef6d6b03844..f8533dd657a 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/TemplateGroupsActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/TemplateGroupsActionTest.java
@@ -127,10 +127,8 @@ public class TemplateGroupsActionTest extends BasePermissionWsTest<TemplateGroup
loginAsAdmin(db.getDefaultOrganization());
WsGroupsResponse response = newRequest()
- .setMediaType(PROTOBUF)
.setParam(PARAM_TEMPLATE_ID, template.getUuid())
- .execute()
- .getInputObject(WsGroupsResponse.class);
+ .executeProtobuf(WsGroupsResponse.class);
assertThat(response.getGroupsList()).extracting("name").containsExactly("Anyone", "group-1-name", "group-2-name");
assertThat(response.getGroups(0).getPermissionsList()).containsOnly("user", "issueadmin");
@@ -160,11 +158,9 @@ public class TemplateGroupsActionTest extends BasePermissionWsTest<TemplateGroup
loginAsAdmin(db.getDefaultOrganization());
WsGroupsResponse response = newRequest()
- .setMediaType(PROTOBUF)
.setParam(PARAM_PERMISSION, USER)
.setParam(PARAM_TEMPLATE_ID, template.getUuid())
- .execute()
- .getInputObject(WsGroupsResponse.class);
+ .executeProtobuf(WsGroupsResponse.class);
assertThat(response.getGroupsList()).extracting("name").containsExactly("Anyone", "group-1-name");
assertThat(response.getGroups(0).getPermissionsList()).containsOnly("user");
@@ -189,10 +185,8 @@ public class TemplateGroupsActionTest extends BasePermissionWsTest<TemplateGroup
loginAsAdmin(db.getDefaultOrganization());
WsGroupsResponse response = newRequest()
- .setMediaType(PROTOBUF)
.setParam(PARAM_TEMPLATE_NAME, template.getName())
- .execute()
- .getInputObject(WsGroupsResponse.class);
+ .executeProtobuf(WsGroupsResponse.class);
assertThat(response.getGroupsList()).extracting("name").containsExactly("Anyone", "group-1-name", "group-2-name");
}
@@ -209,13 +203,11 @@ public class TemplateGroupsActionTest extends BasePermissionWsTest<TemplateGroup
loginAsAdmin(db.getDefaultOrganization());
WsGroupsResponse response = newRequest()
- .setMediaType(PROTOBUF)
.setParam(PARAM_PERMISSION, USER)
.setParam(PARAM_TEMPLATE_NAME, template.getName())
.setParam(PAGE, "2")
.setParam(PAGE_SIZE, "1")
- .execute()
- .getInputObject(WsGroupsResponse.class);
+ .executeProtobuf(WsGroupsResponse.class);
assertThat(response.getGroupsList()).extracting("name").containsExactly("group-2-name");
}
@@ -232,11 +224,9 @@ public class TemplateGroupsActionTest extends BasePermissionWsTest<TemplateGroup
loginAsAdmin(db.getDefaultOrganization());
WsGroupsResponse response = newRequest()
- .setMediaType(PROTOBUF)
.setParam(PARAM_TEMPLATE_NAME, template.getName())
.setParam(TEXT_QUERY, "-nam")
- .execute()
- .getInputObject(WsGroupsResponse.class);
+ .executeProtobuf(WsGroupsResponse.class);
assertThat(response.getGroupsList()).extracting("name").containsExactly("group-1-name", "group-2-name");
}
@@ -252,11 +242,9 @@ public class TemplateGroupsActionTest extends BasePermissionWsTest<TemplateGroup
loginAsAdmin(db.getDefaultOrganization());
WsGroupsResponse response = newRequest()
- .setMediaType(PROTOBUF)
.setParam(PARAM_TEMPLATE_ID, template.getUuid())
.setParam(TEXT_QUERY, "-name")
- .execute()
- .getInputObject(WsGroupsResponse.class);
+ .executeProtobuf(WsGroupsResponse.class);
assertThat(response.getGroupsList()).extracting("name").containsExactly("group-1-name", "group-2-name", "group-3-name");
assertThat(response.getGroups(0).getPermissionsList()).isEmpty();
@@ -273,11 +261,9 @@ public class TemplateGroupsActionTest extends BasePermissionWsTest<TemplateGroup
loginAsAdmin(db.getDefaultOrganization());
WsGroupsResponse response = newRequest()
- .setMediaType(PROTOBUF)
.setParam(PARAM_TEMPLATE_ID, template.getUuid())
.setParam(TEXT_QUERY, "nyo")
- .execute()
- .getInputObject(WsGroupsResponse.class);
+ .executeProtobuf(WsGroupsResponse.class);
assertThat(response.getGroupsList()).extracting("name").containsExactly("Anyone");
assertThat(response.getGroups(0).getPermissionsList()).isEmpty();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/TemplateUsersActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/TemplateUsersActionTest.java
index 07dc1fa7ef7..69c2eadd95e 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/TemplateUsersActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/TemplateUsersActionTest.java
@@ -43,7 +43,6 @@ import static org.sonar.db.permission.OrganizationPermission.SCAN;
import static org.sonar.db.permission.template.PermissionTemplateTesting.newPermissionTemplateUserDto;
import static org.sonar.db.user.UserTesting.newUserDto;
import static org.sonar.test.JsonAssert.assertJson;
-import static org.sonarqube.ws.MediaTypes.PROTOBUF;
import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PERMISSION;
import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_ID;
import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_NAME;
@@ -89,9 +88,7 @@ public class TemplateUsersActionTest extends BasePermissionWsTest<TemplateUsersA
WsPermissions.UsersWsResponse response = newRequest(null, null)
.setParam(PARAM_TEMPLATE_NAME, template.getName())
- .setMediaType(PROTOBUF)
- .execute()
- .getInputObject(WsPermissions.UsersWsResponse.class);
+ .executeProtobuf(WsPermissions.UsersWsResponse.class);
assertThat(response.getUsersList()).extracting("login").containsExactly("login-1", "login-2", "login-3");
assertThat(response.getUsers(0).getPermissionsList()).containsOnly("issueadmin", "user");
@@ -119,9 +116,7 @@ public class TemplateUsersActionTest extends BasePermissionWsTest<TemplateUsersA
WsPermissions.UsersWsResponse response = newRequest(null, null)
.setParam(PARAM_TEMPLATE_NAME, template.getName())
.setParam(WebService.Param.TEXT_QUERY, "ame-1")
- .setMediaType(PROTOBUF)
- .execute()
- .getInputObject(WsPermissions.UsersWsResponse.class);
+ .executeProtobuf(WsPermissions.UsersWsResponse.class);
assertThat(response.getUsersList()).extracting("login").containsOnly("login-1");
}
@@ -143,8 +138,7 @@ public class TemplateUsersActionTest extends BasePermissionWsTest<TemplateUsersA
loginAsAdmin(db.getDefaultOrganization());
WsPermissions.UsersWsResponse response = newRequest(USER, template.getUuid())
- .setMediaType(PROTOBUF)
- .execute().getInputObject(WsPermissions.UsersWsResponse.class);
+ .executeProtobuf(WsPermissions.UsersWsResponse.class);
assertThat(response.getUsersList()).extracting("login").containsExactly("login-1", "login-2");
assertThat(response.getUsers(0).getPermissionsList()).containsOnly("issueadmin", "user");
assertThat(response.getUsers(1).getPermissionsList()).containsOnly("user");
@@ -171,9 +165,7 @@ public class TemplateUsersActionTest extends BasePermissionWsTest<TemplateUsersA
.setParam(WebService.Param.SELECTED, "all")
.setParam(WebService.Param.PAGE, "2")
.setParam(WebService.Param.PAGE_SIZE, "1")
- .setMediaType(PROTOBUF)
- .execute()
- .getInputObject(WsPermissions.UsersWsResponse.class);
+ .executeProtobuf(WsPermissions.UsersWsResponse.class);
assertThat(response.getUsersList()).extracting("login").containsOnly("login-2");
}
@@ -192,9 +184,7 @@ public class TemplateUsersActionTest extends BasePermissionWsTest<TemplateUsersA
loginAsAdmin(db.getDefaultOrganization());
WsPermissions.UsersWsResponse response = newRequest(null, null)
.setParam(PARAM_TEMPLATE_NAME, template.getName())
- .setMediaType(PROTOBUF)
- .execute()
- .getInputObject(WsPermissions.UsersWsResponse.class);
+ .executeProtobuf(WsPermissions.UsersWsResponse.class);
assertThat(response.getUsersList()).extracting("login").containsExactly("login-1", "login-2", "login-3");
}
@@ -209,9 +199,7 @@ public class TemplateUsersActionTest extends BasePermissionWsTest<TemplateUsersA
loginAsAdmin(db.getDefaultOrganization());
WsPermissions.UsersWsResponse response = newRequest(null, null)
.setParam(PARAM_TEMPLATE_NAME, template.getName())
- .setMediaType(PROTOBUF)
- .execute()
- .getInputObject(WsPermissions.UsersWsResponse.class);
+ .executeProtobuf(WsPermissions.UsersWsResponse.class);
assertThat(response.getUsersList()).isEmpty();
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkUpdateKeyActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkUpdateKeyActionTest.java
index b864a48a446..e053e8e24e7 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkUpdateKeyActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/project/ws/BulkUpdateKeyActionTest.java
@@ -45,7 +45,6 @@ import org.sonar.server.measure.index.ProjectMeasuresIndexDefinition;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.WsProjects.BulkUpdateKeyWsResponse;
import org.sonarqube.ws.WsProjects.BulkUpdateKeyWsResponse.Key;
@@ -280,8 +279,7 @@ public class BulkUpdateKeyActionTest {
}
private BulkUpdateKeyWsResponse call(@Nullable String uuid, @Nullable String key, @Nullable String from, @Nullable String to, @Nullable Boolean dryRun) {
- TestRequest request = ws.newRequest()
- .setMediaType(MediaTypes.PROTOBUF);
+ TestRequest request = ws.newRequest();
if (uuid != null) {
request.setParam(PARAM_PROJECT_ID, uuid);
@@ -299,6 +297,6 @@ public class BulkUpdateKeyActionTest {
request.setParam(PARAM_DRY_RUN, String.valueOf(dryRun));
}
- return request.execute().getInputObject(BulkUpdateKeyWsResponse.class);
+ return request.executeProtobuf(BulkUpdateKeyWsResponse.class);
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/project/ws/CreateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/project/ws/CreateActionTest.java
index d7cb5b24542..6287a347a27 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/project/ws/CreateActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/project/ws/CreateActionTest.java
@@ -40,7 +40,6 @@ import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.WsProjects.CreateWsResponse;
import org.sonarqube.ws.client.project.CreateRequest;
@@ -199,13 +198,12 @@ public class CreateActionTest {
private CreateWsResponse call(CreateRequest request) {
TestRequest httpRequest = ws.newRequest()
- .setMethod(POST.name())
- .setMediaType(MediaTypes.PROTOBUF);
+ .setMethod(POST.name());
setNullable(request.getOrganization(), e -> httpRequest.setParam("organization", e));
setNullable(request.getKey(), e -> httpRequest.setParam("project", e));
setNullable(request.getName(), e -> httpRequest.setParam("name", e));
setNullable(request.getBranch(), e -> httpRequest.setParam("branch", e));
- return httpRequest.execute().getInputObject(CreateWsResponse.class);
+ return httpRequest.executeProtobuf(CreateWsResponse.class);
}
private NewComponent verifyCallToComponentUpdater() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/project/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/project/ws/SearchActionTest.java
index e7ec3da5124..ca81752ed4d 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/project/ws/SearchActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/project/ws/SearchActionTest.java
@@ -60,7 +60,6 @@ import static org.sonar.db.component.ComponentTesting.newView;
import static org.sonar.db.permission.OrganizationPermission.ADMINISTER;
import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_PROFILES;
import static org.sonar.test.JsonAssert.assertJson;
-import static org.sonarqube.ws.MediaTypes.PROTOBUF;
import static org.sonarqube.ws.client.project.ProjectsWsParameters.PARAM_ORGANIZATION;
public class SearchActionTest {
@@ -269,8 +268,7 @@ public class SearchActionTest {
}
private SearchWsResponse call(SearchWsRequest wsRequest) {
- TestRequest request = ws.newRequest()
- .setMediaType(PROTOBUF);
+ TestRequest request = ws.newRequest();
setNullable(wsRequest.getOrganization(), organization -> request.setParam(PARAM_ORGANIZATION, organization));
List<String> qualifiers = wsRequest.getQualifiers();
if (!qualifiers.isEmpty()) {
@@ -279,7 +277,7 @@ public class SearchActionTest {
setNullable(wsRequest.getQuery(), query -> request.setParam(TEXT_QUERY, query));
setNullable(wsRequest.getPage(), page -> request.setParam(PAGE, String.valueOf(page)));
setNullable(wsRequest.getPageSize(), pageSize -> request.setParam(PAGE_SIZE, String.valueOf(pageSize)));
- return request.execute().getInputObject(SearchWsResponse.class);
+ return request.executeProtobuf(SearchWsResponse.class);
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/project/ws/SearchMyProjectsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/project/ws/SearchMyProjectsActionTest.java
index a77f5e9727e..3bd58fcfd7e 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/project/ws/SearchMyProjectsActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/project/ws/SearchMyProjectsActionTest.java
@@ -42,9 +42,7 @@ import org.sonar.db.user.GroupDto;
import org.sonar.db.user.UserDto;
import org.sonar.server.exceptions.UnauthorizedException;
import org.sonar.server.tester.UserSessionRule;
-import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.WsProjects.SearchMyProjectsWsResponse;
import org.sonarqube.ws.WsProjects.SearchMyProjectsWsResponse.Project;
@@ -150,9 +148,10 @@ public class SearchMyProjectsActionTest {
db.users().insertProjectPermissionOnUser(user, UserRole.ADMIN, project);
}
- SearchMyProjectsWsResponse result = call_ws(ws.newRequest()
+ SearchMyProjectsWsResponse result = ws.newRequest()
.setParam(Param.PAGE, "2")
- .setParam(Param.PAGE_SIZE, "3"));
+ .setParam(Param.PAGE_SIZE, "3")
+ .executeProtobuf(SearchMyProjectsWsResponse.class);
assertThat(result.getProjectsCount()).isEqualTo(3);
assertThat(result.getProjectsList()).extracting(Project::getName).containsExactly("project-3", "project-4", "project-5");
@@ -269,13 +268,8 @@ public class SearchMyProjectsActionTest {
}
private SearchMyProjectsWsResponse call_ws() {
- return call_ws(ws.newRequest());
+ return ws.newRequest()
+ .executeProtobuf(SearchMyProjectsWsResponse.class);
}
- private SearchMyProjectsWsResponse call_ws(TestRequest request) {
- return request
- .setMediaType(MediaTypes.PROTOBUF)
- .execute()
- .getInputObject(SearchMyProjectsWsResponse.class);
- }
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/CreateEventActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/CreateEventActionTest.java
index 51798083fda..8424b774e1f 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/CreateEventActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/CreateEventActionTest.java
@@ -360,13 +360,12 @@ public class CreateEventActionTest {
private CreateEventResponse call(CreateEventRequest.Builder requestBuilder) {
CreateEventRequest request = requestBuilder.build();
TestRequest httpRequest = ws.newRequest()
- .setMethod(POST.name())
- .setMediaType(MediaTypes.PROTOBUF);
+ .setMethod(POST.name());
httpRequest.setParam(PARAM_CATEGORY, request.getCategory().name())
.setParam(PARAM_NAME, request.getName())
.setParam(PARAM_ANALYSIS, request.getAnalysis());
- return httpRequest.execute().getInputObject(CreateEventResponse.class);
+ return httpRequest.executeProtobuf(CreateEventResponse.class);
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/SearchActionTest.java
index 44e1af96c89..c214937db6e 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/SearchActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/SearchActionTest.java
@@ -57,7 +57,6 @@ import static org.sonar.db.component.SnapshotTesting.newAnalysis;
import static org.sonar.db.event.EventTesting.newEvent;
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
import static org.sonar.test.JsonAssert.assertJson;
-import static org.sonarqube.ws.MediaTypes.PROTOBUF;
import static org.sonarqube.ws.client.WsRequest.Method.POST;
import static org.sonarqube.ws.client.projectanalysis.EventCategory.OTHER;
import static org.sonarqube.ws.client.projectanalysis.EventCategory.QUALITY_GATE;
@@ -258,13 +257,12 @@ public class SearchActionTest {
private SearchResponse call(SearchRequest wsRequest) {
TestRequest request = ws.newRequest()
- .setMediaType(PROTOBUF)
.setMethod(POST.name());
setNullable(wsRequest.getProject(), project -> request.setParam(PARAM_PROJECT, project));
setNullable(wsRequest.getCategory(), category -> request.setParam(PARAM_CATEGORY, category.name()));
setNullable(wsRequest.getPage(), page -> request.setParam(Param.PAGE, String.valueOf(page)));
setNullable(wsRequest.getPageSize(), pageSize -> request.setParam(Param.PAGE_SIZE, String.valueOf(pageSize)));
- return request.execute().getInputObject(SearchResponse.class);
+ return request.executeProtobuf(SearchResponse.class);
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/UpdateEventActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/UpdateEventActionTest.java
index 363b2fe416d..f59583af161 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/UpdateEventActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/UpdateEventActionTest.java
@@ -37,7 +37,6 @@ import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.ProjectAnalyses;
import org.sonarqube.ws.ProjectAnalyses.UpdateEventResponse;
@@ -225,12 +224,11 @@ public class UpdateEventActionTest {
private UpdateEventResponse call(@Nullable String eventUuid, @Nullable String name) {
TestRequest request = ws.newRequest()
- .setMethod(POST.name())
- .setMediaType(MediaTypes.PROTOBUF);
+ .setMethod(POST.name());
setNullable(eventUuid, e -> request.setParam(PARAM_EVENT, e));
setNullable(name, n -> request.setParam(PARAM_NAME, n));
- return request.execute().getInputObject(UpdateEventResponse.class);
+ return request.executeProtobuf(UpdateEventResponse.class);
}
private void logInAsProjectAdministrator(ComponentDto project) {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/projectlink/ws/CreateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/projectlink/ws/CreateActionTest.java
index 752955660bd..2178d69340c 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/projectlink/ws/CreateActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/projectlink/ws/CreateActionTest.java
@@ -45,7 +45,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01;
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
import static org.sonar.test.JsonAssert.assertJson;
-import static org.sonarqube.ws.MediaTypes.PROTOBUF;
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_NAME;
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_PROJECT_ID;
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_PROJECT_KEY;
@@ -84,11 +83,11 @@ public class CreateActionTest {
logInAsProjectAdministrator(project);
String result = ws.newRequest()
- .setMethod("POST")
- .setParam(PARAM_PROJECT_KEY, project.key())
- .setParam(PARAM_NAME, "Custom")
- .setParam(PARAM_URL, "http://example.org")
- .execute().getInput();
+ .setMethod("POST")
+ .setParam(PARAM_PROJECT_KEY, project.key())
+ .setParam(PARAM_NAME, "Custom")
+ .setParam(PARAM_URL, "http://example.org")
+ .execute().getInput();
assertJson(result).ignoreFields("id").isSimilarTo(getClass().getResource("create-example.json"));
}
@@ -99,11 +98,11 @@ public class CreateActionTest {
logInAsProjectAdministrator(project);
String result = ws.newRequest()
- .setMethod("POST")
- .setParam(PARAM_PROJECT_ID, project.uuid())
- .setParam(PARAM_NAME, "Custom")
- .setParam(PARAM_URL, "http://example.org")
- .execute().getInput();
+ .setMethod("POST")
+ .setParam(PARAM_PROJECT_ID, project.uuid())
+ .setParam(PARAM_NAME, "Custom")
+ .setParam(PARAM_URL, "http://example.org")
+ .execute().getInput();
assertJson(result).ignoreFields("id").isSimilarTo(getClass().getResource("create-example.json"));
}
@@ -130,48 +129,48 @@ public class CreateActionTest {
expectedException.expect(IllegalArgumentException.class);
ws.newRequest()
- .setParam(PARAM_PROJECT_KEY, "unknown")
- .setParam(PARAM_URL, "http://example.org")
- .execute();
+ .setParam(PARAM_PROJECT_KEY, "unknown")
+ .setParam(PARAM_URL, "http://example.org")
+ .execute();
}
@Test
public void fail_if_long_name() {
expectedException.expect(IllegalArgumentException.class);
ws.newRequest()
- .setParam(PARAM_PROJECT_KEY, "unknown")
- .setParam(PARAM_NAME, StringUtils.leftPad("", 129, "*"))
- .setParam(PARAM_URL, "http://example.org")
- .execute();
+ .setParam(PARAM_PROJECT_KEY, "unknown")
+ .setParam(PARAM_NAME, StringUtils.leftPad("", 129, "*"))
+ .setParam(PARAM_URL, "http://example.org")
+ .execute();
}
@Test
public void fail_if_no_url() {
expectedException.expect(IllegalArgumentException.class);
ws.newRequest()
- .setParam(PARAM_PROJECT_KEY, "unknown")
- .setParam(PARAM_NAME, "Custom")
- .execute();
+ .setParam(PARAM_PROJECT_KEY, "unknown")
+ .setParam(PARAM_NAME, "Custom")
+ .execute();
}
@Test
public void fail_if_long_url() {
expectedException.expect(IllegalArgumentException.class);
ws.newRequest()
- .setParam(PARAM_PROJECT_KEY, "unknown")
- .setParam(PARAM_NAME, "random")
- .setParam(PARAM_URL, StringUtils.leftPad("", 2049, "*"))
- .execute();
+ .setParam(PARAM_PROJECT_KEY, "unknown")
+ .setParam(PARAM_NAME, "random")
+ .setParam(PARAM_URL, StringUtils.leftPad("", 2049, "*"))
+ .execute();
}
@Test
public void fail_when_no_project() {
expectedException.expect(NotFoundException.class);
ws.newRequest()
- .setParam(PARAM_PROJECT_KEY, "unknown")
- .setParam(PARAM_NAME, "Custom")
- .setParam(PARAM_URL, "http://example.org")
- .execute();
+ .setParam(PARAM_PROJECT_KEY, "unknown")
+ .setParam(PARAM_NAME, "Custom")
+ .setParam(PARAM_URL, "http://example.org")
+ .execute();
}
@Test
@@ -181,10 +180,10 @@ public class CreateActionTest {
expectedException.expect(ForbiddenException.class);
ws.newRequest()
- .setParam(PARAM_PROJECT_KEY, PROJECT_KEY)
- .setParam(PARAM_NAME, "Custom")
- .setParam(PARAM_URL, "http://example.org")
- .execute();
+ .setParam(PARAM_PROJECT_KEY, PROJECT_KEY)
+ .setParam(PARAM_NAME, "Custom")
+ .setParam(PARAM_URL, "http://example.org")
+ .execute();
}
@Test
@@ -194,27 +193,25 @@ public class CreateActionTest {
expectedException.expect(ForbiddenException.class);
ws.newRequest()
- .setParam(PARAM_PROJECT_KEY, PROJECT_KEY)
- .setParam(PARAM_NAME, "Custom")
- .setParam(PARAM_URL, "http://example.org")
- .execute();
+ .setParam(PARAM_PROJECT_KEY, PROJECT_KEY)
+ .setParam(PARAM_NAME, "Custom")
+ .setParam(PARAM_URL, "http://example.org")
+ .execute();
}
private ComponentDto insertProject() {
OrganizationDto org = db.organizations().insert();
return db.components().insertComponent(
- ComponentTesting.newProjectDto(org, PROJECT_UUID).setKey(PROJECT_KEY));
+ ComponentTesting.newProjectDto(org, PROJECT_UUID).setKey(PROJECT_KEY));
}
private void createAndTest(ComponentDto project, String name, String url, String type) throws IOException {
WsProjectLinks.CreateWsResponse response = ws.newRequest()
- .setMethod("POST")
- .setParam(PARAM_PROJECT_KEY, project.key())
- .setParam(PARAM_NAME, name)
- .setParam(PARAM_URL, url)
- .setMediaType(PROTOBUF)
- .execute()
- .getInputObject(WsProjectLinks.CreateWsResponse.class);
+ .setMethod("POST")
+ .setParam(PARAM_PROJECT_KEY, project.key())
+ .setParam(PARAM_NAME, name)
+ .setParam(PARAM_URL, url)
+ .executeProtobuf(WsProjectLinks.CreateWsResponse.class);
long newId = Long.valueOf(response.getLink().getId());
diff --git a/server/sonar-server/src/test/java/org/sonar/server/projectlink/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/projectlink/ws/SearchActionTest.java
index 320ab1d7c09..29ff9d0d6dc 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/projectlink/ws/SearchActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/projectlink/ws/SearchActionTest.java
@@ -46,7 +46,6 @@ import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01;
import static org.sonar.db.component.ComponentTesting.newProjectDto;
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
import static org.sonar.test.JsonAssert.assertJson;
-import static org.sonarqube.ws.MediaTypes.PROTOBUF;
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_PROJECT_ID;
import static org.sonarqube.ws.client.projectlinks.ProjectLinksWsParameters.PARAM_PROJECT_KEY;
@@ -254,16 +253,13 @@ public class SearchActionTest {
private SearchWsResponse callByKey(String projectKey) throws IOException {
return ws.newRequest()
.setParam(PARAM_PROJECT_KEY, projectKey)
- .setMediaType(PROTOBUF)
- .execute()
- .getInputObject(SearchWsResponse.class);
+ .executeProtobuf(SearchWsResponse.class);
}
private SearchWsResponse callByUuid(String projectUuid) throws IOException {
return ws.newRequest()
.setParam(PARAM_PROJECT_ID, projectUuid)
- .setMediaType(PROTOBUF)
- .execute().getInputObject(SearchWsResponse.class);
+ .executeProtobuf(SearchWsResponse.class);
}
private void checkItWorks(ComponentDto project) throws IOException {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/projecttag/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/projecttag/ws/SearchActionTest.java
index 0693f083309..67b2c9a65b1 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/projecttag/ws/SearchActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/projecttag/ws/SearchActionTest.java
@@ -50,7 +50,6 @@ import static org.sonar.core.util.Protobuf.setNullable;
import static org.sonar.db.component.ComponentTesting.newProjectDto;
import static org.sonar.server.measure.index.ProjectMeasuresIndexDefinition.INDEX_TYPE_PROJECT_MEASURES;
import static org.sonar.test.JsonAssert.assertJson;
-import static org.sonarqube.ws.MediaTypes.PROTOBUF;
public class SearchActionTest {
private static final OrganizationDto ORG = OrganizationTesting.newOrganizationDto();
@@ -133,10 +132,10 @@ public class SearchActionTest {
}
private SearchResponse call(@Nullable String textQuery, @Nullable Integer pageSize) {
- TestRequest request = ws.newRequest().setMediaType(PROTOBUF);
+ TestRequest request = ws.newRequest();
setNullable(textQuery, s -> request.setParam("q", s));
setNullable(pageSize, ps -> request.setParam("ps", ps.toString()));
- return request.execute().getInputObject(SearchResponse.class);
+ return request.executeProtobuf(SearchResponse.class);
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/AppActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/AppActionTest.java
index 73fda5245ce..5e666e3fd9d 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/AppActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/AppActionTest.java
@@ -32,7 +32,6 @@ import org.sonar.server.organization.DefaultOrganizationProvider;
import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.WsQualityGates.AppWsResponse;
import static org.assertj.core.api.Assertions.assertThat;
@@ -222,6 +221,6 @@ public class AppActionTest {
}
private AppWsResponse executeRequest() {
- return ws.newRequest().setMediaType(MediaTypes.PROTOBUF).execute().getInputObject(AppWsResponse.class);
+ return ws.newRequest().executeProtobuf(AppWsResponse.class);
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/CreateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/CreateActionTest.java
index 1ce68f17aad..9f4c68ea2f7 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/CreateActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/CreateActionTest.java
@@ -34,7 +34,6 @@ import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.qualitygate.QualityGateUpdater;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.WsQualityGates.CreateWsResponse;
import static org.assertj.core.api.Assertions.assertThat;
@@ -105,10 +104,8 @@ public class CreateActionTest {
private CreateWsResponse executeRequest(String name) {
return ws.newRequest()
- .setMediaType(MediaTypes.PROTOBUF)
.setParam("name", name)
- .execute()
- .getInputObject(CreateWsResponse.class);
+ .executeProtobuf(CreateWsResponse.class);
}
private void logInAsQualityGateAdmin() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/CreateConditionActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/CreateConditionActionTest.java
index 93bf7524942..3f9a127fcdb 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/CreateConditionActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/CreateConditionActionTest.java
@@ -182,7 +182,6 @@ public class CreateConditionActionTest {
private CreateConditionWsResponse executeRequest(long qualityProfileId, String metricKey, String operator, @Nullable String warning, @Nullable String error,
@Nullable Integer period) {
TestRequest request = ws.newRequest()
- .setMediaType(MediaTypes.PROTOBUF)
.setParam(PARAM_GATE_ID, Long.toString(qualityProfileId))
.setParam(PARAM_METRIC, metricKey)
.setParam(PARAM_OPERATOR, operator);
@@ -195,7 +194,7 @@ public class CreateConditionActionTest {
if (period != null) {
request.setParam(PARAM_PERIOD, Integer.toString(period));
}
- return request.execute().getInputObject(CreateConditionWsResponse.class);
+ return request.executeProtobuf(CreateConditionWsResponse.class);
}
private void logInAsQualityGateAdmin() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/GetByProjectActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/GetByProjectActionTest.java
index d766bbbd328..40a633efb4b 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/GetByProjectActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/GetByProjectActionTest.java
@@ -199,8 +199,7 @@ public class GetByProjectActionTest {
}
private GetByProjectWsResponse call(@Nullable String projectUuid, @Nullable String projectKey) {
- TestRequest request = ws.newRequest()
- .setMediaType(MediaTypes.PROTOBUF);
+ TestRequest request = ws.newRequest();
if (projectUuid != null) {
request.setParam(PARAM_PROJECT_ID, projectUuid);
@@ -210,7 +209,7 @@ public class GetByProjectActionTest {
request.setParam(PARAM_PROJECT_KEY, projectKey);
}
- return request.execute().getInputObject(GetByProjectWsResponse.class);
+ return request.executeProtobuf(GetByProjectWsResponse.class);
}
private QualityGateDto insertQualityGate(String name) {
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 5f019da6d98..f169360e8b5 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
@@ -40,7 +40,6 @@ import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.WsQualityGates.ProjectStatusWsResponse;
import org.sonarqube.ws.WsQualityGates.ProjectStatusWsResponse.Status;
@@ -238,16 +237,13 @@ public class ProjectStatusActionTest {
private ProjectStatusWsResponse call(String taskId) {
return ws.newRequest()
.setParam("analysisId", taskId)
- .setMediaType(MediaTypes.PROTOBUF)
- .execute()
- .getInputObject(ProjectStatusWsResponse.class);
+ .executeProtobuf(ProjectStatusWsResponse.class);
}
private ProjectStatusWsResponse callByProjectUuid(String projectUuid) {
return ws.newRequest()
.setParam(PARAM_PROJECT_ID, projectUuid)
- .setMediaType(MediaTypes.PROTOBUF)
- .execute().getInputObject(ProjectStatusWsResponse.class);
+ .executeProtobuf(ProjectStatusWsResponse.class);
}
private void logInAsSystemAdministrator() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/UpdateConditionActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/UpdateConditionActionTest.java
index eba7701e755..208d770fc5b 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/UpdateConditionActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/UpdateConditionActionTest.java
@@ -190,7 +190,6 @@ public class UpdateConditionActionTest {
private CreateConditionWsResponse executeRequest(long conditionId, String metricKey, String operator, @Nullable String warning, @Nullable String error,
@Nullable Integer period) {
TestRequest request = ws.newRequest()
- .setMediaType(MediaTypes.PROTOBUF)
.setParam(PARAM_ID, Long.toString(conditionId))
.setParam(PARAM_METRIC, metricKey)
.setParam(PARAM_OPERATOR, operator);
@@ -203,7 +202,7 @@ public class UpdateConditionActionTest {
if (period != null) {
request.setParam(PARAM_PERIOD, Integer.toString(period));
}
- return request.execute().getInputObject(CreateConditionWsResponse.class);
+ return request.executeProtobuf(CreateConditionWsResponse.class);
}
private void logInAsQualityGateAdmin() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java
index 9f98a42fa25..0dd18acd492 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/CreateActionTest.java
@@ -161,7 +161,6 @@ public class CreateActionTest {
String orgKey = organization.getKey();
TestRequest request = wsTester.newRequest()
- .setMediaType(MediaTypes.PROTOBUF)
.setParam("organization", orgKey)
.setParam("name", "Profile with messages")
.setParam("language", XOO_LANGUAGE)
@@ -180,7 +179,6 @@ public class CreateActionTest {
OrganizationDto organization1 = dbTester.organizations().insert();
logInAsQProfileAdministrator(organization1);
TestRequest request1 = wsTester.newRequest()
- .setMediaType(MediaTypes.PROTOBUF)
.setParam("organization", organization1.getKey())
.setParam("name", profileName)
.setParam("language", XOO_LANGUAGE);
@@ -190,7 +188,6 @@ public class CreateActionTest {
OrganizationDto organization2 = dbTester.organizations().insert();
logInAsQProfileAdministrator(organization2);
TestRequest request2 = wsTester.newRequest()
- .setMediaType(MediaTypes.PROTOBUF)
.setParam("organization", organization2.getKey())
.setParam("name", profileName)
.setParam("language", XOO_LANGUAGE);
@@ -249,7 +246,6 @@ public class CreateActionTest {
private CreateWsResponse executeRequest(String name, String language, Map<String, String> xmls) {
TestRequest request = wsTester.newRequest()
- .setMediaType(MediaTypes.PROTOBUF)
.setParam("organization", organization.getKey())
.setParam("name", name)
.setParam("language", language);
@@ -260,7 +256,7 @@ public class CreateActionTest {
}
private CreateWsResponse executeRequest(TestRequest request) {
- return request.execute().getInputObject(CreateWsResponse.class);
+ return request.executeProtobuf(CreateWsResponse.class);
}
private ProfileImporter[] createImporters() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java
index 93e5ab9b57e..f8ac75c9cdc 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/qualityprofile/ws/SearchActionTest.java
@@ -51,9 +51,7 @@ import org.sonar.server.organization.DefaultOrganizationProvider;
import org.sonar.server.organization.TestDefaultOrganizationProvider;
import org.sonar.server.qualityprofile.QProfileLookup;
import org.sonar.server.tester.UserSessionRule;
-import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.QualityProfiles;
import org.sonarqube.ws.QualityProfiles.SearchWsResponse;
import org.sonarqube.ws.QualityProfiles.SearchWsResponse.QualityProfile;
@@ -218,7 +216,8 @@ public class SearchActionTest {
.setLastUsed(time)
.setUserUpdatedAt(time));
- SearchWsResponse result = call(ws.newRequest());
+ SearchWsResponse result = ws.newRequest()
+ .executeProtobuf(SearchWsResponse.class);
assertThat(result.getProfilesCount()).isEqualTo(1);
assertThat(result.getProfiles(0).getRulesUpdatedAt()).isEqualTo("2016-12-21T19:10:03+0100");
@@ -265,7 +264,8 @@ public class SearchActionTest {
qualityProfileDb.insertQualityProfiles(qualityProfileOnXoo1, qualityProfileOnXoo2, anotherQualityProfileOnXoo1);
qualityProfileDb.insertProjectWithQualityProfileAssociations(project, qualityProfileOnXoo1, qualityProfileOnXoo2);
- SearchWsResponse result = call(ws.newRequest().setParam(PARAM_PROJECT_KEY, project.key()));
+ SearchWsResponse result = ws.newRequest().setParam(PARAM_PROJECT_KEY, project.key())
+ .executeProtobuf(SearchWsResponse.class);
assertThat(result.getProfilesList())
.hasSize(2)
@@ -463,13 +463,6 @@ public class SearchActionTest {
return underTest.doHandle(request);
}
- private SearchWsResponse call(TestRequest request) {
- return request
- .setMediaType(MediaTypes.PROTOBUF)
- .execute()
- .getInputObject(SearchWsResponse.class);
- }
-
private OrganizationDto getDefaultOrganization() {
return db.getDefaultOrganization();
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/root/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/root/ws/SearchActionTest.java
index 9dcbdf9382e..a47344191e7 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/root/ws/SearchActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/root/ws/SearchActionTest.java
@@ -142,9 +142,7 @@ public class SearchActionTest {
private List<WsRoot.Root> executeRequest() {
return wsTester.newRequest()
- .setMediaType(MediaTypes.PROTOBUF)
- .execute()
- .getInputObject(WsRoot.SearchWsResponse.class)
+ .executeProtobuf(WsRoot.SearchWsResponse.class)
.getRootsList();
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ListActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ListActionTest.java
index 0fc124d5189..731a7b6a7bd 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ListActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ListActionTest.java
@@ -26,8 +26,6 @@ import org.sonar.api.server.ws.WebService;
import org.sonar.api.utils.System2;
import org.sonar.db.DbTester;
import org.sonar.db.rule.RuleTesting;
-import org.sonarqube.ws.MediaTypes;
-import org.sonar.server.ws.TestResponse;
import org.sonar.server.ws.WsActionTester;
import org.sonarqube.ws.Rules;
@@ -54,12 +52,9 @@ public class ListActionTest {
dbTester.rules().insert(RuleTesting.newRule(RuleKey.of("java", "S002")).setConfigKey("I002").setName("Rule Two"));
dbTester.getSession().commit();
- TestResponse response = tester.newRequest()
- .setMediaType(MediaTypes.PROTOBUF)
- .execute();
+ Rules.ListResponse listResponse = tester.newRequest()
+ .executeProtobuf(Rules.ListResponse.class);
- assertThat(response.getMediaType()).isEqualTo(MediaTypes.PROTOBUF);
- Rules.ListResponse listResponse = response.getInputObject(Rules.ListResponse.class);
assertThat(listResponse.getRulesCount()).isEqualTo(2);
assertThat(listResponse.getRules(0).getKey()).isEqualTo("S001");
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionTest.java
index 8b0cafe2603..7b51abbf0cd 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/SearchActionTest.java
@@ -54,7 +54,6 @@ import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.sonar.db.rule.RuleTesting.setSystemTags;
import static org.sonar.db.rule.RuleTesting.setTags;
-import static org.sonarqube.ws.MediaTypes.PROTOBUF;
public class SearchActionTest {
@@ -91,9 +90,7 @@ public class SearchActionTest {
doReturn("interpreted").when(macroInterpreter).interpret(anyString());
SearchResponse result = actionTester.newRequest()
- .setMediaType(PROTOBUF)
- .execute()
- .getInputObject(SearchResponse.class);
+ .executeProtobuf(SearchResponse.class);
assertThat(result.getRulesList()).extracting(Rule::getKey).containsExactly(rule.getKey().toString());
}
@@ -106,12 +103,10 @@ public class SearchActionTest {
RuleMetadataDto metadata2 = insertMetadata(organization, rule2);
SearchResponse result = actionTester.newRequest()
- .setMediaType(PROTOBUF)
.setParam("f", "repo,name")
.setParam("tags", metadata1.getTags().stream().collect(Collectors.joining(",")))
.setParam("organization", organization.getKey())
- .execute()
- .getInputObject(SearchResponse.class);
+ .executeProtobuf(SearchResponse.class);
assertThat(result.getRulesList()).extracting(Rule::getKey).containsExactly(rule1.getKey().toString());
}
@@ -122,11 +117,9 @@ public class SearchActionTest {
RuleMetadataDto metadata = insertMetadata(organization, rule, setTags("tag2", "tag4", "tag6", "tag8", "tagA"));
SearchResponse result = actionTester.newRequest()
- .setMediaType(PROTOBUF)
.setParam("facets", "tags")
.setParam("organization", organization.getKey())
- .execute()
- .getInputObject(SearchResponse.class);
+ .executeProtobuf(SearchResponse.class);
assertThat(result.getFacets().getFacets(0).getValuesList()).extracting(v -> entry(v.getVal(), v.getCount()))
.containsExactly(entry("tag1", 1L), entry("tag2", 1L), entry("tag3", 1L), entry("tag4", 1L), entry("tag5", 1L), entry("tag6", 1L), entry("tag7", 1L), entry("tag8", 1L),
entry("tag9", 1L), entry("tagA", 1L));
@@ -137,11 +130,9 @@ public class SearchActionTest {
insertRuleDefinition(setSystemTags("tag1", "tag2", "tag3", "tag4", "tag5", "tag6", "tag7", "tag8", "tag9", "tagA", "x"));
SearchResponse result = actionTester.newRequest()
- .setMediaType(PROTOBUF)
.setParam("facets", "tags")
.setParam("tags", "x")
- .execute()
- .getInputObject(SearchResponse.class);
+ .executeProtobuf(SearchResponse.class);
assertThat(result.getFacets().getFacets(0).getValuesList()).extracting(v -> entry(v.getVal(), v.getCount())).contains(entry("x", 1L));
}
@@ -150,11 +141,9 @@ public class SearchActionTest {
insertRuleDefinition(setSystemTags("tag1", "tag2", "tag3", "tag4", "tag5", "tag6", "tag7", "tag8", "tag9", "tagA"));
SearchResponse result = actionTester.newRequest()
- .setMediaType(PROTOBUF)
.setParam("facets", "tags")
.setParam("tags", "x")
- .execute()
- .getInputObject(SearchResponse.class);
+ .executeProtobuf(SearchResponse.class);
assertThat(result.getFacets().getFacets(0).getValuesList()).extracting(v -> entry(v.getVal(), v.getCount())).contains(entry("x", 0L));
}
@@ -165,11 +154,9 @@ public class SearchActionTest {
RuleMetadataDto metadata = insertMetadata(organization, rule, setTags("tag1", "tag2"));
SearchResponse result = actionTester.newRequest()
- .setMediaType(PROTOBUF)
.setParam("f", "tags")
.setParam("organization", organization.getKey())
- .execute()
- .getInputObject(SearchResponse.class);
+ .executeProtobuf(SearchResponse.class);
assertThat(result.getRulesList()).extracting(Rule::getKey).containsExactly(rule.getKey().toString());
assertThat(result.getRulesList())
.extracting(Rule::getTags).flatExtracting(Rules.Tags::getTagsList)
@@ -198,10 +185,8 @@ public class SearchActionTest {
@SafeVarargs
private final <T> void checkField(RuleDefinitionDto rule, String fieldName, Extractor<Rule, T> responseExtractor, T... expected) throws IOException {
SearchResponse result = actionTester.newRequest()
- .setMediaType(PROTOBUF)
.setParam("f", fieldName)
- .execute()
- .getInputObject(SearchResponse.class);
+ .executeProtobuf(SearchResponse.class);
assertThat(result.getRulesList()).extracting(Rule::getKey).containsExactly(rule.getKey().toString());
assertThat(result.getRulesList()).extracting(responseExtractor).containsExactly(expected);
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ShowActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ShowActionTest.java
index 371872a78dd..bc672870c34 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ShowActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/ShowActionTest.java
@@ -96,10 +96,8 @@ public class ShowActionTest {
RuleDefinitionDto rule = insertRule();
Rules.ShowResponse result = actionTester.newRequest()
- .setMediaType(PROTOBUF)
.setParam(PARAM_KEY, rule.getKey().toString())
- .execute()
- .getInputObject(Rules.ShowResponse.class);
+ .executeProtobuf(Rules.ShowResponse.class);
assertThat(result.getRule()).extracting(Rule::getKey).containsExactly(rule.getKey().toString());
}
@@ -109,10 +107,8 @@ public class ShowActionTest {
RuleMetadataDto metadata = insertMetadata(dbTester.getDefaultOrganization(), rule, setTags("tag1", "tag2"));
Rules.ShowResponse result = actionTester.newRequest()
- .setMediaType(PROTOBUF)
.setParam(PARAM_KEY, rule.getKey().toString())
- .execute()
- .getInputObject(Rules.ShowResponse.class);
+ .executeProtobuf(Rules.ShowResponse.class);
assertThat(result.getRule().getTags().getTagsList())
.containsExactly(metadata.getTags().toArray(new String[0]));
}
@@ -124,11 +120,9 @@ public class ShowActionTest {
RuleMetadataDto metadata = insertMetadata(organization, rule, setTags("tag1", "tag2"));
Rules.ShowResponse result = actionTester.newRequest()
- .setMediaType(PROTOBUF)
.setParam(PARAM_KEY, rule.getKey().toString())
.setParam(PARAM_ORGANIZATION, organization.getKey())
- .execute()
- .getInputObject(Rules.ShowResponse.class);
+ .executeProtobuf(Rules.ShowResponse.class);
assertThat(result.getRule().getTags().getTagsList())
.containsExactly(metadata.getTags().toArray(new String[0]));
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/UpdateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/UpdateActionTest.java
index 8c6cb95d8bf..168585c18bc 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/rule/ws/UpdateActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/rule/ws/UpdateActionTest.java
@@ -41,8 +41,6 @@ import org.sonar.server.rule.index.RuleIndexDefinition;
import org.sonar.server.rule.index.RuleIndexer;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.text.MacroInterpreter;
-import org.sonar.server.ws.TestRequest;
-import org.sonar.server.ws.TestResponse;
import org.sonar.server.ws.WsAction;
import org.sonar.server.ws.WsActionTester;
import org.sonarqube.ws.Rules;
@@ -65,7 +63,6 @@ import static org.sonar.server.rule.ws.UpdateAction.PARAM_REMEDIATION_FN_BASE_EF
import static org.sonar.server.rule.ws.UpdateAction.PARAM_REMEDIATION_FN_GAP_MULTIPLIER;
import static org.sonar.server.rule.ws.UpdateAction.PARAM_REMEDIATION_FN_TYPE;
import static org.sonar.server.rule.ws.UpdateAction.PARAM_TAGS;
-import static org.sonarqube.ws.MediaTypes.PROTOBUF;
public class UpdateActionTest {
@@ -104,12 +101,10 @@ public class UpdateActionTest {
RuleDefinitionDto rule = dbTester.rules().insert(setSystemTags("stag1", "stag2"));
dbTester.rules().insertOrUpdateMetadata(rule, defaultOrganization, setTags("tag1", "tag2"));
- TestRequest request = actionTester.newRequest().setMethod("POST")
- .setMediaType(PROTOBUF)
+ Rules.UpdateResponse result = actionTester.newRequest().setMethod("POST")
.setParam(PARAM_KEY, rule.getKey().toString())
- .setParam(PARAM_TAGS, "tag2,tag3");
- TestResponse response = request.execute();
- Rules.UpdateResponse result = response.getInputObject(Rules.UpdateResponse.class);
+ .setParam(PARAM_TAGS, "tag2,tag3")
+ .executeProtobuf(Rules.UpdateResponse.class);
Rules.Rule updatedRule = result.getRule();
assertThat(updatedRule).isNotNull();
@@ -128,13 +123,11 @@ public class UpdateActionTest {
RuleDefinitionDto rule = dbTester.rules().insert(setSystemTags("stag1", "stag2"));
dbTester.rules().insertOrUpdateMetadata(rule, organization, setTags("tagAlt1", "tagAlt2"));
- TestRequest request = actionTester.newRequest().setMethod("POST")
- .setMediaType(PROTOBUF)
+ Rules.UpdateResponse result = actionTester.newRequest().setMethod("POST")
.setParam(PARAM_KEY, rule.getKey().toString())
.setParam(PARAM_TAGS, "tag2,tag3")
- .setParam(PARAM_ORGANIZATION, organization.getKey());
- TestResponse response = request.execute();
- Rules.UpdateResponse result = response.getInputObject(Rules.UpdateResponse.class);
+ .setParam(PARAM_ORGANIZATION, organization.getKey())
+ .executeProtobuf(Rules.UpdateResponse.class);
Rules.Rule updatedRule = result.getRule();
assertThat(updatedRule).isNotNull();
@@ -165,15 +158,13 @@ public class UpdateActionTest {
String newMultiplier = "15d";
String newEffort = "5min";
- TestRequest request = actionTester.newRequest().setMethod("POST")
- .setMediaType(PROTOBUF)
+ Rules.UpdateResponse result = actionTester.newRequest().setMethod("POST")
.setParam("key", rule.getKey().toString())
.setParam(PARAM_ORGANIZATION, organization.getKey())
.setParam(PARAM_REMEDIATION_FN_TYPE, newOffset)
.setParam(PARAM_REMEDIATION_FN_GAP_MULTIPLIER, newMultiplier)
- .setParam(PARAM_REMEDIATION_FN_BASE_EFFORT, newEffort);
- TestResponse response = request.execute();
- Rules.UpdateResponse result = response.getInputObject(Rules.UpdateResponse.class);
+ .setParam(PARAM_REMEDIATION_FN_BASE_EFFORT, newEffort)
+ .executeProtobuf(Rules.UpdateResponse.class);
Rules.Rule updatedRule = result.getRule();
assertThat(updatedRule).isNotNull();
@@ -210,14 +201,12 @@ public class UpdateActionTest {
String newCoeff = "11d";
String newOffset = "6min";
- TestRequest request = actionTester.newRequest().setMethod("POST")
- .setMediaType(PROTOBUF)
+ Rules.UpdateResponse result = actionTester.newRequest().setMethod("POST")
.setParam(PARAM_KEY, rule.getKey().toString())
.setParam(DEPRECATED_PARAM_REMEDIATION_FN_TYPE, newType)
.setParam(DEPRECATED_PARAM_REMEDIATION_FN_COEFF, newCoeff)
- .setParam(DEPRECATED_PARAM_REMEDIATION_FN_OFFSET, newOffset);
- TestResponse response = request.execute();
- Rules.UpdateResponse result = response.getInputObject(Rules.UpdateResponse.class);
+ .setParam(DEPRECATED_PARAM_REMEDIATION_FN_OFFSET, newOffset)
+ .executeProtobuf(Rules.UpdateResponse.class);
Rules.Rule updatedRule = result.getRule();
assertThat(updatedRule).isNotNull();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/serverid/ws/GenerateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/serverid/ws/GenerateActionTest.java
index e8fd2035029..474b76fce26 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/serverid/ws/GenerateActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/serverid/ws/GenerateActionTest.java
@@ -46,7 +46,6 @@ import static org.sonar.api.CoreProperties.SERVER_ID_IP_ADDRESS;
import static org.sonar.server.serverid.ws.GenerateAction.PARAM_IP;
import static org.sonar.server.serverid.ws.GenerateAction.PARAM_ORGANIZATION;
import static org.sonar.test.JsonAssert.assertJson;
-import static org.sonarqube.ws.MediaTypes.PROTOBUF;
public class GenerateActionTest {
@@ -169,8 +168,7 @@ public class GenerateActionTest {
private GenerateWsResponse call(@Nullable String organization, @Nullable String ip) {
TestRequest request = ws.newRequest()
- .setMethod("POST")
- .setMediaType(PROTOBUF);
+ .setMethod("POST");
if (organization != null) {
request.setParam(PARAM_ORGANIZATION, organization);
@@ -180,7 +178,7 @@ public class GenerateActionTest {
request.setParam(PARAM_IP, ip);
}
- return request.execute().getInputObject(GenerateWsResponse.class);
+ return request.executeProtobuf(GenerateWsResponse.class);
}
private void logInAsSystemAdministrator() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/serverid/ws/ShowActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/serverid/ws/ShowActionTest.java
index 0205a18aeaa..330698bc2e6 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/serverid/ws/ShowActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/serverid/ws/ShowActionTest.java
@@ -36,7 +36,6 @@ import org.sonar.server.platform.ServerIdGenerator;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.WsActionTester;
import org.sonar.test.JsonAssert;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.ServerId.ShowWsResponse;
import static org.assertj.core.api.Assertions.assertThat;
@@ -193,9 +192,7 @@ public class ShowActionTest {
private ShowWsResponse executeRequest() {
return ws.newRequest()
- .setMediaType(MediaTypes.PROTOBUF)
- .execute()
- .getInputObject(ShowWsResponse.class);
+ .executeProtobuf(ShowWsResponse.class);
}
private void logInAsSystemAdministrator() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/setting/ws/CheckSecretKeyActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/setting/ws/CheckSecretKeyActionTest.java
index b0f2bcbc4bb..3aeceb8710e 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/setting/ws/CheckSecretKeyActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/setting/ws/CheckSecretKeyActionTest.java
@@ -33,7 +33,6 @@ import org.sonar.api.server.ws.WebService;
import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.Settings.CheckSecretKeyWsResponse;
import static org.assertj.core.api.Assertions.assertThat;
@@ -100,10 +99,8 @@ public class CheckSecretKeyActionTest {
private CheckSecretKeyWsResponse call() {
return ws.newRequest()
- .setMediaType(MediaTypes.PROTOBUF)
.setMethod("GET")
- .execute()
- .getInputObject(CheckSecretKeyWsResponse.class);
+ .executeProtobuf(CheckSecretKeyWsResponse.class);
}
private void logInAsSystemAdministrator() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/setting/ws/EncryptActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/setting/ws/EncryptActionTest.java
index 251047ab356..4798ed07c72 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/setting/ws/EncryptActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/setting/ws/EncryptActionTest.java
@@ -36,7 +36,6 @@ import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.Settings.EncryptWsResponse;
import static org.assertj.core.api.Assertions.assertThat;
@@ -138,14 +137,13 @@ public class EncryptActionTest {
private EncryptWsResponse call(@Nullable String value) {
TestRequest request = ws.newRequest()
- .setMediaType(MediaTypes.PROTOBUF)
.setMethod("POST");
if (value != null) {
request.setParam(PARAM_VALUE, value);
}
- return request.execute().getInputObject(EncryptWsResponse.class);
+ return request.executeProtobuf(EncryptWsResponse.class);
}
private void logInAsSystemAdministrator() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/setting/ws/GenerateSecretKeyActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/setting/ws/GenerateSecretKeyActionTest.java
index aa51af733af..f91fa01fe2b 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/setting/ws/GenerateSecretKeyActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/setting/ws/GenerateSecretKeyActionTest.java
@@ -88,10 +88,8 @@ public class GenerateSecretKeyActionTest {
private GenerateSecretKeyWsResponse call() {
return ws.newRequest()
- .setMediaType(MediaTypes.PROTOBUF)
.setMethod("GET")
- .execute()
- .getInputObject(GenerateSecretKeyWsResponse.class);
+ .executeProtobuf(GenerateSecretKeyWsResponse.class);
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/setting/ws/ListDefinitionsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/setting/ws/ListDefinitionsActionTest.java
index f5fca95f9cd..8abc30b9bbd 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/setting/ws/ListDefinitionsActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/setting/ws/ListDefinitionsActionTest.java
@@ -43,7 +43,6 @@ import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
import org.sonar.test.JsonAssert;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.Settings;
import org.sonarqube.ws.Settings.ListDefinitionsWsResponse;
@@ -458,12 +457,11 @@ public class ListDefinitionsActionTest {
}
private ListDefinitionsWsResponse executeRequest(@Nullable String key) {
- TestRequest request = ws.newRequest()
- .setMediaType(MediaTypes.PROTOBUF);
+ TestRequest request = ws.newRequest();
if (key != null) {
request.setParam("component", key);
}
- return request.execute().getInputObject(ListDefinitionsWsResponse.class);
+ return request.executeProtobuf(ListDefinitionsWsResponse.class);
}
private void logIn() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/setting/ws/ValuesActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/setting/ws/ValuesActionTest.java
index 4f093965df5..35e0adda7a9 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/setting/ws/ValuesActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/setting/ws/ValuesActionTest.java
@@ -47,7 +47,6 @@ import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
import org.sonar.test.JsonAssert;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.Settings;
import org.sonarqube.ws.Settings.ValuesWsResponse;
@@ -804,15 +803,14 @@ public class ValuesActionTest {
}
private ValuesWsResponse executeRequest(@Nullable String componentKey, String... keys) {
- TestRequest request = ws.newRequest()
- .setMediaType(MediaTypes.PROTOBUF);
+ TestRequest request = ws.newRequest();
if (keys.length > 0) {
request.setParam("keys", COMMA_JOINER.join(keys));
}
if (componentKey != null) {
request.setParam("component", componentKey);
}
- return request.execute().getInputObject(ValuesWsResponse.class);
+ return request.executeProtobuf(ValuesWsResponse.class);
}
private void logIn() {
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 d19fb81d71c..15acd7da032 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
@@ -39,7 +39,6 @@ import org.sonar.server.test.index.TestIndexer;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.WsTests;
import org.sonarqube.ws.WsTests.ListResponse;
@@ -288,8 +287,7 @@ public class ListActionTest {
private static ListResponse call(TestRequest request) {
return request
- .setMediaType(MediaTypes.PROTOBUF)
- .execute().getInputObject(ListResponse.class);
+ .executeProtobuf(ListResponse.class);
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/ws/CreateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/ws/CreateActionTest.java
index 6beb175bab5..60fc9a9d4fb 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/user/ws/CreateActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/user/ws/CreateActionTest.java
@@ -50,7 +50,6 @@ import org.sonar.server.user.index.UserIndexer;
import org.sonar.server.usergroups.DefaultGroupFinder;
import org.sonar.server.ws.TestRequest;
import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.WsUsers.CreateWsResponse;
import org.sonarqube.ws.WsUsers.CreateWsResponse.User;
import org.sonarqube.ws.client.user.CreateRequest;
@@ -350,15 +349,14 @@ public class CreateActionTest {
}
private CreateWsResponse call(CreateRequest createRequest) {
- TestRequest request = tester.newRequest()
- .setMediaType(MediaTypes.PROTOBUF);
+ TestRequest request = tester.newRequest();
setNullable(createRequest.getLogin(), e -> request.setParam("login", e));
setNullable(createRequest.getName(), e -> request.setParam("name", e));
setNullable(createRequest.getEmail(), e -> request.setParam("email", e));
setNullable(createRequest.getPassword(), e -> request.setParam("password", e));
setNullable(createRequest.getScmAccounts(), e -> request.setMultiParam("scmAccount", e));
request.setParam("local", createRequest.isLocal() ? "true" : "false");
- return request.execute().getInputObject(CreateWsResponse.class);
+ return request.executeProtobuf(CreateWsResponse.class);
}
private void enableCreatePersonalOrg(boolean flag) {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/user/ws/GroupsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/user/ws/GroupsActionTest.java
index e7f3cd456a6..a29772a55bc 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/user/ws/GroupsActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/user/ws/GroupsActionTest.java
@@ -354,9 +354,7 @@ public class GroupsActionTest {
}
private GroupsWsResponse call(TestRequest request) {
- return request.setMediaType(MediaTypes.PROTOBUF)
- .execute()
- .getInputObject(GroupsWsResponse.class);
+ return request.executeProtobuf(GroupsWsResponse.class);
}
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/usergroups/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/usergroups/ws/SearchActionTest.java
index 82b89aea431..0b20a89e739 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/usergroups/ws/SearchActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/usergroups/ws/SearchActionTest.java
@@ -232,9 +232,7 @@ public class SearchActionTest {
}
private SearchWsResponse call(TestRequest request) {
- return request.setMediaType(MediaTypes.PROTOBUF)
- .execute()
- .getInputObject(SearchWsResponse.class);
+ return request.executeProtobuf(SearchWsResponse.class);
}
private void insertDefaultGroup(OrganizationDto org, String name, int numberOfMembers) {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/usertoken/ws/GenerateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/usertoken/ws/GenerateActionTest.java
index d180ddabdb0..27c0b65fbed 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/usertoken/ws/GenerateActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/usertoken/ws/GenerateActionTest.java
@@ -169,15 +169,12 @@ public class GenerateActionTest {
private GenerateWsResponse newRequest(@Nullable String login, String name) {
TestRequest testRequest = ws.newRequest()
- .setMediaType(MediaTypes.PROTOBUF)
.setParam(PARAM_NAME, name);
if (login != null) {
testRequest.setParam(PARAM_LOGIN, login);
}
- return testRequest
- .execute()
- .getInputObject(GenerateWsResponse.class);
+ return testRequest.executeProtobuf(GenerateWsResponse.class);
}
private void logInAsSystemAdministrator() {
diff --git a/server/sonar-server/src/test/java/org/sonar/server/usertoken/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/usertoken/ws/SearchActionTest.java
index 7613aac66e3..04f78ea535d 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/usertoken/ws/SearchActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/usertoken/ws/SearchActionTest.java
@@ -135,13 +135,12 @@ public class SearchActionTest {
}
private SearchWsResponse newRequest(@Nullable String login) {
- TestRequest testRequest = ws.newRequest()
- .setMediaType(MediaTypes.PROTOBUF);
+ TestRequest testRequest = ws.newRequest();
if (login != null) {
testRequest.setParam(PARAM_LOGIN, login);
}
- return testRequest.execute().getInputObject(SearchWsResponse.class);
+ return testRequest.executeProtobuf(SearchWsResponse.class);
}
private void logInAsSystemAdministrator() {
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 04175ad887b..776af78a28e 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
@@ -35,7 +35,6 @@ import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.exceptions.UnauthorizedException;
import org.sonar.server.tester.UserSessionRule;
import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.MediaTypes;
import org.sonarqube.ws.Webhooks;
import static org.assertj.core.api.Assertions.assertThat;
@@ -86,10 +85,8 @@ public class WebhookDeliveriesActionTest {
userSession.logIn().addProjectUuidPermissions(project.uuid(), UserRole.ADMIN);
Webhooks.DeliveriesWsResponse response = ws.newRequest()
- .setMediaType(MediaTypes.PROTOBUF)
.setParam("componentKey", project.getKey())
- .execute()
- .getInputObject(Webhooks.DeliveriesWsResponse.class);
+ .executeProtobuf(Webhooks.DeliveriesWsResponse.class);
assertThat(response.getDeliveriesCount()).isEqualTo(0);
}
@@ -99,10 +96,8 @@ public class WebhookDeliveriesActionTest {
userSession.logIn().addProjectUuidPermissions(project.uuid(), UserRole.ADMIN);
Webhooks.DeliveriesWsResponse response = ws.newRequest()
- .setMediaType(MediaTypes.PROTOBUF)
.setParam("ceTaskId", "t1")
- .execute()
- .getInputObject(Webhooks.DeliveriesWsResponse.class);
+ .executeProtobuf(Webhooks.DeliveriesWsResponse.class);
assertThat(response.getDeliveriesCount()).isEqualTo(0);
}
@@ -143,10 +138,8 @@ public class WebhookDeliveriesActionTest {
userSession.logIn().addProjectUuidPermissions(UserRole.ADMIN, project.uuid());
Webhooks.DeliveriesWsResponse response = ws.newRequest()
- .setMediaType(MediaTypes.PROTOBUF)
.setParam("ceTaskId", "t1")
- .execute()
- .getInputObject(Webhooks.DeliveriesWsResponse.class);
+ .executeProtobuf(Webhooks.DeliveriesWsResponse.class);
assertThat(response.getDeliveriesCount()).isEqualTo(2);
assertThat(response.getDeliveriesList()).extracting(Webhooks.Delivery::getId).containsOnly(dto1.getUuid(), dto2.getUuid());
}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/webhook/ws/WebhookDeliveryActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/webhook/ws/WebhookDeliveryActionTest.java
index fa96a5db985..353ebe1773c 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/webhook/ws/WebhookDeliveryActionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/webhook/ws/WebhookDeliveryActionTest.java
@@ -135,10 +135,8 @@ public class WebhookDeliveryActionTest {
userSession.logIn().addProjectUuidPermissions(UserRole.ADMIN, project.uuid());
Webhooks.DeliveryWsResponse response = ws.newRequest()
- .setMediaType(MediaTypes.PROTOBUF)
.setParam("deliveryId", dto.getUuid())
- .execute()
- .getInputObject(Webhooks.DeliveryWsResponse.class);
+ .executeProtobuf(Webhooks.DeliveryWsResponse.class);
Webhooks.Delivery actual = response.getDelivery();
assertThat(actual.hasHttpStatus()).isFalse();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/ws/TestRequest.java b/server/sonar-server/src/test/java/org/sonar/server/ws/TestRequest.java
index 3c2e9eb92a7..5d173a9071c 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/ws/TestRequest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/ws/TestRequest.java
@@ -23,6 +23,7 @@ import com.google.common.base.Throwables;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.Maps;
+import com.google.protobuf.GeneratedMessage;
import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
@@ -33,6 +34,7 @@ import org.sonar.api.server.ws.internal.ValidatingRequest;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Objects.requireNonNull;
+import static org.sonarqube.ws.MediaTypes.PROTOBUF;
public class TestRequest extends ValidatingRequest {
@@ -135,4 +137,7 @@ public class TestRequest extends ValidatingRequest {
}
}
+ public <T extends GeneratedMessage> T executeProtobuf(Class<T> protobufClass) {
+ return setMediaType(PROTOBUF).execute().getInputObject(protobufClass);
+ }
}