Format files with google-java-format 1.6
Change-Id: Ifeb63b1ad3d42ac3339d12a4094b4c4d45490efd
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/bugzilla/BugzillaClient.java b/src/main/java/com/googlesource/gerrit/plugins/its/bugzilla/BugzillaClient.java
index bf2ba68..16f5b12 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/bugzilla/BugzillaClient.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/bugzilla/BugzillaClient.java
@@ -14,9 +14,6 @@
package com.googlesource.gerrit.plugins.its.bugzilla;
-import java.util.HashMap;
-import java.util.Set;
-
import com.googlesource.gerrit.plugins.its.base.its.InvalidTransitionException;
import com.j2bugzilla.base.Bug;
import com.j2bugzilla.base.BugzillaConnector;
@@ -30,6 +27,8 @@
import com.j2bugzilla.rpc.LogIn;
import com.j2bugzilla.rpc.LogOut;
import com.j2bugzilla.rpc.UpdateBug;
+import java.util.HashMap;
+import java.util.Set;
public class BugzillaClient {
@@ -50,7 +49,7 @@
public String login(final String username, final String password) throws BugzillaException {
LogIn logIn = new LogIn(username, password);
connector.executeMethod(logIn);
- return "username="+username+", userid="+logIn.getUserID();
+ return "username=" + username + ", userid=" + logIn.getUserID();
}
public void logout() throws BugzillaException {
@@ -72,9 +71,9 @@
connector.executeMethod(bugComment);
}
- private void performSimpleActionChainable(final Bug bug, final String actionName,
- final String actionValue) throws BugzillaException,
- InvalidTransitionException {
+ private void performSimpleActionChainable(
+ final Bug bug, final String actionName, final String actionValue)
+ throws BugzillaException, InvalidTransitionException {
if ("status".equals(actionName)) {
assertLegalValue(Fields.STATUS, actionValue);
bug.setStatus(actionValue);
@@ -82,30 +81,29 @@
assertLegalValue(Fields.RESOLUTION, actionValue);
bug.setResolution(actionValue);
} else {
- throw new InvalidTransitionException("Simple action " + actionName
- + " is not known");
+ throw new InvalidTransitionException("Simple action " + actionName + " is not known");
}
}
- private void performChainedAction(final Bug bug, final String actionName,
- final String actionValue) throws BugzillaException,
- InvalidTransitionException {
+ private void performChainedAction(
+ final Bug bug, final String actionName, final String actionValue)
+ throws BugzillaException, InvalidTransitionException {
String[] actionNames = actionName.split("/");
String[] actionValues = actionValue.split("/");
if (actionNames.length != actionValues.length) {
- throw new InvalidTransitionException("Number of chained actions does not"
- + " match number of action values");
+ throw new InvalidTransitionException(
+ "Number of chained actions does not" + " match number of action values");
}
int i;
- for (i=0; i<actionNames.length; i++) {
- performSimpleActionChainable(bug, actionNames[i], actionValues[i]);
+ for (i = 0; i < actionNames.length; i++) {
+ performSimpleActionChainable(bug, actionNames[i], actionValues[i]);
}
}
- public void performAction(final String bugId, final String actionNameParam,
- final String actionValueParam) throws BugzillaException,
- InvalidTransitionException {
+ public void performAction(
+ final String bugId, final String actionNameParam, final String actionValueParam)
+ throws BugzillaException, InvalidTransitionException {
Bug bug = getBug(bugId);
String actionName = actionNameParam;
@@ -122,8 +120,7 @@
} else if ("status/resolution".equals(actionName)) {
performChainedAction(bug, actionName, actionValue);
} else {
- throw new InvalidTransitionException("Action " + actionNameParam
- + " is not known");
+ throw new InvalidTransitionException("Action " + actionNameParam + " is not known");
}
connector.executeMethod(new UpdateBug(bug));
}
@@ -131,9 +128,12 @@
private void assertLegalValue(Fields field, String actionValue)
throws BugzillaException, InvalidTransitionException {
if (!getLegalValues(field).contains(actionValue)) {
- throw new InvalidTransitionException( "The value '" + actionValue
- + "' is not an allowed value for bugzilla's " + field.getInternalName()
- + " field");
+ throw new InvalidTransitionException(
+ "The value '"
+ + actionValue
+ + "' is not an allowed value for bugzilla's "
+ + field.getInternalName()
+ + " field");
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/bugzilla/BugzillaItsFacade.java b/src/main/java/com/googlesource/gerrit/plugins/its/bugzilla/BugzillaItsFacade.java
index d63289f..0895f1b 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/bugzilla/BugzillaItsFacade.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/bugzilla/BugzillaItsFacade.java
@@ -14,14 +14,6 @@
package com.googlesource.gerrit.plugins.its.bugzilla;
-import java.io.IOException;
-import java.net.URL;
-import java.util.concurrent.Callable;
-
-import org.eclipse.jgit.lib.Config;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.inject.Inject;
@@ -29,6 +21,12 @@
import com.googlesource.gerrit.plugins.its.base.its.ItsFacade;
import com.j2bugzilla.base.BugzillaException;
import com.j2bugzilla.base.ConnectionException;
+import java.io.IOException;
+import java.net.URL;
+import java.util.concurrent.Callable;
+import org.eclipse.jgit.lib.Config;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class BugzillaItsFacade implements ItsFacade {
private static final String GERRIT_CONFIG_USERNAME = "username";
@@ -45,13 +43,15 @@
private BugzillaClient client;
@Inject
- public BugzillaItsFacade(@PluginName String pluginName,
- @GerritServerConfig Config cfg) {
+ public BugzillaItsFacade(@PluginName String pluginName, @GerritServerConfig Config cfg) {
this.pluginName = pluginName;
try {
this.gerritConfig = cfg;
- log.info("Connected to Bugzilla at " + client().getXmlRpcUrl()
- + ", reported version is " + client().getServerVersion());
+ log.info(
+ "Connected to Bugzilla at "
+ + client().getXmlRpcUrl()
+ + ", reported version is "
+ + client().getServerVersion());
} catch (Exception ex) {
log.warn("Bugzilla is currently not available", ex);
}
@@ -59,47 +59,51 @@
@Override
public String healthCheck(final Check check) throws IOException {
- return execute(new Callable<String>(){
- @Override
- public String call() throws Exception {
- if (check.equals(Check.ACCESS))
- return healthCheckAccess();
- else
- return healthCheckSysinfo();
- }});
+ return execute(
+ new Callable<String>() {
+ @Override
+ public String call() throws Exception {
+ if (check.equals(Check.ACCESS)) return healthCheckAccess();
+ else return healthCheckSysinfo();
+ }
+ });
}
@Override
public void addComment(final String bugId, final String comment) throws IOException {
- execute(new Callable<String>(){
- @Override
- public String call() throws Exception {
- log.debug("Adding comment " + comment + " to bug " + bugId);
- client().addComment(bugId, comment);
- log.debug("Added comment " + comment + " to bug " + bugId);
- return bugId;
- }});
+ execute(
+ new Callable<String>() {
+ @Override
+ public String call() throws Exception {
+ log.debug("Adding comment " + comment + " to bug " + bugId);
+ client().addComment(bugId, comment);
+ log.debug("Added comment " + comment + " to bug " + bugId);
+ return bugId;
+ }
+ });
}
@Override
public void addRelatedLink(final String issueKey, final URL relatedUrl, String description)
throws IOException {
- addComment(issueKey, "Related URL: " + createLinkForWebui(relatedUrl.toExternalForm(), description));
+ addComment(
+ issueKey, "Related URL: " + createLinkForWebui(relatedUrl.toExternalForm(), description));
}
@Override
- public void performAction(final String bugId, final String actionString)
- throws IOException {
+ public void performAction(final String bugId, final String actionString) throws IOException {
- execute(new Callable<String>(){
- @Override
- public String call() throws Exception {
- String actionName = actionString.substring(0, actionString.indexOf(" "));
- String actionValue = actionString.substring(actionString.indexOf(" ") + 1);
- doPerformAction(bugId, actionName, actionValue);
- return bugId;
- }});
+ execute(
+ new Callable<String>() {
+ @Override
+ public String call() throws Exception {
+ String actionName = actionString.substring(0, actionString.indexOf(" "));
+ String actionValue = actionString.substring(actionString.indexOf(" ") + 1);
+ doPerformAction(bugId, actionName, actionValue);
+ return bugId;
+ }
+ });
}
private void doPerformAction(final String bugId, final String fieldName, final String fieldValue)
@@ -109,11 +113,13 @@
@Override
public boolean exists(final String bugId) throws IOException {
- return execute(new Callable<Boolean>(){
- @Override
- public Boolean call() throws Exception {
- return client().getBug(bugId) != null;
- }});
+ return execute(
+ new Callable<Boolean>() {
+ @Override
+ public Boolean call() throws Exception {
+ return client().getBug(bugId) != null;
+ }
+ });
}
public void logout() {
@@ -123,8 +129,7 @@
public void logout(boolean quiet) {
try {
client().logout();
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
if (!quiet) log.error("I was unable to logout", ex);
}
}
@@ -138,8 +143,7 @@
String token = client.login(getUsername(), getPassword());
log.info("Connected to " + getUrl() + " as " + token);
return token;
- }
- catch (Exception ex) {
+ } catch (Exception ex) {
if (!quiet) {
log.error("I was unable to login", ex);
}
@@ -156,8 +160,7 @@
client = new BugzillaClient(getUrl());
log.debug("Autenthicating as user " + getUsername());
} catch (Exception ex) {
- log.info("Unable to connect to " + getUrl() + " as "
- + getUsername());
+ log.info("Unable to connect to " + getUrl() + " as " + getUsername());
throw new IOException(ex);
}
@@ -170,7 +173,7 @@
private <P> P execute(Callable<P> function) throws IOException {
int attempt = 0;
- while(true) {
+ while (true) {
try {
return function.call();
} catch (Exception ex) {
@@ -181,10 +184,8 @@
continue;
}
- if (ex instanceof IOException)
- throw ((IOException)ex);
- else
- throw new IOException(ex);
+ if (ex instanceof IOException) throw ((IOException) ex);
+ else throw new IOException(ex);
}
}
}
@@ -194,30 +195,25 @@
}
private String getPassword() {
- final String pass =
- gerritConfig.getString(pluginName, null,
- GERRIT_CONFIG_PASSWORD);
+ final String pass = gerritConfig.getString(pluginName, null, GERRIT_CONFIG_PASSWORD);
return pass;
}
private String getUsername() {
- final String user =
- gerritConfig.getString(pluginName, null,
- GERRIT_CONFIG_USERNAME);
+ final String user = gerritConfig.getString(pluginName, null, GERRIT_CONFIG_USERNAME);
return user;
}
private String getUrl() {
- final String url =
- gerritConfig.getString(pluginName, null, GERRIT_CONFIG_URL);
+ final String url = gerritConfig.getString(pluginName, null, GERRIT_CONFIG_URL);
return url;
}
@Override
public String createLinkForWebui(String url, String text) {
String ret = url;
- if (text != null && ! text.equals(url)) {
- ret += " (" + text + ")";
+ if (text != null && !text.equals(url)) {
+ ret += " (" + text + ")";
}
return ret;
}
@@ -226,13 +222,18 @@
BugzillaClient client = new BugzillaClient(getUrl());
client.login(getUsername(), getPassword());
client.logout();
- final String result = "{\"status\"=\"ok\",\"username\"=\""+getUsername()+"\"}";
+ final String result = "{\"status\"=\"ok\",\"username\"=\"" + getUsername() + "\"}";
log.debug("Healtheck on access result: {}", result);
return result;
}
private String healthCheckSysinfo() throws BugzillaException, IOException {
- final String result = "{\"status\"=\"ok\",\"system\"=\"Bugzilla\",\"version\"=\""+client().getServerVersion()+"\",\"url\"=\""+getUrl()+"\"}";
+ final String result =
+ "{\"status\"=\"ok\",\"system\"=\"Bugzilla\",\"version\"=\""
+ + client().getServerVersion()
+ + "\",\"url\"=\""
+ + getUrl()
+ + "\"}";
log.debug("Healtheck on sysinfo result: {}", result);
return result;
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/bugzilla/BugzillaModule.java b/src/main/java/com/googlesource/gerrit/plugins/its/bugzilla/BugzillaModule.java
index 6d863c9..fdf16a7 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/bugzilla/BugzillaModule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/bugzilla/BugzillaModule.java
@@ -14,18 +14,16 @@
package com.googlesource.gerrit.plugins.its.bugzilla;
-import org.eclipse.jgit.lib.Config;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.config.PluginConfigFactory;
import com.google.inject.AbstractModule;
import com.google.inject.Inject;
-
import com.googlesource.gerrit.plugins.its.base.ItsHookModule;
import com.googlesource.gerrit.plugins.its.base.its.ItsFacade;
+import org.eclipse.jgit.lib.Config;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class BugzillaModule extends AbstractModule {
@@ -36,7 +34,8 @@
private final PluginConfigFactory pluginCfgFactory;
@Inject
- public BugzillaModule(@PluginName final String pluginName,
+ public BugzillaModule(
+ @PluginName final String pluginName,
@GerritServerConfig final Config config,
PluginConfigFactory pluginCfgFactory) {
this.pluginName = pluginName;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/bugzilla/InitBugzilla.java b/src/main/java/com/googlesource/gerrit/plugins/its/bugzilla/InitBugzilla.java
index 97fd212..956a9be 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/bugzilla/InitBugzilla.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/bugzilla/InitBugzilla.java
@@ -17,21 +17,18 @@
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.pgm.init.api.AllProjectsConfig;
import com.google.gerrit.pgm.init.api.AllProjectsNameOnInitProvider;
+import com.google.gerrit.pgm.init.api.ConsoleUI;
import com.google.gerrit.pgm.init.api.InitFlags;
import com.google.gerrit.pgm.init.api.Section;
-import com.google.gerrit.pgm.init.api.ConsoleUI;
import com.google.inject.Inject;
import com.google.inject.Singleton;
-
import com.googlesource.gerrit.plugins.its.base.its.InitIts;
import com.googlesource.gerrit.plugins.its.base.validation.ItsAssociationPolicy;
import com.j2bugzilla.base.BugzillaException;
import com.j2bugzilla.base.ConnectionException;
-
-import org.eclipse.jgit.errors.ConfigInvalidException;
-
import java.io.IOException;
import java.util.Arrays;
+import org.eclipse.jgit.errors.ConfigInvalidException;
/** Initialize the GitRepositoryManager configuration section. */
@Singleton
@@ -46,9 +43,13 @@
private String bugzillaPassword;
@Inject
- InitBugzilla(@PluginName String pluginName, ConsoleUI ui,
- Section.Factory sections, AllProjectsConfig allProjectsConfig,
- AllProjectsNameOnInitProvider allProjects, InitFlags flags) {
+ InitBugzilla(
+ @PluginName String pluginName,
+ ConsoleUI ui,
+ Section.Factory sections,
+ AllProjectsConfig allProjectsConfig,
+ AllProjectsNameOnInitProvider allProjects,
+ InitFlags flags) {
super(pluginName, "Bugzilla", ui, allProjectsConfig, allProjects);
this.pluginName = pluginName;
this.sections = sections;
@@ -68,11 +69,14 @@
ui.message("A Bugzilla configuration for the 'hooks-bugzilla' plugin was found.\n");
if (ui.yesno(true, "Copy it for the '%s' plugin?", pluginName)) {
for (String n : flags.cfg.getNames("bugzilla")) {
- flags.cfg.setStringList(pluginName, null, n,
- Arrays.asList(flags.cfg.getStringList("bugzilla", null, n)));
+ flags.cfg.setStringList(
+ pluginName, null, n, Arrays.asList(flags.cfg.getStringList("bugzilla", null, n)));
}
for (String n : flags.cfg.getNames(COMMENT_LINK_SECTION, "bugzilla")) {
- flags.cfg.setStringList(COMMENT_LINK_SECTION, pluginName, n,
+ flags.cfg.setStringList(
+ COMMENT_LINK_SECTION,
+ pluginName,
+ n,
Arrays.asList(flags.cfg.getStringList(COMMENT_LINK_SECTION, "bugzilla", n)));
}
@@ -92,7 +96,6 @@
this.bugzilla = sections.get(pluginName, null);
this.bugzillaComment = sections.get(COMMENT_LINK_SECTION, pluginName);
-
do {
enterBugzillaConnectivity();
} while (bugzillaUrl != null
@@ -103,11 +106,12 @@
}
ui.header("Bugzilla issue-tracking association");
- bugzillaComment.string("Bugzilla bug number regex", "match", "\\([Bb][Uu][Gg][ ]*[1-9][0-9]*\\)");
- bugzillaComment.set("html",
- String.format("<a href=\"%s/show_bug.cgi?id=$1\">$1</a>", bugzillaUrl));
- bugzillaComment.select("Bug number enforced in commit message", "association",
- ItsAssociationPolicy.SUGGESTED);
+ bugzillaComment.string(
+ "Bugzilla bug number regex", "match", "\\([Bb][Uu][Gg][ ]*[1-9][0-9]*\\)");
+ bugzillaComment.set(
+ "html", String.format("<a href=\"%s/show_bug.cgi?id=$1\">$1</a>", bugzillaUrl));
+ bugzillaComment.select(
+ "Bug number enforced in commit message", "association", ItsAssociationPolicy.SUGGESTED);
}
public void enterBugzillaConnectivity() {
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/bugzilla/BugzillaItsFacadeTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/bugzilla/BugzillaItsFacadeTest.java
index 58d9b4d..53b194e 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/bugzilla/BugzillaItsFacadeTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/bugzilla/BugzillaItsFacadeTest.java
@@ -15,16 +15,13 @@
import static org.easymock.EasyMock.expect;
-import org.eclipse.jgit.lib.Config;
-
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.extensions.config.FactoryModule;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.inject.Guice;
import com.google.inject.Injector;
-
import com.googlesource.gerrit.plugins.its.base.testutil.LoggingMockingTestCase;
-import com.googlesource.gerrit.plugins.its.bugzilla.BugzillaItsFacade;
+import org.eclipse.jgit.lib.Config;
public class BugzillaItsFacadeTest extends LoggingMockingTestCase {
private Injector injector;
@@ -39,10 +36,8 @@
String actual = itsFacade.createLinkForWebui("Test-Url", "Test-Text");
assertNotNull("Created link is null", actual);
- assertTrue("Created link does not contain url",
- actual.contains("Test-Url"));
- assertTrue("Created link does not contain text",
- actual.contains("Test-Text"));
+ assertTrue("Created link does not contain url", actual.contains("Test-Url"));
+ assertTrue("Created link does not contain text", actual.contains("Test-Text"));
assertUnconnectableBugzilla();
}
@@ -80,12 +75,9 @@
}
private void mockUnconnectableBugzilla() {
- expect(serverConfig.getString("its-bugzilla", null, "url"))
- .andReturn("<no-url>").anyTimes();
- expect(serverConfig.getString("its-bugzilla", null, "username"))
- .andReturn("none").anyTimes();
- expect(serverConfig.getString("its-bugzilla", null, "password"))
- .andReturn("none").anyTimes();
+ expect(serverConfig.getString("its-bugzilla", null, "url")).andReturn("<no-url>").anyTimes();
+ expect(serverConfig.getString("its-bugzilla", null, "username")).andReturn("none").anyTimes();
+ expect(serverConfig.getString("its-bugzilla", null, "password")).andReturn("none").anyTimes();
}
private void assertUnconnectableBugzilla() {
@@ -105,10 +97,8 @@
@Override
protected void configure() {
serverConfig = createMock(Config.class);
- bind(Config.class).annotatedWith(GerritServerConfig.class)
- .toInstance(serverConfig);
- bind(String.class).annotatedWith(PluginName.class)
- .toInstance("its-bugzilla");
+ bind(Config.class).annotatedWith(GerritServerConfig.class).toInstance(serverConfig);
+ bind(String.class).annotatedWith(PluginName.class).toInstance("its-bugzilla");
}
}
-}
\ No newline at end of file
+}