Minor java nitpicks - Unused imports - Redundant type declarations - Better exception docs Change-Id: Iebbd03cd9e1d9cf78cc4486085619bb6f17c1ec9
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/phabricator/conduit/Conduit.java b/src/main/java/com/googlesource/gerrit/plugins/its/phabricator/conduit/Conduit.java index 27b838f..fa49281 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/its/phabricator/conduit/Conduit.java +++ b/src/main/java/com/googlesource/gerrit/plugins/its/phabricator/conduit/Conduit.java
@@ -98,7 +98,7 @@ log.debug("Trying to start new session"); conduitConnect(); } - Map<String, Object> conduitParams = new HashMap<String, Object>(); + Map<String, Object> conduitParams = new HashMap<>(); conduitParams.put("sessionKey",sessionKey); params.put("__conduit__", conduitParams); } @@ -118,7 +118,7 @@ * Runs the API's 'conduit.connect' method */ public ConduitConnect conduitConnect() throws ConduitException { - Map<String, Object> params = new HashMap<String, Object>(); + Map<String, Object> params = new HashMap<>(); params.put("client", "its-phabricator"); params.put("clientVersion", CONDUIT_VERSION); params.put("user", username); @@ -164,7 +164,7 @@ * Runs the API's 'maniphest.Info' method */ public ManiphestInfo maniphestInfo(int taskId) throws ConduitException { - Map<String, Object> params = new HashMap<String, Object>(); + Map<String, Object> params = new HashMap<>(); fillInSession(params); params.put("task_id", taskId); @@ -191,7 +191,7 @@ * Runs the API's 'maniphest.update' method */ public ManiphestUpdate maniphestUpdate(int taskId, String comment, Iterable<String> projects) throws ConduitException { - Map<String, Object> params = new HashMap<String, Object>(); + Map<String, Object> params = new HashMap<>(); fillInSession(params); params.put("id", taskId); if (comment != null) { @@ -210,7 +210,7 @@ * Runs the API's 'projectQuery' method to match exactly one project name */ public ProjectInfo projectQuery(String name) throws ConduitException { - Map<String, Object> params = new HashMap<String, Object>(); + Map<String, Object> params = new HashMap<>(); fillInSession(params); params.put("names", Arrays.asList(name));
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/phabricator/conduit/ConduitConnection.java b/src/main/java/com/googlesource/gerrit/plugins/its/phabricator/conduit/ConduitConnection.java index 10644d1..2233df0 100644 --- a/src/main/java/com/googlesource/gerrit/plugins/its/phabricator/conduit/ConduitConnection.java +++ b/src/main/java/com/googlesource/gerrit/plugins/its/phabricator/conduit/ConduitConnection.java
@@ -30,7 +30,6 @@ import org.slf4j.LoggerFactory; import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -73,7 +72,7 @@ * * @param method The name of the method that should get called * @return The call's result, if there has been no error - * @throws Exception + * @throws ConduitException */ JsonElement call(String method) throws ConduitException { return call(method, new HashMap<String, Object>()); @@ -85,7 +84,7 @@ * @param method The name of the method that should get called * @param params A map of parameters to pass to the call * @return The call's result, if there has been no error - * @throws Exception + * @throws ConduitException */ JsonElement call(String method, Map<String, Object> params) throws ConduitException { String methodUrl = apiUrlBase + method;
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/phabricator/conduit/ConduitTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/phabricator/conduit/ConduitTest.java index f2e80e6..58ea0b8 100644 --- a/src/test/java/com/googlesource/gerrit/plugins/its/phabricator/conduit/ConduitTest.java +++ b/src/test/java/com/googlesource/gerrit/plugins/its/phabricator/conduit/ConduitTest.java
@@ -27,10 +27,7 @@ import java.util.Arrays; import java.util.List; import java.util.Map; -import java.util.Set; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; @@ -93,7 +90,7 @@ JsonObject ret = new JsonObject(); ret.add("sessionKey", new JsonPrimitive("KeyFoo")); - Capture<Map<String, Object>> paramsCapture = new Capture<Map<String, Object>>(); + Capture<Map<String, Object>> paramsCapture = new Capture<>(); expect(connection.call(eq("conduit.connect"), capture(paramsCapture))) .andReturn(ret) @@ -117,7 +114,7 @@ ConduitException conduitException = new ConduitException(); - Capture<Map<String, Object>> paramsCapture = new Capture<Map<String, Object>>(); + Capture<Map<String, Object>> paramsCapture = new Capture<>(); expect(connection.call(eq("conduit.connect"), capture(paramsCapture))) .andThrow(conduitException) @@ -146,7 +143,7 @@ JsonObject retConnect = new JsonObject(); retConnect.add("sessionKey", new JsonPrimitive("KeyFoo")); - Capture<Map<String, Object>> paramsCaptureConnect = new Capture<Map<String, Object>>(); + Capture<Map<String, Object>> paramsCaptureConnect = new Capture<>(); expect(connection.call(eq("conduit.connect"), capture(paramsCaptureConnect))) .andReturn(retConnect) @@ -155,7 +152,7 @@ JsonObject retRelevant = new JsonObject(); retRelevant.add("id", new JsonPrimitive(42)); - Capture<Map<String, Object>> paramsCaptureRelevant = new Capture<Map<String, Object>>(); + Capture<Map<String, Object>> paramsCaptureRelevant = new Capture<>(); expect(connection.call(eq("maniphest.info"), capture(paramsCaptureRelevant))) .andReturn(retRelevant) @@ -183,7 +180,7 @@ ConduitException conduitException = new ConduitException(); - Capture<Map<String, Object>> paramsCapture = new Capture<Map<String, Object>>(); + Capture<Map<String, Object>> paramsCapture = new Capture<>(); expect(connection.call(eq("conduit.connect"), capture(paramsCapture))) .andThrow(conduitException) @@ -214,7 +211,7 @@ JsonObject retConnect = new JsonObject(); retConnect.add("sessionKey", new JsonPrimitive("KeyFoo")); - Capture<Map<String, Object>> paramsCaptureConnect = new Capture<Map<String, Object>>(); + Capture<Map<String, Object>> paramsCaptureConnect = new Capture<>(); expect(connection.call(eq("conduit.connect"), capture(paramsCaptureConnect))) .andReturn(retConnect) @@ -222,7 +219,7 @@ ConduitException conduitException = new ConduitException(); - Capture<Map<String, Object>> paramsCaptureRelevant = new Capture<Map<String, Object>>(); + Capture<Map<String, Object>> paramsCaptureRelevant = new Capture<>(); expect(connection.call(eq("maniphest.info"), capture(paramsCaptureRelevant))) .andThrow(conduitException) @@ -256,7 +253,7 @@ JsonObject retConnect = new JsonObject(); retConnect.add("sessionKey", new JsonPrimitive("KeyFoo")); - Capture<Map<String, Object>> paramsCaptureConnect = new Capture<Map<String, Object>>(); + Capture<Map<String, Object>> paramsCaptureConnect = new Capture<>(); expect(connection.call(eq("conduit.connect"), capture(paramsCaptureConnect))) .andReturn(retConnect) @@ -265,7 +262,7 @@ JsonObject retRelevant = new JsonObject(); retRelevant.add("id", new JsonPrimitive(42)); - Capture<Map<String, Object>> paramsCaptureRelevant = new Capture<Map<String, Object>>(); + Capture<Map<String, Object>> paramsCaptureRelevant = new Capture<>(); expect(connection.call(eq("maniphest.update"), capture(paramsCaptureRelevant))) .andReturn(retRelevant) @@ -296,7 +293,7 @@ JsonObject retConnect = new JsonObject(); retConnect.add("sessionKey", new JsonPrimitive("KeyFoo")); - Capture<Map<String, Object>> paramsCaptureConnect = new Capture<Map<String, Object>>(); + Capture<Map<String, Object>> paramsCaptureConnect = new Capture<>(); expect(connection.call(eq("conduit.connect"), capture(paramsCaptureConnect))) .andReturn(retConnect) @@ -305,7 +302,7 @@ JsonObject retRelevant = new JsonObject(); retRelevant.add("id", new JsonPrimitive(42)); - Capture<Map<String, Object>> paramsCaptureRelevant = new Capture<Map<String, Object>>(); + Capture<Map<String, Object>> paramsCaptureRelevant = new Capture<>(); expect(connection.call(eq("maniphest.update"), capture(paramsCaptureRelevant))) .andReturn(retRelevant) @@ -339,7 +336,7 @@ JsonObject retConnect = new JsonObject(); retConnect.add("sessionKey", new JsonPrimitive("KeyFoo")); - Capture<Map<String, Object>> paramsCaptureConnect = new Capture<Map<String, Object>>(); + Capture<Map<String, Object>> paramsCaptureConnect = new Capture<>(); expect(connection.call(eq("conduit.connect"), capture(paramsCaptureConnect))) .andReturn(retConnect) @@ -348,7 +345,7 @@ JsonObject retRelevant = new JsonObject(); retRelevant.add("id", new JsonPrimitive(42)); - Capture<Map<String, Object>> paramsCaptureRelevant = new Capture<Map<String, Object>>(); + Capture<Map<String, Object>> paramsCaptureRelevant = new Capture<>(); expect(connection.call(eq("maniphest.update"), capture(paramsCaptureRelevant))) .andReturn(retRelevant) @@ -381,7 +378,7 @@ ConduitException conduitException = new ConduitException(); - Capture<Map<String, Object>> paramsCapture = new Capture<Map<String, Object>>(); + Capture<Map<String, Object>> paramsCapture = new Capture<>(); expect(connection.call(eq("conduit.connect"), capture(paramsCapture))) .andThrow(conduitException) @@ -412,7 +409,7 @@ JsonObject retConnect = new JsonObject(); retConnect.add("sessionKey", new JsonPrimitive("KeyFoo")); - Capture<Map<String, Object>> paramsCaptureConnect = new Capture<Map<String, Object>>(); + Capture<Map<String, Object>> paramsCaptureConnect = new Capture<>(); expect(connection.call(eq("conduit.connect"), capture(paramsCaptureConnect))) .andReturn(retConnect) @@ -420,7 +417,7 @@ ConduitException conduitException = new ConduitException(); - Capture<Map<String, Object>> paramsCaptureRelevant = new Capture<Map<String, Object>>(); + Capture<Map<String, Object>> paramsCaptureRelevant = new Capture<>(); expect(connection.call(eq("maniphest.update"), capture(paramsCaptureRelevant))) .andThrow(conduitException) @@ -454,7 +451,7 @@ JsonObject retConnect = new JsonObject(); retConnect.add("sessionKey", new JsonPrimitive("KeyFoo")); - Capture<Map<String, Object>> paramsCaptureConnect = new Capture<Map<String, Object>>(); + Capture<Map<String, Object>> paramsCaptureConnect = new Capture<>(); expect(connection.call(eq("conduit.connect"), capture(paramsCaptureConnect))) .andReturn(retConnect) @@ -463,7 +460,7 @@ JsonObject retRelevant = new JsonObject(); retRelevant.add("id", new JsonPrimitive(42)); - Capture<Map<String, Object>> paramsCaptureRelevant = new Capture<Map<String, Object>>(); + Capture<Map<String, Object>> paramsCaptureRelevant = new Capture<>(); expect(connection.call(eq("maniphest.info"), capture(paramsCaptureRelevant))) .andReturn(retRelevant) @@ -495,7 +492,7 @@ JsonObject retConnect = new JsonObject(); retConnect.add("sessionKey", new JsonPrimitive("KeyFoo")); - Capture<Map<String, Object>> paramsCaptureConnect = new Capture<Map<String, Object>>(); + Capture<Map<String, Object>> paramsCaptureConnect = new Capture<>(); expect(connection.call(eq("conduit.connect"), capture(paramsCaptureConnect))) .andReturn(retConnect) @@ -511,7 +508,7 @@ JsonObject retRelevant = new JsonObject(); retRelevant.add("data", queryDataJson); - Capture<Map<String, Object>> paramsCaptureRelevant = new Capture<Map<String, Object>>(); + Capture<Map<String, Object>> paramsCaptureRelevant = new Capture<>(); expect(connection.call(eq("project.query"), capture(paramsCaptureRelevant))) .andReturn(retRelevant) @@ -544,7 +541,7 @@ JsonObject retConnect = new JsonObject(); retConnect.add("sessionKey", new JsonPrimitive("KeyFoo")); - Capture<Map<String, Object>> paramsCaptureConnect = new Capture<Map<String, Object>>(); + Capture<Map<String, Object>> paramsCaptureConnect = new Capture<>(); expect(connection.call(eq("conduit.connect"), capture(paramsCaptureConnect))) .andReturn(retConnect) @@ -570,7 +567,7 @@ JsonObject retRelevant = new JsonObject(); retRelevant.add("data", queryDataJson); - Capture<Map<String, Object>> paramsCaptureRelevant = new Capture<Map<String, Object>>(); + Capture<Map<String, Object>> paramsCaptureRelevant = new Capture<>(); expect(connection.call(eq("project.query"), capture(paramsCaptureRelevant))) .andReturn(retRelevant) @@ -596,7 +593,7 @@ } private void mockConnection() throws Exception { - connection = createMock(ConduitConnection.class);; + connection = createMock(ConduitConnection.class); expectNew(ConduitConnection.class, URL) .andReturn(connection) .once();