diff options
Diffstat (limited to 'server')
19 files changed, 146 insertions, 132 deletions
diff --git a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QGateTester.java b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QGateTester.java index 5db54abe49f..66ef0f036db 100644 --- a/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QGateTester.java +++ b/server/sonar-qa-util/src/main/java/org/sonarqube/qa/util/QGateTester.java @@ -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())); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/AppAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/AppAction.java index f24c9bb7ecf..e1851a29d4b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/AppAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/AppAction.java @@ -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() diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/CreateAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/CreateAction.java index 9dae665d2d4..6c8d57a8680 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/CreateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/CreateAction.java @@ -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); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/CreateConditionAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/CreateConditionAction.java index d54894299c6..6509351d621 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/CreateConditionAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/CreateConditionAction.java @@ -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(); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/GetByProjectAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/GetByProjectAction.java index 8c89d6381d3..23d7bb84ea7 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/GetByProjectAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/GetByProjectAction.java @@ -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())) diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/ProjectStatusAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/ProjectStatusAction.java index 46fbf90e8d0..53c9b817282 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/ProjectStatusAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/ProjectStatusAction.java @@ -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(); } diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/QualityGateDetailsFormatter.java b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/QualityGateDetailsFormatter.java index 9e593013ffd..84c902f8729 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/QualityGateDetailsFormatter.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/QualityGateDetailsFormatter.java @@ -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() { diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/UpdateConditionAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/UpdateConditionAction.java index dff97b49f94..5bfd1c58e9e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/UpdateConditionAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/UpdateConditionAction.java @@ -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(); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/root/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/root/ws/SearchAction.java index ea8519f37c9..07333fa58dd 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/root/ws/SearchAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/root/ws/SearchAction.java @@ -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 index 00000000000..e53dcdd1fb1 --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/qualitygate/ws/create-condition-example.json @@ -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 index 00000000000..f362b98bd3f --- /dev/null +++ b/server/sonar-server/src/main/resources/org/sonar/server/qualitygate/ws/create-example.json @@ -0,0 +1,4 @@ +{ + "id": 1, + "name": "My Quality Gate" +} 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 ec037e309f9..2c019103772 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,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); } } 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 66181d1f55b..8e877eac7d9 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,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() { 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 995bad40b56..f37e8c72f60 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 @@ -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() { 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 63879d99429..cfbd5e10c1f 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 @@ -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) { 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 7e0115e803d..2bf2c728243 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 @@ -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() { diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/QualityGateDetailsFormatterTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/QualityGateDetailsFormatterTest.java index 00196c7e001..62f96974cf8 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/QualityGateDetailsFormatterTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/QualityGateDetailsFormatterTest.java @@ -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"); 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 560a7de1529..ea5072a6cae 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 @@ -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() { 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 0c7d2ef1aa1..55557c52b5b 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 @@ -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(); } |