aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws/src/test
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2016-07-29 17:41:48 +0200
committerGitHub <noreply@github.com>2016-07-29 17:41:48 +0200
commit7b93c4de175621ce43236126a4a239534bed229e (patch)
tree25d9743ec3e0610a24bd877ee878e50a2386e2cc /sonar-ws/src/test
parentf6f754fc4a291b18ea4c9d183b7a2bfecbe1e2e3 (diff)
downloadsonarqube-7b93c4de175621ce43236126a4a239534bed229e.tar.gz
sonarqube-7b93c4de175621ce43236126a4a239534bed229e.zip
SONAR-7924 Modify WS api/qualitygates/select to accept project key (#1126)
Diffstat (limited to 'sonar-ws/src/test')
-rw-r--r--sonar-ws/src/test/java/org/sonarqube/ws/client/qualitygate/QualityGatesServiceTest.java63
1 files changed, 63 insertions, 0 deletions
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualitygate/QualityGatesServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualitygate/QualityGatesServiceTest.java
new file mode 100644
index 00000000000..3000be63863
--- /dev/null
+++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualitygate/QualityGatesServiceTest.java
@@ -0,0 +1,63 @@
+
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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.qualitygate;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.sonarqube.ws.client.PostRequest;
+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.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_PROJECT_ID;
+import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_PROJECT_KEY;
+import static org.sonarqube.ws.client.qualitygate.QualityGatesWsParameters.PARAM_GATE_ID;
+
+public class QualityGatesServiceTest {
+ private static final Long PROJECT_ID_VALUE = 195L;
+ private static final String PROJECT_KEY_VALUE = "project_key_value";
+ private static final Long GATE_ID_VALUE = 243L;
+
+ @Rule
+ public ServiceTester<QualityGatesService> serviceTester = new ServiceTester<>(new QualityGatesService(mock(WsConnector.class)));
+
+ private QualityGatesService underTest = serviceTester.getInstanceUnderTest();
+
+ @Test
+ public void associate_project_does_POST_request() {
+ underTest.associateProject(new SelectWsRequest()
+ .setGateId(GATE_ID_VALUE)
+ .setProjectId(PROJECT_ID_VALUE)
+ .setProjectKey(PROJECT_KEY_VALUE));
+
+ assertThat(serviceTester.getPostParser()).isNull();
+
+ PostRequest postRequest = serviceTester.getPostRequest();
+
+ serviceTester.assertThat(postRequest)
+ .hasPath("select")
+ .hasParam(PARAM_GATE_ID, String.valueOf(GATE_ID_VALUE))
+ .hasParam(PARAM_PROJECT_ID, String.valueOf(PROJECT_ID_VALUE))
+ .hasParam(PARAM_PROJECT_KEY, PROJECT_KEY_VALUE)
+ .andNoOtherParam();
+ }
+}