aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2018-02-05 17:49:04 +0100
committerDuarte Meneses <duarte.meneses@sonarsource.com>2018-02-07 14:33:55 +0100
commit4991e63dbe3edb7327588c080e88c3de5a6ec3f5 (patch)
tree780d5bfb750e5867ae81a0622489eef129c5a8e4 /tests
parent8ec822898f98c85194b9394e347f1cf68805cbb9 (diff)
downloadsonarqube-4991e63dbe3edb7327588c080e88c3de5a6ec3f5.tar.gz
sonarqube-4991e63dbe3edb7327588c080e88c3de5a6ec3f5.zip
SONAR-10257 apply feedback
Diffstat (limited to 'tests')
-rw-r--r--tests/src/test/java/org/sonarqube/tests/source/NoScmTest.java8
-rw-r--r--tests/src/test/java/org/sonarqube/tests/source/NoScmThenScmTest.java8
-rw-r--r--tests/src/test/java/org/sonarqube/tests/source/ScmThenNoScmTest.java8
-rw-r--r--tests/src/test/java/org/sonarqube/tests/source/SourceScmWS.java13
4 files changed, 27 insertions, 10 deletions
diff --git a/tests/src/test/java/org/sonarqube/tests/source/NoScmTest.java b/tests/src/test/java/org/sonarqube/tests/source/NoScmTest.java
index de23ed8a23e..0add9b91c9a 100644
--- a/tests/src/test/java/org/sonarqube/tests/source/NoScmTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/source/NoScmTest.java
@@ -26,6 +26,7 @@ import java.io.IOException;
import java.text.ParseException;
import java.util.Date;
import java.util.Map;
+import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
@@ -49,7 +50,7 @@ public class NoScmTest {
@ClassRule
public static Orchestrator orchestrator = ORCHESTRATOR;
- private SourceScmWS ws = new SourceScmWS(orchestrator);
+ private SourceScmWS ws;
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@@ -57,6 +58,11 @@ public class NoScmTest {
@Rule
public Tester tester = new Tester(orchestrator);
+ @Before
+ public void setUp() {
+ ws = new SourceScmWS(tester);
+ }
+
@Test
public void two_analysis_without_scm_on_same_file() throws ParseException, IOException {
diff --git a/tests/src/test/java/org/sonarqube/tests/source/NoScmThenScmTest.java b/tests/src/test/java/org/sonarqube/tests/source/NoScmThenScmTest.java
index 8da6f589b67..f44fc83c68a 100644
--- a/tests/src/test/java/org/sonarqube/tests/source/NoScmThenScmTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/source/NoScmThenScmTest.java
@@ -26,6 +26,7 @@ import java.io.IOException;
import java.text.ParseException;
import java.util.Date;
import java.util.Map;
+import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
@@ -48,7 +49,7 @@ public class NoScmThenScmTest {
@ClassRule
public static Orchestrator orchestrator = ORCHESTRATOR;
- private SourceScmWS ws = new SourceScmWS(orchestrator);
+ private SourceScmWS ws;
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@@ -56,6 +57,11 @@ public class NoScmThenScmTest {
@Rule
public Tester tester = new Tester(orchestrator);
+ @Before
+ public void setUp() {
+ ws = new SourceScmWS(tester);
+ }
+
@Test
public void without_and_then_with_scm_on_same_file() throws ParseException, IOException {
diff --git a/tests/src/test/java/org/sonarqube/tests/source/ScmThenNoScmTest.java b/tests/src/test/java/org/sonarqube/tests/source/ScmThenNoScmTest.java
index b53fbcd6300..2a61e74dd37 100644
--- a/tests/src/test/java/org/sonarqube/tests/source/ScmThenNoScmTest.java
+++ b/tests/src/test/java/org/sonarqube/tests/source/ScmThenNoScmTest.java
@@ -28,6 +28,7 @@ import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.util.Date;
import java.util.Map;
+import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
@@ -46,7 +47,7 @@ public class ScmThenNoScmTest {
@ClassRule
public static Orchestrator orchestrator = ORCHESTRATOR;
- private SourceScmWS ws = new SourceScmWS(orchestrator);
+ private SourceScmWS ws;
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@@ -54,6 +55,11 @@ public class ScmThenNoScmTest {
@Rule
public Tester tester = new Tester(orchestrator);
+ @Before
+ public void setUp() {
+ ws = new SourceScmWS(tester);
+ }
+
@Test
public void with_and_then_without_scm_on_same_file() throws ParseException, IOException {
diff --git a/tests/src/test/java/org/sonarqube/tests/source/SourceScmWS.java b/tests/src/test/java/org/sonarqube/tests/source/SourceScmWS.java
index 77472ed4be0..c61aeca894c 100644
--- a/tests/src/test/java/org/sonarqube/tests/source/SourceScmWS.java
+++ b/tests/src/test/java/org/sonarqube/tests/source/SourceScmWS.java
@@ -19,25 +19,25 @@
*/
package org.sonarqube.tests.source;
-import com.sonar.orchestrator.Orchestrator;
import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;
import org.sonar.wsclient.jsonsimple.JSONArray;
import org.sonar.wsclient.jsonsimple.JSONObject;
import org.sonar.wsclient.jsonsimple.JSONValue;
+import org.sonarqube.qa.util.Tester;
+import org.sonarqube.ws.client.GetRequest;
public class SourceScmWS {
+ public final Tester tester;
- private final Orchestrator orchestrator;
-
- public SourceScmWS(Orchestrator orchestrator) {
- this.orchestrator = orchestrator;
+ public SourceScmWS(Tester tester) {
+ this.tester = tester;
}
public Map<Integer, LineData> getScmData(String fileKey) throws ParseException {
Map<Integer, LineData> result = new HashMap<>();
- String json = orchestrator.getServer().adminWsClient().get("api/sources/scm", "key", fileKey);
+ String json = tester.asAnonymous().wsClient().wsConnector().call(new GetRequest("api/sources/scm").setParam("key", fileKey)).content();
JSONObject obj = (JSONObject) JSONValue.parse(json);
JSONArray array = (JSONArray) obj.get("scm");
for (Object anArray : array) {
@@ -48,5 +48,4 @@ public class SourceScmWS {
return result;
}
-
}