]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8719 batch/file WS return 404 instead of 400 on unknown file
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 1 Feb 2017 09:52:31 +0000 (10:52 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Thu, 2 Feb 2017 16:05:26 +0000 (17:05 +0100)
14 files changed:
server/sonar-server/src/main/java/org/sonar/server/batch/BatchIndex.java
server/sonar-server/src/main/java/org/sonar/server/batch/BatchWs.java
server/sonar-server/src/main/java/org/sonar/server/batch/BatchWsModule.java
server/sonar-server/src/main/java/org/sonar/server/batch/FileAction.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/batch/IndexAction.java [new file with mode: 0644]
server/sonar-server/src/main/resources/org/sonar/server/batch/batch-index-example.txt [deleted file]
server/sonar-server/src/main/resources/org/sonar/server/batch/index-example.txt [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/batch/BatchIndexTest.java
server/sonar-server/src/test/java/org/sonar/server/batch/BatchWsModuleTest.java
server/sonar-server/src/test/java/org/sonar/server/batch/BatchWsTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/batch/FileActionTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/batch/IndexActionTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/batch/IssuesActionTest.java
server/sonar-server/src/test/java/org/sonar/server/batch/UsersActionTest.java

index 9fbf1e9e0af01539596c16796571b9200fd3d3f9..613149170eca7f0dd3207a42dd5be5973a3ee20d 100644 (file)
@@ -31,6 +31,7 @@ import org.apache.commons.lang.CharUtils;
 import org.apache.commons.lang.StringUtils;
 import org.picocontainer.Startable;
 import org.sonar.api.server.ServerSide;
+import org.sonar.server.exceptions.NotFoundException;
 import org.sonar.server.platform.ServerFileSystem;
 
 /**
@@ -81,10 +82,9 @@ public class BatchIndex implements Startable {
     try {
       File input = new File(batchDir, filename);
       if (!input.exists() || !FileUtils.directoryContains(batchDir, input)) {
-        throw new IllegalArgumentException("Bad filename: " + filename);
+        throw new NotFoundException("Bad filename: " + filename);
       }
       return input;
-
     } catch (IOException e) {
       throw new IllegalStateException("Can get file " + filename, e);
     }
index 8218c8e57fc2f2f7d064f8574c93e65b566ed07e..747ab87273e19e6d7ddc099cfc86405ad2c3d551 100644 (file)
  */
 package org.sonar.server.batch;
 
-import java.io.IOException;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.io.IOUtils;
 import org.sonar.api.server.ws.WebService;
 
+import static java.util.Arrays.stream;
+
 public class BatchWs implements WebService {
 
   public static final String API_ENDPOINT = "batch";
 
-  private final BatchIndex batchIndex;
   private final BatchWsAction[] actions;
 
-  public BatchWs(BatchIndex batchIndex, BatchWsAction... actions) {
-    this.batchIndex = batchIndex;
+  public BatchWs(BatchWsAction... actions) {
     this.actions = actions;
   }
 
@@ -41,50 +38,8 @@ public class BatchWs implements WebService {
     NewController controller = context.createController(API_ENDPOINT)
       .setSince("4.4")
       .setDescription("Get JAR files and referentials for batch");
-
-    defineIndexAction(controller);
-    defineFileAction(controller);
-    for (BatchWsAction action : actions) {
-      action.define(controller);
-    }
-
+    stream(actions).forEach(action -> action.define(controller));
     controller.done();
   }
 
-  private void defineIndexAction(NewController controller) {
-    controller.createAction("index")
-      .setInternal(true)
-      .setSince("4.4")
-      .setDescription("List the JAR files to be downloaded by scanners")
-      .setHandler((request, response) -> {
-        try {
-          response.stream().setMediaType("text/plain");
-          IOUtils.write(batchIndex.getIndex(), response.stream().output());
-        } catch (IOException e) {
-          throw new IllegalStateException(e);
-        }
-      })
-      .setResponseExample(getClass().getResource("batch-index-example.txt"));
-  }
-
-  private void defineFileAction(NewController controller) {
-    NewAction action = controller.createAction("file")
-      .setInternal(true)
-      .setSince("4.4")
-      .setDescription("Download a JAR file listed in the index (see batch/index)")
-      .setResponseExample(getClass().getResource("batch-file-example.txt"))
-      .setHandler((request, response) -> {
-        String filename = request.mandatoryParam("name");
-        try {
-          response.stream().setMediaType("application/java-archive");
-          FileUtils.copyFile(batchIndex.getFile(filename), response.stream().output());
-        } catch (IOException e) {
-          throw new IllegalStateException(e);
-        }
-      });
-    action
-      .createParam("name")
-      .setDescription("File name")
-      .setExampleValue("batch-library-2.3.jar");
-  }
 }
index cce8355b9004be2f046e84280c84f2c29c20b37c..7508ca8b198755665f2e6b9885d0a47b41f45289 100644 (file)
@@ -30,6 +30,8 @@ public class BatchWsModule extends Module {
       ProjectDataLoader.class,
       IssuesAction.class,
       UsersAction.class,
+      IndexAction.class,
+      FileAction.class,
       BatchWs.class);
   }
 }
diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/FileAction.java b/server/sonar-server/src/main/java/org/sonar/server/batch/FileAction.java
new file mode 100644 (file)
index 0000000..d40fc01
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * 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.sonar.server.batch;
+
+import java.io.File;
+import java.io.IOException;
+import org.apache.commons.io.FileUtils;
+import org.sonar.api.server.ws.Request;
+import org.sonar.api.server.ws.Response;
+import org.sonar.api.server.ws.WebService;
+
+public class FileAction implements BatchWsAction {
+
+  private final BatchIndex batchIndex;
+
+  public FileAction(BatchIndex batchIndex) {
+    this.batchIndex = batchIndex;
+  }
+
+  @Override
+  public void define(WebService.NewController context) {
+    WebService.NewAction action = context.createAction("file")
+      .setInternal(true)
+      .setSince("4.4")
+      .setDescription("Download a JAR file listed in the index (see batch/index)")
+      .setResponseExample(getClass().getResource("batch-file-example.txt"))
+      .setHandler(this);
+    action
+      .createParam("name")
+      .setDescription("File name")
+      .setExampleValue("batch-library-2.3.jar");
+  }
+
+  @Override
+  public void handle(Request request, Response response) throws Exception {
+    String filename = request.mandatoryParam("name");
+    try {
+      response.stream().setMediaType("application/java-archive");
+      File file = batchIndex.getFile(filename);
+      FileUtils.copyFile(file, response.stream().output());
+    } catch (IOException e) {
+      throw new IllegalStateException(e);
+    }
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/batch/IndexAction.java b/server/sonar-server/src/main/java/org/sonar/server/batch/IndexAction.java
new file mode 100644 (file)
index 0000000..f5b36db
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * 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.sonar.server.batch;
+
+import java.io.IOException;
+import org.apache.commons.io.IOUtils;
+import org.sonar.api.server.ws.Request;
+import org.sonar.api.server.ws.Response;
+import org.sonar.api.server.ws.WebService;
+
+import static com.google.common.base.Preconditions.checkState;
+
+public class IndexAction implements BatchWsAction {
+
+  private final BatchIndex batchIndex;
+
+  public IndexAction(BatchIndex batchIndex) {
+    this.batchIndex = batchIndex;
+  }
+
+  @Override
+  public void define(WebService.NewController context) {
+    context.createAction("index")
+      .setInternal(true)
+      .setSince("4.4")
+      .setDescription("List the JAR files to be downloaded by scanners")
+      .setHandler(this)
+      .setResponseExample(getClass().getResource("index-example.txt"));
+  }
+
+  @Override
+  public void handle(Request request, Response response) throws Exception {
+    try {
+      response.stream().setMediaType("text/plain");
+      String index = batchIndex.getIndex();
+      checkState(index != null, "No available files");
+      IOUtils.write(index, response.stream().output());
+    } catch (IOException e) {
+      throw new IllegalStateException(e);
+    }
+  }
+}
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/batch/batch-index-example.txt b/server/sonar-server/src/main/resources/org/sonar/server/batch/batch-index-example.txt
deleted file mode 100644 (file)
index fe0e477..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-sonar-batch-4.4.jar|2d7cbec208114970ea419ce963775f68
-sonar-batch-library-2.3.jar|86f577369ec914ae079411803cebc7d2
diff --git a/server/sonar-server/src/main/resources/org/sonar/server/batch/index-example.txt b/server/sonar-server/src/main/resources/org/sonar/server/batch/index-example.txt
new file mode 100644 (file)
index 0000000..fe0e477
--- /dev/null
@@ -0,0 +1,2 @@
+sonar-batch-4.4.jar|2d7cbec208114970ea419ce963775f68
+sonar-batch-library-2.3.jar|86f577369ec914ae079411803cebc7d2
index b935d9798753387e53ee4c36010ed01e897208c8..33b06b1cc57c2205c99530369df6698dd9ae5eb1 100644 (file)
@@ -28,6 +28,7 @@ import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.junit.rules.TemporaryFolder;
+import org.sonar.server.exceptions.NotFoundException;
 import org.sonar.server.platform.ServerFileSystem;
 
 import static org.assertj.core.api.Assertions.assertThat;
@@ -83,7 +84,7 @@ public class BatchIndexTest {
    */
   @Test
   public void check_location_of_file() {
-    thrown.expect(IllegalArgumentException.class);
+    thrown.expect(NotFoundException.class);
     thrown.expectMessage("Bad filename: ../sonar-batch.jar");
 
     BatchIndex batchIndex = new BatchIndex(fs);
@@ -94,7 +95,7 @@ public class BatchIndexTest {
 
   @Test
   public void file_does_not_exist() {
-    thrown.expect(IllegalArgumentException.class);
+    thrown.expect(NotFoundException.class);
     thrown.expectMessage("Bad filename: other.jar");
 
     BatchIndex batchIndex = new BatchIndex(fs);
index 131d88883714ef183d9a8eff42d6467ebeddffdb..09112e33ea76a901c78b2b4f9b37a059a92888ae 100644 (file)
@@ -29,7 +29,7 @@ public class BatchWsModuleTest {
   public void verify_count_of_added_components() {
     ComponentContainer container = new ComponentContainer();
     new BatchWsModule().configure(container);
-    assertThat(container.size()).isEqualTo(8);
+    assertThat(container.size()).isEqualTo(10);
   }
 
 }
diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/BatchWsTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/BatchWsTest.java
deleted file mode 100644 (file)
index 8adf471..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * 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.sonar.server.batch;
-
-import java.io.File;
-import org.apache.commons.io.FileUtils;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.rules.TemporaryFolder;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.sonar.db.DbClient;
-import org.sonar.server.component.ComponentFinder;
-import org.sonar.server.issue.index.IssueIndex;
-import org.sonar.server.tester.UserSessionRule;
-import org.sonar.server.ws.WsTester;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
-public class BatchWsTest {
-  @Rule
-  public UserSessionRule userSessionRule = UserSessionRule.standalone();
-
-  @Rule
-  public TemporaryFolder temp = new TemporaryFolder();
-
-  @Rule
-  public ExpectedException thrown = ExpectedException.none();
-
-  @Mock
-  BatchIndex batchIndex;
-
-  WsTester tester;
-
-  @Before
-  public void before() {
-    tester = new WsTester(new BatchWs(batchIndex,
-      new ProjectAction(mock(ProjectDataLoader.class)),
-      new IssuesAction(mock(DbClient.class), mock(IssueIndex.class), userSessionRule, mock(ComponentFinder.class))));
-  }
-
-  @Test
-  public void download_index() throws Exception {
-    when(batchIndex.getIndex()).thenReturn("sonar-batch.jar|acbd18db4cc2f85cedef654fccc4a4d8");
-
-    String index = tester.newGetRequest("batch", "index").execute().outputAsString();
-    assertThat(index).isEqualTo("sonar-batch.jar|acbd18db4cc2f85cedef654fccc4a4d8");
-  }
-
-  @Test
-  public void download_file() throws Exception {
-    String filename = "sonar-batch.jar";
-
-    File file = temp.newFile(filename);
-    FileUtils.writeStringToFile(file, "foo");
-    when(batchIndex.getFile(filename)).thenReturn(file);
-
-    String jar = tester.newGetRequest("batch", "file").setParam("name", filename).execute().outputAsString();
-    assertThat(jar).isEqualTo("foo");
-  }
-
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/FileActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/FileActionTest.java
new file mode 100644 (file)
index 0000000..5b8fd35
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * 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.sonar.server.batch;
+
+import java.io.File;
+import org.apache.commons.io.FileUtils;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.rules.TemporaryFolder;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.server.exceptions.NotFoundException;
+import org.sonar.server.platform.ServerFileSystem;
+import org.sonar.server.ws.WsActionTester;
+
+import static org.apache.commons.io.FileUtils.writeStringToFile;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class FileActionTest {
+
+  @Rule
+  public ExpectedException thrown = ExpectedException.none();
+
+  @Rule
+  public TemporaryFolder temp = new TemporaryFolder();
+
+  private ServerFileSystem serverFileSystem = mock(ServerFileSystem.class);
+  private BatchIndex batchIndex = new BatchIndex(serverFileSystem);
+
+  private File batchDir;
+
+  private WsActionTester tester = new WsActionTester(new FileAction(batchIndex));
+
+  @Before
+  public void setUp() throws Exception {
+    File homeDir = temp.newFolder();
+    when(serverFileSystem.getHomeDir()).thenReturn(homeDir);
+    batchDir = new File(homeDir, "lib/scanner");
+    FileUtils.forceMkdir(batchDir);
+  }
+
+  @Test
+  public void download_file() throws Exception {
+    writeStringToFile(new File(batchDir, "sonar-batch.jar"), "foo");
+    writeStringToFile(new File(batchDir, "other.jar"), "bar");
+    batchIndex.start();
+
+    String jar = tester.newRequest().setParam("name", "sonar-batch.jar").execute().getInput();
+
+    assertThat(jar).isEqualTo("foo");
+  }
+
+  @Test
+  public void throw_NotFoundException_when_file_does_not_exist() throws Exception {
+    writeStringToFile(new File(batchDir, "sonar-batch.jar"), "foo");
+    batchIndex.start();
+
+    thrown.expect(NotFoundException.class);
+    thrown.expectMessage("Bad filename: unknown");
+    tester.newRequest().setParam("name", "unknown").execute();
+  }
+
+  @Test
+  public void throw_IAE_when_no_name_parameter() throws Exception {
+    thrown.expect(IllegalArgumentException.class);
+    thrown.expectMessage("The 'name' parameter is missing");
+    tester.newRequest().execute();
+  }
+
+  @Test
+  public void test_definition() throws Exception {
+    WebService.Action definition = tester.getDef();
+    assertThat(definition.isInternal()).isTrue();
+    assertThat(definition.isPost()).isFalse();
+    assertThat(definition.responseExampleAsString()).isNotEmpty();
+    assertThat(definition.params()).extracting(WebService.Param::key).containsOnly("name");
+  }
+
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/batch/IndexActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/batch/IndexActionTest.java
new file mode 100644 (file)
index 0000000..7745dcd
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * 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.sonar.server.batch;
+
+import java.io.File;
+import org.apache.commons.io.FileUtils;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.rules.TemporaryFolder;
+import org.sonar.api.server.ws.WebService;
+import org.sonar.server.platform.ServerFileSystem;
+import org.sonar.server.ws.WsActionTester;
+
+import static org.apache.commons.io.FileUtils.writeStringToFile;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+public class IndexActionTest {
+
+  @Rule
+  public ExpectedException thrown = ExpectedException.none();
+
+  @Rule
+  public TemporaryFolder temp = new TemporaryFolder();
+
+  private ServerFileSystem serverFileSystem = mock(ServerFileSystem.class);
+  private BatchIndex batchIndex = new BatchIndex(serverFileSystem);
+
+  private File batchDir;
+
+  private WsActionTester tester = new WsActionTester(new IndexAction(batchIndex));
+
+  @Before
+  public void setUp() throws Exception {
+    File homeDir = temp.newFolder();
+    when(serverFileSystem.getHomeDir()).thenReturn(homeDir);
+    batchDir = new File(homeDir, "lib/scanner");
+    FileUtils.forceMkdir(batchDir);
+  }
+
+  @Test
+  public void get_index() throws Exception {
+    writeStringToFile(new File(batchDir, "sonar-batch.jar"), "something");
+    batchIndex.start();
+
+    String index = tester.newRequest().execute().getInput();
+
+    assertThat(index).startsWith("sonar-batch.jar|");
+  }
+
+  @Test
+  public void throw_ISE_when_no_file() throws Exception {
+    thrown.expect(IllegalStateException.class);
+    tester.newRequest().execute();
+  }
+
+  @Test
+  public void test_definition() throws Exception {
+    WebService.Action definition = tester.getDef();
+    assertThat(definition.isInternal()).isTrue();
+    assertThat(definition.isPost()).isFalse();
+    assertThat(definition.responseExampleAsString()).isNotEmpty();
+    assertThat(definition.params()).isEmpty();
+  }
+}
index a25f4948c74014b00e07582f2c9cee51d5a31de2..2d0837109181ec17ab234178f334b025265f4721 100644 (file)
@@ -85,7 +85,7 @@ public class IssuesActionTest {
   public void before() {
     IssueIndex issueIndex = new IssueIndex(es.client(), system2, userSessionRule, new AuthorizationTypeSupport(userSessionRule));
     IssuesAction issuesAction = new IssuesAction(db.getDbClient(), issueIndex, userSessionRule, new ComponentFinder(db.getDbClient()));
-    tester = new WsTester(new BatchWs(new BatchIndex(fs), issuesAction));
+    tester = new WsTester(new BatchWs(issuesAction));
   }
 
   @Test
index 3a12fdd82e3bb1dd25424b7fc9905e03ba4f20bf..aba3938d1567fe77e9866d97b1f097d9eff07b58 100644 (file)
@@ -30,7 +30,6 @@ import org.sonar.api.config.MapSettings;
 import org.sonar.scanner.protocol.input.ScannerInput.User;
 import org.sonar.server.es.EsTester;
 import org.sonar.server.exceptions.UnauthorizedException;
-import org.sonar.server.platform.ServerFileSystem;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.user.index.UserDoc;
 import org.sonar.server.user.index.UserIndex;
@@ -38,7 +37,6 @@ import org.sonar.server.user.index.UserIndexDefinition;
 import org.sonar.server.ws.WsTester;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.Mockito.mock;
 
 public class UsersActionTest {
 
@@ -61,7 +59,7 @@ public class UsersActionTest {
   public void before() {
     userIndex = new UserIndex(es.client());
     usersAction = new UsersAction(userIndex, userSessionRule);
-    tester = new WsTester(new BatchWs(new BatchIndex(mock(ServerFileSystem.class)), usersAction));
+    tester = new WsTester(new BatchWs(usersAction));
   }
 
   @Test