diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-09-13 17:27:32 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2016-09-14 11:10:52 +0200 |
commit | 82bcba2289a6866284dfb8559241c4467c4b9ddc (patch) | |
tree | 2f8b4af1f4ec0e7f6ed435fccf5aff8d9166eefe /sonar-ws/src/test | |
parent | 5cfc682cb1337718b49b3b7663be08c05a29641e (diff) | |
download | sonarqube-82bcba2289a6866284dfb8559241c4467c4b9ddc.tar.gz sonarqube-82bcba2289a6866284dfb8559241c4467c4b9ddc.zip |
SONAR-7855 Use protobuf in api/qualityprofiles/create WS
Diffstat (limited to 'sonar-ws/src/test')
2 files changed, 72 insertions, 0 deletions
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/CreateRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/CreateRequestTest.java new file mode 100644 index 00000000000..768f3a68cda --- /dev/null +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/CreateRequestTest.java @@ -0,0 +1,59 @@ +/* + * 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.qualityprofile; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import static org.assertj.core.api.Assertions.assertThat; + +public class CreateRequestTest { + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + CreateRequest.Builder underTest = CreateRequest.builder(); + + @Test + public void create_set_request() { + CreateRequest result = underTest + .setLanguage("java") + .setProfileName("Sonar way") + .build(); + + assertThat(result.getLanguage()).isEqualTo("java"); + assertThat(result.getProfileName()).isEqualTo("Sonar way"); + } + + @Test + public void fail_when_no_language() { + expectedException.expect(IllegalArgumentException.class); + underTest.setProfileName("Sonar way").build(); + } + + @Test + public void fail_when_no_profile_name() { + expectedException.expect(IllegalArgumentException.class); + underTest.setLanguage("java").build(); + } + +} diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java index 91ddb86ef69..0867a1542f3 100644 --- a/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/qualityprofile/QualityProfilesServiceTest.java @@ -87,4 +87,17 @@ public class QualityProfilesServiceTest { .hasParam(PARAM_PROJECT_KEY, "sample") .andNoOtherParam(); } + + @Test + public void create_project() throws Exception { + underTest.create(CreateRequest.builder() + .setLanguage("xoo") + .setProfileName("Sonar Way") + .build()); + + serviceTester.assertThat(serviceTester.getPostRequest()) + .hasParam(PARAM_LANGUAGE, "xoo") + .hasParam(PARAM_PROFILE_NAME, "Sonar Way") + .andNoOtherParam(); + } } |