diff options
author | Julien Lancelot <julien.lancelot@gmail.com> | 2013-05-13 18:55:51 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@gmail.com> | 2013-05-13 18:55:51 +0200 |
commit | 2d4b079141608ec417e284ff714bfe0b7d6dd040 (patch) | |
tree | e2c0ea11a50493c5099a7f30f0c433af00d663e4 /sonar-ws-client/src/test/java/org/sonar | |
parent | 3920d6ae7a4ece63563995c9505dca8f2544eceb (diff) | |
download | sonarqube-2d4b079141608ec417e284ff714bfe0b7d6dd040.tar.gz sonarqube-2d4b079141608ec417e284ff714bfe0b7d6dd040.zip |
SONAR-4282 Create Action Plan WS to get all action plans
Diffstat (limited to 'sonar-ws-client/src/test/java/org/sonar')
3 files changed, 108 insertions, 0 deletions
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarClientTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarClientTest.java index 03ae927b15d..9c9acbbbd55 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarClientTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarClientTest.java @@ -20,6 +20,7 @@ package org.sonar.wsclient; import org.junit.Test; +import org.sonar.wsclient.issue.DefaultActionPlanClient; import org.sonar.wsclient.issue.DefaultIssueClient; import org.sonar.wsclient.user.DefaultUserClient; @@ -31,6 +32,7 @@ public class SonarClientTest { public void should_build_clients() { SonarClient client = SonarClient.builder().url("http://localhost:9000").build(); assertThat(client.issueClient()).isNotNull().isInstanceOf(DefaultIssueClient.class); + assertThat(client.actionPlanClient()).isNotNull().isInstanceOf(DefaultActionPlanClient.class); assertThat(client.userClient()).isNotNull().isInstanceOf(DefaultUserClient.class); } diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/ActionPlanQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/ActionPlanQueryTest.java new file mode 100644 index 00000000000..b446736f86c --- /dev/null +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/ActionPlanQueryTest.java @@ -0,0 +1,38 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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.wsclient.issue; + +import org.junit.Test; + +import java.util.Map; + +import static org.fest.assertions.Assertions.assertThat; + +public class ActionPlanQueryTest { + + @Test + public void test_empty_params() throws Exception { + ActionPlanQuery query = ActionPlanQuery.create(); + Map<String, Object> params = query.urlParams(); + + assertThat(params).isEmpty(); + } +} diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/DefaultActionPlanClientTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/DefaultActionPlanClientTest.java new file mode 100644 index 00000000000..3ce0afb9f59 --- /dev/null +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/issue/DefaultActionPlanClientTest.java @@ -0,0 +1,68 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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.wsclient.issue; + +import org.junit.Rule; +import org.junit.Test; +import org.sonar.wsclient.MockHttpServerInterceptor; +import org.sonar.wsclient.internal.HttpRequestFactory; + +import java.util.List; + +import static org.fest.assertions.Assertions.assertThat; + +public class DefaultActionPlanClientTest { + + @Rule + public MockHttpServerInterceptor httpServer = new MockHttpServerInterceptor(); + + @Test + public void should_find_action_plans() { + HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url(), null, null); + httpServer.doReturnBody("{\"actionPlans\": [{\"key\": \"382f6f2e-ad9d-424a-b973-9b065e04348a\",\n" + + "\"name\": \"Long term\",\n" + + "\"status\": \"CLOSED\",\n" + + "\"project\": \"com.sonarsource.it.samples:simple-sample\",\n" + + "\"userLogin\": \"admin\",\n" + + "\"deadLine\": \"2013-05-30T00:00:00+0200\",\n" + + "\"totalIssues\": 0,\n" + + "\"openIssues\": 0,\n" + + "\"createdAt\": \"2013-05-13T12:50:29+0200\",\n" + + "\"updatedAt\": \"2013-05-13T12:50:44+0200\"}]}"); + + ActionPlanClient client = new DefaultActionPlanClient(requestFactory); + List<ActionPlan> actionPlans = client.find(); + + assertThat(httpServer.requestedPath()).isEqualTo("/api/action_plans/search"); + assertThat(actionPlans).hasSize(1); + ActionPlan actionPlan = actionPlans.get(0); + assertThat(actionPlan.key()).isEqualTo("382f6f2e-ad9d-424a-b973-9b065e04348a"); + assertThat(actionPlan.name()).isEqualTo("Long term"); + assertThat(actionPlan.status()).isEqualTo("CLOSED"); + assertThat(actionPlan.userLogin()).isEqualTo("admin"); + assertThat(actionPlan.deadLine()).isNotNull(); + assertThat(actionPlan.totalIssues()).isEqualTo(0); + assertThat(actionPlan.openIssues()).isEqualTo(0); + assertThat(actionPlan.createdAt()).isNotNull(); + assertThat(actionPlan.updatedAt()).isNotNull(); + } + +} |