aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2017-04-11 15:05:06 +0200
committerdbmeneses <duarte.meneses@sonarsource.com>2017-04-12 09:33:10 +0200
commitdf9e95d9da11cafb5d894b589a80c614b654a9b1 (patch)
treef35d27655f1ba130f732135084734f5f428b02a0 /sonar-scanner-engine
parent8893f0dab4f866ac9a49cf4723fb6340196560d3 (diff)
downloadsonarqube-df9e95d9da11cafb5d894b589a80c614b654a9b1.tar.gz
sonarqube-df9e95d9da11cafb5d894b589a80c614b654a9b1.zip
SONAR-9080 Stop using api/batch/users
Diffstat (limited to 'sonar-scanner-engine')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/DefaultIssueCallback.java48
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/user/UserRepositoryLoader.java114
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/user/package-info.java23
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java4
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/JSONReport.java19
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/DefaultIssueCallbackTest.java22
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/user/UserRepositoryLoaderTest.java119
-rw-r--r--sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/report/JSONReportTest.java8
-rw-r--r--sonar-scanner-engine/src/test/resources/org/sonar/scanner/scan/report/JSONReportTest/report.json2
9 files changed, 19 insertions, 340 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/DefaultIssueCallback.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/DefaultIssueCallback.java
index c4061dc6092..e1c8531e6b9 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/DefaultIssueCallback.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/DefaultIssueCallback.java
@@ -19,43 +19,29 @@
*/
package org.sonar.scanner.issue;
-import org.apache.commons.lang.StringUtils;
import org.sonar.api.rule.RuleKey;
import org.sonar.batch.bootstrapper.IssueListener;
import org.sonar.api.batch.rule.Rule;
import org.sonar.api.batch.rule.Rules;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.stream.Collectors;
import org.sonar.scanner.issue.tracking.TrackedIssue;
-import org.sonar.scanner.protocol.input.ScannerInput.User;
-import org.sonar.scanner.repository.user.UserRepositoryLoader;
public class DefaultIssueCallback implements IssueCallback {
private final IssueCache issues;
private final IssueListener listener;
- private final UserRepositoryLoader userRepository;
private final Rules rules;
- private Set<String> userLoginNames = new HashSet<>();
- private Map<String, String> userMap = new HashMap<>();
- private Set<RuleKey> ruleKeys = new HashSet<>();
-
- public DefaultIssueCallback(IssueCache issues, IssueListener listener, UserRepositoryLoader userRepository, Rules rules) {
+ public DefaultIssueCallback(IssueCache issues, IssueListener listener, Rules rules) {
this.issues = issues;
this.listener = listener;
- this.userRepository = userRepository;
this.rules = rules;
}
/**
* If no listener exists, this constructor will be used by pico.
*/
- public DefaultIssueCallback(IssueCache issues, UserRepositoryLoader userRepository, Rules rules) {
- this(issues, null, userRepository, rules);
+ public DefaultIssueCallback(IssueCache issues, Rules rules) {
+ this(issues, null, rules);
}
@Override
@@ -65,15 +51,9 @@ public class DefaultIssueCallback implements IssueCallback {
}
for (TrackedIssue issue : issues.all()) {
- collectInfo(issue);
- }
-
- getUsers();
-
- for (TrackedIssue issue : issues.all()) {
IssueListener.Issue newIssue = new IssueListener.Issue();
newIssue.setAssigneeLogin(issue.assignee());
- newIssue.setAssigneeName(getAssigneeName(issue.assignee()));
+ newIssue.setAssigneeName(issue.assignee());
newIssue.setComponentKey(issue.componentKey());
newIssue.setKey(issue.key());
newIssue.setMessage(issue.getMessage());
@@ -92,26 +72,6 @@ public class DefaultIssueCallback implements IssueCallback {
}
}
- private void collectInfo(TrackedIssue issue) {
- if (!StringUtils.isEmpty(issue.assignee())) {
- userLoginNames.add(issue.assignee());
- }
- if (issue.getRuleKey() != null) {
- ruleKeys.add(issue.getRuleKey());
- }
- }
-
- private String getAssigneeName(String login) {
- return userMap.get(login);
- }
-
- private void getUsers() {
- Map<String, User> map = userRepository.map(userLoginNames);
-
- userMap = map.entrySet().stream()
- .collect(Collectors.toMap(Map.Entry::getKey, e -> e.getValue().getName()));
- }
-
private String getRuleName(RuleKey ruleKey) {
Rule rule = rules.find(ruleKey);
return rule != null ? rule.name() : null;
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/user/UserRepositoryLoader.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/user/UserRepositoryLoader.java
deleted file mode 100644
index 365739bc93e..00000000000
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/user/UserRepositoryLoader.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * 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.sonar.scanner.repository.user;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-
-import org.apache.commons.io.IOUtils;
-import org.sonar.scanner.bootstrap.ScannerWsClient;
-import org.sonar.scanner.protocol.input.ScannerInput;
-import org.sonar.scanner.util.ScannerUtils;
-import org.sonarqube.ws.client.GetRequest;
-
-public class UserRepositoryLoader {
- private final ScannerWsClient wsClient;
-
- public UserRepositoryLoader(ScannerWsClient wsClient) {
- this.wsClient = wsClient;
- }
-
- public ScannerInput.User load(String userLogin) {
- InputStream is = loadQuery(new UserEncodingFunction().apply(userLogin));
- return parseUser(is);
- }
-
- public Collection<ScannerInput.User> load(Collection<String> userLogins) {
- if (userLogins.isEmpty()) {
- return Collections.emptyList();
- }
- UserEncodingFunction userEncodingFunction = new UserEncodingFunction();
- String encodedUserLogins = userLogins.stream()
- .map(userEncodingFunction::apply)
- .collect(Collectors.joining(","));
- InputStream is = loadQuery(encodedUserLogins);
-
- return parseUsers(is);
- }
-
- public Map<String, ScannerInput.User> map(Collection<String> userLogins) {
- Collection<ScannerInput.User> users = load(userLogins);
- Map<String, ScannerInput.User> map = new HashMap<>();
-
- for (ScannerInput.User user : users) {
- map.put(user.getLogin(), user);
- }
- return map;
- }
-
- private InputStream loadQuery(String loginsQuery) {
- GetRequest getRequest = new GetRequest("/batch/users?logins=" + loginsQuery);
- return wsClient.call(getRequest).contentStream();
- }
-
- private static class UserEncodingFunction implements Function<String, String> {
- @Override
- public String apply(String input) {
- return ScannerUtils.encodeForUrl(input);
- }
- }
-
- private static ScannerInput.User parseUser(InputStream is) {
- try {
- return ScannerInput.User.parseDelimitedFrom(is);
- } catch (IOException e) {
- throw new IllegalStateException("Unable to get user details from server", e);
- } finally {
- IOUtils.closeQuietly(is);
- }
- }
-
- private static Collection<ScannerInput.User> parseUsers(InputStream is) {
- List<ScannerInput.User> users = new ArrayList<>();
-
- try {
- ScannerInput.User user = ScannerInput.User.parseDelimitedFrom(is);
- while (user != null) {
- users.add(user);
- user = ScannerInput.User.parseDelimitedFrom(is);
- }
- } catch (IOException e) {
- throw new IllegalStateException("Unable to get user details from server", e);
- } finally {
- IOUtils.closeQuietly(is);
- }
-
- return users;
- }
-
-}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/user/package-info.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/user/package-info.java
deleted file mode 100644
index 8d4219d7814..00000000000
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/repository/user/package-info.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.scanner.repository.user;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
index aede44cda81..b3a9fb68c21 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ProjectScanContainer.java
@@ -80,7 +80,6 @@ import org.sonar.scanner.repository.QualityProfileLoader;
import org.sonar.scanner.repository.QualityProfileProvider;
import org.sonar.scanner.repository.ServerIssuesLoader;
import org.sonar.scanner.repository.language.DefaultLanguagesRepository;
-import org.sonar.scanner.repository.user.UserRepositoryLoader;
import org.sonar.scanner.rule.ActiveRulesLoader;
import org.sonar.scanner.rule.ActiveRulesProvider;
import org.sonar.scanner.rule.DefaultActiveRulesLoader;
@@ -200,8 +199,7 @@ public class ProjectScanContainer extends ComponentContainer {
CpdExecutor.class,
SonarCpdBlockIndex.class,
- ScanTaskObservers.class,
- UserRepositoryLoader.class);
+ ScanTaskObservers.class);
addIfMissing(DefaultRulesLoader.class, RulesLoader.class);
addIfMissing(DefaultActiveRulesLoader.class, ActiveRulesLoader.class);
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/JSONReport.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/JSONReport.java
index 05ab73ac247..7db8f84929a 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/JSONReport.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/JSONReport.java
@@ -53,9 +53,6 @@ import org.sonar.api.utils.text.JsonWriter;
import org.sonar.core.component.ComponentKeys;
import org.sonar.scanner.issue.IssueCache;
import org.sonar.scanner.issue.tracking.TrackedIssue;
-import org.sonar.scanner.protocol.input.ScannerInput;
-import org.sonar.scanner.protocol.input.ScannerInput.User;
-import org.sonar.scanner.repository.user.UserRepositoryLoader;
import org.sonar.scanner.scan.filesystem.InputComponentStore;
@Properties({
@@ -75,12 +72,11 @@ public class JSONReport implements Reporter {
private final IssueCache issueCache;
private final InputComponentStore componentStore;
private final DefaultInputModule rootModule;
- private final UserRepositoryLoader userRepository;
private final InputModuleHierarchy moduleHierarchy;
private final InputComponentTree inputComponentTree;
public JSONReport(InputModuleHierarchy moduleHierarchy, Settings settings, FileSystem fileSystem, Server server, Rules rules, IssueCache issueCache,
- DefaultInputModule rootModule, InputComponentStore componentStore, UserRepositoryLoader userRepository, InputComponentTree inputComponentTree) {
+ DefaultInputModule rootModule, InputComponentStore componentStore, InputComponentTree inputComponentTree) {
this.moduleHierarchy = moduleHierarchy;
this.settings = settings;
this.fileSystem = fileSystem;
@@ -89,7 +85,6 @@ public class JSONReport implements Reporter {
this.issueCache = issueCache;
this.rootModule = rootModule;
this.componentStore = componentStore;
- this.userRepository = userRepository;
this.inputComponentTree = inputComponentTree;
}
@@ -232,15 +227,15 @@ public class JSONReport implements Reporter {
json.endArray();
}
- private void writeUsers(JsonWriter json, Collection<String> userLogins) throws IOException {
- Collection<User> users = userRepository.load(userLogins);
-
+ private static void writeUsers(JsonWriter json, Collection<String> userLogins) throws IOException {
json.name("users").beginArray();
- for (ScannerInput.User user : users) {
+
+ // for compatiblity with programs that parse the json report. We no longer get the name for logins.
+ for (String user : userLogins) {
json
.beginObject()
- .prop("login", user.getLogin())
- .prop("name", user.getName())
+ .prop("login", user)
+ .prop("name", user)
.endObject();
}
json.endArray();
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/DefaultIssueCallbackTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/DefaultIssueCallbackTest.java
index cdedd8e62f1..c6c7f1b7aec 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/DefaultIssueCallbackTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/DefaultIssueCallbackTest.java
@@ -32,12 +32,9 @@ import org.sonar.api.batch.rule.Rules;
import org.sonar.scanner.issue.DefaultIssueCallback;
import org.sonar.scanner.issue.IssueCache;
import org.sonar.scanner.issue.tracking.TrackedIssue;
-import org.sonar.scanner.protocol.input.ScannerInput;
-import org.sonar.scanner.repository.user.UserRepositoryLoader;
import org.junit.Before;
import com.google.common.collect.ImmutableList;
-import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -49,8 +46,6 @@ public class DefaultIssueCallbackTest {
@Mock
private IssueCache issueCache;
@Mock
- private UserRepositoryLoader userRepository;
- @Mock
private Rules rules;
private TrackedIssue issue;
@@ -67,12 +62,6 @@ public class DefaultIssueCallbackTest {
when(issueCache.all()).thenReturn(ImmutableList.of(issue));
- ScannerInput.User.Builder userBuilder = ScannerInput.User.newBuilder();
- userBuilder.setLogin("user");
- userBuilder.setName("name");
- when(userRepository.map(Collections.singleton("user")))
- .thenReturn(Collections.singletonMap("user", userBuilder.build()));
-
Rule r = mock(Rule.class);
when(r.name()).thenReturn("rule name");
when(rules.find(ruleKey)).thenReturn(r);
@@ -80,7 +69,7 @@ public class DefaultIssueCallbackTest {
@Test
public void testWithoutListener() {
- DefaultIssueCallback issueCallback = new DefaultIssueCallback(issueCache, userRepository, rules);
+ DefaultIssueCallback issueCallback = new DefaultIssueCallback(issueCache, rules);
issueCallback.execute();
}
@@ -94,13 +83,13 @@ public class DefaultIssueCallbackTest {
}
};
- DefaultIssueCallback issueCallback = new DefaultIssueCallback(issueCache, listener, userRepository, rules);
+ DefaultIssueCallback issueCallback = new DefaultIssueCallback(issueCache, listener, rules);
issueCallback.execute();
assertThat(issueList).hasSize(1);
Issue callbackIssue = issueList.get(0);
- assertThat(callbackIssue.getAssigneeName()).isEqualTo("name");
+ assertThat(callbackIssue.getAssigneeName()).isEqualTo("user");
assertThat(callbackIssue.getRuleName()).isEqualTo("rule name");
}
@@ -117,7 +106,7 @@ public class DefaultIssueCallbackTest {
issue.setKey(null);
issue.setAssignee(null);
- DefaultIssueCallback issueCallback = new DefaultIssueCallback(issueCache, listener, userRepository, rules);
+ DefaultIssueCallback issueCallback = new DefaultIssueCallback(issueCache, listener, rules);
issueCallback.execute();
}
@@ -131,10 +120,9 @@ public class DefaultIssueCallbackTest {
}
};
- when(userRepository.load(any(String.class))).thenReturn(null);
when(rules.find(any(RuleKey.class))).thenReturn(null);
- DefaultIssueCallback issueCallback = new DefaultIssueCallback(issueCache, listener, userRepository, rules);
+ DefaultIssueCallback issueCallback = new DefaultIssueCallback(issueCache, listener, rules);
issueCallback.execute();
}
}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/user/UserRepositoryLoaderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/user/UserRepositoryLoaderTest.java
deleted file mode 100644
index 473cd73159d..00000000000
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/repository/user/UserRepositoryLoaderTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * 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.sonar.scanner.repository.user;
-
-import org.assertj.core.util.Lists;
-import org.sonar.scanner.bootstrap.ScannerWsClient;
-import org.sonar.scanner.protocol.input.ScannerInput;
-import org.sonar.scanner.protocol.input.ScannerInput.User;
-import org.sonar.scanner.repository.user.UserRepositoryLoader;
-import org.sonar.scanner.WsTestUtil;
-import org.junit.Before;
-import com.google.common.collect.ImmutableMap;
-import org.junit.rules.ExpectedException;
-import org.junit.Rule;
-import org.mockito.Mockito;
-import org.junit.Test;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Arrays;
-import java.util.Map;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.tuple;
-import static org.mockito.Mockito.mock;
-
-public class UserRepositoryLoaderTest {
- @Rule
- public final ExpectedException exception = ExpectedException.none();
-
- private ScannerWsClient wsClient;
- private UserRepositoryLoader userRepo;
-
- @Before
- public void setUp() {
- wsClient = mock(ScannerWsClient.class);
- userRepo = new UserRepositoryLoader(wsClient);
- }
-
- @Test
- public void testLoadEmptyList() {
- assertThat(userRepo.load(Lists.<String>emptyList())).isEmpty();
- }
-
- @Test
- public void testLoad() throws IOException {
- Map<String, String> userMap = ImmutableMap.of("fmallet", "Freddy Mallet", "sbrandhof", "Simon");
- InputStream is = createUsersMock(userMap);
- WsTestUtil.mockStream(wsClient, "/batch/users?logins=fmallet,sbrandhof", is);
- assertThat(userRepo.load(Arrays.asList("fmallet", "sbrandhof"))).extracting("login", "name").containsOnly(tuple("fmallet", "Freddy Mallet"), tuple("sbrandhof", "Simon"));
- }
-
- @Test
- public void testLoadListWithSingleUser() throws IOException {
- Map<String, String> userMap = ImmutableMap.of("fmallet", "Freddy Mallet");
- InputStream is = createUsersMock(userMap);
- WsTestUtil.mockStream(wsClient, "/batch/users?logins=fmallet", is);
- assertThat(userRepo.load(Arrays.asList("fmallet"))).extracting("login", "name").containsOnly(tuple("fmallet", "Freddy Mallet"));
- }
-
- @Test
- public void testMapUsers() throws IOException {
- Map<String, String> userMap = ImmutableMap.of("fmallet", "Freddy Mallet");
- InputStream is = createUsersMock(userMap);
- WsTestUtil.mockStream(wsClient, "/batch/users?logins=fmallet,sbrandhof", is);
- Map<String, User> map = userRepo.map(Arrays.asList("fmallet", "sbrandhof"));
-
- // one user doesn't exist
- assertThat(map).hasSize(1);
- assertThat(map.values().iterator().next().getLogin()).isEqualTo("fmallet");
- }
-
- @Test
- public void testLoadSingleUser() throws IOException {
- InputStream is = createUsersMock(ImmutableMap.of("fmallet", "Freddy Mallet"));
- WsTestUtil.mockStream(wsClient, "/batch/users?logins=fmallet", is);
- assertThat(userRepo.load("fmallet").getName()).isEqualTo("Freddy Mallet");
- }
-
- private InputStream createUsersMock(Map<String, String> users) throws IOException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
-
- for (Map.Entry<String, String> user : users.entrySet()) {
- ScannerInput.User.Builder builder = ScannerInput.User.newBuilder();
- builder.setLogin(user.getKey()).setName(user.getValue()).build().writeDelimitedTo(out);
- }
- return new ByteArrayInputStream(out.toByteArray());
- }
-
- @Test
- public void testInputStreamError() throws IOException {
- InputStream is = mock(InputStream.class);
- Mockito.doThrow(IOException.class).when(is).read();
- WsTestUtil.mockStream(wsClient, "/batch/users?logins=fmallet,sbrandhof", is);
-
- exception.expect(IllegalStateException.class);
- exception.expectMessage("Unable to get user details from server");
-
- userRepo.load(Arrays.asList("fmallet", "sbrandhof"));
- }
-}
diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/report/JSONReportTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/report/JSONReportTest.java
index 7dfcdc7d367..e999104d907 100644
--- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/report/JSONReportTest.java
+++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/scan/report/JSONReportTest.java
@@ -49,8 +49,6 @@ import org.sonar.api.rule.RuleKey;
import org.sonar.api.scan.filesystem.PathResolver;
import org.sonar.scanner.issue.IssueCache;
import org.sonar.scanner.issue.tracking.TrackedIssue;
-import org.sonar.scanner.protocol.input.ScannerInput;
-import org.sonar.scanner.repository.user.UserRepositoryLoader;
import org.sonar.scanner.scan.DefaultComponentTree;
import org.sonar.scanner.scan.filesystem.InputComponentStore;
@@ -73,13 +71,11 @@ public class JSONReportTest {
Rules rules = mock(Rules.class);
Settings settings = new MapSettings();
IssueCache issueCache = mock(IssueCache.class);
- private UserRepositoryLoader userRepository;
private InputModuleHierarchy moduleHierarchy;
@Before
public void before() throws Exception {
moduleHierarchy = mock(InputModuleHierarchy.class);
- userRepository = mock(UserRepositoryLoader.class);
File projectBaseDir = temp.newFolder();
fs = new DefaultFileSystem(projectBaseDir.toPath());
SIMPLE_DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT+02:00"));
@@ -115,7 +111,7 @@ public class JSONReportTest {
RulesBuilder builder = new RulesBuilder();
builder.add(RuleKey.of("squid", "AvoidCycles")).setName("Avoid Cycles");
rules = builder.build();
- jsonReport = new JSONReport(moduleHierarchy, settings, fs, server, rules, issueCache, rootModule, inputComponentStore, userRepository, inputComponentTree);
+ jsonReport = new JSONReport(moduleHierarchy, settings, fs, server, rules, issueCache, rootModule, inputComponentStore, inputComponentTree);
}
@Test
@@ -137,8 +133,6 @@ public class JSONReportTest {
issue.setCreationDate(SIMPLE_DATE_FORMAT.parse("2013-04-24"));
issue.setNew(false);
when(issueCache.all()).thenReturn(Collections.singleton(issue));
- ScannerInput.User user = ScannerInput.User.newBuilder().setLogin("simon").setName("Simon").build();
- when(userRepository.load(Collections.singleton("simon"))).thenReturn(Collections.singleton(user));
StringWriter writer = new StringWriter();
jsonReport.writeJson(writer);
diff --git a/sonar-scanner-engine/src/test/resources/org/sonar/scanner/scan/report/JSONReportTest/report.json b/sonar-scanner-engine/src/test/resources/org/sonar/scanner/scan/report/JSONReportTest/report.json
index e024e17340d..a78fbca71e5 100644
--- a/sonar-scanner-engine/src/test/resources/org/sonar/scanner/scan/report/JSONReportTest/report.json
+++ b/sonar-scanner-engine/src/test/resources/org/sonar/scanner/scan/report/JSONReportTest/report.json
@@ -54,7 +54,7 @@
"users": [
{
"login": "simon",
- "name": "Simon"
+ "name": "simon"
}
]
}