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;
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<String> ALLOWED_QUALIFIERS = ImmutableSet.of(Qualifiers.PROJECT, Qualifiers.APP);
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;
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;
--- /dev/null
+/*
+ * 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.sonar.server.projectanalysis.ws;
+
+public enum EventCategory {
+ VERSION("Version"), OTHER("Other"), QUALITY_PROFILE("Profile"), QUALITY_GATE("Alert");
+
+ private final String label;
+
+ EventCategory(String label) {
+ this.label = label;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public static EventCategory fromLabel(String label) {
+ for (EventCategory category : values()) {
+ if (category.getLabel().equals(label)) {
+ return category;
+ }
+ }
+
+ throw new IllegalArgumentException("Unknown event category label '" + label + "'");
+ }
+}
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<String> AUTHORIZED_CATEGORIES = ImmutableSet.of(VERSION.name(), OTHER.name());
--- /dev/null
+/*
+ * 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.sonar.server.projectanalysis.ws;
+
+public class ProjectAnalysesWsParameters {
+ public static final String PARAM_ANALYSIS = "analysis";
+ public static final String PARAM_CATEGORY = "category";
+ public static final String PARAM_NAME = "name";
+ public static final String PARAM_EVENT = "event";
+ public static final String PARAM_PROJECT = "project";
+ public static final String PARAM_FROM = "from";
+ public static final String PARAM_TO = "to";
+ public static final String PARAM_BRANCH = "branch";
+
+ private ProjectAnalysesWsParameters() {
+ // static access only
+ }
+}
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;
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 {
*/
package org.sonar.server.projectanalysis.ws;
-import org.sonarqube.ws.client.projectanalysis.EventCategory;
-
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
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;
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;
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;
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 {
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
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
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
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;
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 {
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
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;
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;
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);
return webhooksService;
}
- @Override
- public ProjectAnalysisService projectAnalysisOld() {
- return projectAnalysisOld;
- }
-
@Override
public ProjectAnalysesService projectAnalyses() {
return projectAnalyses;
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;
*/
WebhooksService webhooks();
- /**
- * @since 6.3
- * @deprecated since 7.0 use {@link #projectAnalyses()} instead
- */
- @Deprecated
- ProjectAnalysisService projectAnalysisOld();
-
ProjectAnalysesService projectAnalyses();
/**
+++ /dev/null
-/*
- * 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);
- }
- }
-}
+++ /dev/null
-/*
- * 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;
- }
-}
+++ /dev/null
-/*
- * 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;
- }
-}
+++ /dev/null
-/*
- * 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;
-
-public enum EventCategory {
- VERSION("Version"), OTHER("Other"), QUALITY_PROFILE("Profile"), QUALITY_GATE("Alert");
-
- private final String label;
-
- EventCategory(String label) {
- this.label = label;
- }
-
- public String getLabel() {
- return label;
- }
-
- public static EventCategory fromLabel(String label) {
- for (EventCategory category : values()) {
- if (category.getLabel().equals(label)) {
- return category;
- }
- }
-
- throw new IllegalArgumentException("Unknown event category label '" + label + "'");
- }
-}
+++ /dev/null
-/*
- * 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;
-
-public class ProjectAnalysesWsParameters {
- public static final String PARAM_ANALYSIS = "analysis";
- public static final String PARAM_CATEGORY = "category";
- public static final String PARAM_NAME = "name";
- public static final String PARAM_EVENT = "event";
- public static final String PARAM_PROJECT = "project";
- public static final String PARAM_FROM = "from";
- public static final String PARAM_TO = "to";
- public static final String PARAM_BRANCH = "branch";
-
- private ProjectAnalysesWsParameters() {
- // static access only
- }
-}
+++ /dev/null
-/*
- * 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());
- }
-
-}
+++ /dev/null
-/*
- * 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);
- }
- }
-}
+++ /dev/null
-/*
- * 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;
- }
-}
+++ /dev/null
-/*
- * 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;
-
+++ /dev/null
-/*
- * 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();
- }
-}
+++ /dev/null
-/*
- * 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();
- }
-}
+++ /dev/null
-/*
- * 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<ProjectAnalysisService> 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();
- }
-
-}
+++ /dev/null
-/*
- * 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();
- }
-}
+++ /dev/null
-/*
- * 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);
- }
-}
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;
private static Date getAnalysisDate(Function<List<ProjectAnalyses.Analysis>, Optional<ProjectAnalyses.Analysis>> 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)