From 2259c6808e011a95fa1d0b8e5681f507befdb4e9 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Mon, 4 Dec 2017 15:19:04 +0100 Subject: [PATCH] Remove deprecated ProjectAnalysisService --- .../projectanalysis/ws/CreateEventAction.java | 13 +- .../projectanalysis/ws/DeleteAction.java | 2 +- .../projectanalysis/ws/DeleteEventAction.java | 6 +- .../projectanalysis/ws}/EventCategory.java | 2 +- .../projectanalysis/ws/EventValidator.java | 7 +- .../ws}/ProjectAnalysesWsParameters.java | 2 +- .../projectanalysis/ws/SearchAction.java | 13 +- .../projectanalysis/ws/SearchRequest.java | 2 - .../ws/SearchResponseBuilder.java | 2 +- .../projectanalysis/ws/UpdateEventAction.java | 9 +- .../ws/CreateEventActionTest.java | 10 +- .../projectanalysis/ws/DeleteActionTest.java | 2 +- .../ws/DeleteEventActionTest.java | 4 +- .../ws/EventValidatorTest.java | 2 +- .../projectanalysis/ws/SearchActionTest.java | 17 +-- .../ws/UpdateEventActionTest.java | 8 +- .../sonarqube/ws/client/DefaultWsClient.java | 8 - .../org/sonarqube/ws/client/WsClient.java | 8 - .../projectanalysis/CreateEventRequest.java | 83 ----------- .../projectanalysis/DeleteEventRequest.java | 34 ----- .../client/projectanalysis/DeleteRequest.java | 34 ----- .../ProjectAnalysisService.java | 54 ------- .../client/projectanalysis/SearchRequest.java | 140 ------------------ .../projectanalysis/UpdateEventRequest.java | 43 ------ .../client/projectanalysis/package-info.java | 24 --- .../CreateEventRequestTest.java | 76 ---------- .../ProjectAnalysesWsParametersTest.java | 33 ----- .../ProjectAnalysisServiceTest.java | 81 ---------- .../projectanalysis/SearchRequestTest.java | 80 ---------- .../UpdateEventRequestTest.java | 65 -------- .../issue/IssueCreationDateQPChangedTest.java | 6 +- 31 files changed, 50 insertions(+), 820 deletions(-) rename {sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis => server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws}/EventCategory.java (96%) rename {sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis => server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws}/ProjectAnalysesWsParameters.java (96%) delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/CreateEventRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/DeleteEventRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/DeleteRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/ProjectAnalysisService.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/SearchRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/UpdateEventRequest.java delete mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/package-info.java delete mode 100644 sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/CreateEventRequestTest.java delete mode 100644 sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/ProjectAnalysesWsParametersTest.java delete mode 100644 sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/ProjectAnalysisServiceTest.java delete mode 100644 sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/SearchRequestTest.java delete mode 100644 sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/UpdateEventRequestTest.java diff --git a/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/CreateEventAction.java b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/CreateEventAction.java index 2128a1f32ec..f33235b3f1f 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/CreateEventAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/CreateEventAction.java @@ -42,7 +42,6 @@ import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.user.UserSession; import org.sonarqube.ws.ProjectAnalyses.CreateEventResponse; import org.sonarqube.ws.ProjectAnalyses.Event; -import org.sonarqube.ws.client.projectanalysis.EventCategory; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkState; @@ -50,13 +49,13 @@ import static java.lang.String.format; import static org.apache.commons.lang.StringUtils.isNotBlank; import static org.sonar.core.util.Protobuf.setNullable; import static org.sonar.db.event.EventValidator.MAX_NAME_LENGTH; +import static org.sonar.server.projectanalysis.ws.EventCategory.OTHER; +import static org.sonar.server.projectanalysis.ws.EventCategory.VERSION; +import static org.sonar.server.projectanalysis.ws.EventCategory.fromLabel; +import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_ANALYSIS; +import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_CATEGORY; +import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_NAME; import static org.sonar.server.ws.WsUtils.writeProtobuf; -import static org.sonarqube.ws.client.projectanalysis.EventCategory.OTHER; -import static org.sonarqube.ws.client.projectanalysis.EventCategory.VERSION; -import static org.sonarqube.ws.client.projectanalysis.EventCategory.fromLabel; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_ANALYSIS; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_CATEGORY; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_NAME; public class CreateEventAction implements ProjectAnalysesWsAction { private static final Set ALLOWED_QUALIFIERS = ImmutableSet.of(Qualifiers.PROJECT, Qualifiers.APP); diff --git a/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/DeleteAction.java b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/DeleteAction.java index e7a66a3dc5b..8cb1aeb9a8d 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/DeleteAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/DeleteAction.java @@ -33,7 +33,7 @@ import org.sonar.server.user.UserSession; import static com.google.common.base.Preconditions.checkArgument; import static java.lang.String.format; import static org.sonar.db.component.SnapshotDto.STATUS_UNPROCESSED; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_ANALYSIS; +import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_ANALYSIS; public class DeleteAction implements ProjectAnalysesWsAction { private final DbClient dbClient; diff --git a/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/DeleteEventAction.java b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/DeleteEventAction.java index 087ff98fc1e..dbe48a54ff1 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/DeleteEventAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/DeleteEventAction.java @@ -36,9 +36,9 @@ import org.sonar.server.user.UserSession; import static com.google.common.base.Preconditions.checkArgument; import static java.lang.String.format; import static org.sonar.server.projectanalysis.ws.EventValidator.checkModifiable; -import static org.sonarqube.ws.client.projectanalysis.EventCategory.OTHER; -import static org.sonarqube.ws.client.projectanalysis.EventCategory.VERSION; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_EVENT; +import static org.sonar.server.projectanalysis.ws.EventCategory.OTHER; +import static org.sonar.server.projectanalysis.ws.EventCategory.VERSION; +import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_EVENT; public class DeleteEventAction implements ProjectAnalysesWsAction { private final DbClient dbClient; diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/EventCategory.java b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/EventCategory.java similarity index 96% rename from sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/EventCategory.java rename to server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/EventCategory.java index 39305b41ab2..4baa77a1a4e 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/EventCategory.java +++ b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/EventCategory.java @@ -17,7 +17,7 @@ * 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.projectanalysis; +package org.sonar.server.projectanalysis.ws; public enum EventCategory { VERSION("Version"), OTHER("Other"), QUALITY_PROFILE("Profile"), QUALITY_GATE("Alert"); diff --git a/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/EventValidator.java b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/EventValidator.java index b6247bcb7d9..818cccb309a 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/EventValidator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/EventValidator.java @@ -24,12 +24,11 @@ import com.google.common.collect.ImmutableSet; import java.util.Set; import java.util.function.Consumer; import org.sonar.db.event.EventDto; -import org.sonarqube.ws.client.projectanalysis.EventCategory; import static com.google.common.base.Preconditions.checkArgument; -import static org.sonarqube.ws.client.projectanalysis.EventCategory.OTHER; -import static org.sonarqube.ws.client.projectanalysis.EventCategory.VERSION; -import static org.sonarqube.ws.client.projectanalysis.EventCategory.fromLabel; +import static org.sonar.server.projectanalysis.ws.EventCategory.OTHER; +import static org.sonar.server.projectanalysis.ws.EventCategory.VERSION; +import static org.sonar.server.projectanalysis.ws.EventCategory.fromLabel; class EventValidator { private static final Set AUTHORIZED_CATEGORIES = ImmutableSet.of(VERSION.name(), OTHER.name()); diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/ProjectAnalysesWsParameters.java b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/ProjectAnalysesWsParameters.java similarity index 96% rename from sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/ProjectAnalysesWsParameters.java rename to server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/ProjectAnalysesWsParameters.java index 39607605092..f4259e909ad 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/ProjectAnalysesWsParameters.java +++ b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/ProjectAnalysesWsParameters.java @@ -17,7 +17,7 @@ * 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.projectanalysis; +package org.sonar.server.projectanalysis.ws; public class ProjectAnalysesWsParameters { public static final String PARAM_ANALYSIS = "analysis"; diff --git a/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/SearchAction.java index 20438481202..16fa7f535e1 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/SearchAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/SearchAction.java @@ -40,7 +40,6 @@ import org.sonar.server.component.ComponentFinder; import org.sonar.server.user.UserSession; import org.sonar.server.ws.KeyExamples; import org.sonarqube.ws.ProjectAnalyses; -import org.sonarqube.ws.client.projectanalysis.EventCategory; import static com.google.common.base.Preconditions.checkArgument; import static org.sonar.api.utils.DateUtils.parseEndingDateOrDateTime; @@ -50,12 +49,12 @@ import static org.sonar.db.component.SnapshotQuery.SORT_FIELD.BY_DATE; import static org.sonar.db.component.SnapshotQuery.SORT_ORDER.DESC; import static org.sonar.server.ws.KeyExamples.KEY_BRANCH_EXAMPLE_001; import static org.sonar.server.ws.WsUtils.writeProtobuf; -import static org.sonarqube.ws.client.projectanalysis.EventCategory.OTHER; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_BRANCH; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_CATEGORY; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_FROM; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_PROJECT; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_TO; +import static org.sonar.server.projectanalysis.ws.EventCategory.OTHER; +import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_BRANCH; +import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_CATEGORY; +import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_FROM; +import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_PROJECT; +import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_TO; import static org.sonar.server.projectanalysis.ws.SearchRequest.DEFAULT_PAGE_SIZE; public class SearchAction implements ProjectAnalysesWsAction { diff --git a/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/SearchRequest.java b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/SearchRequest.java index d55ce270bdc..38ed38f33b3 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/SearchRequest.java +++ b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/SearchRequest.java @@ -19,8 +19,6 @@ */ package org.sonar.server.projectanalysis.ws; -import org.sonarqube.ws.client.projectanalysis.EventCategory; - import javax.annotation.CheckForNull; import javax.annotation.Nullable; diff --git a/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/SearchResponseBuilder.java b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/SearchResponseBuilder.java index 41c0a746b3e..1ffdfbf4edb 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/SearchResponseBuilder.java +++ b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/SearchResponseBuilder.java @@ -27,7 +27,7 @@ import org.sonarqube.ws.ProjectAnalyses.SearchResponse; import static org.sonar.api.utils.DateUtils.formatDateTime; import static org.sonar.core.util.Protobuf.setNullable; -import static org.sonarqube.ws.client.projectanalysis.EventCategory.fromLabel; +import static org.sonar.server.projectanalysis.ws.EventCategory.fromLabel; class SearchResponseBuilder { private final Analysis.Builder wsAnalysis; diff --git a/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/UpdateEventAction.java b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/UpdateEventAction.java index 45164cb841e..f9fd401c509 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/UpdateEventAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/UpdateEventAction.java @@ -37,7 +37,6 @@ import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.user.UserSession; import org.sonarqube.ws.ProjectAnalyses.Event; import org.sonarqube.ws.ProjectAnalyses.UpdateEventResponse; -import org.sonarqube.ws.client.projectanalysis.EventCategory; import javax.annotation.CheckForNull; @@ -48,10 +47,10 @@ import static org.apache.commons.lang.StringUtils.isNotBlank; import static org.sonar.core.util.Protobuf.setNullable; import static org.sonar.server.projectanalysis.ws.EventValidator.checkModifiable; import static org.sonar.server.ws.WsUtils.writeProtobuf; -import static org.sonarqube.ws.client.projectanalysis.EventCategory.VERSION; -import static org.sonarqube.ws.client.projectanalysis.EventCategory.fromLabel; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_EVENT; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_NAME; +import static org.sonar.server.projectanalysis.ws.EventCategory.VERSION; +import static org.sonar.server.projectanalysis.ws.EventCategory.fromLabel; +import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_EVENT; +import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_NAME; public class UpdateEventAction implements ProjectAnalysesWsAction { private static final int MAX_NAME_LENGTH = 100; diff --git a/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/CreateEventActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/CreateEventActionTest.java index 5b536ebcf36..8d9bd715578 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/CreateEventActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/CreateEventActionTest.java @@ -56,11 +56,11 @@ import static org.sonar.db.component.SnapshotTesting.newAnalysis; import static org.sonar.db.component.SnapshotTesting.newSnapshot; import static org.sonar.test.JsonAssert.assertJson; import static org.sonarqube.ws.client.WsRequest.Method.POST; -import static org.sonarqube.ws.client.projectanalysis.EventCategory.OTHER; -import static org.sonarqube.ws.client.projectanalysis.EventCategory.VERSION; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_ANALYSIS; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_CATEGORY; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_NAME; +import static org.sonar.server.projectanalysis.ws.EventCategory.OTHER; +import static org.sonar.server.projectanalysis.ws.EventCategory.VERSION; +import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_ANALYSIS; +import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_CATEGORY; +import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_NAME; public class CreateEventActionTest { diff --git a/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/DeleteActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/DeleteActionTest.java index 246c794fe27..23fd7eaa5af 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/DeleteActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/DeleteActionTest.java @@ -40,7 +40,7 @@ import static org.assertj.core.api.Assertions.tuple; import static org.sonar.db.component.SnapshotDto.STATUS_PROCESSED; import static org.sonar.db.component.SnapshotDto.STATUS_UNPROCESSED; import static org.sonar.db.component.SnapshotTesting.newAnalysis; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_ANALYSIS; +import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_ANALYSIS; public class DeleteActionTest { @Rule diff --git a/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/DeleteEventActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/DeleteEventActionTest.java index 4bb5a15b3bc..dcc6d2e7070 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/DeleteEventActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/DeleteEventActionTest.java @@ -44,8 +44,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.sonar.db.component.ComponentTesting.newPrivateProjectDto; import static org.sonar.db.component.SnapshotTesting.newAnalysis; import static org.sonar.db.event.EventTesting.newEvent; -import static org.sonarqube.ws.client.projectanalysis.EventCategory.VERSION; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_EVENT; +import static org.sonar.server.projectanalysis.ws.EventCategory.VERSION; +import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_EVENT; public class DeleteEventActionTest { @Rule diff --git a/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/EventValidatorTest.java b/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/EventValidatorTest.java index 43bbcfd2f6c..1172c9b3c2a 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/EventValidatorTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/EventValidatorTest.java @@ -28,7 +28,7 @@ import org.sonar.db.event.EventTesting; import org.sonar.db.organization.OrganizationTesting; import static org.sonar.db.component.SnapshotTesting.newAnalysis; -import static org.sonarqube.ws.client.projectanalysis.EventCategory.QUALITY_GATE; +import static org.sonar.server.projectanalysis.ws.EventCategory.QUALITY_GATE; public class EventValidatorTest { @Rule diff --git a/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/SearchActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/SearchActionTest.java index 703d093398c..338c710d795 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/SearchActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/SearchActionTest.java @@ -47,7 +47,6 @@ import org.sonarqube.ws.Common.Paging; import org.sonarqube.ws.ProjectAnalyses.Analysis; import org.sonarqube.ws.ProjectAnalyses.Event; import org.sonarqube.ws.ProjectAnalyses.SearchResponse; -import org.sonarqube.ws.client.projectanalysis.EventCategory; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.tuple; @@ -61,14 +60,14 @@ import static org.sonar.db.event.EventTesting.newEvent; import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; import static org.sonar.test.JsonAssert.assertJson; import static org.sonarqube.ws.client.WsRequest.Method.POST; -import static org.sonarqube.ws.client.projectanalysis.EventCategory.OTHER; -import static org.sonarqube.ws.client.projectanalysis.EventCategory.QUALITY_GATE; -import static org.sonarqube.ws.client.projectanalysis.EventCategory.VERSION; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_BRANCH; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_CATEGORY; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_FROM; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_PROJECT; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_TO; +import static org.sonar.server.projectanalysis.ws.EventCategory.OTHER; +import static org.sonar.server.projectanalysis.ws.EventCategory.QUALITY_GATE; +import static org.sonar.server.projectanalysis.ws.EventCategory.VERSION; +import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_BRANCH; +import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_CATEGORY; +import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_FROM; +import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_PROJECT; +import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_TO; public class SearchActionTest { diff --git a/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/UpdateEventActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/UpdateEventActionTest.java index 48d788a1406..0bd7d881596 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/UpdateEventActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/UpdateEventActionTest.java @@ -48,10 +48,10 @@ import static org.sonar.db.component.SnapshotTesting.newAnalysis; import static org.sonar.db.event.EventTesting.newEvent; import static org.sonar.test.JsonAssert.assertJson; import static org.sonarqube.ws.client.WsRequest.Method.POST; -import static org.sonarqube.ws.client.projectanalysis.EventCategory.OTHER; -import static org.sonarqube.ws.client.projectanalysis.EventCategory.VERSION; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_EVENT; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_NAME; +import static org.sonar.server.projectanalysis.ws.EventCategory.OTHER; +import static org.sonar.server.projectanalysis.ws.EventCategory.VERSION; +import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_EVENT; +import static org.sonar.server.projectanalysis.ws.ProjectAnalysesWsParameters.PARAM_NAME; public class UpdateEventActionTest { @Rule diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java index e0cd34ed343..27d06ffac66 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/DefaultWsClient.java @@ -29,7 +29,6 @@ import org.sonarqube.ws.client.organizations.OrganizationsService; import org.sonarqube.ws.client.permissions.PermissionsService; import org.sonarqube.ws.client.project.ProjectsService; import org.sonarqube.ws.client.projectanalyses.ProjectAnalysesService; -import org.sonarqube.ws.client.projectanalysis.ProjectAnalysisService; import org.sonarqube.ws.client.projectbranches.ProjectBranchesService; import org.sonarqube.ws.client.projectlinks.ProjectLinksService; import org.sonarqube.ws.client.qualitygates.QualitygatesService; @@ -74,7 +73,6 @@ class DefaultWsClient implements WsClient { private final SettingsService settingsService; private final RootsService rootsService; private final WebhooksService webhooksService; - private final ProjectAnalysisService projectAnalysisOld; private final ProjectAnalysesService projectAnalyses; private final NotificationsService notificationsService; private final ProjectBranchesService projectBranchesService; @@ -102,7 +100,6 @@ class DefaultWsClient implements WsClient { this.settingsService = new SettingsService(wsConnector); this.rootsService = new RootsService(wsConnector); this.webhooksService = new WebhooksService(wsConnector); - this.projectAnalysisOld = new ProjectAnalysisService(wsConnector); this.projectAnalyses = new ProjectAnalysesService(wsConnector); this.projectBranchesService = new ProjectBranchesService(wsConnector); this.notificationsService = new NotificationsService(wsConnector); @@ -218,11 +215,6 @@ class DefaultWsClient implements WsClient { return webhooksService; } - @Override - public ProjectAnalysisService projectAnalysisOld() { - return projectAnalysisOld; - } - @Override public ProjectAnalysesService projectAnalyses() { return projectAnalyses; diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java index 82becf77c3d..1de94f492e4 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsClient.java @@ -29,7 +29,6 @@ import org.sonarqube.ws.client.organizations.OrganizationsService; import org.sonarqube.ws.client.permissions.PermissionsService; import org.sonarqube.ws.client.project.ProjectsService; import org.sonarqube.ws.client.projectanalyses.ProjectAnalysesService; -import org.sonarqube.ws.client.projectanalysis.ProjectAnalysisService; import org.sonarqube.ws.client.projectbranches.ProjectBranchesService; import org.sonarqube.ws.client.projectlinks.ProjectLinksService; import org.sonarqube.ws.client.qualitygates.QualitygatesService; @@ -133,13 +132,6 @@ public interface WsClient { */ WebhooksService webhooks(); - /** - * @since 6.3 - * @deprecated since 7.0 use {@link #projectAnalyses()} instead - */ - @Deprecated - ProjectAnalysisService projectAnalysisOld(); - ProjectAnalysesService projectAnalyses(); /** diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/CreateEventRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/CreateEventRequest.java deleted file mode 100644 index 909d2d757ec..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/CreateEventRequest.java +++ /dev/null @@ -1,83 +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.projectanalysis; - -import static com.google.common.base.Preconditions.checkArgument; - -public class CreateEventRequest { - private final String analysis; - private final EventCategory category; - private final String name; - - private CreateEventRequest(Builder builder) { - analysis = builder.analysis; - category = builder.category; - name = builder.name; - } - - public String getAnalysis() { - return analysis; - } - - public EventCategory getCategory() { - return category; - } - - public String getName() { - return name; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String analysis; - private EventCategory category = EventCategory.OTHER; - private String name; - - private Builder() { - // enforce static factory method - } - - public Builder setAnalysis(String analysis) { - this.analysis = analysis; - return this; - } - - public Builder setCategory(EventCategory category) { - this.category = category; - return this; - } - - public Builder setName(String name) { - this.name = name; - return this; - } - - public CreateEventRequest build() { - checkArgument(analysis != null, "Analysis key is required"); - checkArgument(category != null, "Category is required"); - checkArgument(name != null, "Name is required"); - - return new CreateEventRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/DeleteEventRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/DeleteEventRequest.java deleted file mode 100644 index 3b4c3eddfda..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/DeleteEventRequest.java +++ /dev/null @@ -1,34 +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.projectanalysis; - -import static java.util.Objects.requireNonNull; - -public class DeleteEventRequest { - private final String event; - - public DeleteEventRequest(String event) { - this.event = requireNonNull(event); - } - - public String getEvent() { - return event; - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/DeleteRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/DeleteRequest.java deleted file mode 100644 index 95590fe75b2..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/DeleteRequest.java +++ /dev/null @@ -1,34 +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.projectanalysis; - -import static java.util.Objects.requireNonNull; - -public class DeleteRequest { - private final String analysis; - - public DeleteRequest(String analysis) { - this.analysis = requireNonNull(analysis); - } - - public String getAnalysis() { - return analysis; - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/ProjectAnalysisService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/ProjectAnalysisService.java deleted file mode 100644 index cf4ca3cf831..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/ProjectAnalysisService.java +++ /dev/null @@ -1,54 +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.projectanalysis; - -import org.sonarqube.ws.ProjectAnalyses.SearchResponse; -import org.sonarqube.ws.client.BaseService; -import org.sonarqube.ws.client.GetRequest; -import org.sonarqube.ws.client.WsConnector; - -import static org.sonar.api.server.ws.WebService.Param.PAGE; -import static org.sonar.api.server.ws.WebService.Param.PAGE_SIZE; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_BRANCH; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_CATEGORY; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_PROJECT; - -/** - * @deprecated since 7.0, use {@link org.sonarqube.ws.client.projectanalyses.ProjectAnalysesService} instead - */ -@Deprecated -public class ProjectAnalysisService extends BaseService { - - public ProjectAnalysisService(WsConnector wsConnector) { - super(wsConnector, "api/project_analyses"); - } - - public SearchResponse search(SearchRequest searchRequest) { - EventCategory eventCategory = searchRequest.getCategory(); - GetRequest request = new GetRequest(path("search")) - .setParam(PARAM_PROJECT, searchRequest.getProject()) - .setParam(PARAM_BRANCH, searchRequest.getBranch()) - .setParam(PARAM_CATEGORY, eventCategory == null ? null : eventCategory.name()) - .setParam(PAGE, searchRequest.getPage()) - .setParam(PAGE_SIZE, searchRequest.getPageSize()); - return call(request, SearchResponse.parser()); - } - -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/SearchRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/SearchRequest.java deleted file mode 100644 index c415d62b6ad..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/SearchRequest.java +++ /dev/null @@ -1,140 +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.projectanalysis; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import static com.google.common.base.Preconditions.checkArgument; -import static java.util.Objects.requireNonNull; - -public class SearchRequest { - public static final int DEFAULT_PAGE_SIZE = 100; - public static final int MAX_SIZE = 500; - - private final String project; - private final String branch; - private final EventCategory category; - private final int page; - private final int pageSize; - private final String from; - private final String to; - - private SearchRequest(Builder builder) { - this.project = builder.project; - this.branch= builder.branch; - this.category = builder.category; - this.page = builder.page; - this.pageSize = builder.pageSize; - this.from = builder.from; - this.to = builder.to; - } - - public String getProject() { - return project; - } - - @CheckForNull - public String getBranch() { - return branch; - } - - @CheckForNull - public EventCategory getCategory() { - return category; - } - - public int getPage() { - return page; - } - - public int getPageSize() { - return pageSize; - } - - @CheckForNull - public String getFrom() { - return from; - } - - @CheckForNull - public String getTo() { - return to; - } - - public static Builder builder() { - return new Builder(); - } - - public static class Builder { - private String project; - private String branch; - private EventCategory category; - private int page = 1; - private int pageSize = DEFAULT_PAGE_SIZE; - private String from; - private String to; - - private Builder() { - // enforce static factory method - } - - public Builder setProject(String project) { - this.project = project; - return this; - } - - public Builder setBranch(@Nullable String branch) { - this.branch = branch; - return this; - } - - public Builder setCategory(@Nullable EventCategory category) { - this.category = category; - return this; - } - - public Builder setPage(int page) { - this.page = page; - return this; - } - - public Builder setPageSize(int pageSize) { - this.pageSize = pageSize; - return this; - } - - public Builder setFrom(@Nullable String from) { - this.from = from; - return this; - } - - public Builder setTo(@Nullable String to) { - this.to = to; - return this; - } - - public SearchRequest build() { - requireNonNull(project, "Project is required"); - checkArgument(pageSize <= MAX_SIZE, "Page size must be lower than or equal to " + MAX_SIZE); - return new SearchRequest(this); - } - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/UpdateEventRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/UpdateEventRequest.java deleted file mode 100644 index 27dbbf77730..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/UpdateEventRequest.java +++ /dev/null @@ -1,43 +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.projectanalysis; - -import javax.annotation.CheckForNull; - -import static java.util.Objects.requireNonNull; - -public class UpdateEventRequest { - private final String event; - private final String name; - - public UpdateEventRequest(String event, String name) { - this.event = requireNonNull(event, "Event key is required"); - this.name = requireNonNull(name, "Name is required"); - } - - public String getEvent() { - return event; - } - - @CheckForNull - public String getName() { - return name; - } -} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/package-info.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/package-info.java deleted file mode 100644 index 7ffc784f651..00000000000 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectanalysis/package-info.java +++ /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.projectanalysis; - -import javax.annotation.ParametersAreNonnullByDefault; - diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/CreateEventRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/CreateEventRequestTest.java deleted file mode 100644 index 41bac7caf0b..00000000000 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/CreateEventRequestTest.java +++ /dev/null @@ -1,76 +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.projectanalysis; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.sonarqube.ws.client.projectanalysis.EventCategory.OTHER; -import static org.sonarqube.ws.client.projectanalysis.EventCategory.VERSION; - -public class CreateEventRequestTest { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private CreateEventRequest.Builder underTest = CreateEventRequest.builder(); - - @Test - public void build_request() { - CreateEventRequest result = underTest.setAnalysis("P1").setCategory(OTHER).setName("name").build(); - - assertThat(result.getAnalysis()).isEqualTo("P1"); - assertThat(result.getCategory()).isEqualTo(OTHER); - assertThat(result.getName()).isEqualTo("name"); - } - - @Test - public void other_category_by_default() { - CreateEventRequest result = underTest.setAnalysis("P1").setName("name").build(); - - assertThat(OTHER).isEqualTo(result.getCategory()); - } - - @Test - public void fail_when_no_category() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Category is required"); - - underTest.setAnalysis("P1").setName("name").setCategory(null).build(); - } - - @Test - public void fail_when_no_analysis() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Analysis key is required"); - - underTest.setCategory(VERSION).setName("name").build(); - } - - @Test - public void fail_when_no_name() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Name is required"); - - underTest.setAnalysis("P1").setCategory(VERSION).build(); - } -} diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/ProjectAnalysesWsParametersTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/ProjectAnalysesWsParametersTest.java deleted file mode 100644 index d72c477b6a5..00000000000 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/ProjectAnalysesWsParametersTest.java +++ /dev/null @@ -1,33 +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.projectanalysis; - -import org.junit.Test; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.sonar.test.TestUtils.hasOnlyPrivateConstructors; - -public class ProjectAnalysesWsParametersTest { - - @Test - public void private_access_only() { - assertThat(hasOnlyPrivateConstructors(ProjectAnalysesWsParameters.class)).isTrue(); - } -} diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/ProjectAnalysisServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/ProjectAnalysisServiceTest.java deleted file mode 100644 index 8139bd00434..00000000000 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/ProjectAnalysisServiceTest.java +++ /dev/null @@ -1,81 +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.projectanalysis; - -import org.junit.Rule; -import org.junit.Test; -import org.sonarqube.ws.ProjectAnalyses; -import org.sonarqube.ws.client.GetRequest; -import org.sonarqube.ws.client.ServiceTester; -import org.sonarqube.ws.client.WsConnector; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.sonar.api.server.ws.WebService.Param.PAGE; -import static org.sonar.api.server.ws.WebService.Param.PAGE_SIZE; -import static org.sonarqube.ws.client.projectanalysis.EventCategory.QUALITY_GATE; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_BRANCH; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_CATEGORY; -import static org.sonarqube.ws.client.projectanalysis.ProjectAnalysesWsParameters.PARAM_PROJECT; - -public class ProjectAnalysisServiceTest { - - @Rule - public ServiceTester serviceTester = new ServiceTester<>(new ProjectAnalysisService(mock(WsConnector.class))); - - private ProjectAnalysisService underTest = serviceTester.getInstanceUnderTest(); - - @Test - public void search() { - underTest.search(SearchRequest.builder() - .setProject("project") - .setBranch("my_branch") - .setCategory(QUALITY_GATE) - .setPage(10) - .setPageSize(50) - .build()); - GetRequest getRequest = serviceTester.getGetRequest(); - - assertThat(serviceTester.getGetParser()).isSameAs(ProjectAnalyses.SearchResponse.parser()); - serviceTester.assertThat(getRequest) - .hasParam(PARAM_PROJECT, "project") - .hasParam(PARAM_BRANCH, "my_branch") - .hasParam(PARAM_CATEGORY, QUALITY_GATE.name()) - .hasParam(PAGE, 10) - .hasParam(PAGE_SIZE, 50) - .andNoOtherParam(); - } - - @Test - public void search_with_minimal_fields() { - underTest.search(SearchRequest.builder() - .setProject("project") - .build()); - GetRequest getRequest = serviceTester.getGetRequest(); - - assertThat(serviceTester.getGetParser()).isSameAs(ProjectAnalyses.SearchResponse.parser()); - serviceTester.assertThat(getRequest) - .hasParam(PARAM_PROJECT, "project") - .hasParam(PAGE, 1) - .hasParam(PAGE_SIZE, 100) - .andNoOtherParam(); - } - -} diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/SearchRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/SearchRequestTest.java deleted file mode 100644 index 4abe04fa8a4..00000000000 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/SearchRequestTest.java +++ /dev/null @@ -1,80 +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.projectanalysis; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.sonarqube.ws.client.projectanalysis.EventCategory.QUALITY_GATE; - -public class SearchRequestTest { - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private SearchRequest.Builder underTest = SearchRequest.builder(); - - @Test - public void search_request() { - SearchRequest result = underTest - .setProject("P1") - .setBranch("my_branch") - .setCategory(QUALITY_GATE) - .setPage(2) - .setPageSize(500) - .setFrom("2016-01-01") - .setTo("2017-07-01") - .build(); - - assertThat(result.getProject()).isEqualTo("P1"); - assertThat(result.getBranch()).isEqualTo("my_branch"); - assertThat(result.getPage()).isEqualTo(2); - assertThat(result.getPageSize()).isEqualTo(500); - assertThat(result.getCategory()).isEqualTo(QUALITY_GATE); - assertThat(result.getFrom()).isEqualTo("2016-01-01"); - assertThat(result.getTo()).isEqualTo("2017-07-01"); - } - - @Test - public void page_default_values() { - SearchRequest result = underTest.setProject("P1").build(); - - assertThat(result.getPage()).isEqualTo(1); - assertThat(result.getPageSize()).isEqualTo(100); - } - - @Test - public void fail_if_project_is_null() { - expectedException.expect(NullPointerException.class); - - underTest.build(); - } - - @Test - public void fail_if_page_size_greater_than_500() { - expectedException.expect(IllegalArgumentException.class); - expectedException.expectMessage("Page size must be lower than or equal to 500"); - - underTest.setProject("P1") - .setPageSize(501) - .build(); - } -} diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/UpdateEventRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/UpdateEventRequestTest.java deleted file mode 100644 index a5321c695a9..00000000000 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/UpdateEventRequestTest.java +++ /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.projectanalysis; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import static org.assertj.core.api.Assertions.assertThat; - -public class UpdateEventRequestTest { - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - private UpdateEventRequest underTest; - - @Test - public void request_with_name_only() { - underTest = new UpdateEventRequest("E1", "name"); - - assertThat(underTest.getEvent()).isEqualTo("E1"); - assertThat(underTest.getName()).isEqualTo("name"); - } - - @Test - public void request_with_all_parameters() { - underTest = new UpdateEventRequest("E1", "name"); - - assertThat(underTest.getEvent()).isEqualTo("E1"); - assertThat(underTest.getName()).isEqualTo("name"); - } - - @Test - public void fail_if_null_event() { - expectedException.expect(NullPointerException.class); - expectedException.expectMessage("Event key is required"); - - new UpdateEventRequest(null, "name"); - } - - @Test - public void fail_if_name_not_provided() { - expectedException.expect(NullPointerException.class); - expectedException.expectMessage("Name is required"); - - new UpdateEventRequest("E1", null); - } -} diff --git a/tests/src/test/java/org/sonarqube/tests/issue/IssueCreationDateQPChangedTest.java b/tests/src/test/java/org/sonarqube/tests/issue/IssueCreationDateQPChangedTest.java index c50bd459e95..43dbee9f167 100644 --- a/tests/src/test/java/org/sonarqube/tests/issue/IssueCreationDateQPChangedTest.java +++ b/tests/src/test/java/org/sonarqube/tests/issue/IssueCreationDateQPChangedTest.java @@ -37,7 +37,7 @@ import org.junit.Test; import org.sonar.wsclient.issue.Issue; import org.sonar.wsclient.issue.IssueQuery; import org.sonarqube.ws.ProjectAnalyses; -import org.sonarqube.ws.client.projectanalysis.SearchRequest; +import org.sonarqube.ws.client.projectanalyses.SearchRequest; import util.ItUtils; import static org.assertj.core.api.Assertions.assertThat; @@ -358,8 +358,8 @@ public class IssueCreationDateQPChangedTest extends AbstractIssueTest { private static Date getAnalysisDate(Function, Optional> chooseItem) { return Optional.of( ItUtils.newWsClient(ORCHESTRATOR) - .projectAnalysisOld() - .search(SearchRequest.builder().setProject(SAMPLE_PROJECT_KEY).build()) + .projectAnalyses() + .search(new SearchRequest().setProject(SAMPLE_PROJECT_KEY)) .getAnalysesList()) .flatMap(chooseItem) .map(ProjectAnalyses.Analysis::getDate) -- 2.39.5