]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR 8363 IT to test favorite auto-assignment 1381/head
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Mon, 14 Nov 2016 10:17:36 +0000 (11:17 +0100)
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>
Mon, 14 Nov 2016 10:17:46 +0000 (11:17 +0100)
it/it-tests/src/test/java/it/Category3Suite.java
it/it-tests/src/test/java/it/analysis/FavoriteTest.java [new file with mode: 0644]

index 7d96b5058252fdbd2d00ee35eacbcd38774fc1a9..99f74cc3909c932a208d3090aa65661113ab6db7 100644 (file)
@@ -20,8 +20,8 @@
 package it;
 
 import com.sonar.orchestrator.Orchestrator;
-import it.analysis.ScannerTest;
 import it.analysis.ExtensionLifecycleTest;
+import it.analysis.FavoriteTest;
 import it.analysis.IssueJsonReportTest;
 import it.analysis.IssuesModeTest;
 import it.analysis.LinksTest;
@@ -30,6 +30,7 @@ import it.analysis.ProjectBuilderTest;
 import it.analysis.ProjectProvisioningTest;
 import it.analysis.ReportDumpTest;
 import it.analysis.SSLTest;
+import it.analysis.ScannerTest;
 import it.analysis.SettingsEncryptionTest;
 import it.analysis.TempFolderTest;
 import it.measure.DecimalScaleMetricTest;
@@ -57,6 +58,7 @@ import static util.ItUtils.xooPlugin;
   SettingsEncryptionTest.class,
   ReportDumpTest.class,
   SSLTest.class,
+  FavoriteTest.class,
   // measures
   DecimalScaleMetricTest.class,
   // organization
diff --git a/it/it-tests/src/test/java/it/analysis/FavoriteTest.java b/it/it-tests/src/test/java/it/analysis/FavoriteTest.java
new file mode 100644 (file)
index 0000000..8ee6eaa
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * 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 it.analysis;
+
+import com.sonar.orchestrator.Orchestrator;
+import com.sonar.orchestrator.build.SonarScanner;
+import it.Category3Suite;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.sonarqube.ws.MediaTypes;
+import org.sonarqube.ws.client.GetRequest;
+import org.sonarqube.ws.client.WsClient;
+
+import static com.sonar.orchestrator.container.Server.ADMIN_LOGIN;
+import static com.sonar.orchestrator.container.Server.ADMIN_PASSWORD;
+import static org.assertj.core.api.Assertions.assertThat;
+import static util.ItUtils.newAdminWsClient;
+import static util.ItUtils.projectDir;
+
+public class FavoriteTest {
+  @ClassRule
+  public static Orchestrator orchestrator = Category3Suite.ORCHESTRATOR;
+  private static WsClient adminWsClient;
+
+  private static final String PROJECT_KEY = "sample";
+
+  @Before
+  public void setUp() {
+    orchestrator.resetData();
+  }
+
+  @BeforeClass
+  public static void classSetUp() {
+    adminWsClient = newAdminWsClient(orchestrator);
+  }
+
+  @Test
+  public void project_as_favorite_when_authenticated_and_first_analysis() {
+    SonarScanner sampleProject = SonarScanner.create(projectDir("shared/xoo-sample"))
+      .setProperty("sonar.login", ADMIN_LOGIN)
+      .setProperty("sonar.password", ADMIN_PASSWORD);
+    orchestrator.executeBuild(sampleProject);
+
+    String response = adminWsClient.wsConnector().call(new GetRequest("api/favourites").setMediaType(MediaTypes.JSON)).content();
+    assertThat(response).contains(PROJECT_KEY);
+  }
+
+  @Test
+  public void no_project_as_favorite_when_second_analysis() {
+    SonarScanner sampleProject = SonarScanner.create(projectDir("shared/xoo-sample"));
+    orchestrator.executeBuild(sampleProject);
+    sampleProject
+      .setProperty("sonar.login", ADMIN_LOGIN)
+      .setProperty("sonar.password", ADMIN_PASSWORD);
+    orchestrator.executeBuild(sampleProject);
+
+    String response = adminWsClient.wsConnector().call(new GetRequest("api/favourites").setMediaType(MediaTypes.JSON)).content();
+    assertThat(response).doesNotContain(PROJECT_KEY);
+  }
+}