From da4ad168305e74d8de03764be07acc3bf024f8d5 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Wed, 23 Aug 2017 15:19:55 +0200 Subject: [PATCH] SONAR-9616 Add IT on api/project_branches/list --- .../org/sonarqube/tests/Category2Suite.java | 5 +- .../sonarqube/tests/branch/BranchTest.java | 54 +++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 tests/src/test/java/org/sonarqube/tests/branch/BranchTest.java diff --git a/tests/src/test/java/org/sonarqube/tests/Category2Suite.java b/tests/src/test/java/org/sonarqube/tests/Category2Suite.java index 4df919b09c1..832da865d7b 100644 --- a/tests/src/test/java/org/sonarqube/tests/Category2Suite.java +++ b/tests/src/test/java/org/sonarqube/tests/Category2Suite.java @@ -23,6 +23,7 @@ import com.sonar.orchestrator.Orchestrator; import org.junit.ClassRule; import org.junit.runner.RunWith; import org.junit.runners.Suite; +import org.sonarqube.tests.branch.BranchTest; import org.sonarqube.tests.issue.AutoAssignTest; import org.sonarqube.tests.issue.CommonRulesTest; import org.sonarqube.tests.issue.CustomRulesTest; @@ -97,7 +98,9 @@ import static util.ItUtils.xooPlugin; TechnicalDebtMeasureVariationTest.class, TechnicalDebtTest.class, // ui - IssuesPageTest.class + IssuesPageTest.class, + // branch + BranchTest.class }) public class Category2Suite { diff --git a/tests/src/test/java/org/sonarqube/tests/branch/BranchTest.java b/tests/src/test/java/org/sonarqube/tests/branch/BranchTest.java new file mode 100644 index 00000000000..3be6b17d4c3 --- /dev/null +++ b/tests/src/test/java/org/sonarqube/tests/branch/BranchTest.java @@ -0,0 +1,54 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 SonarSource SA + * mailto:info 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.tests.branch; + +import com.sonar.orchestrator.Orchestrator; +import org.assertj.core.groups.Tuple; +import org.junit.ClassRule; +import org.junit.Rule; +import org.junit.Test; +import org.sonarqube.tests.Category1Suite; +import org.sonarqube.tests.Tester; +import org.sonarqube.ws.Common; +import org.sonarqube.ws.WsBranches; + +import static org.assertj.core.api.Java6Assertions.assertThat; +import static util.ItUtils.runProjectAnalysis; + +public class BranchTest { + + @ClassRule + public static Orchestrator orchestrator = Category1Suite.ORCHESTRATOR; + + @Rule + public Tester tester = new Tester(orchestrator); + + @Test + public void list_branches_contains_main_branch() { + runProjectAnalysis(orchestrator, "shared/xoo-sample"); + + WsBranches.ListWsResponse result = tester.wsClient().projectBranches().list("sample"); + + assertThat(result.getBranchesList()) + .extracting(WsBranches.Branch::getName, WsBranches.Branch::getType, WsBranches.Branch::getIsMain) + .containsExactlyInAnyOrder(Tuple.tuple("master", Common.BranchType.LONG, true)); + } +} -- 2.39.5