diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2016-12-06 18:34:44 +0100 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2016-12-07 17:23:30 +0100 |
commit | fbb33db724f16444ac882a4ffe88d15e8ff39837 (patch) | |
tree | 5a20bb22ec851a140d3a1ba5764c2055170e5c9e /sonar-ws/src/test | |
parent | 2f2b6fd1d3a3674d2864c1927e902d043f6e44ca (diff) | |
download | sonarqube-fbb33db724f16444ac882a4ffe88d15e8ff39837.tar.gz sonarqube-fbb33db724f16444ac882a4ffe88d15e8ff39837.zip |
SONAR-8464 Create WS api/project_analyses/create_event
Diffstat (limited to 'sonar-ws/src/test')
2 files changed, 112 insertions, 0 deletions
diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/CreateEventRequestTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/CreateEventRequestTest.java new file mode 100644 index 00000000000..a96e1e0ce30 --- /dev/null +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/CreateEventRequestTest.java @@ -0,0 +1,78 @@ +/* + * 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.projectanalysis; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.sonarqube.ws.client.projectanalysis.CreateEventRequest.Category.OTHER; +import static org.sonarqube.ws.client.projectanalysis.CreateEventRequest.Category.VERSION; + +public class CreateEventRequestTest { + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + private CreateEventRequest.Builder underTest = CreateEventRequest.builder(); + + @Test + public void build_request() { + CreateEventRequest result = underTest.setAnalysis("P1").setCategory(OTHER).setName("name").setDescription("description").build(); + + assertThat(result.getAnalysis()).isEqualTo("P1"); + assertThat(result.getCategory()).isEqualTo(OTHER); + assertThat(result.getName()).isEqualTo("name"); + assertThat(result.getDescription()).isEqualTo("description"); + } + + @Test + public void other_category_by_default() { + CreateEventRequest result = underTest.setAnalysis("P1").setName("name").build(); + + assertThat(OTHER.equals(result.getCategory())); + } + + @Test + public void fail_when_no_category() { + expectedException.expect(IllegalArgumentException.class); + expectedException.expectMessage("Category is required"); + + underTest.setAnalysis("P1").setName("name").setCategory(null).build(); + } + + @Test + public void fail_when_no_analysis() { + expectedException.expect(IllegalArgumentException.class); + expectedException.expectMessage("Analysis key is required"); + + underTest.setCategory(VERSION).setName("name").build(); + } + + @Test + public void fail_when_no_name() { + expectedException.expect(IllegalArgumentException.class); + expectedException.expectMessage("Name is required"); + + underTest.setAnalysis("P1").setCategory(VERSION).build(); + } +} diff --git a/sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/ProjectAnalysesWsParametersTest.java b/sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/ProjectAnalysesWsParametersTest.java new file mode 100644 index 00000000000..f431cbd0858 --- /dev/null +++ b/sonar-ws/src/test/java/org/sonarqube/ws/client/projectanalysis/ProjectAnalysesWsParametersTest.java @@ -0,0 +1,34 @@ +/* + * 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.projectanalysis; + +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.sonar.test.TestUtils.hasOnlyPrivateConstructors; + +public class ProjectAnalysesWsParametersTest { + + @Test + public void private_access_only() { + assertThat(hasOnlyPrivateConstructors(ProjectAnalysesWsParameters.class)).isTrue(); + } +} |