diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2017-08-21 16:01:34 +0200 |
---|---|---|
committer | Janos Gyerik <janos.gyerik@sonarsource.com> | 2017-09-12 11:34:48 +0200 |
commit | b6b7953d88cdcca4edabc6b40101500df93fad6d (patch) | |
tree | 6c8a3b629c520ea299ce28036c27969b3dbbdac7 /sonar-ws | |
parent | 60b1fcc8948c4eeeb3e8843002fe0211994ddb7f (diff) | |
download | sonarqube-b6b7953d88cdcca4edabc6b40101500df93fad6d.tar.gz sonarqube-b6b7953d88cdcca4edabc6b40101500df93fad6d.zip |
SONAR-9616 Ability to manually delete a non-main branch
Diffstat (limited to 'sonar-ws')
3 files changed, 23 insertions, 0 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbranches/ProjectBranchesParameters.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbranches/ProjectBranchesParameters.java index e64477d1b11..c1370b92093 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbranches/ProjectBranchesParameters.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbranches/ProjectBranchesParameters.java @@ -26,6 +26,7 @@ public class ProjectBranchesParameters { // actions public static final String ACTION_LIST = "list"; public static final String ACTION_SHOW = "show"; + public static final String ACTION_DELETE = "delete"; // parameters public static final String PARAM_PROJECT = "project"; diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbranches/ProjectBranchesService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbranches/ProjectBranchesService.java index c9a5a21fc24..0a0b23a09aa 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbranches/ProjectBranchesService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/projectbranches/ProjectBranchesService.java @@ -23,10 +23,12 @@ import org.sonarqube.ws.WsBranches.ListWsResponse; import org.sonarqube.ws.WsBranches.ShowWsResponse; 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 static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.ACTION_LIST; import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.ACTION_SHOW; +import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.ACTION_DELETE; import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.CONTROLLER; import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.PARAM_BRANCH; import static org.sonarqube.ws.client.projectbranches.ProjectBranchesParameters.PARAM_PROJECT; @@ -50,4 +52,11 @@ public class ProjectBranchesService extends BaseService { return call(get, ShowWsResponse.parser()); } + public void delete(String project, String branch) { + PostRequest post = new PostRequest(path(ACTION_DELETE)) + .setParam(PARAM_PROJECT, project) + .setParam(PARAM_BRANCH, branch); + call(post); + } + } diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/projectbranches/ProjectBranchesServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/projectbranches/ProjectBranchesServiceTest.java index 54bec8cd894..6a5b894e035 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/projectbranches/ProjectBranchesServiceTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/projectbranches/ProjectBranchesServiceTest.java @@ -25,6 +25,7 @@ import org.junit.Test; import org.sonarqube.ws.WsBranches.ListWsResponse; import org.sonarqube.ws.WsBranches.ShowWsResponse; import org.sonarqube.ws.client.GetRequest; +import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.ServiceTester; import org.sonarqube.ws.client.WsConnector; @@ -67,4 +68,16 @@ public class ProjectBranchesServiceTest { .andNoOtherParam(); } + @Test + public void delete() { + underTest.delete("projectKey", "my_branch"); + + PostRequest postRequest = serviceTester.getPostRequest(); + serviceTester.assertThat(postRequest) + .hasPath("delete") + .hasParam(PARAM_PROJECT, "projectKey") + .hasParam(PARAM_BRANCH, "my_branch") + .andNoOtherParam(); + } + } |