From d1fd889554bccbb50122550899dbb66b90b04f78 Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Mon, 9 Dec 2019 09:34:43 -0600 Subject: Fix code quality issues and reduce dependency on Guava --- .../src/main/java/org/sonar/server/ws/DefaultLocalResponse.java | 4 ++-- .../test/java/org/sonar/server/ws/RemovedWebServiceHandlerTest.java | 2 +- .../src/testFixtures/java/org/sonar/server/ws/DumbResponse.java | 6 +++--- .../src/testFixtures/java/org/sonar/server/ws/TestRequest.java | 3 +-- 4 files changed, 7 insertions(+), 8 deletions(-) (limited to 'server/sonar-webserver-ws/src') diff --git a/server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/DefaultLocalResponse.java b/server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/DefaultLocalResponse.java index 07c11840a16..a55a8c2b1dc 100644 --- a/server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/DefaultLocalResponse.java +++ b/server/sonar-webserver-ws/src/main/java/org/sonar/server/ws/DefaultLocalResponse.java @@ -20,7 +20,6 @@ package org.sonar.server.ws; import com.google.common.base.Throwables; -import com.google.common.collect.Maps; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; @@ -28,6 +27,7 @@ import java.io.OutputStreamWriter; import java.net.HttpURLConnection; import java.nio.charset.StandardCharsets; import java.util.Collection; +import java.util.HashMap; import java.util.Map; import javax.annotation.CheckForNull; import org.apache.commons.io.IOUtils; @@ -41,7 +41,7 @@ public class DefaultLocalResponse implements Response, LocalConnector.LocalRespo private final InMemoryStream stream = new InMemoryStream(); private final ByteArrayOutputStream output = new ByteArrayOutputStream(); - private final Map headers = Maps.newHashMap(); + private final Map headers = new HashMap<>(); @Override public int getStatus() { diff --git a/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/RemovedWebServiceHandlerTest.java b/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/RemovedWebServiceHandlerTest.java index 262a8325845..e300f834aca 100644 --- a/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/RemovedWebServiceHandlerTest.java +++ b/server/sonar-webserver-ws/src/test/java/org/sonar/server/ws/RemovedWebServiceHandlerTest.java @@ -36,7 +36,7 @@ public class RemovedWebServiceHandlerTest { public ExpectedException expectedException = ExpectedException.none(); @Test - public void throw_server_exception() throws Exception { + public void throw_server_exception() { Request request = mock(Request.class); when(request.getPath()).thenReturn("/api/resources/index"); diff --git a/server/sonar-webserver-ws/src/testFixtures/java/org/sonar/server/ws/DumbResponse.java b/server/sonar-webserver-ws/src/testFixtures/java/org/sonar/server/ws/DumbResponse.java index f7d2aeedd80..8ff41e5080a 100644 --- a/server/sonar-webserver-ws/src/testFixtures/java/org/sonar/server/ws/DumbResponse.java +++ b/server/sonar-webserver-ws/src/testFixtures/java/org/sonar/server/ws/DumbResponse.java @@ -20,7 +20,6 @@ package org.sonar.server.ws; import com.google.common.base.Throwables; -import com.google.common.collect.Maps; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; @@ -28,6 +27,7 @@ import java.io.OutputStreamWriter; import java.net.HttpURLConnection; import java.nio.charset.StandardCharsets; import java.util.Collection; +import java.util.HashMap; import java.util.Map; import javax.annotation.CheckForNull; import org.apache.commons.io.IOUtils; @@ -40,7 +40,7 @@ public class DumbResponse implements Response { private final ByteArrayOutputStream output = new ByteArrayOutputStream(); - private Map headers = Maps.newHashMap(); + private Map headers = new HashMap<>(); public class InMemoryStream implements Response.Stream { private String mediaType; @@ -118,7 +118,7 @@ public class DumbResponse implements Response { } @CheckForNull - public String getHeader(String name){ + public String getHeader(String name) { return headers.get(name); } diff --git a/server/sonar-webserver-ws/src/testFixtures/java/org/sonar/server/ws/TestRequest.java b/server/sonar-webserver-ws/src/testFixtures/java/org/sonar/server/ws/TestRequest.java index aea0e0d69bd..9992319c361 100644 --- a/server/sonar-webserver-ws/src/testFixtures/java/org/sonar/server/ws/TestRequest.java +++ b/server/sonar-webserver-ws/src/testFixtures/java/org/sonar/server/ws/TestRequest.java @@ -23,7 +23,6 @@ import com.google.common.base.Throwables; import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ListMultimap; -import com.google.common.collect.Maps; import com.google.protobuf.GeneratedMessageV3; import java.io.BufferedReader; import java.io.InputStream; @@ -47,7 +46,7 @@ public class TestRequest extends ValidatingRequest { private final ListMultimap multiParams = ArrayListMultimap.create(); private final Map params = new HashMap<>(); private final Map headers = new HashMap<>(); - private final Map parts = Maps.newHashMap(); + private final Map parts = new HashMap<>(); private String payload = ""; private boolean payloadConsumed = false; private String method = "GET"; -- cgit v1.2.3