From 769e6a497f24c71e3d11a711d5bd12f8cef413c5 Mon Sep 17 00:00:00 2001 From: Lukasz Jarocki Date: Tue, 16 Nov 2021 15:19:28 +0100 Subject: SONAR-13427 implement ITs --- .../ws/client/projectbadges/MeasureRequest.java | 13 ++++++ .../client/projectbadges/ProjectBadgesService.java | 32 +++++++++++++++ .../client/projectbadges/QualityGateRequest.java | 13 ++++++ .../ws/client/projectbadges/RenewTokenRequest.java | 47 ++++++++++++++++++++++ .../ws/client/projectbadges/TokenRequest.java | 47 ++++++++++++++++++++++ 5 files changed, 152 insertions(+) create mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/RenewTokenRequest.java create mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/TokenRequest.java (limited to 'sonar-ws/src/main') diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/MeasureRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/MeasureRequest.java index 6d08e716944..ddecb76a245 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/MeasureRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/MeasureRequest.java @@ -33,6 +33,7 @@ public class MeasureRequest { private String branch; private String metric; private String project; + private String token; /** * Example value: "feature/my_branch" @@ -84,4 +85,16 @@ public class MeasureRequest { public String getProject() { return project; } + + /** + * Tthis an optional parameter. + */ + public MeasureRequest setToken(String token) { + this.token = token; + return this; + } + + public String getToken() { + return token; + } } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/ProjectBadgesService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/ProjectBadgesService.java index 393a0355dcf..f06083b0d5c 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/ProjectBadgesService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/ProjectBadgesService.java @@ -21,9 +21,12 @@ package org.sonarqube.ws.client.projectbadges; import javax.annotation.Generated; import org.sonarqube.ws.MediaTypes; +import org.sonarqube.ws.ProjectBadgeToken.TokenWsResponse; import org.sonarqube.ws.client.BaseService; import org.sonarqube.ws.client.GetRequest; +import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsConnector; +import org.sonarqube.ws.client.WsResponse; /** * @see Further information about this web service online @@ -48,6 +51,7 @@ public class ProjectBadgesService extends BaseService { .setParam("branch", request.getBranch()) .setParam("metric", request.getMetric()) .setParam("project", request.getProject()) + .setParam("token", request.getToken()) .setMediaType(MediaTypes.JSON) ).content(); } @@ -64,7 +68,35 @@ public class ProjectBadgesService extends BaseService { new GetRequest(path("quality_gate")) .setParam("branch", request.getBranch()) .setParam("project", request.getProject()) + .setParam("token", request.getToken()) .setMediaType(MediaTypes.JSON) ).content(); } + + /** + * + * This is part of the internal API. + * This is a GET request. + * @see Further information about this action online (including a response example) + * @since 9.2 + * @return + */ + public TokenWsResponse token(TokenRequest request) { + return call( + new GetRequest(path("token")) + .setParam("project", request.getProject()) + .setMediaType(MediaTypes.JSON), + TokenWsResponse.parser() + ); + } + + + public WsResponse renewToken(RenewTokenRequest request) { + return call( + new PostRequest(path("renew_token")) + .setParam("project", request.getProject()) + .setMediaType(MediaTypes.JSON) + ); + + } } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/QualityGateRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/QualityGateRequest.java index dc3e47f78d9..d345552ba55 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/QualityGateRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/QualityGateRequest.java @@ -32,6 +32,7 @@ public class QualityGateRequest { private String branch; private String project; + private String token; /** * Example value: "feature/my_branch" @@ -57,4 +58,16 @@ public class QualityGateRequest { public String getProject() { return project; } + + /** + * This is aan optional parameter. + */ + public QualityGateRequest setToken(String token) { + this.token = token; + return this; + } + + public String getToken() { + return token; + } } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/RenewTokenRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/RenewTokenRequest.java new file mode 100644 index 00000000000..8a8e86b7edb --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/RenewTokenRequest.java @@ -0,0 +1,47 @@ +/* + * SonarQube + * Copyright (C) 2009-2021 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.projectbadges; + +import javax.annotation.Generated; + +/** + * This is part of the internal API. + * This is a POST request. + * @see Further information about this action online (including a response example) + * @since 9.2 + */ +@Generated("sonar-ws-generator") +public class RenewTokenRequest { + + private String project; + + /** + * This is a mandatory parameter. + * Example value: "my_project" + */ + public RenewTokenRequest setProject(String project) { + this.project = project; + return this; + } + + public String getProject() { + return project; + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/TokenRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/TokenRequest.java new file mode 100644 index 00000000000..7054f2f6ec2 --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbadges/TokenRequest.java @@ -0,0 +1,47 @@ +/* + * SonarQube + * Copyright (C) 2009-2021 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.projectbadges; + +import javax.annotation.Generated; + +/** + * This is part of the internal API. + * This is a GET request. + * @see Further information about this action online (including a response example) + * @since 9.2 + */ +@Generated("sonar-ws-generator") +public class TokenRequest { + + private String project; + + /** + * This is a mandatory parameter. + * Example value: "my_project" + */ + public TokenRequest setProject(String project) { + this.project = project; + return this; + } + + public String getProject() { + return project; + } +} -- cgit v1.2.3