]> source.dussan.org Git - sonarqube.git/commitdiff
Generate client of api/qualitygates and api/roots
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 23 Nov 2017 15:14:40 +0000 (16:14 +0100)
committerDaniel Schwarz <bartfastiel@users.noreply.github.com>
Wed, 29 Nov 2017 19:24:11 +0000 (20:24 +0100)
43 files changed:
server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QGateTester.java
server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/AppAction.java
server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/CreateAction.java
server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/CreateConditionAction.java
server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/GetByProjectAction.java
server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/ProjectStatusAction.java
server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/QualityGateDetailsFormatter.java
server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/UpdateConditionAction.java
server/sonar-server/src/main/java/org/sonar/server/root/ws/SearchAction.java
server/sonar-server/src/main/resources/org/sonar/server/qualitygate/ws/create-condition-example.json [new file with mode: 0644]
server/sonar-server/src/main/resources/org/sonar/server/qualitygate/ws/create-example.json [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/AppActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/CreateActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/CreateConditionActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/GetByProjectActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java
server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/QualityGateDetailsFormatterTest.java
server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/UpdateConditionActionTest.java
server/sonar-server/src/test/java/org/sonar/server/root/ws/SearchActionTest.java
sonar-ws-generated/src/main/java/org/sonarqube/ws/client/batch/BatchService.java
sonar-ws-generated/src/main/java/org/sonarqube/ws/client/ce/ActivityRequest.java
sonar-ws-generated/src/main/java/org/sonarqube/ws/client/components/ComponentsService.java
sonar-ws-generated/src/main/java/org/sonarqube/ws/client/components/ShowRequest.java
sonar-ws-generated/src/main/java/org/sonarqube/ws/client/projectanalyses/ProjectAnalysesService.java
sonar-ws-generated/src/main/java/org/sonarqube/ws/client/qualitygates/QualitygatesService.java
sonar-ws-generated/src/main/java/org/sonarqube/ws/client/roots/RootsService.java
sonar-ws-generated/src/main/protobuf/ws-qualitygates.proto
sonar-ws-generated/src/main/protobuf/ws-root.proto
sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java
sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java
sonar-ws/src/main/java/org/sonarqube/ws/client/root/RootsService.java [deleted file]
sonar-ws/src/main/java/org/sonarqube/ws/client/root/package-info.java [deleted file]
sonar-ws/src/test/java/org/sonarqube/ws/client/root/RootsServiceTest.java [deleted file]
tests/src/test/java/org/sonarqube/tests/organization/OrganizationMembershipUiTest.java
tests/src/test/java/org/sonarqube/tests/organization/OrganizationTest.java
tests/src/test/java/org/sonarqube/tests/organization/RootUserTest.java
tests/src/test/java/org/sonarqube/tests/qualityGate/OrganizationQualityGateForSmallChangesetsTest.java
tests/src/test/java/org/sonarqube/tests/qualityGate/OrganizationQualityGateTest.java
tests/src/test/java/org/sonarqube/tests/qualityGate/QualityGateNotificationTest.java
tests/src/test/java/org/sonarqube/tests/qualityGate/QualityGateOnRatingMeasuresTest.java
tests/src/test/java/org/sonarqube/tests/qualityGate/QualityGateTest.java
tests/src/test/java/org/sonarqube/tests/qualityGate/QualityGateUiTest.java
tests/src/test/java/util/user/UserRule.java

index 5db54abe49f2780c2d106c560f4ad55edb5cfc54..66ef0f036db5f92f88b6e7de4ba2fbccb7aa8452 100644 (file)
@@ -25,7 +25,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
 import org.sonarqube.ws.Projects.CreateWsResponse.Project;
-import org.sonarqube.ws.Qualitygates.CreateWsResponse;
+import org.sonarqube.ws.Qualitygates;
 import org.sonarqube.ws.client.GetRequest;
 import org.sonarqube.ws.client.PostRequest;
 import org.sonarqube.ws.client.qualitygates.CreateRequest;
@@ -53,12 +53,12 @@ public class QGateTester {
       .forEach(qualityGate -> session.wsClient().wsConnector().call(new PostRequest("api/qualitygates/destroy").setParam("id", qualityGate.getId())).failIfNotSuccessful());
   }
 
-  public CreateWsResponse generate() {
+  public Qualitygates.CreateResponse generate() {
     int id = ID_GENERATOR.getAndIncrement();
     return session.wsClient().qualityGates().create(new CreateRequest().setName("QualityGate" + id));
   }
 
-  public void associateProject(CreateWsResponse qualityGate, Project project){
+  public void associateProject(Qualitygates.CreateResponse qualityGate, Project project){
     service().select(new SelectRequest().setGateId(String.valueOf(qualityGate.getId())).setProjectKey(project.getKey()));
   }
 
index f24c9bb7ecf5f2be4dfcd39f34374444f818c4f7..e1851a29d4b9c59d143688110fa53abe455d25d8 100644 (file)
@@ -30,13 +30,13 @@ import org.sonar.db.metric.MetricDto;
 import org.sonar.server.organization.DefaultOrganizationProvider;
 import org.sonar.db.permission.OrganizationPermission;
 import org.sonar.server.user.UserSession;
-import org.sonarqube.ws.Qualitygates.AppWsResponse.Metric;
+import org.sonarqube.ws.Qualitygates.AppResponse.Metric;
 
 import static org.sonar.api.measures.CoreMetrics.ALERT_STATUS_KEY;
 import static org.sonar.api.measures.Metric.ValueType.RATING;
 import static org.sonar.server.qualitygate.ValidRatingMetrics.isCoreRatingMetric;
 import static org.sonar.server.ws.WsUtils.writeProtobuf;
-import static org.sonarqube.ws.Qualitygates.AppWsResponse;
+import static org.sonarqube.ws.Qualitygates.AppResponse;
 
 public class AppAction implements QualityGatesWsAction {
 
@@ -62,7 +62,7 @@ public class AppAction implements QualityGatesWsAction {
 
   @Override
   public void handle(Request request, Response response) {
-    writeProtobuf(AppWsResponse.newBuilder()
+    writeProtobuf(AppResponse.newBuilder()
       .setEdit(userSession.hasPermission(OrganizationPermission.ADMINISTER_QUALITY_GATES, defaultOrganizationProvider.get().getUuid()))
       .addAllMetrics(loadMetrics()
         .stream()
index 9dae665d2d44911aef5d54c57626944578754a10..6c8d57a86806222ba69ae95764fa67277cdf1191 100644 (file)
@@ -29,7 +29,7 @@ import org.sonar.db.qualitygate.QualityGateDto;
 import org.sonar.server.organization.DefaultOrganizationProvider;
 import org.sonar.server.qualitygate.QualityGateUpdater;
 import org.sonar.server.user.UserSession;
-import org.sonarqube.ws.Qualitygates.CreateWsResponse;
+import org.sonarqube.ws.Qualitygates.CreateResponse;
 
 import static org.sonar.server.ws.WsUtils.writeProtobuf;
 import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.ACTION_CREATE;
@@ -38,6 +38,7 @@ import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_NAM
 public class CreateAction implements QualityGatesWsAction {
 
   public static final int NAME_MAXIMUM_LENGTH = 100;
+
   private final DbClient dbClient;
   private final UserSession userSession;
   private final QualityGateUpdater qualityGateUpdater;
@@ -58,6 +59,7 @@ public class CreateAction implements QualityGatesWsAction {
       .setDescription("Create a Quality Gate.<br>" +
         "Requires the 'Administer Quality Gates' permission.")
       .setSince("4.3")
+      .setResponseExample(getClass().getResource("create-example.json"))
       .setHandler(this);
 
     action.createParam(PARAM_NAME)
@@ -73,11 +75,11 @@ public class CreateAction implements QualityGatesWsAction {
 
     try (DbSession dbSession = dbClient.openSession(false)) {
       QualityGateDto newQualityGate = qualityGateUpdater.create(dbSession, request.mandatoryParam(PARAM_NAME));
-      CreateWsResponse.Builder createWsResponse = CreateWsResponse.newBuilder()
+      CreateResponse.Builder createResponse = CreateResponse.newBuilder()
         .setId(newQualityGate.getId())
         .setName(newQualityGate.getName());
       dbSession.commit();
-      writeProtobuf(createWsResponse.build(), request, response);
+      writeProtobuf(createResponse.build(), request, response);
     }
   }
 
index d54894299c6ea6f43486bb46ad958bd191f27f3a..6509351d6211714f7c2dee98be4093f2c548f79a 100644 (file)
@@ -29,7 +29,7 @@ import org.sonar.db.qualitygate.QualityGateConditionDto;
 import org.sonar.server.organization.DefaultOrganizationProvider;
 import org.sonar.server.qualitygate.QualityGateConditionsUpdater;
 import org.sonar.server.user.UserSession;
-import org.sonarqube.ws.Qualitygates.CreateConditionWsResponse;
+import org.sonarqube.ws.Qualitygates.CreateConditionResponse;
 
 import static org.sonar.core.util.Protobuf.setNullable;
 import static org.sonar.server.qualitygate.ws.QualityGatesWs.addConditionParams;
@@ -64,6 +64,7 @@ public class CreateConditionAction implements QualityGatesWsAction {
       .setDescription("Add a new condition to a quality gate.<br>" +
         "Requires the 'Administer Quality Gates' permission.")
       .setSince("4.3")
+      .setResponseExample(getClass().getResource("create-condition-example.json"))
       .setHandler(this);
 
     createCondition
@@ -89,14 +90,14 @@ public class CreateConditionAction implements QualityGatesWsAction {
     try (DbSession dbSession = dbClient.openSession(false)) {
       QualityGateConditionDto condition = qualityGateConditionsUpdater.createCondition(dbSession, gateId, metric, operator, warning, error, period);
 
-      CreateConditionWsResponse.Builder createConditionWsResponse = CreateConditionWsResponse.newBuilder()
+      CreateConditionResponse.Builder createConditionResponse = CreateConditionResponse.newBuilder()
         .setId(condition.getId())
         .setMetric(condition.getMetricKey())
         .setOp(condition.getOperator());
-      setNullable(condition.getWarningThreshold(), createConditionWsResponse::setWarning);
-      setNullable(condition.getErrorThreshold(), createConditionWsResponse::setError);
-      setNullable(condition.getPeriod(), createConditionWsResponse::setPeriod);
-      writeProtobuf(createConditionWsResponse.build(), request, response);
+      setNullable(condition.getWarningThreshold(), createConditionResponse::setWarning);
+      setNullable(condition.getErrorThreshold(), createConditionResponse::setError);
+      setNullable(condition.getPeriod(), createConditionResponse::setPeriod);
+      writeProtobuf(createConditionResponse.build(), request, response);
       dbSession.commit();
     }
   }
index 8c89d6381d3e5ae4f3c72a8f0b91e5a37d707e39..23d7bb84ea7f0e8be071933af2f67d8136fde001 100644 (file)
@@ -33,7 +33,7 @@ import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.qualitygate.QualityGateFinder;
 import org.sonar.server.qualitygate.QualityGateFinder.QualityGateData;
 import org.sonar.server.user.UserSession;
-import org.sonarqube.ws.Qualitygates.GetByProjectWsResponse;
+import org.sonarqube.ws.Qualitygates.GetByProjectResponse;
 
 import static org.sonar.server.user.AbstractUserSession.insufficientPrivilegesException;
 import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
@@ -97,13 +97,13 @@ public class GetByProjectAction implements QualityGatesWsAction {
     }
   }
 
-  private static GetByProjectWsResponse buildResponse(Optional<QualityGateData> data) {
+  private static GetByProjectResponse buildResponse(Optional<QualityGateData> data) {
     if (!data.isPresent()) {
-      return GetByProjectWsResponse.getDefaultInstance();
+      return GetByProjectResponse.getDefaultInstance();
     }
 
     QualityGateDto qualityGate = data.get().getQualityGate();
-    GetByProjectWsResponse.Builder response = GetByProjectWsResponse.newBuilder();
+    GetByProjectResponse.Builder response = GetByProjectResponse.newBuilder();
 
     response.getQualityGateBuilder()
       .setId(String.valueOf(qualityGate.getId()))
index 46fbf90e8d0f208c637027bc75b41aed169da8ea..53c9b8172823ba33ea95df4f6d84589992739091 100644 (file)
@@ -42,7 +42,7 @@ import org.sonar.server.component.ComponentFinder.ParamNames;
 import org.sonar.server.exceptions.BadRequestException;
 import org.sonar.server.user.UserSession;
 import org.sonar.server.ws.KeyExamples;
-import org.sonarqube.ws.Qualitygates.ProjectStatusWsResponse;
+import org.sonarqube.ws.Qualitygates.ProjectStatusResponse;
 
 import static com.google.common.base.Strings.isNullOrEmpty;
 import static java.util.Collections.singletonList;
@@ -56,7 +56,7 @@ import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_PRO
 import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_PROJECT_KEY;
 
 public class ProjectStatusAction implements QualityGatesWsAction {
-  private static final String QG_STATUSES_ONE_LINE = Arrays.stream(ProjectStatusWsResponse.Status.values())
+  private static final String QG_STATUSES_ONE_LINE = Arrays.stream(ProjectStatusResponse.Status.values())
     .map(Enum::toString)
     .collect(Collectors.joining(", "));
   private static final String MSG_ONE_PARAMETER_ONLY = String.format("Either '%s', '%s' or '%s' must be provided", PARAM_ANALYSIS_ID, PARAM_PROJECT_ID, PARAM_PROJECT_KEY);
@@ -83,7 +83,7 @@ public class ProjectStatusAction implements QualityGatesWsAction {
         "<li>'Administer System'</li>" +
         "<li>'Administer' rights on the specified project</li>" +
         "<li>'Browse' on the specified project</li>" +
-        "</ul>", QG_STATUSES_ONE_LINE, ProjectStatusWsResponse.Status.NONE))
+        "</ul>", QG_STATUSES_ONE_LINE, ProjectStatusResponse.Status.NONE))
       .setResponseExample(getClass().getResource("project_status-example.json"))
       .setSince("5.3")
       .setHandler(this)
@@ -116,17 +116,17 @@ public class ProjectStatusAction implements QualityGatesWsAction {
         ^ !isNullOrEmpty(projectId)
         ^ !isNullOrEmpty(projectKey),
       MSG_ONE_PARAMETER_ONLY);
-    ProjectStatusWsResponse projectStatusWsResponse = doHandle(analysisId, projectId, projectKey);
-    writeProtobuf(projectStatusWsResponse, request, response);
+    ProjectStatusResponse projectStatusResponse = doHandle(analysisId, projectId, projectKey);
+    writeProtobuf(projectStatusResponse, request, response);
   }
 
-  private ProjectStatusWsResponse doHandle(String analysisId, String projectId, String projectKey) {
+  private ProjectStatusResponse doHandle(String analysisId, String projectId, String projectKey) {
     try (DbSession dbSession = dbClient.openSession(false)) {
       ProjectAndSnapshot projectAndSnapshot = getProjectAndSnapshot(dbSession, analysisId, projectId, projectKey);
       checkPermission(projectAndSnapshot.project);
       Optional<String> measureData = getQualityGateDetailsMeasureData(dbSession, projectAndSnapshot.project);
 
-      return ProjectStatusWsResponse.newBuilder()
+      return ProjectStatusResponse.newBuilder()
         .setProjectStatus(new QualityGateDetailsFormatter(measureData, projectAndSnapshot.snapshotDto).format())
         .build();
     }
index 9e593013ffdf0c13f7acb61fbf9a875c9177edaf..84c902f872934dbd1af4ca931990ece7dd5ee8e8 100644 (file)
@@ -28,7 +28,7 @@ import java.util.function.Predicate;
 import java.util.stream.StreamSupport;
 import javax.annotation.Nullable;
 import org.sonar.db.component.SnapshotDto;
-import org.sonarqube.ws.Qualitygates.ProjectStatusWsResponse;
+import org.sonarqube.ws.Qualitygates.ProjectStatusResponse;
 
 import static com.google.common.base.Strings.isNullOrEmpty;
 import static org.sonar.api.utils.DateUtils.formatDateTime;
@@ -36,15 +36,15 @@ import static org.sonar.api.utils.DateUtils.formatDateTime;
 public class QualityGateDetailsFormatter {
   private final Optional<String> optionalMeasureData;
   private final Optional<SnapshotDto> optionalSnapshot;
-  private final ProjectStatusWsResponse.ProjectStatus.Builder projectStatusBuilder;
+  private final ProjectStatusResponse.ProjectStatus.Builder projectStatusBuilder;
 
   public QualityGateDetailsFormatter(Optional<String> measureData, Optional<SnapshotDto> snapshot) {
     this.optionalMeasureData = measureData;
     this.optionalSnapshot = snapshot;
-    this.projectStatusBuilder = ProjectStatusWsResponse.ProjectStatus.newBuilder();
+    this.projectStatusBuilder = ProjectStatusResponse.ProjectStatus.newBuilder();
   }
 
-  public ProjectStatusWsResponse.ProjectStatus format() {
+  public ProjectStatusResponse.ProjectStatus format() {
     if (!optionalMeasureData.isPresent()) {
       return newResponseWithoutQualityGateDetails();
     }
@@ -52,7 +52,7 @@ public class QualityGateDetailsFormatter {
     JsonParser parser = new JsonParser();
     JsonObject json = parser.parse(optionalMeasureData.get()).getAsJsonObject();
 
-    ProjectStatusWsResponse.Status qualityGateStatus = measureLevelToQualityGateStatus(json.get("level").getAsString());
+    ProjectStatusResponse.Status qualityGateStatus = measureLevelToQualityGateStatus(json.get("level").getAsString());
     projectStatusBuilder.setStatus(qualityGateStatus);
 
     formatIgnoredConditions(json);
@@ -76,7 +76,7 @@ public class QualityGateDetailsFormatter {
       return;
     }
 
-    ProjectStatusWsResponse.Period.Builder periodBuilder = ProjectStatusWsResponse.Period.newBuilder();
+    ProjectStatusResponse.Period.Builder periodBuilder = ProjectStatusResponse.Period.newBuilder();
     periodBuilder.clear();
 
     SnapshotDto snapshot = this.optionalSnapshot.get();
@@ -109,7 +109,7 @@ public class QualityGateDetailsFormatter {
   }
 
   private void formatCondition(JsonObject jsonCondition) {
-    ProjectStatusWsResponse.Condition.Builder conditionBuilder = ProjectStatusWsResponse.Condition.newBuilder();
+    ProjectStatusResponse.Condition.Builder conditionBuilder = ProjectStatusResponse.Condition.newBuilder();
 
     formatConditionLevel(conditionBuilder, jsonCondition);
     formatConditionMetric(conditionBuilder, jsonCondition);
@@ -122,28 +122,28 @@ public class QualityGateDetailsFormatter {
     projectStatusBuilder.addConditions(conditionBuilder);
   }
 
-  private static void formatConditionActual(ProjectStatusWsResponse.Condition.Builder conditionBuilder, JsonObject jsonCondition) {
+  private static void formatConditionActual(ProjectStatusResponse.Condition.Builder conditionBuilder, JsonObject jsonCondition) {
     JsonElement actual = jsonCondition.get("actual");
     if (actual != null && !isNullOrEmpty(actual.getAsString())) {
       conditionBuilder.setActualValue(actual.getAsString());
     }
   }
 
-  private static void formatConditionErrorThreshold(ProjectStatusWsResponse.Condition.Builder conditionBuilder, JsonObject jsonCondition) {
+  private static void formatConditionErrorThreshold(ProjectStatusResponse.Condition.Builder conditionBuilder, JsonObject jsonCondition) {
     JsonElement error = jsonCondition.get("error");
     if (error != null && !isNullOrEmpty(error.getAsString())) {
       conditionBuilder.setErrorThreshold(error.getAsString());
     }
   }
 
-  private static void formatConditionWarningThreshold(ProjectStatusWsResponse.Condition.Builder conditionBuilder, JsonObject jsonCondition) {
+  private static void formatConditionWarningThreshold(ProjectStatusResponse.Condition.Builder conditionBuilder, JsonObject jsonCondition) {
     JsonElement warning = jsonCondition.get("warning");
     if (warning != null && !isNullOrEmpty(warning.getAsString())) {
       conditionBuilder.setWarningThreshold(warning.getAsString());
     }
   }
 
-  private static void formatConditionPeriod(ProjectStatusWsResponse.Condition.Builder conditionBuilder, JsonObject jsonCondition) {
+  private static void formatConditionPeriod(ProjectStatusResponse.Condition.Builder conditionBuilder, JsonObject jsonCondition) {
     JsonElement periodIndex = jsonCondition.get("period");
     if (periodIndex == null) {
       return;
@@ -151,31 +151,31 @@ public class QualityGateDetailsFormatter {
     conditionBuilder.setPeriodIndex(periodIndex.getAsInt());
   }
 
-  private static void formatConditionOperation(ProjectStatusWsResponse.Condition.Builder conditionBuilder, JsonObject jsonCondition) {
+  private static void formatConditionOperation(ProjectStatusResponse.Condition.Builder conditionBuilder, JsonObject jsonCondition) {
     JsonElement op = jsonCondition.get("op");
     if (op != null && !isNullOrEmpty(op.getAsString())) {
       String stringOp = op.getAsString();
-      ProjectStatusWsResponse.Comparator comparator = measureOpToQualityGateComparator(stringOp);
+      ProjectStatusResponse.Comparator comparator = measureOpToQualityGateComparator(stringOp);
       conditionBuilder.setComparator(comparator);
     }
   }
 
-  private static void formatConditionMetric(ProjectStatusWsResponse.Condition.Builder conditionBuilder, JsonObject jsonCondition) {
+  private static void formatConditionMetric(ProjectStatusResponse.Condition.Builder conditionBuilder, JsonObject jsonCondition) {
     JsonElement metric = jsonCondition.get("metric");
     if (metric != null && !isNullOrEmpty(metric.getAsString())) {
       conditionBuilder.setMetricKey(metric.getAsString());
     }
   }
 
-  private static void formatConditionLevel(ProjectStatusWsResponse.Condition.Builder conditionBuilder, JsonObject jsonCondition) {
+  private static void formatConditionLevel(ProjectStatusResponse.Condition.Builder conditionBuilder, JsonObject jsonCondition) {
     JsonElement measureLevel = jsonCondition.get("level");
     if (measureLevel != null && !isNullOrEmpty(measureLevel.getAsString())) {
       conditionBuilder.setStatus(measureLevelToQualityGateStatus(measureLevel.getAsString()));
     }
   }
 
-  private static ProjectStatusWsResponse.Status measureLevelToQualityGateStatus(String measureLevel) {
-    for (ProjectStatusWsResponse.Status status : ProjectStatusWsResponse.Status.values()) {
+  private static ProjectStatusResponse.Status measureLevelToQualityGateStatus(String measureLevel) {
+    for (ProjectStatusResponse.Status status : ProjectStatusResponse.Status.values()) {
       if (status.name().equals(measureLevel)) {
         return status;
       }
@@ -184,8 +184,8 @@ public class QualityGateDetailsFormatter {
     throw new IllegalStateException(String.format("Unknown quality gate status '%s'", measureLevel));
   }
 
-  private static ProjectStatusWsResponse.Comparator measureOpToQualityGateComparator(String measureOp) {
-    for (ProjectStatusWsResponse.Comparator comparator : ProjectStatusWsResponse.Comparator.values()) {
+  private static ProjectStatusResponse.Comparator measureOpToQualityGateComparator(String measureOp) {
+    for (ProjectStatusResponse.Comparator comparator : ProjectStatusResponse.Comparator.values()) {
       if (comparator.name().equals(measureOp)) {
         return comparator;
       }
@@ -194,8 +194,8 @@ public class QualityGateDetailsFormatter {
     throw new IllegalStateException(String.format("Unknown quality gate comparator '%s'", measureOp));
   }
 
-  private static ProjectStatusWsResponse.ProjectStatus newResponseWithoutQualityGateDetails() {
-    return ProjectStatusWsResponse.ProjectStatus.newBuilder().setStatus(ProjectStatusWsResponse.Status.NONE).build();
+  private static ProjectStatusResponse.ProjectStatus newResponseWithoutQualityGateDetails() {
+    return ProjectStatusResponse.ProjectStatus.newBuilder().setStatus(ProjectStatusResponse.Status.NONE).build();
   }
 
   private static Predicate<JsonObject> isConditionOnValidPeriod() {
index dff97b49f944b8fb8a76143269ae025bb4ba2256..5bfd1c58e9e4025674e169e1387136072334b7f9 100644 (file)
@@ -28,7 +28,7 @@ import org.sonar.db.qualitygate.QualityGateConditionDto;
 import org.sonar.server.organization.DefaultOrganizationProvider;
 import org.sonar.server.qualitygate.QualityGateConditionsUpdater;
 import org.sonar.server.user.UserSession;
-import org.sonarqube.ws.Qualitygates.UpdateConditionWsResponse;
+import org.sonarqube.ws.Qualitygates.UpdateConditionResponse;
 
 import static org.sonar.core.util.Protobuf.setNullable;
 import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_GATES;
@@ -88,14 +88,14 @@ public class UpdateConditionAction implements QualityGatesWsAction {
 
     try (DbSession dbSession = dbClient.openSession(false)) {
       QualityGateConditionDto condition = qualityGateConditionsUpdater.updateCondition(dbSession, id, metric, operator, warning, error, period);
-      UpdateConditionWsResponse.Builder updateConditionWsResponse = UpdateConditionWsResponse.newBuilder()
+      UpdateConditionResponse.Builder updateConditionResponse = UpdateConditionResponse.newBuilder()
         .setId(condition.getId())
         .setMetric(condition.getMetricKey())
         .setOp(condition.getOperator());
-      setNullable(condition.getWarningThreshold(), updateConditionWsResponse::setWarning);
-      setNullable(condition.getErrorThreshold(), updateConditionWsResponse::setError);
-      setNullable(condition.getPeriod(), updateConditionWsResponse::setPeriod);
-      writeProtobuf(updateConditionWsResponse.build(), request, response);
+      setNullable(condition.getWarningThreshold(), updateConditionResponse::setWarning);
+      setNullable(condition.getErrorThreshold(), updateConditionResponse::setError);
+      setNullable(condition.getPeriod(), updateConditionResponse::setPeriod);
+      writeProtobuf(updateConditionResponse.build(), request, response);
       dbSession.commit();
     }
   }
index ea8519f37c9be0678b49c0bd314e589b00c9e513..07333fa58dd7a7f2ab567998df67344999435c29 100644 (file)
@@ -28,7 +28,7 @@ import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.user.UserDto;
 import org.sonar.server.user.UserSession;
-import org.sonarqube.ws.Root;
+import org.sonarqube.ws.Roots;
 
 import static org.sonar.server.ws.WsUtils.writeProtobuf;
 
@@ -69,13 +69,13 @@ public class SearchAction implements RootsWsAction {
   }
 
   private static void writeResponse(Request request, Response response, List<UserDto> dtos) {
-    Root.SearchWsResponse.Builder responseBuilder = Root.SearchWsResponse.newBuilder();
-    Root.RootContent.Builder rootBuilder = Root.RootContent.newBuilder();
+    Roots.SearchResponse.Builder responseBuilder = Roots.SearchResponse.newBuilder();
+    Roots.RootContent.Builder rootBuilder = Roots.RootContent.newBuilder();
     dtos.forEach(dto -> responseBuilder.addRoots(toRoot(rootBuilder, dto)));
     writeProtobuf(responseBuilder.build(), request, response);
   }
 
-  private static Root.RootContent toRoot(Root.RootContent.Builder builder, UserDto dto) {
+  private static Roots.RootContent toRoot(Roots.RootContent.Builder builder, UserDto dto) {
     builder.clear();
     builder.setLogin(dto.getLogin());
     if (dto.getName() != null) {
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/qualitygate/ws/create-condition-example.json b/server/sonar-server/src/main/resources/org/sonar/server/qualitygate/ws/create-condition-example.json
new file mode 100644 (file)
index 0000000..e53dcdd
--- /dev/null
@@ -0,0 +1,7 @@
+{
+  "id": 1,
+  "metric": "blocker_violations",
+  "op": "LT",
+  "error": "10",
+  "warning": "5"
+}
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/qualitygate/ws/create-example.json b/server/sonar-server/src/main/resources/org/sonar/server/qualitygate/ws/create-example.json
new file mode 100644 (file)
index 0000000..f362b98
--- /dev/null
@@ -0,0 +1,4 @@
+{
+  "id": 1,
+  "name": "My Quality Gate"
+}
index ec037e309f9ce6c083eac228d69bca0f8e2100f4..2c019103772038b8856c49d86827b599f8fcbfcd 100644 (file)
@@ -32,7 +32,7 @@ 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.Qualitygates.AppWsResponse;
+import org.sonarqube.ws.Qualitygates.AppResponse;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.api.measures.Metric.ValueType.BOOL;
@@ -70,11 +70,11 @@ public class AppActionTest {
       .setHidden(true));
     dbSession.commit();
 
-    AppWsResponse response = executeRequest();
+    AppResponse response = executeRequest();
 
-    List<AppWsResponse.Metric> metrics = response.getMetricsList();
+    List<AppResponse.Metric> metrics = response.getMetricsList();
     assertThat(metrics).hasSize(1);
-    AppWsResponse.Metric metric = metrics.get(0);
+    AppResponse.Metric metric = metrics.get(0);
     assertThat(metric.getKey()).isEqualTo("metric");
     assertThat(metric.getName()).isEqualTo("Metric");
     assertThat(metric.getDomain()).isEqualTo("General");
@@ -92,11 +92,11 @@ public class AppActionTest {
       .setHidden(true));
     dbSession.commit();
 
-    AppWsResponse response = executeRequest();
+    AppResponse response = executeRequest();
 
-    List<AppWsResponse.Metric> metrics = response.getMetricsList();
+    List<AppResponse.Metric> metrics = response.getMetricsList();
     assertThat(metrics).hasSize(1);
-    AppWsResponse.Metric metric = metrics.get(0);
+    AppResponse.Metric metric = metrics.get(0);
     assertThat(metric.getKey()).isEqualTo("metric");
     assertThat(metric.hasDomain()).isFalse();
   }
@@ -109,9 +109,9 @@ public class AppActionTest {
       newMetricDto().setKey("sqale_rating").setValueType(RATING.name()).setHidden(false),
       newMetricDto().setKey("none_core_rating").setValueType(RATING.name()).setHidden(false));
 
-    AppWsResponse response = executeRequest();
+    AppResponse response = executeRequest();
 
-    assertThat(response.getMetricsList()).extracting(AppWsResponse.Metric::getKey).containsOnly(
+    assertThat(response.getMetricsList()).extracting(AppResponse.Metric::getKey).containsOnly(
       "reliability_rating", "new_reliability_rating", "sqale_rating");
   }
 
@@ -125,7 +125,7 @@ public class AppActionTest {
       .setHidden(false));
     dbSession.commit();
 
-    AppWsResponse response = executeRequest();
+    AppResponse response = executeRequest();
 
     assertThat(response.getMetricsList()).isEmpty();
   }
@@ -140,7 +140,7 @@ public class AppActionTest {
       .setHidden(false));
     dbSession.commit();
 
-    AppWsResponse response = executeRequest();
+    AppResponse response = executeRequest();
 
     assertThat(response.getMetricsList()).isEmpty();
   }
@@ -155,7 +155,7 @@ public class AppActionTest {
       .setHidden(false));
     dbSession.commit();
 
-    AppWsResponse response = executeRequest();
+    AppResponse response = executeRequest();
 
     assertThat(response.getMetricsList()).isEmpty();
   }
@@ -164,7 +164,7 @@ public class AppActionTest {
   public void return_edit_to_false_when_not_quality_gate_permission() throws Exception {
     userSession.logIn();
 
-    AppWsResponse response = executeRequest();
+    AppResponse response = executeRequest();
 
     assertThat(response.getEdit()).isFalse();
   }
@@ -173,7 +173,7 @@ public class AppActionTest {
   public void return_edit_to_true_when_quality_gate_permission() throws Exception {
     userSession.logIn().addPermission(ADMINISTER_QUALITY_GATES, db.getDefaultOrganization());
 
-    AppWsResponse response = executeRequest();
+    AppResponse response = executeRequest();
 
     assertThat(response.getEdit()).isTrue();
   }
@@ -220,7 +220,7 @@ public class AppActionTest {
     dbSession.commit();
   }
 
-  private AppWsResponse executeRequest() {
-    return ws.newRequest().executeProtobuf(AppWsResponse.class);
+  private AppResponse executeRequest() {
+    return ws.newRequest().executeProtobuf(AppResponse.class);
   }
 }
index 66181d1f55be14ecb1226d71223cd3df4630ba89..8e877eac7d9c68213e320d22dda75f7dfd9a7685 100644 (file)
@@ -34,7 +34,7 @@ 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.Qualitygates.CreateWsResponse;
+import org.sonarqube.ws.Qualitygates.CreateResponse;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_GATES;
@@ -60,7 +60,7 @@ public class CreateActionTest {
   public void create_quality_gate() throws Exception {
     logInAsQualityGateAdmin();
 
-    CreateWsResponse response = executeRequest("Default");
+    CreateResponse response = executeRequest("Default");
 
     assertThat(response.getName()).isEqualTo("Default");
     assertThat(response.getId()).isNotNull();
@@ -98,14 +98,14 @@ public class CreateActionTest {
     assertThat(action).isNotNull();
     assertThat(action.isInternal()).isFalse();
     assertThat(action.isPost()).isTrue();
-    assertThat(action.responseExampleAsString()).isNull();
+    assertThat(action.responseExampleAsString()).isNotEmpty();
     assertThat(action.params()).hasSize(1);
   }
 
-  private CreateWsResponse executeRequest(String name) {
+  private CreateResponse executeRequest(String name) {
     return ws.newRequest()
       .setParam("name", name)
-      .executeProtobuf(CreateWsResponse.class);
+      .executeProtobuf(CreateResponse.class);
   }
 
   private void logInAsQualityGateAdmin() {
index 995bad40b56419f41d14c81261c4e3e78e074139..f37e8c72f60944c08f1ee327898e531cc58c8653 100644 (file)
@@ -42,7 +42,7 @@ import org.sonar.server.qualitygate.QualityGateConditionsUpdater;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.ws.TestRequest;
 import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.Qualitygates.CreateConditionWsResponse;
+import org.sonarqube.ws.Qualitygates.CreateConditionResponse;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.db.metric.MetricTesting.newMetricDto;
@@ -91,7 +91,7 @@ public class CreateConditionActionTest {
   public void create_warning_condition() throws Exception {
     logInAsQualityGateAdmin();
 
-    CreateConditionWsResponse response = executeRequest(qualityGateDto.getId(), coverageMetricDto.getKey(), "LT", "90", null, null);
+    CreateConditionResponse response = executeRequest(qualityGateDto.getId(), coverageMetricDto.getKey(), "LT", "90", null, null);
 
     assertCondition(response, "LT", "90", null, null);
   }
@@ -100,7 +100,7 @@ public class CreateConditionActionTest {
   public void create_error_condition() throws Exception {
     logInAsQualityGateAdmin();
 
-    CreateConditionWsResponse response = executeRequest(qualityGateDto.getId(), coverageMetricDto.getKey(), "LT", null, "90", null);
+    CreateConditionResponse response = executeRequest(qualityGateDto.getId(), coverageMetricDto.getKey(), "LT", null, "90", null);
 
     assertCondition(response, "LT", null, "90", null);
   }
@@ -109,7 +109,7 @@ public class CreateConditionActionTest {
   public void create_condition_over_leak_period() throws Exception {
     logInAsQualityGateAdmin();
 
-    CreateConditionWsResponse response = executeRequest(qualityGateDto.getId(), coverageMetricDto.getKey(), "LT", null, "90", 1);
+    CreateConditionResponse response = executeRequest(qualityGateDto.getId(), coverageMetricDto.getKey(), "LT", null, "90", 1);
 
     assertCondition(response, "LT", null, "90", 1);
   }
@@ -143,11 +143,11 @@ public class CreateConditionActionTest {
     assertThat(action).isNotNull();
     assertThat(action.isInternal()).isFalse();
     assertThat(action.isPost()).isTrue();
-    assertThat(action.responseExampleAsString()).isNull();
+    assertThat(action.responseExampleAsString()).isNotEmpty();
     assertThat(action.params()).hasSize(6);
   }
 
-  private void assertCondition(CreateConditionWsResponse response, String operator, @Nullable String warning, @Nullable String error, @Nullable Integer period) {
+  private void assertCondition(CreateConditionResponse response, String operator, @Nullable String warning, @Nullable String error, @Nullable Integer period) {
     List<QualityGateConditionDto> conditionDtoList = new ArrayList<>(dbClient.gateConditionDao().selectForQualityGate(dbSession, qualityGateDto.getId()));
     assertThat(conditionDtoList).hasSize(1);
     QualityGateConditionDto qualityGateConditionDto = conditionDtoList.get(0);
@@ -178,7 +178,7 @@ public class CreateConditionActionTest {
     }
   }
 
-  private CreateConditionWsResponse executeRequest(long qualityProfileId, String metricKey, String operator, @Nullable String warning, @Nullable String error,
+  private CreateConditionResponse executeRequest(long qualityProfileId, String metricKey, String operator, @Nullable String warning, @Nullable String error,
     @Nullable Integer period) {
     TestRequest request = ws.newRequest()
       .setParam(PARAM_GATE_ID, Long.toString(qualityProfileId))
@@ -193,7 +193,7 @@ public class CreateConditionActionTest {
     if (period != null) {
       request.setParam(PARAM_PERIOD, Integer.toString(period));
     }
-    return request.executeProtobuf(CreateConditionWsResponse.class);
+    return request.executeProtobuf(CreateConditionResponse.class);
   }
 
   private void logInAsQualityGateAdmin() {
index 63879d9942924d9f9f890d942aa0bc00a4e4f419..cfbd5e10c1f66ff3a2469b63c68d2d3e6a8646fd 100644 (file)
@@ -44,7 +44,7 @@ import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.ws.TestRequest;
 import org.sonar.server.ws.WsActionTester;
 import org.sonarqube.ws.Qualitygates;
-import org.sonarqube.ws.Qualitygates.GetByProjectWsResponse;
+import org.sonarqube.ws.Qualitygates.GetByProjectResponse;
 
 import static java.lang.String.format;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -118,7 +118,7 @@ public class GetByProjectActionTest {
     setDefaultQualityGate(dbQualityGate.getId());
     logInAsProjectUser(project);
 
-    GetByProjectWsResponse result = callByKey(project.getKey());
+    GetByProjectResponse result = callByKey(project.getKey());
 
     Qualitygates.QualityGate qualityGate = result.getQualityGate();
     assertThat(Long.valueOf(qualityGate.getId())).isEqualTo(dbQualityGate.getId());
@@ -135,7 +135,7 @@ public class GetByProjectActionTest {
     associateProjectToQualityGate(project.getId(), dbQualityGate.getId());
     logInAsProjectUser(project);
 
-    GetByProjectWsResponse result = callByKey(project.getKey());
+    GetByProjectResponse result = callByKey(project.getKey());
 
     Qualitygates.QualityGate qualityGate = result.getQualityGate();
     assertThat(qualityGate.getName()).isEqualTo(dbQualityGate.getName());
@@ -149,7 +149,7 @@ public class GetByProjectActionTest {
     associateProjectToQualityGate(project.getId(), dbQualityGate.getId());
     logInAsProjectUser(project);
 
-    GetByProjectWsResponse result = callByKey(project.getDbKey());
+    GetByProjectResponse result = callByKey(project.getDbKey());
 
     assertThat(result.getQualityGate().getName()).isEqualTo(dbQualityGate.getName());
   }
@@ -161,7 +161,7 @@ public class GetByProjectActionTest {
     QualityGateDto dbQualityGate = insertQualityGate("Sonar way");
     setDefaultQualityGate(dbQualityGate.getId());
 
-    GetByProjectWsResponse result = callByKey(project.getKey());
+    GetByProjectResponse result = callByKey(project.getKey());
 
     assertThat(result.getQualityGate().getName()).isEqualTo(dbQualityGate.getName());
   }
@@ -173,7 +173,7 @@ public class GetByProjectActionTest {
     QualityGateDto dbQualityGate = insertQualityGate("Sonar way");
     setDefaultQualityGate(dbQualityGate.getId());
 
-    GetByProjectWsResponse result = callByKey(project.getKey());
+    GetByProjectResponse result = callByKey(project.getKey());
 
     assertThat(result.getQualityGate().getName()).isEqualTo(dbQualityGate.getName());
   }
@@ -217,16 +217,16 @@ public class GetByProjectActionTest {
     call(branch.getDbKey());
   }
 
-  private GetByProjectWsResponse callByKey(String projectKey) {
+  private GetByProjectResponse callByKey(String projectKey) {
     return call(projectKey);
   }
 
-  private GetByProjectWsResponse call(@Nullable String projectKey) {
+  private GetByProjectResponse call(@Nullable String projectKey) {
     TestRequest request = ws.newRequest();
     if (projectKey != null) {
       request.setParam("project", projectKey);
     }
-    return request.executeProtobuf(GetByProjectWsResponse.class);
+    return request.executeProtobuf(GetByProjectResponse.class);
   }
 
   private QualityGateDto insertQualityGate(String name) {
index 7e0115e803d5876515d12a997f3ab161983e0cfc..2bf2c728243d7e32531aec0b5a0e37ed7f723a67 100644 (file)
@@ -44,8 +44,8 @@ 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.Qualitygates.ProjectStatusWsResponse;
-import org.sonarqube.ws.Qualitygates.ProjectStatusWsResponse.Status;
+import org.sonarqube.ws.Qualitygates.ProjectStatusResponse;
+import org.sonarqube.ws.Qualitygates.ProjectStatusResponse.Status;
 
 import static java.lang.String.format;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -166,7 +166,7 @@ public class ProjectStatusActionTest {
     dbSession.commit();
     userSession.addProjectPermission(UserRole.USER, project);
 
-    ProjectStatusWsResponse result = call(snapshot.getUuid());
+    ProjectStatusResponse result = call(snapshot.getUuid());
 
     assertThat(result.getProjectStatus().getStatus()).isEqualTo(Status.NONE);
     assertThat(result.getProjectStatus().getConditionsCount()).isEqualTo(0);
@@ -177,7 +177,7 @@ public class ProjectStatusActionTest {
     ComponentDto project = db.components().insertPrivateProject(db.organizations().insert());
     userSession.addProjectPermission(UserRole.USER, project);
 
-    ProjectStatusWsResponse result = callByProjectUuid(project.uuid());
+    ProjectStatusResponse result = callByProjectUuid(project.uuid());
 
     assertThat(result.getProjectStatus().getStatus()).isEqualTo(Status.NONE);
     assertThat(result.getProjectStatus().getConditionsCount()).isEqualTo(0);
@@ -280,16 +280,16 @@ public class ProjectStatusActionTest {
       .execute();
   }
 
-  private ProjectStatusWsResponse call(String taskId) {
+  private ProjectStatusResponse call(String taskId) {
     return ws.newRequest()
       .setParam("analysisId", taskId)
-      .executeProtobuf(ProjectStatusWsResponse.class);
+      .executeProtobuf(ProjectStatusResponse.class);
   }
 
-  private ProjectStatusWsResponse callByProjectUuid(String projectUuid) {
+  private ProjectStatusResponse callByProjectUuid(String projectUuid) {
     return ws.newRequest()
       .setParam(PARAM_PROJECT_ID, projectUuid)
-      .executeProtobuf(ProjectStatusWsResponse.class);
+      .executeProtobuf(ProjectStatusResponse.class);
   }
 
   private void logInAsSystemAdministrator() {
index 00196c7e001963e3cf55ab5286e8453a9469e405..62f96974cf865c1131d3a7836f64c49503d566f6 100644 (file)
@@ -28,8 +28,8 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.sonar.db.component.SnapshotDto;
-import org.sonarqube.ws.Qualitygates.ProjectStatusWsResponse;
-import org.sonarqube.ws.Qualitygates.ProjectStatusWsResponse.ProjectStatus;
+import org.sonarqube.ws.Qualitygates.ProjectStatusResponse;
+import org.sonarqube.ws.Qualitygates.ProjectStatusResponse.ProjectStatus;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.api.utils.DateUtils.formatDateTime;
@@ -51,21 +51,21 @@ public class QualityGateDetailsFormatterTest {
 
     ProjectStatus result = underTest.format();
 
-    assertThat(result.getStatus()).isEqualTo(ProjectStatusWsResponse.Status.ERROR);
+    assertThat(result.getStatus()).isEqualTo(ProjectStatusResponse.Status.ERROR);
     // check conditions
     assertThat(result.getConditionsCount()).isEqualTo(4);
-    List<ProjectStatusWsResponse.Condition> conditions = result.getConditionsList();
+    List<ProjectStatusResponse.Condition> conditions = result.getConditionsList();
     assertThat(conditions).extracting("status").containsExactly(
-      ProjectStatusWsResponse.Status.ERROR,
-      ProjectStatusWsResponse.Status.WARN,
-      ProjectStatusWsResponse.Status.OK,
-      ProjectStatusWsResponse.Status.OK);
+      ProjectStatusResponse.Status.ERROR,
+      ProjectStatusResponse.Status.WARN,
+      ProjectStatusResponse.Status.OK,
+      ProjectStatusResponse.Status.OK);
     assertThat(conditions).extracting("metricKey").containsExactly("new_coverage", "new_blocker_violations", "new_critical_violations", "new_sqale_debt_ratio");
     assertThat(conditions).extracting("comparator").containsExactly(
-      ProjectStatusWsResponse.Comparator.LT,
-      ProjectStatusWsResponse.Comparator.GT,
-      ProjectStatusWsResponse.Comparator.NE,
-      ProjectStatusWsResponse.Comparator.EQ);
+      ProjectStatusResponse.Comparator.LT,
+      ProjectStatusResponse.Comparator.GT,
+      ProjectStatusResponse.Comparator.NE,
+      ProjectStatusResponse.Comparator.EQ);
     assertThat(conditions).extracting("periodIndex").containsExactly(1, 1, 1, 1);
     assertThat(conditions).extracting("warningThreshold").containsOnly("80", "");
     assertThat(conditions).extracting("errorThreshold").containsOnly("85", "0", "5");
@@ -73,7 +73,7 @@ public class QualityGateDetailsFormatterTest {
 
     // check periods
     assertThat(result.getPeriodsCount()).isEqualTo(1);
-    List<ProjectStatusWsResponse.Period> periods = result.getPeriodsList();
+    List<ProjectStatusResponse.Period> periods = result.getPeriodsList();
     assertThat(periods).extracting("index").containsExactly(1);
     assertThat(periods).extracting("mode").containsExactly("last_version");
     assertThat(periods).extracting("parameter").containsExactly("2015-12-07");
@@ -93,10 +93,10 @@ public class QualityGateDetailsFormatterTest {
 
     // check conditions
     assertThat(result.getConditionsCount()).isEqualTo(1);
-    List<ProjectStatusWsResponse.Condition> conditions = result.getConditionsList();
-    assertThat(conditions).extracting("status").containsExactly(ProjectStatusWsResponse.Status.ERROR);
+    List<ProjectStatusResponse.Condition> conditions = result.getConditionsList();
+    assertThat(conditions).extracting("status").containsExactly(ProjectStatusResponse.Status.ERROR);
     assertThat(conditions).extracting("metricKey").containsExactly("new_coverage");
-    assertThat(conditions).extracting("comparator").containsExactly(ProjectStatusWsResponse.Comparator.LT);
+    assertThat(conditions).extracting("comparator").containsExactly(ProjectStatusResponse.Comparator.LT);
     assertThat(conditions).extracting("periodIndex").containsExactly(1);
     assertThat(conditions).extracting("warningThreshold").containsOnly("80");
     assertThat(conditions).extracting("errorThreshold").containsOnly("85");
index 560a7de15291c5077d9137374dc220cdd86cc7dd..ea5072a6caedfe9188e6e3c9f701a7f00c306e47 100644 (file)
@@ -42,7 +42,7 @@ import org.sonar.server.qualitygate.QualityGateConditionsUpdater;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.ws.TestRequest;
 import org.sonar.server.ws.WsActionTester;
-import org.sonarqube.ws.Qualitygates.CreateConditionWsResponse;
+import org.sonarqube.ws.Qualitygates.CreateConditionResponse;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.db.metric.MetricTesting.newMetricDto;
@@ -99,7 +99,7 @@ public class UpdateConditionActionTest {
   public void update_warning_condition() throws Exception {
     logInAsQualityGateAdmin();
 
-    CreateConditionWsResponse response = executeRequest(conditionDto.getId(), coverageMetricDto.getKey(), "LT", "90", null, null);
+    CreateConditionResponse response = executeRequest(conditionDto.getId(), coverageMetricDto.getKey(), "LT", "90", null, null);
 
     assertCondition(response, "LT", "90", null, null);
   }
@@ -108,7 +108,7 @@ public class UpdateConditionActionTest {
   public void update_error_condition() throws Exception {
     logInAsQualityGateAdmin();
 
-    CreateConditionWsResponse response = executeRequest(conditionDto.getId(), coverageMetricDto.getKey(), "LT", null, "90", null);
+    CreateConditionResponse response = executeRequest(conditionDto.getId(), coverageMetricDto.getKey(), "LT", null, "90", null);
 
     assertCondition(response, "LT", null, "90", null);
   }
@@ -117,7 +117,7 @@ public class UpdateConditionActionTest {
   public void update_condition_over_leak_period() throws Exception {
     logInAsQualityGateAdmin();
 
-    CreateConditionWsResponse response = executeRequest(conditionDto.getId(), coverageMetricDto.getKey(), "LT", null, "90", 1);
+    CreateConditionResponse response = executeRequest(conditionDto.getId(), coverageMetricDto.getKey(), "LT", null, "90", 1);
 
     assertCondition(response, "LT", null, "90", 1);
   }
@@ -155,7 +155,7 @@ public class UpdateConditionActionTest {
     assertThat(action.params()).hasSize(6);
   }
 
-  private void assertCondition(CreateConditionWsResponse response, String operator, @Nullable String warning, @Nullable String error, @Nullable Integer period) {
+  private void assertCondition(CreateConditionResponse response, String operator, @Nullable String warning, @Nullable String error, @Nullable Integer period) {
     List<QualityGateConditionDto> conditionDtoList = new ArrayList<>(dbClient.gateConditionDao().selectForQualityGate(dbSession, qualityGateDto.getId()));
     assertThat(conditionDtoList).hasSize(1);
     QualityGateConditionDto qualityGateConditionDto = conditionDtoList.get(0);
@@ -186,7 +186,7 @@ public class UpdateConditionActionTest {
     }
   }
 
-  private CreateConditionWsResponse executeRequest(long conditionId, String metricKey, String operator, @Nullable String warning, @Nullable String error,
+  private CreateConditionResponse executeRequest(long conditionId, String metricKey, String operator, @Nullable String warning, @Nullable String error,
     @Nullable Integer period) {
     TestRequest request = ws.newRequest()
       .setParam(PARAM_ID, Long.toString(conditionId))
@@ -201,7 +201,7 @@ public class UpdateConditionActionTest {
     if (period != null) {
       request.setParam(PARAM_PERIOD, Integer.toString(period));
     }
-    return request.executeProtobuf(CreateConditionWsResponse.class);
+    return request.executeProtobuf(CreateConditionResponse.class);
   }
 
   private void logInAsQualityGateAdmin() {
index 0c7d2ef1aa10d4fd1b98e6dbabac821546aadffd..55557c52b5bfac86951f91a172e97d7429ce9bae 100644 (file)
@@ -35,7 +35,7 @@ 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.Root;
+import org.sonarqube.ws.Roots;
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.sonar.test.JsonAssert.assertJson;
@@ -112,9 +112,9 @@ public class SearchActionTest {
     userDao.setRoot(dbSession, rootDto.getLogin(), true);
     dbSession.commit();
 
-    List<Root.RootContent> roots = executeRequest();
+    List<Roots.RootContent> roots = executeRequest();
     assertThat(roots).hasSize(1);
-    Root.RootContent root = roots.iterator().next();
+    Roots.RootContent root = roots.iterator().next();
     assertThat(root.getLogin()).isEqualTo(rootDto.getLogin());
     assertThat(root.hasName()).isFalse();
     assertThat(root.hasEmail()).isFalse();
@@ -132,7 +132,7 @@ public class SearchActionTest {
     dbSession.commit();
 
     assertThat(executeRequest())
-      .extracting(Root.RootContent::getName)
+      .extracting(Roots.RootContent::getName)
       .containsExactly("bbb", "ccc");
   }
 
@@ -140,9 +140,9 @@ public class SearchActionTest {
     return userSessionRule.logIn().setRoot();
   }
 
-  private List<Root.RootContent> executeRequest() {
+  private List<Roots.RootContent> executeRequest() {
     return wsTester.newRequest()
-      .executeProtobuf(Root.SearchWsResponse.class)
+      .executeProtobuf(Roots.SearchResponse.class)
       .getRootsList();
   }
 
index 410d569803cf3c75747737c5f75c832e6b9c2cb8..86f8551cbaf522663619bbd8fdeb66025d7bdf05 100644 (file)
  */
 package org.sonarqube.ws.client.batch;
 
+import java.util.stream.Collectors;
 import javax.annotation.Generated;
-import org.sonarqube.ws.Batch.WsProjectResponse;
 import org.sonarqube.ws.MediaTypes;
 import org.sonarqube.ws.client.BaseService;
 import org.sonarqube.ws.client.GetRequest;
+import org.sonarqube.ws.client.PostRequest;
 import org.sonarqube.ws.client.WsConnector;
+import org.sonarqube.ws.Batch.WsProjectResponse;
 
 /**
  * Get JAR files and referentials for batch
index 9fda0dc7fb7f1299eae5b46590cd0aec7b21efa5..609d9c44633f5b070fb6e40719561273ca53d80c 100644 (file)
@@ -77,7 +77,7 @@ public class ActivityRequest {
   /**
    * Maximum date of end of task processing (inclusive)
    *
-   * Example value: "2017-11-16T10:21:24+0100"
+   * Example value: "2017-11-23T15:56:03+0100"
    */
   public ActivityRequest setMaxExecutedAt(String maxExecutedAt) {
     this.maxExecutedAt = maxExecutedAt;
@@ -91,7 +91,7 @@ public class ActivityRequest {
   /**
    * Minimum date of task submission (inclusive)
    *
-   * Example value: "2017-11-16T10:21:24+0100"
+   * Example value: "2017-11-23T15:56:03+0100"
    */
   public ActivityRequest setMinSubmittedAt(String minSubmittedAt) {
     this.minSubmittedAt = minSubmittedAt;
index 4e4980c8c3e81df1c03cfdce4c3c370a9a5e87bb..712b44f7614b1a7234fbb3cffd2e7feeb7a260bd 100644 (file)
@@ -104,7 +104,7 @@ public class ComponentsService extends BaseService {
   }
 
   /**
-   * Returns a component (file, directory, project, view…) and its ancestors. The ancestors are ordered from the parent to the root project. The 'componentId' or 'component' parameter must be provided.<br>Requires the following permission: 'Browse' on the project of the specified component.
+   * Returns a component (file, directory, project, view?) and its ancestors. The ancestors are ordered from the parent to the root project. The 'componentId' or 'component' parameter must be provided.<br>Requires the following permission: 'Browse' on the project of the specified component.
    *
    * This is part of the internal API.
    * This is a GET request.
index 6c7a5b8e2ab0ef680e05782d8f8a25afe1b217c3..c07e1b91e6415df4d17d9e03a07ad495d8aee154 100644 (file)
@@ -23,7 +23,7 @@ import java.util.List;
 import javax.annotation.Generated;
 
 /**
- * Returns a component (file, directory, project, view…) and its ancestors. The ancestors are ordered from the parent to the root project. The 'componentId' or 'component' parameter must be provided.<br>Requires the following permission: 'Browse' on the project of the specified component.
+ * Returns a component (file, directory, project, view?) and its ancestors. The ancestors are ordered from the parent to the root project. The 'componentId' or 'component' parameter must be provided.<br>Requires the following permission: 'Browse' on the project of the specified component.
  *
  * This is part of the internal API.
  * This is a POST request.
index 6538f888f8fdb1398b4a519064a3250eeb0754ab..40b8084aa51e98133a6a45bf525c1943231d67bd 100644 (file)
  */
 package org.sonarqube.ws.client.projectanalyses;
 
+import java.util.stream.Collectors;
 import javax.annotation.Generated;
 import org.sonarqube.ws.MediaTypes;
-import org.sonarqube.ws.ProjectAnalyses.CreateEventResponse;
-import org.sonarqube.ws.ProjectAnalyses.SearchResponse;
-import org.sonarqube.ws.ProjectAnalyses.UpdateEventResponse;
 import org.sonarqube.ws.client.BaseService;
 import org.sonarqube.ws.client.GetRequest;
 import org.sonarqube.ws.client.PostRequest;
 import org.sonarqube.ws.client.WsConnector;
+import org.sonarqube.ws.ProjectAnalyses.CreateEventResponse;
+import org.sonarqube.ws.ProjectAnalyses.SearchResponse;
+import org.sonarqube.ws.ProjectAnalyses.UpdateEventResponse;
 
 /**
  * Manage project analyses.
index f37cd94efee383f83ab7a99facf0558c389a5a43..760cee9eac084ce514665ad85294aad53ce4799a 100644 (file)
@@ -21,12 +21,13 @@ package org.sonarqube.ws.client.qualitygates;
 
 import javax.annotation.Generated;
 import org.sonarqube.ws.MediaTypes;
-import org.sonarqube.ws.Qualitygates.AppWsResponse;
-import org.sonarqube.ws.Qualitygates.CreateConditionWsResponse;
-import org.sonarqube.ws.Qualitygates.CreateWsResponse;
-import org.sonarqube.ws.Qualitygates.GetByProjectWsResponse;
-import org.sonarqube.ws.Qualitygates.ProjectStatusWsResponse;
-import org.sonarqube.ws.Qualitygates.UpdateConditionWsResponse;
+import org.sonarqube.ws.Qualitygates;
+import org.sonarqube.ws.Qualitygates.AppResponse;
+import org.sonarqube.ws.Qualitygates.CreateConditionResponse;
+import org.sonarqube.ws.Qualitygates.CreateResponse;
+import org.sonarqube.ws.Qualitygates.GetByProjectResponse;
+import org.sonarqube.ws.Qualitygates.ProjectStatusResponse;
+import org.sonarqube.ws.Qualitygates.UpdateConditionResponse;
 import org.sonarqube.ws.client.BaseService;
 import org.sonarqube.ws.client.GetRequest;
 import org.sonarqube.ws.client.PostRequest;
@@ -51,10 +52,10 @@ public class QualitygatesService extends BaseService {
    * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/app">Further information about this action online (including a response example)</a>
    * @since 4.3
    */
-  public AppWsResponse app() {
+  public AppResponse app() {
     return call(
       new GetRequest(path("app")),
-      AppWsResponse.parser());
+      AppResponse.parser());
   }
 
   /**
@@ -82,11 +83,11 @@ public class QualitygatesService extends BaseService {
    * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/create">Further information about this action online (including a response example)</a>
    * @since 4.3
    */
-  public CreateWsResponse create(CreateRequest request) {
+  public Qualitygates.CreateResponse create(CreateRequest request) {
     return call(
       new PostRequest(path("create"))
         .setParam("name", request.getName()),
-      CreateWsResponse.parser());
+      CreateResponse.parser());
   }
 
   /**
@@ -97,7 +98,7 @@ public class QualitygatesService extends BaseService {
    * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/create_condition">Further information about this action online (including a response example)</a>
    * @since 4.3
    */
-  public CreateConditionWsResponse createCondition(CreateConditionRequest request) {
+  public CreateConditionResponse createCondition(CreateConditionRequest request) {
     return call(
       new PostRequest(path("create_condition"))
         .setParam("error", request.getError())
@@ -106,7 +107,7 @@ public class QualitygatesService extends BaseService {
         .setParam("op", request.getOp())
         .setParam("period", request.getPeriod())
         .setParam("warning", request.getWarning()),
-      CreateConditionWsResponse.parser());
+      CreateConditionResponse.parser());
   }
 
   /**
@@ -166,11 +167,11 @@ public class QualitygatesService extends BaseService {
    * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/get_by_project">Further information about this action online (including a response example)</a>
    * @since 6.1
    */
-  public GetByProjectWsResponse getByProject(GetByProjectRequest request) {
+  public GetByProjectResponse getByProject(GetByProjectRequest request) {
     return call(
       new GetRequest(path("get_by_project"))
         .setParam("project", request.getProject()),
-      GetByProjectWsResponse.parser());
+      GetByProjectResponse.parser());
   }
 
   /**
@@ -196,13 +197,13 @@ public class QualitygatesService extends BaseService {
    * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/qualitygates/project_status">Further information about this action online (including a response example)</a>
    * @since 5.3
    */
-  public ProjectStatusWsResponse projectStatus(ProjectStatusRequest request) {
+  public ProjectStatusResponse projectStatus(ProjectStatusRequest request) {
     return call(
       new GetRequest(path("project_status"))
         .setParam("analysisId", request.getAnalysisId())
         .setParam("projectId", request.getProjectId())
         .setParam("projectKey", request.getProjectKey()),
-      ProjectStatusWsResponse.parser());
+      ProjectStatusResponse.parser());
   }
 
   /**
@@ -326,6 +327,6 @@ public class QualitygatesService extends BaseService {
         .setParam("op", request.getOp())
         .setParam("period", request.getPeriod())
         .setParam("warning", request.getWarning()),
-      UpdateConditionWsResponse.parser());
+      UpdateConditionResponse.parser());
   }
 }
index a1dc93f98f741e1435af34b045e42c1c5f7e5d57..506197f170a15a3607154e1c8fbc0ecb85ac44f0 100644 (file)
@@ -26,6 +26,7 @@ import org.sonarqube.ws.client.BaseService;
 import org.sonarqube.ws.client.GetRequest;
 import org.sonarqube.ws.client.PostRequest;
 import org.sonarqube.ws.client.WsConnector;
+import org.sonarqube.ws.Roots.SearchResponse;
 
 /**
  * Manage root users
@@ -46,11 +47,10 @@ public class RootsService extends BaseService {
    * @see <a href="https://next.sonarqube.com/sonarqube/web_api/api/roots/search">Further information about this action online (including a response example)</a>
    * @since 6.2
    */
-  public String search() {
+  public SearchResponse search() {
     return call(
-      new GetRequest(path("search"))
-        .setMediaType(MediaTypes.JSON)
-      ).content();
+      new GetRequest(path("search")),
+      SearchResponse.parser());
   }
 
   /**
index c7d63b571ca1467b8aa0308d80521c1583da9a97..7a40a0bf2ce1a838efdeba905a62157b5365060d 100644 (file)
@@ -25,7 +25,7 @@ option java_outer_classname = "Qualitygates";
 option optimize_for = SPEED;
 
 // GET api/qualitygates/project_status
-message ProjectStatusWsResponse {
+message ProjectStatusResponse {
   optional ProjectStatus projectStatus = 1;
 
   message ProjectStatus {
@@ -68,7 +68,7 @@ message ProjectStatusWsResponse {
 }
 
 // GET api/qualitygates/get_by_project
-message GetByProjectWsResponse {
+message GetByProjectResponse {
   optional QualityGate qualityGate = 1;
 }
 
@@ -79,7 +79,7 @@ message QualityGate {
 }
 
 // GET api/qualitygates/app
-message AppWsResponse {
+message AppResponse {
   optional bool edit = 1;
   repeated Metric metrics = 3;
 
@@ -93,13 +93,13 @@ message AppWsResponse {
 }
 
 // POST api/qualitygates/create
-message CreateWsResponse {
+message CreateResponse {
   optional int64 id = 1;
   optional string name = 2;
 }
 
 // POST api/qualitygates/create_condition
-message CreateConditionWsResponse {
+message CreateConditionResponse {
   optional int64 id = 1;
   optional string metric = 2;
   optional string op = 3;
@@ -109,7 +109,7 @@ message CreateConditionWsResponse {
 }
 
 // POST api/qualitygates/update_condition
-message UpdateConditionWsResponse {
+message UpdateConditionResponse {
   optional int64 id = 1;
   optional string metric = 2;
   optional string op = 3;
index c80ecfb270f5694fe2a11c4394d6d4ee8243fe9e..fd55b926a4dd02df3e0bc740094c3e0ec371afee 100644 (file)
@@ -21,11 +21,11 @@ syntax = "proto2";
 package sonarqube.ws.root;
 
 option java_package = "org.sonarqube.ws";
-option java_outer_classname = "Root";
+option java_outer_classname = "Roots";
 option optimize_for = SPEED;
 
 // WS api/root/search
-message SearchWsResponse {
+message SearchResponse {
   repeated RootContent roots = 1;
 }
 
index 61f41989b8ff7eab05841f1c51041c791646a52c..660f365241811e9c93042762653799facc6671dd 100644 (file)
@@ -33,7 +33,7 @@ import org.sonarqube.ws.client.projectbranches.ProjectBranchesService;
 import org.sonarqube.ws.client.projectlinks.ProjectLinksService;
 import org.sonarqube.ws.client.qualitygates.QualitygatesService;
 import org.sonarqube.ws.client.qualityprofile.QualityProfilesService;
-import org.sonarqube.ws.client.root.RootsService;
+import org.sonarqube.ws.client.roots.RootsService;
 import org.sonarqube.ws.client.rule.RulesService;
 import org.sonarqube.ws.client.setting.SettingsService;
 import org.sonarqube.ws.client.system.SystemService;
index 824ec0089908916ad0457ac94deaf15dd54f7b98..b81990aa1a6794de587ea25bca94d114d69292a8 100644 (file)
@@ -33,7 +33,7 @@ import org.sonarqube.ws.client.projectbranches.ProjectBranchesService;
 import org.sonarqube.ws.client.projectlinks.ProjectLinksService;
 import org.sonarqube.ws.client.qualitygates.QualitygatesService;
 import org.sonarqube.ws.client.qualityprofile.QualityProfilesService;
-import org.sonarqube.ws.client.root.RootsService;
+import org.sonarqube.ws.client.roots.RootsService;
 import org.sonarqube.ws.client.rule.RulesService;
 import org.sonarqube.ws.client.setting.SettingsService;
 import org.sonarqube.ws.client.system.SystemService;
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/root/RootsService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/root/RootsService.java
deleted file mode 100644 (file)
index 43b06b8..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonarqube.ws.client.root;
-
-import org.sonarqube.ws.Root;
-import org.sonarqube.ws.client.BaseService;
-import org.sonarqube.ws.client.GetRequest;
-import org.sonarqube.ws.client.PostRequest;
-import org.sonarqube.ws.client.WsConnector;
-
-public class RootsService extends BaseService {
-  public RootsService(WsConnector wsConnector) {
-    super(wsConnector, "api/roots");
-  }
-
-  public Root.SearchWsResponse search() {
-    return call(new GetRequest(path("search")), Root.SearchWsResponse.parser());
-  }
-
-  public void setRoot(String login) {
-    PostRequest post = new PostRequest(path("set_root"))
-      .setParam("login", login);
-
-    call(post);
-  }
-
-  public void unsetRoot(String login) {
-    PostRequest post = new PostRequest(path("unset_root"))
-      .setParam("login", login);
-
-    call(post);
-  }
-}
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/root/package-info.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/root/package-info.java
deleted file mode 100644 (file)
index f524396..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-@ParametersAreNonnullByDefault
-package org.sonarqube.ws.client.root;
-
-import javax.annotation.ParametersAreNonnullByDefault;
-
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/root/RootsServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/root/RootsServiceTest.java
deleted file mode 100644 (file)
index b6cbcf4..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonarqube.ws.client.root;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.sonarqube.ws.client.ServiceTester;
-import org.sonarqube.ws.client.WsConnector;
-
-import static org.mockito.Mockito.mock;
-
-public class RootsServiceTest {
-  private static final String SOME_LOGIN = "johnDoe";
-
-  @Rule
-  public ServiceTester<RootsService> serviceTester = new ServiceTester<>(new RootsService(mock(WsConnector.class)));
-
-  private RootsService underTest = serviceTester.getInstanceUnderTest();
-
-  @Test
-  public void search() {
-    underTest.search();
-
-    serviceTester.assertThat(serviceTester.getGetRequest())
-      .hasPath("search")
-      .andNoOtherParam();
-  }
-
-  @Test
-  public void setRoot() {
-    underTest.setRoot(SOME_LOGIN);
-
-    serviceTester.assertThat(serviceTester.getPostRequest())
-      .hasPath("set_root")
-      .hasParam("login", SOME_LOGIN)
-      .andNoOtherParam();
-  }
-
-  @Test
-  public void unsetRoot() {
-    underTest.unsetRoot(SOME_LOGIN);
-
-    serviceTester.assertThat(serviceTester.getPostRequest())
-      .hasPath("unset_root")
-      .hasParam("login", SOME_LOGIN)
-      .andNoOtherParam();
-  }
-}
index e909fd2d8101471b0b139962fb6b63baf2648100..955680532f1e49831a9cd10f19c4d9e98613c5c0 100644 (file)
@@ -30,6 +30,7 @@ import org.sonarqube.qa.util.Tester;
 import org.sonarqube.qa.util.pageobjects.organization.MembersPage;
 import org.sonarqube.ws.Organizations.Organization;
 import org.sonarqube.ws.Users.CreateWsResponse.User;
+import org.sonarqube.ws.client.roots.SetRootRequest;
 
 public class OrganizationMembershipUiTest {
 
@@ -45,7 +46,7 @@ public class OrganizationMembershipUiTest {
   public void setUp() {
     tester.settings().setGlobalSetting("sonar.organizations.anyoneCanCreate", "true");
     root = tester.users().generate();
-    tester.wsClient().roots().setRoot(root.getLogin());
+    tester.wsClient().roots().setRoot(new SetRootRequest().setLogin(root.getLogin()));
   }
 
   @After
index fbf6725f48fd70d54edc031318ed86002490cee6..bbde52e720e1c3c0986fe09fb3bb341af746be96 100644 (file)
@@ -43,6 +43,8 @@ import org.sonarqube.ws.client.organization.SearchWsRequest;
 import org.sonarqube.ws.client.organization.UpdateWsRequest;
 import org.sonarqube.ws.client.permission.AddUserWsRequest;
 import org.sonarqube.ws.client.permission.PermissionsService;
+import org.sonarqube.ws.client.roots.SetRootRequest;
+import org.sonarqube.ws.client.roots.UnsetRootRequest;
 
 import static java.util.Collections.singletonList;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -181,13 +183,13 @@ public class OrganizationTest {
     User user = tester.users().generate();
     OrganizationTester asUser = tester.as(user.getLogin()).organizations();
 
-    tester.wsClient().roots().setRoot(user.getLogin());
+    tester.wsClient().roots().setRoot(new SetRootRequest().setLogin(user.getLogin()));
     Organization org = asUser.generate();
 
     // delete org, attempt recreate when no root anymore and ensure it can't anymore
     asUser.service().delete(org.getKey());
 
-    tester.wsClient().roots().unsetRoot(user.getLogin());
+    tester.wsClient().roots().unsetRoot(new UnsetRootRequest().setLogin(user.getLogin()));
     expectForbiddenError(() -> asUser.generate());
   }
 
index 18451b1233907f214b2a3f34259e919a13f6358b..c9bb141d8e9a274d004c3042574b545220fe1dc1 100644 (file)
@@ -26,8 +26,10 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.qa.util.Tester;
 import org.sonarqube.qa.util.TesterSession;
-import org.sonarqube.ws.Root;
+import org.sonarqube.ws.Roots;
 import org.sonarqube.ws.Users;
+import org.sonarqube.ws.client.roots.SetRootRequest;
+import org.sonarqube.ws.client.roots.UnsetRootRequest;
 import util.user.UserRule;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -45,23 +47,23 @@ public class RootUserTest {
   @Test
   public void system_administrator_is_flagged_as_root_when_he_enables_organization_support() {
     assertThat(tester.wsClient().roots().search().getRootsList())
-      .extracting(Root.RootContent::getLogin)
+      .extracting(Roots.RootContent::getLogin)
       .containsExactly(UserRule.ADMIN_LOGIN);
   }
 
   @Test
   public void a_root_can_flag_other_user_as_root() {
     Users.CreateWsResponse.User user = tester.users().generate();
-    tester.wsClient().roots().setRoot(user.getLogin());
+    tester.wsClient().roots().setRoot(new SetRootRequest().setLogin(user.getLogin()));
 
     assertThat(tester.wsClient().roots().search().getRootsList())
-      .extracting(Root.RootContent::getLogin)
+      .extracting(Roots.RootContent::getLogin)
       .containsExactlyInAnyOrder(UserRule.ADMIN_LOGIN, user.getLogin());
   }
 
   @Test
   public void last_root_can_not_be_unset_root() throws SQLException {
-    expectBadRequestError(() -> tester.wsClient().roots().unsetRoot(UserRule.ADMIN_LOGIN));
+    expectBadRequestError(() -> tester.wsClient().roots().unsetRoot(new UnsetRootRequest().setLogin(UserRule.ADMIN_LOGIN)));
   }
 
   @Test
@@ -72,19 +74,19 @@ public class RootUserTest {
     TesterSession user2Session = tester.as(user2.getLogin());
 
     // non root can not set or unset root another user not itself
-    expectForbiddenError(() -> user1Session.wsClient().roots().setRoot(user2.getLogin()));
-    expectForbiddenError(() -> user1Session.wsClient().roots().setRoot(user1.getLogin()));
-    expectForbiddenError(() -> user1Session.wsClient().roots().unsetRoot(user1.getLogin()));
-    expectForbiddenError(() -> user2Session.wsClient().roots().unsetRoot(user1.getLogin()));
-    expectForbiddenError(() -> user2Session.wsClient().roots().unsetRoot(user2.getLogin()));
+    expectForbiddenError(() -> user1Session.wsClient().roots().setRoot(new SetRootRequest().setLogin(user2.getLogin())));
+    expectForbiddenError(() -> user1Session.wsClient().roots().setRoot(new SetRootRequest().setLogin(user1.getLogin())));
+    expectForbiddenError(() -> user1Session.wsClient().roots().unsetRoot(new UnsetRootRequest().setLogin(user1.getLogin())));
+    expectForbiddenError(() -> user2Session.wsClient().roots().unsetRoot(new UnsetRootRequest().setLogin(user1.getLogin())));
+    expectForbiddenError(() -> user2Session.wsClient().roots().unsetRoot(new UnsetRootRequest().setLogin(user2.getLogin())));
     // admin (the first root) sets root1 as root
-    tester.wsClient().roots().setRoot(user1.getLogin());
+    tester.wsClient().roots().setRoot(new SetRootRequest().setLogin(user1.getLogin()));
     // root1 can set root root2
-    user1Session.wsClient().roots().setRoot(user2.getLogin());
+    user1Session.wsClient().roots().setRoot(new SetRootRequest().setLogin(user2.getLogin()));
     // root2 can unset root root1
-    user2Session.wsClient().roots().unsetRoot(user1.getLogin());
+    user2Session.wsClient().roots().unsetRoot(new UnsetRootRequest().setLogin(user1.getLogin()));
     // root2 can unset root itself as it's not the last root
-    user2Session.wsClient().roots().unsetRoot(user2.getLogin());
+    user2Session.wsClient().roots().unsetRoot(new UnsetRootRequest().setLogin(user2.getLogin()));
   }
 
 }
index e4f9bf3fd273001ff9ba17f7c0bb8b866070a5a8..fd8d71284c046f2a52555c58428e36de0297d34c 100644 (file)
@@ -31,12 +31,11 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.sonarqube.qa.util.Tester;
+import org.sonarqube.ws.Ce;
 import org.sonarqube.ws.MediaTypes;
 import org.sonarqube.ws.Organizations;
-import org.sonarqube.ws.Ce;
 import org.sonarqube.ws.Projects.CreateWsResponse.Project;
 import org.sonarqube.ws.Qualitygates;
-import org.sonarqube.ws.Qualitygates.CreateWsResponse;
 import org.sonarqube.ws.Users;
 import org.sonarqube.ws.client.GetRequest;
 import org.sonarqube.ws.client.WsResponse;
@@ -60,9 +59,9 @@ public class OrganizationQualityGateForSmallChangesetsTest {
   public void do_not_fail_quality_gate_with_poor_LEAK_coverage_and_a_max_of_19_lines_of_NEW_code() throws Exception {
     Organizations.Organization organization = tester.organizations().generate();
     Project project = tester.projects().provision(organization);
-    CreateWsResponse qualityGate = tester.qGates().generate();
+    Qualitygates.CreateResponse qualityGate = tester.qGates().generate();
     tester.qGates().associateProject(qualityGate, project);
-    Qualitygates.CreateConditionWsResponse condition = tester.wsClient().qualityGates().createCondition(new CreateConditionRequest()
+    Qualitygates.CreateConditionResponse condition = tester.wsClient().qualityGates().createCondition(new CreateConditionRequest()
       .setGateId(String.valueOf(qualityGate.getId()))
       .setMetric("new_coverage")
       .setOp("LT")
index 2deaa41a397eaf27708f89854c95b781e1315f0e..953df1c4a21a6232f2d1021c60f8788697df008e 100644 (file)
@@ -28,7 +28,7 @@ import org.junit.Test;
 import org.sonarqube.qa.util.Tester;
 import org.sonarqube.ws.Organizations.Organization;
 import org.sonarqube.ws.Projects.CreateWsResponse.Project;
-import org.sonarqube.ws.Qualitygates.CreateWsResponse;
+import org.sonarqube.ws.Qualitygates;
 import org.sonarqube.ws.Users;
 import org.sonarqube.ws.client.GetRequest;
 import org.sonarqube.ws.client.WsResponse;
@@ -50,7 +50,7 @@ public class OrganizationQualityGateTest {
   public void always_display_current_quality_gate_in_effect() throws Exception {
     Organization organization = tester.organizations().generate();
     Project project = tester.projects().provision(organization);
-    CreateWsResponse qualityGate = tester.qGates().generate();
+    Qualitygates.CreateResponse qualityGate = tester.qGates().generate();
     tester.qGates().associateProject(qualityGate, project);
     tester.wsClient().qualityGates().createCondition(new CreateConditionRequest()
       .setGateId(String.valueOf(qualityGate.getId()))
@@ -80,7 +80,7 @@ public class OrganizationQualityGateTest {
     Map currentQualityGate2 = (Map) ItUtils.jsonToMap(response2.content()).get("qualityGate");
     assertThat((long) (double) (Double) currentQualityGate2.get("key")).isEqualTo(qualityGate.getId());
 
-    CreateWsResponse qualityGate2 = tester.qGates().generate();
+    Qualitygates.CreateResponse qualityGate2 = tester.qGates().generate();
     tester.qGates().associateProject(qualityGate2, project);
     tester.wsClient().qualityGates().createCondition(new CreateConditionRequest()
       .setGateId(String.valueOf(qualityGate2.getId()))
index e2a64b36ddf718b3a4340c1ea56086a545568977..41f36e564a8681577e895f67d191b80d3db94ada 100644 (file)
@@ -86,7 +86,7 @@ public class QualityGateNotificationTest {
       .failIfNotSuccessful();
 
     // Create quality gate with conditions on variations
-    Qualitygates.CreateWsResponse simple = tester.qGates().generate();
+    Qualitygates.CreateResponse simple = tester.qGates().generate();
     tester.qGates().service()
       .createCondition(new CreateConditionRequest().setGateId(String.valueOf(simple.getId())).setMetric("ncloc").setPeriod("1").setOp("EQ").setWarning("0"));
     Project project = tester.projects().provision();
index 5da686950bfe7bd54fcad007f0b74cc378ef202c..66041b9c68b3aa0e903d8373faadb87f606ffa40 100644 (file)
@@ -47,7 +47,7 @@ public class QualityGateOnRatingMeasuresTest {
   @Test
   public void generate_warning_qgate_on_rating_metric() throws Exception {
     Project project = tester.projects().provision();
-    Qualitygates.CreateWsResponse qualityGate = tester.qGates().generate();
+    Qualitygates.CreateResponse qualityGate = tester.qGates().generate();
     tester.qGates().associateProject(qualityGate, project);
     tester.qGates().service().createCondition(new CreateConditionRequest()
       .setGateId(String.valueOf(qualityGate.getId()))
@@ -65,7 +65,7 @@ public class QualityGateOnRatingMeasuresTest {
   @Test
   public void generate_error_qgate_on_rating_metric_on_leak_period() throws Exception {
     Project project = tester.projects().provision();
-    Qualitygates.CreateWsResponse qualityGate = tester.qGates().generate();
+    Qualitygates.CreateResponse qualityGate = tester.qGates().generate();
     tester.qGates().associateProject(qualityGate, project);
     tester.settings().setGlobalSetting("sonar.leak.period", "previous_version");
     tester.wsClient().qualityGates().createCondition(new CreateConditionRequest()
index f4c931997ed8633227efbac48a160d4e4c12fc8f..12be1f958546d4465db0b7e9aca21130933b79ed 100644 (file)
@@ -45,12 +45,11 @@ import org.sonar.wsclient.qualitygate.QualityGateClient;
 import org.sonarqube.qa.util.Tester;
 import org.sonarqube.qa.util.TesterSession;
 import org.sonarqube.ws.Ce;
+import org.sonarqube.ws.Measures.Measure;
 import org.sonarqube.ws.MediaTypes;
 import org.sonarqube.ws.Organizations.Organization;
-import org.sonarqube.ws.Measures.Measure;
 import org.sonarqube.ws.Projects.CreateWsResponse.Project;
 import org.sonarqube.ws.Qualitygates;
-import org.sonarqube.ws.Qualitygates.ProjectStatusWsResponse;
 import org.sonarqube.ws.Users;
 import org.sonarqube.ws.client.GetRequest;
 import org.sonarqube.ws.client.PostRequest;
@@ -247,11 +246,11 @@ public class QualityGateTest {
       String taskId = getTaskIdInLocalReport(projectDir("qualitygate/xoo-sample"));
       String analysisId = getAnalysisId(taskId);
 
-      ProjectStatusWsResponse projectStatusWsResponse = tester.wsClient().qualityGates().projectStatus(new ProjectStatusRequest().setAnalysisId(analysisId));
-      ProjectStatusWsResponse.ProjectStatus projectStatus = projectStatusWsResponse.getProjectStatus();
-      assertThat(projectStatus.getStatus()).isEqualTo(ProjectStatusWsResponse.Status.ERROR);
+      Qualitygates.ProjectStatusResponse projectStatusWsResponse = tester.wsClient().qualityGates().projectStatus(new ProjectStatusRequest().setAnalysisId(analysisId));
+      Qualitygates.ProjectStatusResponse.ProjectStatus projectStatus = projectStatusWsResponse.getProjectStatus();
+      assertThat(projectStatus.getStatus()).isEqualTo(Qualitygates.ProjectStatusResponse.Status.ERROR);
       assertThat(projectStatus.getConditionsCount()).isEqualTo(1);
-      ProjectStatusWsResponse.Condition condition = projectStatus.getConditionsList().get(0);
+      Qualitygates.ProjectStatusResponse.Condition condition = projectStatus.getConditionsList().get(0);
       assertThat(condition.getMetricKey()).isEqualTo("ncloc");
       assertThat(condition.getErrorThreshold()).isEqualTo("7");
     } finally {
@@ -270,7 +269,7 @@ public class QualityGateTest {
     createCustomIntMetric(customMetricKey);
     try {
       // create quality gate
-      Qualitygates.CreateWsResponse simple = tester.wsClient().qualityGates().create(new CreateRequest().setName("OnCustomMetric"));
+      Qualitygates.CreateResponse simple = tester.wsClient().qualityGates().create(new CreateRequest().setName("OnCustomMetric"));
       Long qualityGateId = simple.getId();
       qgClient().createCondition(NewCondition.create(qualityGateId).metricKey(customMetricKey).operator("GT").warningThreshold("40"));
 
@@ -298,8 +297,8 @@ public class QualityGateTest {
     TesterSession qGateAdminTester = tester.as(user.getLogin());
     QualitygatesService qGateService = qGateAdminTester.qGates().service();
     // perform administration operations
-    Qualitygates.CreateWsResponse qualityGate = qGateAdminTester.qGates().generate();
-    Qualitygates.CreateConditionWsResponse condition = qGateService.createCondition(new CreateConditionRequest()
+    Qualitygates.CreateResponse qualityGate = qGateAdminTester.qGates().generate();
+    Qualitygates.CreateConditionResponse condition = qGateService.createCondition(new CreateConditionRequest()
       .setGateId(String.valueOf(qualityGate.getId())).setMetric("coverage").setOp("LT").setError("90"));
     qGateService.updateCondition(new UpdateConditionRequest()
       .setId(String.valueOf(condition.getId())).setMetric("coverage").setOp("LT").setError("90").setWarning("80"));
index 9d7a4b52765b1e7149db4ab11ddbc4ca8d6c8584..0baa09641a2568747de63d973ecd61e79d735188 100644 (file)
@@ -66,14 +66,14 @@ public class QualityGateUiTest {
   @Test
   public void display_alerts_correctly_in_history_page() {
     Project project = tester.projects().provision();
-    Qualitygates.CreateWsResponse qGate = tester.qGates().generate();
+    Qualitygates.CreateResponse qGate = tester.qGates().generate();
     tester.qGates().associateProject(qGate, project);
 
     String firstAnalysisDate = DateFormatUtils.ISO_DATE_FORMAT.format(addDays(new Date(), -2));
     String secondAnalysisDate = DateFormatUtils.ISO_DATE_FORMAT.format(addDays(new Date(), -1));
 
     // with this configuration, project should have an Orange alert
-    Qualitygates.CreateConditionWsResponse lowThresholds = tester.qGates().service()
+    Qualitygates.CreateConditionResponse lowThresholds = tester.qGates().service()
       .createCondition(new CreateConditionRequest().setGateId(String.valueOf(qGate.getId())).setMetric("lines").setOp("GT").setWarning("5").setError("50"));
     scanSampleWithDate(project, firstAnalysisDate);
     // with this configuration, project should have a Green alert
index 80df9438ab695cca61a4f29a35693dcfa82b4f7f..65863a9629df91701c9275c73635e275bb33213a 100644 (file)
@@ -36,6 +36,7 @@ import org.sonarqube.ws.client.PostRequest;
 import org.sonarqube.ws.client.WsClient;
 import org.sonarqube.ws.client.WsResponse;
 import org.sonarqube.ws.client.permission.AddUserWsRequest;
+import org.sonarqube.ws.client.roots.SetRootRequest;
 import org.sonarqube.ws.client.user.CreateRequest;
 import org.sonarqube.ws.client.user.SearchRequest;
 import org.sonarqube.ws.client.user.UsersService;
@@ -152,7 +153,7 @@ public class UserRule extends ExternalResource implements GroupManagement {
   }
 
   public void setRoot(String login) {
-    adminWsClient().roots().setRoot(login);
+    adminWsClient().roots().setRoot(new SetRootRequest().setLogin(login));
   }
 
   public Optional<util.user.Users.User> getUserByLogin(String login) {