diff options
author | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-01-29 10:20:39 +0100 |
---|---|---|
committer | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2014-01-29 15:52:27 +0100 |
commit | ff7d411f8307aca5c62e8422edece454e40c02fb (patch) | |
tree | fb9c14193eb9382a719cf7af64a4b9eef4c9901e /sonar-ws-client/src/test/java/org | |
parent | a4da5c01aa43606948d69fe92a98a2cb1c438f0f (diff) | |
download | sonarqube-ff7d411f8307aca5c62e8422edece454e40c02fb.tar.gz sonarqube-ff7d411f8307aca5c62e8422edece454e40c02fb.zip |
SONAR-4326 Create WS client for rule tag referential management
Diffstat (limited to 'sonar-ws-client/src/test/java/org')
-rw-r--r-- | sonar-ws-client/src/test/java/org/sonar/wsclient/rule/internal/DefaultRuleTagClientTest.java | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/rule/internal/DefaultRuleTagClientTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/rule/internal/DefaultRuleTagClientTest.java new file mode 100644 index 00000000000..ebc9a595786 --- /dev/null +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/rule/internal/DefaultRuleTagClientTest.java @@ -0,0 +1,67 @@ +/* + * 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.rule.internal; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.sonar.wsclient.MockHttpServerInterceptor; +import org.sonar.wsclient.internal.HttpRequestFactory; + +import java.util.Collection; + +import static org.fest.assertions.Assertions.assertThat; +import static org.fest.assertions.MapAssert.entry; + +public class DefaultRuleTagClientTest { + + @Rule + public MockHttpServerInterceptor httpServer = new MockHttpServerInterceptor(); + + private DefaultRuleTagClient client; + + @Before + public void initClient() { + HttpRequestFactory requestFactory = new HttpRequestFactory(httpServer.url()); + this.client = new DefaultRuleTagClient(requestFactory); + } + + @Test + public void should_list_tags() { + httpServer.stubResponseBody("[\"tag1\",\"tag2\",\"tag3\"]"); + + Collection<String> result = client.list(); + + assertThat(httpServer.requestedPath()).isEqualTo("/api/rule_tags/list"); + assertThat(result).containsOnly("tag1", "tag2", "tag3"); + } + + @Test + public void should_create_rule_tag() { + httpServer.stubStatusCode(200); + + final String newTag = "polop"; + client.create(newTag); + + assertThat(httpServer.requestedPath()).isEqualTo("/api/rule_tags/create"); + assertThat(httpServer.requestParams()).includes(entry("tag", newTag)); + } + +} |