Apply google-java-format to all files
Change-Id: I0d11171119b7b0a68e91ec31db0df630339e590b
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/its/InitIts.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/its/InitIts.java
index ac0136c..63223ff 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/its/InitIts.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/its/InitIts.java
@@ -21,23 +21,24 @@
import com.google.gerrit.pgm.init.api.ConsoleUI;
import com.google.gerrit.pgm.init.api.InitStep;
import com.google.gerrit.pgm.init.api.Section;
-
-import org.eclipse.jgit.errors.ConfigInvalidException;
-import org.eclipse.jgit.lib.Config;
-
import java.io.IOException;
import java.util.EnumSet;
+import org.eclipse.jgit.errors.ConfigInvalidException;
+import org.eclipse.jgit.lib.Config;
public class InitIts implements InitStep {
public static String COMMENT_LINK_SECTION = "commentlink";
public static enum TrueFalseEnum {
- TRUE, FALSE;
+ TRUE,
+ FALSE;
}
public static enum ItsIntegration {
- ENABLED, DISABLED, ENFORCED;
+ ENABLED,
+ DISABLED,
+ ENFORCED;
}
private final String pluginName;
@@ -46,7 +47,10 @@
private final AllProjectsConfig allProjectsConfig;
private final AllProjectsNameOnInitProvider allProjects;
- public InitIts(String pluginName, String itsDisplayName, ConsoleUI ui,
+ public InitIts(
+ String pluginName,
+ String itsDisplayName,
+ ConsoleUI ui,
AllProjectsConfig allProjectsConfig,
AllProjectsNameOnInitProvider allProjects) {
this.pluginName = pluginName;
@@ -57,8 +61,7 @@
}
@Override
- public void run() throws IOException, ConfigInvalidException {
- }
+ public void run() throws IOException, ConfigInvalidException {}
@Override
public void postRun() throws IOException, ConfigInvalidException {
@@ -76,7 +79,8 @@
itsintegration = ItsIntegration.DISABLED;
}
itsintegration =
- ui.readEnum(itsintegration,
+ ui.readEnum(
+ itsintegration,
EnumSet.allOf(ItsIntegration.class),
"Issue tracker integration for all projects?");
switch (itsintegration) {
@@ -92,8 +96,8 @@
cfg.unset("plugin", pluginName, "enabled");
break;
default:
- throw new IOException("Unsupported value for issue track integration: "
- + itsintegration.name());
+ throw new IOException(
+ "Unsupported value for issue track integration: " + itsintegration.name());
}
allProjectsConfig.save(pluginName, "Initialize " + itsDisplayName + " Integration");
}
@@ -101,8 +105,9 @@
private void configureBranches(Config cfg) {
String[] branches = cfg.getStringList("plugin", pluginName, "branch");
if (branches.length > 1) {
- ui.message("The issue tracker integration is configured for multiple branches."
- + " Please adapt the configuration in the 'project.config' file of the '%s' project.\n",
+ ui.message(
+ "The issue tracker integration is configured for multiple branches."
+ + " Please adapt the configuration in the 'project.config' file of the '%s' project.\n",
allProjects.get());
return;
}
@@ -114,14 +119,18 @@
boolean validRef;
do {
- String v = ui.readString(branch, "Branches for which the issue tracker integration"
- + " should be enabled (ref, ref pattern or regular expression)");
+ String v =
+ ui.readString(
+ branch,
+ "Branches for which the issue tracker integration"
+ + " should be enabled (ref, ref pattern or regular expression)");
validRef = RefConfigSection.isValid(v);
if (validRef) {
branch = v;
} else {
ui.message(
- "'%s' is not valid. Please specify a valid ref, ref pattern or regular expression\n", v);
+ "'%s' is not valid. Please specify a valid ref, ref pattern or regular expression\n",
+ v);
}
} while (!validRef);
@@ -133,7 +142,7 @@
}
public boolean enterSSLVerify(Section section) {
- return TrueFalseEnum.TRUE == section.select("Verify SSL Certificates",
- "sslVerify", TrueFalseEnum.TRUE);
+ return TrueFalseEnum.TRUE
+ == section.select("Verify SSL Certificates", "sslVerify", TrueFalseEnum.TRUE);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/its/ItsConfig.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/its/ItsConfig.java
index 08d3d1d..c09d071 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/its/ItsConfig.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/its/ItsConfig.java
@@ -39,17 +39,13 @@
import com.google.gerrit.server.project.ProjectState;
import com.google.gerrit.server.project.RefPatternMatcher;
import com.google.inject.Inject;
-
import com.googlesource.gerrit.plugins.its.base.validation.ItsAssociationPolicy;
-
-import org.eclipse.jgit.lib.Config;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.util.Collections;
import java.util.List;
import java.util.regex.Pattern;
-
+import org.eclipse.jgit.lib.Config;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ItsConfig {
private static final String PLUGIN = "plugin";
@@ -74,8 +70,11 @@
}
@Inject
- public ItsConfig(@PluginName String pluginName, ProjectCache projectCache,
- PluginConfigFactory pluginCfgFactory, @GerritServerConfig Config gerritConfig) {
+ public ItsConfig(
+ @PluginName String pluginName,
+ ProjectCache projectCache,
+ PluginConfigFactory pluginCfgFactory,
+ @GerritServerConfig Config gerritConfig) {
this.pluginName = pluginName;
this.projectCache = projectCache;
this.pluginCfgFactory = pluginCfgFactory;
@@ -115,25 +114,32 @@
public boolean isEnabled(Project.NameKey projectNK, String refName) {
ProjectState projectState = projectCache.get(projectNK);
if (projectState == null) {
- log.error("Failed to check if " + pluginName + " is enabled for project "
- + projectNK.get() + ": Project " + projectNK.get() + " not found");
+ log.error(
+ "Failed to check if "
+ + pluginName
+ + " is enabled for project "
+ + projectNK.get()
+ + ": Project "
+ + projectNK.get()
+ + " not found");
return false;
}
- if(isEnforcedByAnyParentProject(refName, projectState)) {
+ if (isEnforcedByAnyParentProject(refName, projectState)) {
return true;
}
- return !"false".equals(pluginCfgFactory.getFromProjectConfigWithInheritance(
- projectState, pluginName).getString("enabled", "false"))
+ return !"false"
+ .equals(
+ pluginCfgFactory
+ .getFromProjectConfigWithInheritance(projectState, pluginName)
+ .getString("enabled", "false"))
&& isEnabledForBranch(projectState, refName);
}
- private boolean isEnforcedByAnyParentProject(String refName,
- ProjectState projectState) {
+ private boolean isEnforcedByAnyParentProject(String refName, ProjectState projectState) {
for (ProjectState parentState : projectState.treeInOrder()) {
- PluginConfig parentCfg =
- pluginCfgFactory.getFromProjectConfig(parentState, pluginName);
+ PluginConfig parentCfg = pluginCfgFactory.getFromProjectConfig(parentState, pluginName);
if ("enforced".equals(parentCfg.getString("enabled", "false"))
&& isEnabledForBranch(parentState, refName)) {
return true;
@@ -144,8 +150,9 @@
private boolean isEnabledForBranch(ProjectState project, String refName) {
String[] refPatterns =
- pluginCfgFactory.getFromProjectConfigWithInheritance(project,
- pluginName).getStringList("branch");
+ pluginCfgFactory
+ .getFromProjectConfigWithInheritance(project, pluginName)
+ .getStringList("branch");
if (refPatterns.length == 0) {
return true;
}
@@ -181,48 +188,46 @@
/**
* Gets the regular expression used to identify issue ids.
- * <p>
- * The index of the group that holds the issue id is
- * {@link #getIssuePatternGroupIndex()}.
*
- * @return the regular expression, or {@code null}, if there is no pattern
- * to match issue ids.
+ * <p>The index of the group that holds the issue id is {@link #getIssuePatternGroupIndex()}.
+ *
+ * @return the regular expression, or {@code null}, if there is no pattern to match issue ids.
*/
public Pattern getIssuePattern() {
Optional<String> match =
- FluentIterable
- .from(getCommentLinkInfo(getCommentLinkName()))
- .filter(new Predicate<CommentLinkInfo>() {
- @Override
- public boolean apply(CommentLinkInfo input) {
- return input.match != null && !input.match.trim().isEmpty();
- }
- })
- .transform(new Function<CommentLinkInfo, String>() {
- @Override
- public String apply(CommentLinkInfo input) {
- return input.match;
- }
- })
+ FluentIterable.from(getCommentLinkInfo(getCommentLinkName()))
+ .filter(
+ new Predicate<CommentLinkInfo>() {
+ @Override
+ public boolean apply(CommentLinkInfo input) {
+ return input.match != null && !input.match.trim().isEmpty();
+ }
+ })
+ .transform(
+ new Function<CommentLinkInfo, String>() {
+ @Override
+ public String apply(CommentLinkInfo input) {
+ return input.match;
+ }
+ })
.last();
-
- String defPattern = gerritConfig.getString("commentlink", getCommentLinkName(),
- "match");
+
+ String defPattern = gerritConfig.getString("commentlink", getCommentLinkName(), "match");
if (!match.isPresent() && defPattern == null) {
return null;
}
-
+
return Pattern.compile(match.or(defPattern));
}
/**
* Gets the index of the group in the issue pattern that holds the issue id.
- * <p>
- * The corresponding issue pattern is {@link #getIssuePattern()}
*
- * @return the group index for {@link #getIssuePattern()} that holds the
- * issue id. The group index is guaranteed to be a valid group index.
+ * <p>The corresponding issue pattern is {@link #getIssuePattern()}
+ *
+ * @return the group index for {@link #getIssuePattern()} that holds the issue id. The group index
+ * is guaranteed to be a valid group index.
*/
public int getIssuePatternGroupIndex() {
Pattern pattern = getIssuePattern();
@@ -241,36 +246,33 @@
*/
public ItsAssociationPolicy getItsAssociationPolicy() {
ItsAssociationPolicy legacyItsAssociationPolicy =
- gerritConfig.getEnum("commentlink", getCommentLinkName(),
- "association", ItsAssociationPolicy.OPTIONAL);
+ gerritConfig.getEnum(
+ "commentlink", getCommentLinkName(), "association", ItsAssociationPolicy.OPTIONAL);
return getPluginConfigEnum("association", legacyItsAssociationPolicy);
}
private String getPluginConfigString(String key) {
- return getCurrentPluginConfig().getString(key,
- gerritConfig.getString(PLUGIN, pluginName, key));
+ return getCurrentPluginConfig().getString(key, gerritConfig.getString(PLUGIN, pluginName, key));
}
private int getPluginConfigInt(String key, int defaultValue) {
- return getCurrentPluginConfig().getInt(key,
- gerritConfig.getInt(PLUGIN, pluginName, key, defaultValue));
+ return getCurrentPluginConfig()
+ .getInt(key, gerritConfig.getInt(PLUGIN, pluginName, key, defaultValue));
}
private <T extends Enum<?>> T getPluginConfigEnum(String key, T defaultValue) {
- return getCurrentPluginConfig().getEnum(key,
- gerritConfig.getEnum(PLUGIN, pluginName, key, defaultValue));
+ return getCurrentPluginConfig()
+ .getEnum(key, gerritConfig.getEnum(PLUGIN, pluginName, key, defaultValue));
}
private PluginConfig getCurrentPluginConfig() {
NameKey projectName = currentProjectName.get();
if (projectName != null) {
try {
- return pluginCfgFactory.getFromProjectConfigWithInheritance(
- projectName, pluginName);
+ return pluginCfgFactory.getFromProjectConfigWithInheritance(projectName, pluginName);
} catch (NoSuchProjectException e) {
- log.error("Cannot access " + projectName + " configuration for plugin "
- + pluginName, e);
+ log.error("Cannot access " + projectName + " configuration for plugin " + pluginName, e);
}
}
return new PluginConfig(pluginName, new Config());
@@ -279,15 +281,16 @@
private List<CommentLinkInfo> getCommentLinkInfo(final String commentlinkName) {
NameKey projectName = currentProjectName.get();
if (projectName != null) {
- List<CommentLinkInfo> commentlinks =
- projectCache.get(projectName).getCommentLinks();
+ List<CommentLinkInfo> commentlinks = projectCache.get(projectName).getCommentLinks();
return FluentIterable.from(commentlinks)
- .filter(new Predicate<CommentLinkInfo>() {
- @Override
- public boolean apply(CommentLinkInfo input) {
- return input.name.equals(commentlinkName);
- }
- }).toList();
+ .filter(
+ new Predicate<CommentLinkInfo>() {
+ @Override
+ public boolean apply(CommentLinkInfo input) {
+ return input.name.equals(commentlinkName);
+ }
+ })
+ .toList();
}
return Collections.emptyList();
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/its/ItsFacade.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/its/ItsFacade.java
index 53e3ced..9d7b3fa 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/its/ItsFacade.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/its/ItsFacade.java
@@ -17,9 +17,7 @@
import java.io.IOException;
import java.net.URL;
-/**
- * A simple facade to an issue tracking system (its)
- */
+/** A simple facade to an issue tracking system (its) */
public interface ItsFacade {
public enum Check {
@@ -27,20 +25,15 @@
ACCESS
}
- public String healthCheck(Check check)
- throws IOException;
+ public String healthCheck(Check check) throws IOException;
- public void addRelatedLink(String issueId, URL relatedUrl, String description)
- throws IOException;
+ public void addRelatedLink(String issueId, URL relatedUrl, String description) throws IOException;
- public void addComment(String issueId, String comment)
- throws IOException;
+ public void addComment(String issueId, String comment) throws IOException;
- public void performAction(String issueId, String actionName)
- throws IOException;
+ public void performAction(String issueId, String actionName) throws IOException;
- public boolean exists(final String issueId)
- throws IOException;
+ public boolean exists(final String issueId) throws IOException;
public String createLinkForWebui(String url, String text);
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/its/ItsHookEnabledConfigEntry.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/its/ItsHookEnabledConfigEntry.java
index 17bcf6b..85cbfb3 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/its/ItsHookEnabledConfigEntry.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/its/ItsHookEnabledConfigEntry.java
@@ -18,17 +18,18 @@
import com.google.gerrit.server.config.PluginConfigFactory;
import com.google.gerrit.server.config.ProjectConfigEntry;
import com.google.gerrit.server.project.ProjectState;
-
import java.util.Arrays;
public class ItsHookEnabledConfigEntry extends ProjectConfigEntry {
private final String pluginName;
private final PluginConfigFactory pluginCfgFactory;
- public ItsHookEnabledConfigEntry(String pluginName,
- PluginConfigFactory pluginCfgFactory) {
- super("Enable " + pluginName + " integration", "false",
- Arrays.asList(new String[] {"false", "true", "enforced"}), true);
+ public ItsHookEnabledConfigEntry(String pluginName, PluginConfigFactory pluginCfgFactory) {
+ super(
+ "Enable " + pluginName + " integration",
+ "false",
+ Arrays.asList(new String[] {"false", "true", "enforced"}),
+ true);
this.pluginName = pluginName;
this.pluginCfgFactory = pluginCfgFactory;
}
@@ -36,8 +37,7 @@
@Override
public boolean isEditable(ProjectState project) {
for (ProjectState parentState : project.parents()) {
- PluginConfig parentCfg =
- pluginCfgFactory.getFromProjectConfig(parentState, pluginName);
+ PluginConfig parentCfg = pluginCfgFactory.getFromProjectConfig(parentState, pluginName);
if ("enforced".equals(parentCfg.getString("enabled"))) {
return false;
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/its/NoopItsFacade.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/its/NoopItsFacade.java
index 1d563e7..267a4b8 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/its/NoopItsFacade.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/its/NoopItsFacade.java
@@ -14,16 +14,12 @@
package com.googlesource.gerrit.plugins.its.base.its;
+import java.io.IOException;
+import java.net.URL;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-import java.net.URL;
-
-/**
- * An ITS facade doing nothing, it's configured when no ITS are referenced in
- * config
- */
+/** An ITS facade doing nothing, it's configured when no ITS are referenced in config */
public class NoopItsFacade implements ItsFacade {
private Logger log = LoggerFactory.getLogger(NoopItsFacade.class);
@@ -39,8 +35,7 @@
public void addRelatedLink(String issueId, URL relatedUrl, String description)
throws IOException {
if (log.isDebugEnabled()) {
- log.debug("addRelatedLink({},{},{})", new Object[] {issueId, relatedUrl,
- description});
+ log.debug("addRelatedLink({},{},{})", new Object[] {issueId, relatedUrl, description});
}
}
@@ -53,8 +48,7 @@
}
@Override
- public void performAction(String issueId, String actionName)
- throws IOException {
+ public void performAction(String issueId, String actionName) throws IOException {
if (log.isDebugEnabled()) {
log.debug("performAction({},{})", issueId, actionName);
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/util/CommitMessageFetcher.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/util/CommitMessageFetcher.java
index 76a1a5a..905a2a3 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/util/CommitMessageFetcher.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/util/CommitMessageFetcher.java
@@ -3,7 +3,7 @@
import com.google.gerrit.reviewdb.client.Project.NameKey;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.inject.Inject;
-
+import java.io.IOException;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
@@ -11,11 +11,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-
public class CommitMessageFetcher {
- private static final Logger log = LoggerFactory.getLogger(
- CommitMessageFetcher.class);
+ private static final Logger log = LoggerFactory.getLogger(CommitMessageFetcher.class);
private final GitRepositoryManager repoManager;
@@ -38,8 +35,9 @@
try {
ret = fetch(projectName, commitId);
} catch (IOException e) {
- log.error("Could not fetch commit message for commit " + commitId +
- " of project " + projectName, e);
+ log.error(
+ "Could not fetch commit message for commit " + commitId + " of project " + projectName,
+ e);
}
return ret;
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/util/IssueExtractor.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/util/IssueExtractor.java
index 546e6c7..291fb65 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/util/IssueExtractor.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/util/IssueExtractor.java
@@ -7,30 +7,24 @@
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
-
import com.googlesource.gerrit.plugins.its.base.its.ItsConfig;
-
-import org.apache.commons.lang.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class IssueExtractor {
- private static final Logger log = LoggerFactory.getLogger(
- IssueExtractor.class);
+ private static final Logger log = LoggerFactory.getLogger(IssueExtractor.class);
private final CommitMessageFetcher commitMessageFetcher;
private final ReviewDb db;
private final ItsConfig itsConfig;
@Inject
- IssueExtractor(ItsConfig itsConfig,
- CommitMessageFetcher commitMessageFetcher,
- ReviewDb db) {
+ IssueExtractor(ItsConfig itsConfig, CommitMessageFetcher commitMessageFetcher, ReviewDb db) {
this.commitMessageFetcher = commitMessageFetcher;
this.db = db;
this.itsConfig = itsConfig;
@@ -64,15 +58,15 @@
/**
* Helper funcion for {@link #getIssueIds(String, String)}.
- * <p>
- * Adds a text's issues for a given occurrence to the map returned by
- * {@link #getIssueIds(String, String)}.
+ *
+ * <p>Adds a text's issues for a given occurrence to the map returned by {@link
+ * #getIssueIds(String, String)}.
*
* @param text The text to extract issues from.
* @param occurrence The occurrence the issues get added at in {@code map}.
* @param map The map that the issues should get added to.
*/
- private void addIssuesOccurrence(String text, String occurrence, Map<String,Set<String>> map) {
+ private void addIssuesOccurrence(String text, String occurrence, Map<String, Set<String>> map) {
for (String issue : getIssueIds(text)) {
Set<String> occurrences = map.get(issue);
if (occurrences == null) {
@@ -88,17 +82,14 @@
*
* @param projectName The project to fetch {@code commitId} from.
* @param commitId The commit id to fetch issues for.
- * @return A mapping, whose keys are issue ids and whose values is a set of
- * places where the issue occurs. Each issue occurs at least in
- * "somewhere". Issues from the first line get tagged with an occurrence
- * "subject". Issues in the last block get tagged with "footer". Issues
- * occurring between "subject" and "footer" get tagged with "body".
+ * @return A mapping, whose keys are issue ids and whose values is a set of places where the issue
+ * occurs. Each issue occurs at least in "somewhere". Issues from the first line get tagged
+ * with an occurrence "subject". Issues in the last block get tagged with "footer". Issues
+ * occurring between "subject" and "footer" get tagged with "body".
*/
- public Map<String,Set<String>> getIssueIds(String projectName,
- String commitId) {
- Map<String,Set<String>> ret = Maps.newHashMap();
- String commitMessage = commitMessageFetcher.fetchGuarded(projectName,
- commitId);
+ public Map<String, Set<String>> getIssueIds(String projectName, String commitId) {
+ Map<String, Set<String>> ret = Maps.newHashMap();
+ String commitMessage = commitMessageFetcher.fetchGuarded(projectName, commitId);
addIssuesOccurrence(commitMessage, "somewhere", ret);
@@ -108,12 +99,12 @@
addIssuesOccurrence(lines[0], "subject", ret);
// Determining footer line numbers
- int currentLine = lines.length-1;
- while (currentLine >=0 && lines[currentLine].isEmpty()) {
+ int currentLine = lines.length - 1;
+ while (currentLine >= 0 && lines[currentLine].isEmpty()) {
currentLine--;
}
int footerEnd = currentLine + 1;
- while (currentLine >=0 && !lines[currentLine].isEmpty()) {
+ while (currentLine >= 0 && !lines[currentLine].isEmpty()) {
currentLine--;
}
int footerStart = currentLine + 1;
@@ -131,7 +122,7 @@
// No footer could be found. So all lines after the first one (that's
// the subject) is the body.
//body = String[] templateParameters =
- // Arrays.copyOfRange(allParameters, 1, allParameters.length);
+ // Arrays.copyOfRange(allParameters, 1, allParameters.length);
if (lines.length > 0) {
body = StringUtils.join(lines, "\n", 1, lines.length);
}
@@ -170,37 +161,34 @@
/**
* Gets issues for a commit with new issue occurrences marked as "added".
- * <p>
- * Fetches the patch set's immediate ancestor and compares issue occurrences
- * between them. Any new occurrence gets marked as "added." So if for
- * example in patch sets 1, and 2 issue 23 occurs in the subject, while in
- * patch set the issue occurs in the body, then patch set 2 has occurrences
- * "somewhere", and "subject" for issue 23. Patch set 3 has occurrences
- * "somewhere", "body", and "body-added" for issue 23.
+ *
+ * <p>Fetches the patch set's immediate ancestor and compares issue occurrences between them. Any
+ * new occurrence gets marked as "added." So if for example in patch sets 1, and 2 issue 23 occurs
+ * in the subject, while in patch set the issue occurs in the body, then patch set 2 has
+ * occurrences "somewhere", and "subject" for issue 23. Patch set 3 has occurrences "somewhere",
+ * "body", and "body-added" for issue 23.
*
* @param projectName The project to fetch {@code commitId} from.
* @param commitId The commit id to fetch issues for.
- * @param patchSetId The patch set for the {@code commitId}. If it is null,
- * no occurrence can be marked as "-added".
- * @return A mapping, whose keys are issue ids and whose values is a set of
- * places where the issue occurs. Each issue occurs at least in
- * "somewhere". Issues from the first line get tagged with an occurrence
- * "subject". Issues in the last block get tagged with "footer". Issues
- * occurring between "subject" and "footer" get tagged with "body".
+ * @param patchSetId The patch set for the {@code commitId}. If it is null, no occurrence can be
+ * marked as "-added".
+ * @return A mapping, whose keys are issue ids and whose values is a set of places where the issue
+ * occurs. Each issue occurs at least in "somewhere". Issues from the first line get tagged
+ * with an occurrence "subject". Issues in the last block get tagged with "footer". Issues
+ * occurring between "subject" and "footer" get tagged with "body".
*/
- public Map<String,Set<String>> getIssueIds(String projectName,
- String commitId, PatchSet.Id patchSetId) {
- Map<String,Set<String>> current = getIssueIds(projectName, commitId);
+ public Map<String, Set<String>> getIssueIds(
+ String projectName, String commitId, PatchSet.Id patchSetId) {
+ Map<String, Set<String>> current = getIssueIds(projectName, commitId);
if (patchSetId != null) {
- Map<String,Set<String>> previous = Maps.newHashMap();
+ Map<String, Set<String>> previous = Maps.newHashMap();
if (patchSetId.get() != 1) {
- PatchSet.Id previousPatchSetId = new PatchSet.Id(
- patchSetId.getParentKey(), patchSetId.get() - 1);
+ PatchSet.Id previousPatchSetId =
+ new PatchSet.Id(patchSetId.getParentKey(), patchSetId.get() - 1);
try {
PatchSet previousPatchSet = db.patchSets().get(previousPatchSetId);
if (previousPatchSet != null) {
- previous = getIssueIds(projectName,
- previousPatchSet.getRevision().get());
+ previous = getIssueIds(projectName, previousPatchSet.getRevision().get());
}
} catch (OrmException e) {
// previous is still empty to indicate that there was no previous
@@ -219,7 +207,7 @@
newOccurrences.removeAll(previousOccurrences);
}
for (String occurrence : newOccurrences) {
- currentOccurrences.add( "added@" + occurrence);
+ currentOccurrences.add("added@" + occurrence);
}
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/util/PropertyAttributeExtractor.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/util/PropertyAttributeExtractor.java
index 0384699..2032f74 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/util/PropertyAttributeExtractor.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/util/PropertyAttributeExtractor.java
@@ -21,16 +21,11 @@
import com.google.gerrit.server.data.PatchSetAttribute;
import com.google.gerrit.server.data.RefUpdateAttribute;
import com.google.inject.Inject;
-
import com.googlesource.gerrit.plugins.its.base.its.ItsFacade;
import com.googlesource.gerrit.plugins.its.base.workflow.Property;
-
import java.util.Set;
-/**
- * Extractor to translate the various {@code *Attribute}s to
- * {@link Property Properties}.
- */
+/** Extractor to translate the various {@code *Attribute}s to {@link Property Properties}. */
public class PropertyAttributeExtractor {
private Property.Factory propertyFactory;
private ItsFacade its;
@@ -41,25 +36,18 @@
this.propertyFactory = propertyFactory;
}
- public Set<Property> extractFrom(AccountAttribute accountAttribute,
- String prefix) {
+ public Set<Property> extractFrom(AccountAttribute accountAttribute, String prefix) {
Set<Property> properties = Sets.newHashSet();
if (accountAttribute != null) {
// deprecated, to be removed soon. migrate to ones without dash.
- properties.add(propertyFactory.create(prefix + "-email",
- accountAttribute.email));
- properties.add(propertyFactory.create(prefix + "-username",
- accountAttribute.username));
- properties.add(propertyFactory.create(prefix + "-name",
- accountAttribute.name));
+ properties.add(propertyFactory.create(prefix + "-email", accountAttribute.email));
+ properties.add(propertyFactory.create(prefix + "-username", accountAttribute.username));
+ properties.add(propertyFactory.create(prefix + "-name", accountAttribute.name));
// New style configs for vm and soy
- properties.add(propertyFactory.create(prefix + "Email",
- accountAttribute.email));
- properties.add(propertyFactory.create(prefix + "Username",
- accountAttribute.username));
- properties.add(propertyFactory.create(prefix + "Name",
- accountAttribute.name));
+ properties.add(propertyFactory.create(prefix + "Email", accountAttribute.email));
+ properties.add(propertyFactory.create(prefix + "Username", accountAttribute.username));
+ properties.add(propertyFactory.create(prefix + "Name", accountAttribute.name));
}
return properties;
}
@@ -74,20 +62,19 @@
// deprecated, to be removed soon. migrate to ones without dash.
properties.add(propertyFactory.create("commit-message", changeAttribute.commitMessage));
properties.add(propertyFactory.create("change-id", changeAttribute.id));
- properties.add(propertyFactory.create("change-number",
- String.valueOf(changeAttribute.number)));
+ properties.add(propertyFactory.create("change-number", String.valueOf(changeAttribute.number)));
properties.add(propertyFactory.create("change-url", changeAttribute.url));
// New style configs for vm and soy
properties.add(propertyFactory.create("commitMessage", changeAttribute.commitMessage));
properties.add(propertyFactory.create("changeId", changeAttribute.id));
- properties.add(propertyFactory.create("changeNumber",
- String.valueOf(changeAttribute.number)));
+ properties.add(propertyFactory.create("changeNumber", String.valueOf(changeAttribute.number)));
properties.add(propertyFactory.create("changeUrl", changeAttribute.url));
// Soy specfic config though will work with Velocity too
- properties.add(propertyFactory.create("formatChangeUrl",
- its.createLinkForWebui(changeAttribute.url, changeAttribute.url)));
+ properties.add(
+ propertyFactory.create(
+ "formatChangeUrl", its.createLinkForWebui(changeAttribute.url, changeAttribute.url)));
String status = null;
if (changeAttribute.status != null) {
@@ -98,75 +85,63 @@
return properties;
}
- public Set<Property>extractFrom(PatchSetAttribute patchSetAttribute) {
+ public Set<Property> extractFrom(PatchSetAttribute patchSetAttribute) {
Set<Property> properties = Sets.newHashSet();
- properties.add(propertyFactory.create("revision",
- patchSetAttribute.revision));
+ properties.add(propertyFactory.create("revision", patchSetAttribute.revision));
// deprecated, to be removed soon. migrate to ones without dash.
- properties.add(propertyFactory.create("patch-set-number",
- String.valueOf(patchSetAttribute.number)));
+ properties.add(
+ propertyFactory.create("patch-set-number", String.valueOf(patchSetAttribute.number)));
// New style configs for vm and soy
- properties.add(propertyFactory.create("patchSetNumber",
- String.valueOf(patchSetAttribute.number)));
+ properties.add(
+ propertyFactory.create("patchSetNumber", String.valueOf(patchSetAttribute.number)));
properties.add(propertyFactory.create("ref", patchSetAttribute.ref));
// deprecated, to be removed soon. migrate to ones without dash.
- properties.add(propertyFactory.create("created-on",
- patchSetAttribute.createdOn.toString()));
+ properties.add(propertyFactory.create("created-on", patchSetAttribute.createdOn.toString()));
// New style configs for vm and soy
- properties.add(propertyFactory.create("createdOn",
- patchSetAttribute.createdOn.toString()));
+ properties.add(propertyFactory.create("createdOn", patchSetAttribute.createdOn.toString()));
- properties.add(propertyFactory.create("parents",
- patchSetAttribute.parents.toString()));
- properties.add(propertyFactory.create("deletions",
- Integer.toString(patchSetAttribute.sizeDeletions)));
- properties.add(propertyFactory.create("insertions",
- Integer.toString(patchSetAttribute.sizeInsertions)));
+ properties.add(propertyFactory.create("parents", patchSetAttribute.parents.toString()));
+ properties.add(
+ propertyFactory.create("deletions", Integer.toString(patchSetAttribute.sizeDeletions)));
+ properties.add(
+ propertyFactory.create("insertions", Integer.toString(patchSetAttribute.sizeInsertions)));
// deprecated, to be removed soon. migrate to ones without dash.
- properties.add(propertyFactory.create("is-draft",
- Boolean.toString(patchSetAttribute.isDraft)));
+ properties.add(propertyFactory.create("is-draft", Boolean.toString(patchSetAttribute.isDraft)));
// New style configs for vm and soy
- properties.add(propertyFactory.create("isDraft",
- Boolean.toString(patchSetAttribute.isDraft)));
- properties.addAll(extractFrom(patchSetAttribute.uploader,
- "uploader"));
- properties.addAll(extractFrom(patchSetAttribute.author,
- "author"));
+ properties.add(propertyFactory.create("isDraft", Boolean.toString(patchSetAttribute.isDraft)));
+ properties.addAll(extractFrom(patchSetAttribute.uploader, "uploader"));
+ properties.addAll(extractFrom(patchSetAttribute.author, "author"));
return properties;
}
- public Set<Property>extractFrom(RefUpdateAttribute refUpdateAttribute) {
+ public Set<Property> extractFrom(RefUpdateAttribute refUpdateAttribute) {
Set<Property> properties = Sets.newHashSet();
- properties.add(propertyFactory.create("revision",
- refUpdateAttribute.newRev));
+ properties.add(propertyFactory.create("revision", refUpdateAttribute.newRev));
// deprecated, to be removed soon. migrate to ones without dash.
- properties.add(propertyFactory.create("revision-old",
- refUpdateAttribute.oldRev));
+ properties.add(propertyFactory.create("revision-old", refUpdateAttribute.oldRev));
// New style configs for vm and soy
- properties.add(propertyFactory.create("revisionOld",
- refUpdateAttribute.oldRev));
- properties.add(propertyFactory.create("project",
- refUpdateAttribute.project));
- properties.add(propertyFactory.create("ref",
- refUpdateAttribute.refName));
+ properties.add(propertyFactory.create("revisionOld", refUpdateAttribute.oldRev));
+ properties.add(propertyFactory.create("project", refUpdateAttribute.project));
+ properties.add(propertyFactory.create("ref", refUpdateAttribute.refName));
return properties;
}
- public Set<Property>extractFrom(ApprovalAttribute approvalAttribute) {
+ public Set<Property> extractFrom(ApprovalAttribute approvalAttribute) {
Set<Property> properties = Sets.newHashSet();
// deprecated, to be removed soon. migrate to ones without dash.
- properties.add(propertyFactory.create("approval-" +
- approvalAttribute.type, approvalAttribute.value));
+ properties.add(
+ propertyFactory.create("approval-" + approvalAttribute.type, approvalAttribute.value));
// New style configs for vm and soy
- properties.add(propertyFactory.create("approval" +
- approvalAttribute.type.replace("-", ""), approvalAttribute.value));
+ properties.add(
+ propertyFactory.create(
+ "approval" + approvalAttribute.type.replace("-", ""), approvalAttribute.value));
return properties;
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/util/PropertyExtractor.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/util/PropertyExtractor.java
index d93a2a3..b26db77 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/util/PropertyExtractor.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/util/PropertyExtractor.java
@@ -33,19 +33,13 @@
import com.google.gerrit.server.events.PatchSetEvent;
import com.google.gerrit.server.events.RefUpdatedEvent;
import com.google.inject.Inject;
-
import com.googlesource.gerrit.plugins.its.base.workflow.Property;
-
-import org.eclipse.jgit.lib.ObjectId;
-
import java.util.Collections;
import java.util.Map;
import java.util.Set;
+import org.eclipse.jgit.lib.ObjectId;
-/**
- * Extractor to translate an {@link ChangeEvent} to
- * {@link Property Properties}.
- */
+/** Extractor to translate an {@link ChangeEvent} to {@link Property Properties}. */
public class PropertyExtractor {
private IssueExtractor issueExtractor;
private Property.Factory propertyFactory;
@@ -53,7 +47,8 @@
private final String pluginName;
@Inject
- PropertyExtractor(IssueExtractor issueExtractor,
+ PropertyExtractor(
+ IssueExtractor issueExtractor,
Property.Factory propertyFactory,
PropertyAttributeExtractor propertyAttributeExtractor,
@PluginName String pluginName) {
@@ -65,62 +60,54 @@
/**
* creates a patch id for change id string and patchset id string.
+ *
* @param changeId String representation of the patch sets {@code Change.Id@}
* @param patchId String representation of the patch sets {@code Patchset.Id@}
- * @return PatchSet.Id for the specified patch set. If the String to int
- * conversion fails for any of the parameters, null is returned.
+ * @return PatchSet.Id for the specified patch set. If the String to int conversion fails for any
+ * of the parameters, null is returned.
*/
private PatchSet.Id newPatchSetId(String changeId, String patchId) {
try {
- return new PatchSet.Id(new Change.Id(Integer.parseInt(changeId)),
- Integer.parseInt(patchId));
+ return new PatchSet.Id(new Change.Id(Integer.parseInt(changeId)), Integer.parseInt(patchId));
} catch (NumberFormatException e) {
return null;
}
}
- private Map<String,Set<String>> extractFrom(PatchSetEvent event,
- Set<Property> common) {
+ private Map<String, Set<String>> extractFrom(PatchSetEvent event, Set<Property> common) {
common.add(propertyFactory.create("event-type", event.type));
ChangeAttribute change = event.change.get();
PatchSetAttribute patchSet = event.patchSet.get();
common.addAll(propertyAttributeExtractor.extractFrom(change));
common.addAll(propertyAttributeExtractor.extractFrom(patchSet));
PatchSet.Id patchSetId =
- newPatchSetId(Integer.toString(change.number),
- Integer.toString(patchSet.number));
- return issueExtractor.getIssueIds(change.project,
- patchSet.revision, patchSetId);
+ newPatchSetId(Integer.toString(change.number), Integer.toString(patchSet.number));
+ return issueExtractor.getIssueIds(change.project, patchSet.revision, patchSetId);
}
- private Map<String,Set<String>> extractFrom(ChangeAbandonedEvent event,
- Set<Property> common) {
+ private Map<String, Set<String>> extractFrom(ChangeAbandonedEvent event, Set<Property> common) {
common.addAll(propertyAttributeExtractor.extractFrom(event.abandoner.get(), "abandoner"));
common.add(propertyFactory.create("reason", event.reason));
return extractFrom((PatchSetEvent) event, common);
}
- private Map<String,Set<String>> extractFrom(ChangeMergedEvent event,
- Set<Property> common) {
+ private Map<String, Set<String>> extractFrom(ChangeMergedEvent event, Set<Property> common) {
common.addAll(propertyAttributeExtractor.extractFrom(event.submitter.get(), "submitter"));
return extractFrom((PatchSetEvent) event, common);
}
- private Map<String,Set<String>> extractFrom(ChangeRestoredEvent event,
- Set<Property> common) {
+ private Map<String, Set<String>> extractFrom(ChangeRestoredEvent event, Set<Property> common) {
common.addAll(propertyAttributeExtractor.extractFrom(event.restorer.get(), "restorer"));
common.add(propertyFactory.create("reason", event.reason));
return extractFrom((PatchSetEvent) event, common);
}
- private Map<String,Set<String>> extractFrom(DraftPublishedEvent event,
- Set<Property> common) {
+ private Map<String, Set<String>> extractFrom(DraftPublishedEvent event, Set<Property> common) {
common.addAll(propertyAttributeExtractor.extractFrom(event.uploader.get(), "uploader"));
return extractFrom((PatchSetEvent) event, common);
}
- private Map<String,Set<String>> extractFrom(RefUpdatedEvent event,
- Set<Property> common) {
+ private Map<String, Set<String>> extractFrom(RefUpdatedEvent event, Set<Property> common) {
common.add(propertyFactory.create("event-type", event.type));
common.addAll(propertyAttributeExtractor.extractFrom(event.submitter.get(), "submitter"));
common.addAll(propertyAttributeExtractor.extractFrom(event.refUpdate.get()));
@@ -128,23 +115,19 @@
if (ObjectId.zeroId().name().equals(refUpdated.newRev)) {
return Collections.emptyMap();
}
- return issueExtractor.getIssueIds(event.getProjectNameKey().get(),
- refUpdated.newRev);
+ return issueExtractor.getIssueIds(event.getProjectNameKey().get(), refUpdated.newRev);
}
- private Map<String,Set<String>> extractFrom(PatchSetCreatedEvent event,
- Set<Property> common) {
+ private Map<String, Set<String>> extractFrom(PatchSetCreatedEvent event, Set<Property> common) {
common.addAll(propertyAttributeExtractor.extractFrom(event.uploader.get(), "uploader"));
return extractFrom((PatchSetEvent) event, common);
}
- private Map<String,Set<String>> extractFrom(CommentAddedEvent event,
- Set<Property> common) {
+ private Map<String, Set<String>> extractFrom(CommentAddedEvent event, Set<Property> common) {
common.addAll(propertyAttributeExtractor.extractFrom(event.author.get(), "commenter"));
if (event.approvals != null) {
for (ApprovalAttribute approvalAttribute : event.approvals.get()) {
- common.addAll(propertyAttributeExtractor.extractFrom(
- approvalAttribute));
+ common.addAll(propertyAttributeExtractor.extractFrom(approvalAttribute));
}
}
common.add(propertyFactory.create("comment", event.comment));
@@ -154,10 +137,10 @@
/**
* A set of property sets extracted from an event.
*
- * As events may relate to more that a single issue, and properties sets are
- * should be tied to a single issue, returning {@code Set<Property>} is not
- * sufficient, and we need to return {@code Set<Set<Property>>}. Using this
- * approach, a PatchSetCreatedEvent for a patch set with commit message:
+ * <p>As events may relate to more that a single issue, and properties sets are should be tied to
+ * a single issue, returning {@code Set<Property>} is not sufficient, and we need to return {@code
+ * Set<Set<Property>>}. Using this approach, a PatchSetCreatedEvent for a patch set with commit
+ * message:
*
* <pre>
* (bug 4711) Fix treatment of special characters in title
@@ -183,16 +166,15 @@
* event: patchset-created
* </pre>
*
- * Thereby, sites can choose to cause different actions for different issues
- * associated to the same event. So in the above example, a comment
- * "mentioned in change 123" may be added for issue 42, and a comment
- * "fixed by change 123” may be added for issue 4711.
+ * Thereby, sites can choose to cause different actions for different issues associated to the
+ * same event. So in the above example, a comment "mentioned in change 123" may be added for issue
+ * 42, and a comment "fixed by change 123” may be added for issue 4711.
*
* @param event The event to extract property sets from.
* @return sets of property sets extracted from the event.
*/
public Set<Set<Property>> extractFrom(Event event) {
- Map<String,Set<String>> associations = null;
+ Map<String, Set<String>> associations = null;
Set<Set<Property>> ret = Sets.newHashSet();
Set<Property> common = Sets.newHashSet();
@@ -221,7 +203,7 @@
properties.add(property);
property = propertyFactory.create("its-name", pluginName);
properties.add(property);
- for (String occurrence: associations.get(issue)) {
+ for (String occurrence : associations.get(issue)) {
property = propertyFactory.create("association", occurrence);
properties.add(property);
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/validation/ItsAssociationPolicy.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/validation/ItsAssociationPolicy.java
index ea363a8..4cdfa5b 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/validation/ItsAssociationPolicy.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/validation/ItsAssociationPolicy.java
@@ -15,5 +15,7 @@
package com.googlesource.gerrit.plugins.its.base.validation;
public enum ItsAssociationPolicy {
- MANDATORY, SUGGESTED, OPTIONAL;
+ MANDATORY,
+ SUGGESTED,
+ OPTIONAL;
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/validation/ItsValidateComment.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/validation/ItsValidateComment.java
index 3d8816f..969eeb0 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/validation/ItsValidateComment.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/validation/ItsValidateComment.java
@@ -21,35 +21,27 @@
import com.google.gerrit.server.git.validators.CommitValidationListener;
import com.google.gerrit.server.git.validators.CommitValidationMessage;
import com.google.inject.Inject;
-
import com.googlesource.gerrit.plugins.its.base.its.ItsConfig;
import com.googlesource.gerrit.plugins.its.base.its.ItsFacade;
import com.googlesource.gerrit.plugins.its.base.util.IssueExtractor;
-
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
import org.eclipse.jgit.revwalk.RevCommit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-
public class ItsValidateComment implements CommitValidationListener {
- private static final Logger log = LoggerFactory
- .getLogger(ItsValidateComment.class);
+ private static final Logger log = LoggerFactory.getLogger(ItsValidateComment.class);
- @Inject
- private ItsFacade client;
+ @Inject private ItsFacade client;
- @Inject @PluginName
- private String pluginName;
+ @Inject @PluginName private String pluginName;
- @Inject
- private ItsConfig itsConfig;
+ @Inject private ItsConfig itsConfig;
- @Inject
- private IssueExtractor issueExtractor;
+ @Inject private IssueExtractor issueExtractor;
private List<CommitValidationMessage> validCommit(RevCommit commit)
throws CommitValidationException {
@@ -70,8 +62,7 @@
try {
exists = client.exists(issueId);
} catch (IOException e) {
- synopsis = "Failed to check whether or not issue " + issueId
- + " exists";
+ synopsis = "Failed to check whether or not issue " + issueId + " exists";
log.warn(synopsis, e);
details = e.toString();
ret.add(commitValidationFailure(synopsis, details));
@@ -129,20 +120,18 @@
return ret;
}
- private CommitValidationMessage commitValidationFailure(
- String synopsis, String details) throws CommitValidationException {
- CommitValidationMessage ret =
- new CommitValidationMessage(synopsis + "\n" + details, false);
+ private CommitValidationMessage commitValidationFailure(String synopsis, String details)
+ throws CommitValidationException {
+ CommitValidationMessage ret = new CommitValidationMessage(synopsis + "\n" + details, false);
if (itsConfig.getItsAssociationPolicy() == ItsAssociationPolicy.MANDATORY) {
- throw new CommitValidationException(synopsis,
- Collections.singletonList(ret));
+ throw new CommitValidationException(synopsis, Collections.singletonList(ret));
}
return ret;
}
@Override
- public List<CommitValidationMessage> onCommitReceived(
- CommitReceivedEvent receiveEvent) throws CommitValidationException {
+ public List<CommitValidationMessage> onCommitReceived(CommitReceivedEvent receiveEvent)
+ throws CommitValidationException {
ItsConfig.setCurrentProjectName(receiveEvent.getProjectNameKey());
if (itsConfig.isEnabled(receiveEvent.getProjectNameKey(), receiveEvent.getRefName())) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/ActionController.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/ActionController.java
index 9e7bb7d..b1c0982 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/ActionController.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/ActionController.java
@@ -17,18 +17,16 @@
import com.google.gerrit.common.EventListener;
import com.google.gerrit.server.events.Event;
import com.google.inject.Inject;
-
import com.googlesource.gerrit.plugins.its.base.its.ItsConfig;
import com.googlesource.gerrit.plugins.its.base.util.PropertyExtractor;
-
import java.util.Collection;
import java.util.Set;
/**
* Controller that takes actions according to {@code ChangeEvents@}.
*
- * The taken actions are typically Its related (e.g.: adding an Its comment, or
- * changing an issue's status).
+ * <p>The taken actions are typically Its related (e.g.: adding an Its comment, or changing an
+ * issue's status).
*/
public class ActionController implements EventListener {
private final PropertyExtractor propertyExtractor;
@@ -37,8 +35,11 @@
private final ItsConfig itsConfig;
@Inject
- public ActionController(PropertyExtractor propertyExtractor,
- RuleBase ruleBase, ActionExecutor actionExecutor, ItsConfig itsConfig) {
+ public ActionController(
+ PropertyExtractor propertyExtractor,
+ RuleBase ruleBase,
+ ActionExecutor actionExecutor,
+ ItsConfig itsConfig) {
this.propertyExtractor = propertyExtractor;
this.ruleBase = ruleBase;
this.actionExecutor = actionExecutor;
@@ -51,11 +52,9 @@
return;
}
- Set<Set<Property>> propertiesCollections =
- propertyExtractor.extractFrom(event);
+ Set<Set<Property>> propertiesCollections = propertyExtractor.extractFrom(event);
for (Set<Property> properties : propertiesCollections) {
- Collection<ActionRequest> actions =
- ruleBase.actionRequestsFor(properties);
+ Collection<ActionRequest> actions = ruleBase.actionRequestsFor(properties);
if (!actions.isEmpty()) {
for (Property property : properties) {
if ("issue".equals(property.getKey())) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/ActionRequest.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/ActionRequest.java
index 0394e09..dec671e 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/ActionRequest.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/ActionRequest.java
@@ -17,14 +17,13 @@
import com.google.gerrit.common.Nullable;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
-
import java.util.Arrays;
/**
* An action to take for an {@code ChangeEvent}.
*
- * Actions are typically related to an Its (e.g.:adding an Its comment, or
- * changing an issue's status).
+ * <p>Actions are typically related to an Its (e.g.:adding an Its comment, or changing an issue's
+ * status).
*/
public class ActionRequest {
private final String unparsed;
@@ -47,8 +46,7 @@
/**
* Gets the name of the requested action.
*
- * @return The name of the requested action, if a name has been given.
- * "" otherwise.
+ * @return The name of the requested action, if a name has been given. "" otherwise.
*/
public String getName() {
String ret = "";
@@ -62,8 +60,7 @@
* Gets the name of the requested action.
*
* @param i The number of the parameter to extract. 1 is the first parameter.
- * @return The name of the requested parameter, if the requested parameter
- * exists. "" otherwise.
+ * @return The name of the requested parameter, if the requested parameter exists. "" otherwise.
*/
public String getParameter(int i) {
String ret = "";
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/Condition.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/Condition.java
index bf9f9df..6f8df84 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/Condition.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/Condition.java
@@ -20,25 +20,23 @@
import com.google.gerrit.common.Nullable;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
-
import com.googlesource.gerrit.plugins.its.base.workflow.action.Action;
-
import java.util.Collections;
import java.util.List;
import java.util.Set;
/**
* A condition as used in {@link Rule}, as precondition to {@link Action}s.
- * <p>
- * A condition consists of a key and an associated set of values.
- * <p>
- * For positive conditions (see constructor), the condition is said to match a
- * set of properties, if this set contains at least one property that matches
- * the rules key and whose value matches at least one of the rule's value.
- * <p>
- * For negated conditions (see constructor), the condition is said to match a
- * set of properties, if this set does not contain any property that matches
- * the rules key and whose value matches at least one of the rule's value.
+ *
+ * <p>A condition consists of a key and an associated set of values.
+ *
+ * <p>For positive conditions (see constructor), the condition is said to match a set of properties,
+ * if this set contains at least one property that matches the rules key and whose value matches at
+ * least one of the rule's value.
+ *
+ * <p>For negated conditions (see constructor), the condition is said to match a set of properties,
+ * if this set does not contain any property that matches the rules key and whose value matches at
+ * least one of the rule's value.
*/
public class Condition {
private final String key;
@@ -46,29 +44,26 @@
private final boolean negated;
public interface Factory {
- Condition create(@Assisted("key") String key,
- @Assisted("values") String values);
+ Condition create(@Assisted("key") String key, @Assisted("values") String values);
}
/**
* Constructs a condition.
+ *
* @param key The key to use for values.
- * @param values A comma separated list of values to associate to the key. If
- * the first value is not "!", it's a positive condition. If the first
- * value is "!", the "!" is removed from the values and the condition is
- * considered a negated condition.
+ * @param values A comma separated list of values to associate to the key. If the first value is
+ * not "!", it's a positive condition. If the first value is "!", the "!" is removed from the
+ * values and the condition is considered a negated condition.
*/
@Inject
- public Condition(@Assisted("key") String key,
- @Nullable @Assisted("values") String values) {
+ public Condition(@Assisted("key") String key, @Nullable @Assisted("values") String values) {
this.key = key;
Set<String> modifyableValues;
boolean modifyableNegated = false;
if (values == null) {
modifyableValues = Collections.emptySet();
} else {
- List<String> valueList = Lists.newArrayList(
- Splitter.on(',').trimResults().split(values));
+ List<String> valueList = Lists.newArrayList(Splitter.on(',').trimResults().split(values));
if (!valueList.isEmpty() && "!".equals(valueList.get(0))) {
modifyableNegated = true;
valueList.remove(0);
@@ -87,17 +82,15 @@
* Checks whether or not the Condition matches the given set of properties
*
* @param properties The set of properties to match against.
- * @return For positive conditions, true iff properties contains at least
- * one property that matches the rules key and whose value matches at
- * least one of the rule's value. For negated conditions, true iff
- * properties does not contain any property that matches the rules key
- * and whose value matches at least one of the rule's value.
+ * @return For positive conditions, true iff properties contains at least one property that
+ * matches the rules key and whose value matches at least one of the rule's value. For negated
+ * conditions, true iff properties does not contain any property that matches the rules key
+ * and whose value matches at least one of the rule's value.
*/
public boolean isMetBy(Iterable<Property> properties) {
for (Property property : properties) {
String propertyKey = property.getKey();
- if ((key == null && propertyKey == null)
- || (key != null && key.equals(propertyKey))) {
+ if ((key == null && propertyKey == null) || (key != null && key.equals(propertyKey))) {
if (values.contains(property.getValue())) {
return !negated;
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/Property.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/Property.java
index 98a8117..eb1f087 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/Property.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/Property.java
@@ -21,20 +21,18 @@
/**
* A property to match against {@code Condition}s.
*
- * A property is a simple key value pair.
+ * <p>A property is a simple key value pair.
*/
public class Property {
public interface Factory {
- Property create(@Assisted("key") String key,
- @Assisted("value") String value);
+ Property create(@Assisted("key") String key, @Assisted("value") String value);
}
private final String key;
private final String value;
@Inject
- public Property(@Assisted("key") String key,
- @Nullable @Assisted("value") String value) {
+ public Property(@Assisted("key") String key, @Nullable @Assisted("value") String value) {
this.key = key;
this.value = value;
}
@@ -71,8 +69,7 @@
@Override
public int hashCode() {
- return (key == null ? 0 : key.hashCode()) * 31 +
- (value == null ? 0 : value.hashCode());
+ return (key == null ? 0 : key.hashCode()) * 31 + (value == null ? 0 : value.hashCode());
}
@Override
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/Rule.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/Rule.java
index 4ec6be3..3efa269 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/Rule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/Rule.java
@@ -18,15 +18,12 @@
import com.google.common.collect.Sets;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
-
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
-/**
- * A single rule that associates {@code Action}s to {@code Condition}s.
- */
+/** A single rule that associates {@code Action}s to {@code Condition}s. */
public class Rule {
private final String name;
private List<ActionRequest> actionRequests;
@@ -68,14 +65,13 @@
/**
* Gets this rule's the action requests for a given set of properties.
*
- * If the given set of properties meets all of the rule's conditions, the
- * rule's actions are returned. Otherwise the empty collection is returned.
+ * <p>If the given set of properties meets all of the rule's conditions, the rule's actions are
+ * returned. Otherwise the empty collection is returned.
*
* @param properties The properties to check against the rule's conditions.
* @return The actions that should get fired.
*/
- public Collection<ActionRequest> actionRequestsFor(
- Iterable<Property> properties) {
+ public Collection<ActionRequest> actionRequestsFor(Iterable<Property> properties) {
for (Condition condition : conditions) {
if (!condition.isMetBy(properties)) {
return Collections.emptyList();
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/RuleBase.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/RuleBase.java
index 2f0e1a2..1b5780b 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/RuleBase.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/RuleBase.java
@@ -14,48 +14,35 @@
package com.googlesource.gerrit.plugins.its.base.workflow;
-
import com.google.common.collect.Lists;
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.server.config.SitePath;
import com.google.inject.Inject;
-
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.util.Collection;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.util.FS;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Path;
-import java.util.Collection;
-
-/**
- * Collection and matcher agains {@link Rule}s.
- */
+/** Collection and matcher agains {@link Rule}s. */
public class RuleBase {
private static final Logger log = LoggerFactory.getLogger(RuleBase.class);
- /**
- * File beginning (relative to site) to load rules from
- */
- private static final String ITS_CONFIG_FILE_START = "etc" +
- File.separatorChar + "its" + File.separator + "actions";
+ /** File beginning (relative to site) to load rules from */
+ private static final String ITS_CONFIG_FILE_START =
+ "etc" + File.separatorChar + "its" + File.separator + "actions";
- /**
- * File end to load rules from
- */
+ /** File end to load rules from */
private static final String ITS_CONFIG_FILE_END = ".config";
- /**
- * The section for rules within rulebases
- */
+ /** The section for rules within rulebases */
private static final String RULE_SECTION = "rule";
- /**
- * The key for actions within rulebases
- */
+ /** The key for actions within rulebases */
private static final String ACTION_KEY = "action";
private final Path sitePath;
@@ -71,7 +58,9 @@
}
@Inject
- public RuleBase(@SitePath Path sitePath, Rule.Factory ruleFactory,
+ public RuleBase(
+ @SitePath Path sitePath,
+ Rule.Factory ruleFactory,
Condition.Factory conditionFactory,
ActionRequest.Factory actionRequestFactory,
@PluginName String pluginName) {
@@ -85,8 +74,8 @@
/**
* Adds rules from a file to the the RuleBase.
- * <p>
- * If the given file does not exist, it is silently ignored
+ *
+ * <p>If the given file does not exist, it is silently ignored
*
* @param ruleFile File from which to read the rules
*/
@@ -123,9 +112,7 @@
}
}
- /**
- * Loads the rules for the RuleBase.
- */
+ /** Loads the rules for the RuleBase. */
private void reloadRules() {
rules = Lists.newArrayList();
@@ -137,34 +124,40 @@
// "actions.config" (with trailing "s", we (for now) load files from both
// locations, but consider "actions.config" (with trailing "s" the
// canonical place.
- File faultyNameRuleFile = new File(sitePath.toFile(), "etc" + File.separatorChar
- + "its" + File.separator + "action.config");
+ File faultyNameRuleFile =
+ new File(
+ sitePath.toFile(),
+ "etc" + File.separatorChar + "its" + File.separator + "action.config");
if (faultyNameRuleFile.exists()) {
- log.warn("Loading rules from deprecated 'etc/its/action.config' (No "
- + "trailing 's' in 'action'). Please migrate to "
- + "'etc/its/actions.config' (Trailing 's' in 'actions').");
+ log.warn(
+ "Loading rules from deprecated 'etc/its/action.config' (No "
+ + "trailing 's' in 'action'). Please migrate to "
+ + "'etc/its/actions.config' (Trailing 's' in 'actions').");
addRulesFromFile(faultyNameRuleFile);
}
// Add global rules
- File globalRuleFile = new File(sitePath.toFile(), ITS_CONFIG_FILE_START +
- ITS_CONFIG_FILE_END);
+ File globalRuleFile = new File(sitePath.toFile(), ITS_CONFIG_FILE_START + ITS_CONFIG_FILE_END);
addRulesFromFile(globalRuleFile);
// Add its-specific rules
- File itsSpecificRuleFile = new File(sitePath.toFile(), ITS_CONFIG_FILE_START + "-" +
- pluginName + ITS_CONFIG_FILE_END);
+ File itsSpecificRuleFile =
+ new File(sitePath.toFile(), ITS_CONFIG_FILE_START + "-" + pluginName + ITS_CONFIG_FILE_END);
addRulesFromFile(itsSpecificRuleFile);
if (!globalRuleFile.exists() && !itsSpecificRuleFile.exists()) {
try {
- log.warn("Neither global rule file "
- + globalRuleFile.getCanonicalPath() + " nor Its specific rule file"
- + itsSpecificRuleFile.getCanonicalPath() + " exist. Please configure "
- + "rules.");
+ log.warn(
+ "Neither global rule file "
+ + globalRuleFile.getCanonicalPath()
+ + " nor Its specific rule file"
+ + itsSpecificRuleFile.getCanonicalPath()
+ + " exist. Please configure "
+ + "rules.");
} catch (IOException e) {
- log.warn("Neither global rule file nor Its specific rule files exist. "
- + "Please configure rules.");
+ log.warn(
+ "Neither global rule file nor Its specific rule files exist. "
+ + "Please configure rules.");
}
}
}
@@ -175,8 +168,7 @@
* @param properties The properties to search actions for.
* @return Requests for the actions that should be fired.
*/
- public Collection<ActionRequest> actionRequestsFor(
- Iterable<Property> properties) {
+ public Collection<ActionRequest> actionRequestsFor(Iterable<Property> properties) {
Collection<ActionRequest> ret = Lists.newLinkedList();
for (Rule rule : rules) {
ret.addAll(rule.actionRequestsFor(properties));
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/Action.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/Action.java
index 24feee5..b8b2102 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/Action.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/Action.java
@@ -16,13 +16,10 @@
import com.googlesource.gerrit.plugins.its.base.workflow.ActionRequest;
import com.googlesource.gerrit.plugins.its.base.workflow.Property;
-
import java.io.IOException;
import java.util.Set;
-/**
- * Interface for actions on an issue tracking system
- */
+/** Interface for actions on an issue tracking system */
public interface Action {
/**
@@ -32,6 +29,6 @@
* @param actionRequest The request to execute.
* @param properties The properties for the execution.
*/
- public void execute(String issue, ActionRequest actionRequest,
- Set<Property> properties) throws IOException;
+ public void execute(String issue, ActionRequest actionRequest, Set<Property> properties)
+ throws IOException;
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddComment.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddComment.java
index 8ca9c59..16855d3 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddComment.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddComment.java
@@ -16,20 +16,17 @@
import com.google.common.base.Strings;
import com.google.inject.Inject;
-
import com.googlesource.gerrit.plugins.its.base.its.ItsFacade;
import com.googlesource.gerrit.plugins.its.base.workflow.ActionRequest;
import com.googlesource.gerrit.plugins.its.base.workflow.Property;
-
-import org.apache.commons.lang.StringUtils;
-
import java.io.IOException;
import java.util.Set;
+import org.apache.commons.lang.StringUtils;
/**
* Adds a fixed comment to an issue.
*
- * The action requests parameters get concatenated and get added to the issue.
+ * <p>The action requests parameters get concatenated and get added to the issue.
*/
public class AddComment implements Action {
public interface Factory {
@@ -44,8 +41,8 @@
}
@Override
- public void execute(String issue, ActionRequest actionRequest,
- Set<Property> properties) throws IOException {
+ public void execute(String issue, ActionRequest actionRequest, Set<Property> properties)
+ throws IOException {
String[] parameters = actionRequest.getParameters();
String comment = StringUtils.join(parameters, " ");
if (!Strings.isNullOrEmpty(comment)) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddSoyComment.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddSoyComment.java
index f65d6c6..3068164 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddSoyComment.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddSoyComment.java
@@ -28,15 +28,11 @@
import java.io.File;
import java.io.IOException;
import java.io.Reader;
-import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.util.Arrays;
import java.util.HashMap;
-import java.util.Map;
import java.util.Set;
-import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -81,13 +77,17 @@
return soyContext;
}
- private String soyTemplate(SoyFileSet.Builder builder, String template, SanitizedContent.ContentKind kind, Set<Property> properties) {
+ private String soyTemplate(
+ SoyFileSet.Builder builder,
+ String template,
+ SanitizedContent.ContentKind kind,
+ Set<Property> properties) {
Path templateDir = sitePath.resolve(ITS_TEMPLATE_DIR);
Path templatePath = templateDir.resolve(template + ".soy");
String content;
try (Reader r = Files.newBufferedReader(templatePath, StandardCharsets.UTF_8)) {
- content = CharStreams.toString(r);
+ content = CharStreams.toString(r);
} catch (IOException err) {
throw new ProvisionException(
"Failed to read template file " + templatePath.toAbsolutePath().toString(), err);
@@ -107,7 +107,8 @@
return renderer.render();
}
- protected String soyTextTemplate(SoyFileSet.Builder builder, String template, Set<Property> properties) {
+ protected String soyTextTemplate(
+ SoyFileSet.Builder builder, String template, Set<Property> properties) {
return soyTemplate(builder, template, SanitizedContent.ContentKind.TEXT, properties);
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddStandardComment.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddStandardComment.java
index b033603..9753cf3 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddStandardComment.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddStandardComment.java
@@ -17,11 +17,9 @@
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import com.google.inject.Inject;
-
import com.googlesource.gerrit.plugins.its.base.its.ItsFacade;
import com.googlesource.gerrit.plugins.its.base.workflow.ActionRequest;
import com.googlesource.gerrit.plugins.its.base.workflow.Property;
-
import java.io.IOException;
import java.util.Map;
import java.util.Set;
@@ -29,8 +27,7 @@
/**
* Adds a short predefined comments to an issue.
*
- * Comments are added for merging, abandoning, restoring of changes and adding
- * of patch sets.
+ * <p>Comments are added for merging, abandoning, restoring of changes and adding of patch sets.
*/
public class AddStandardComment implements Action {
public interface Factory {
@@ -54,8 +51,7 @@
return ret;
}
- private String getCommentChangeEvent(String Action, String prefix,
- Map<String, String> map) {
+ private String getCommentChangeEvent(String Action, String prefix, Map<String, String> map) {
String ret = "";
String changeNumber = Strings.nullToEmpty(map.get("change-number"));
changeNumber = Strings.nullToEmpty(map.get("changeNumber"));
@@ -96,19 +92,17 @@
}
private String getCommentPatchSetCreated(Map<String, String> map) {
- return getCommentChangeEvent("had a related patch set uploaded",
- "uploader", map);
+ return getCommentChangeEvent("had a related patch set uploaded", "uploader", map);
}
@Override
- public void execute(String issue, ActionRequest actionRequest,
- Set<Property> properties) throws IOException {
+ public void execute(String issue, ActionRequest actionRequest, Set<Property> properties)
+ throws IOException {
String comment = "";
Map<String, String> map = Maps.newHashMap();
for (Property property : properties) {
String current = property.getValue();
- if (!Strings.isNullOrEmpty(current))
- {
+ if (!Strings.isNullOrEmpty(current)) {
String key = property.getKey();
String old = Strings.nullToEmpty(map.get(key));
if (!old.isEmpty()) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddVelocityComment.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddVelocityComment.java
index f3a1cc2..6fbdb86 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddVelocityComment.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddVelocityComment.java
@@ -17,17 +17,9 @@
import com.google.common.base.Strings;
import com.google.gerrit.server.config.SitePath;
import com.google.inject.Inject;
-
import com.googlesource.gerrit.plugins.its.base.its.ItsFacade;
import com.googlesource.gerrit.plugins.its.base.workflow.ActionRequest;
import com.googlesource.gerrit.plugins.its.base.workflow.Property;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.runtime.RuntimeInstance;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
@@ -35,33 +27,35 @@
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Set;
+import org.apache.commons.lang.StringUtils;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.runtime.RuntimeInstance;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Adds a short predefined comments to an issue.
*
- * Comments are added for merging, abandoning, restoring of changes and adding
- * of patch sets.
+ * <p>Comments are added for merging, abandoning, restoring of changes and adding of patch sets.
*/
public class AddVelocityComment implements Action {
- private static final Logger log = LoggerFactory.getLogger(
- AddVelocityComment.class);
+ private static final Logger log = LoggerFactory.getLogger(AddVelocityComment.class);
public interface Factory {
AddVelocityComment create();
}
- /**
- * Directory (relative to site) to search templates in
- */
- private static final String ITS_TEMPLATE_DIR = "etc" + File.separator +
- "its" + File.separator + "templates";
+ /** Directory (relative to site) to search templates in */
+ private static final String ITS_TEMPLATE_DIR =
+ "etc" + File.separator + "its" + File.separator + "templates";
private final ItsFacade its;
private final Path sitePath;
private final RuntimeInstance velocityRuntime;
@Inject
- public AddVelocityComment(RuntimeInstance velocityRuntime, @SitePath Path sitePath, ItsFacade its) {
+ public AddVelocityComment(
+ RuntimeInstance velocityRuntime, @SitePath Path sitePath, ItsFacade its) {
this.velocityRuntime = velocityRuntime;
this.sitePath = sitePath;
this.its = its;
@@ -79,7 +73,7 @@
}
}
- velocityContext.put("its", new VelocityAdapterItsFacade(its));
+ velocityContext.put("its", new VelocityAdapterItsFacade(its));
return velocityContext;
}
@@ -92,14 +86,13 @@
}
@Override
- public void execute(String issue, ActionRequest actionRequest,
- Set<Property> properties) throws IOException {
+ public void execute(String issue, ActionRequest actionRequest, Set<Property> properties)
+ throws IOException {
String template = null;
String templateName = actionRequest.getParameter(1);
if ("inline".equals(templateName)) {
String[] allParameters = actionRequest.getParameters();
- String[] templateParameters =
- Arrays.copyOfRange(allParameters, 1, allParameters.length);
+ String[] templateParameters = Arrays.copyOfRange(allParameters, 1, allParameters.length);
template = StringUtils.join(templateParameters, " ");
} else {
if (templateName.isEmpty()) {
@@ -120,9 +113,7 @@
}
}
- /**
- * Adapter for ItsFacade to be used through Velocity
- */
+ /** Adapter for ItsFacade to be used through Velocity */
// Although we'd prefer to keep this class private, Velocity will only pick
// it up, if it is public.
public class VelocityAdapterItsFacade {
@@ -146,8 +137,8 @@
/**
* Format a link to an URL.
- * <p>
- * The provided URL is used as caption for the formatted link.
+ *
+ * <p>The provided URL is used as caption for the formatted link.
*
* @param url URL to link to
* @return Link to the given URL in the used Its' syntax.
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/LogEvent.java b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/LogEvent.java
index d66dbce..3a46202 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/LogEvent.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/base/workflow/action/LogEvent.java
@@ -15,34 +15,34 @@
package com.googlesource.gerrit.plugins.its.base.workflow.action;
import com.google.inject.Inject;
-
import com.googlesource.gerrit.plugins.its.base.workflow.ActionRequest;
import com.googlesource.gerrit.plugins.its.base.workflow.Property;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import java.io.IOException;
import java.util.Set;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Dumps the event's properties to the log.
*
- * This event helps when developing rules as available properties become
- * visible.
+ * <p>This event helps when developing rules as available properties become visible.
*/
public class LogEvent implements Action {
private static final Logger log = LoggerFactory.getLogger(LogEvent.class);
- private enum Level { ERROR, WARN, INFO, DEBUG }
+ private enum Level {
+ ERROR,
+ WARN,
+ INFO,
+ DEBUG
+ }
public interface Factory {
LogEvent create();
}
@Inject
- public LogEvent() {
- }
+ public LogEvent() {}
private void logProperty(Level level, Property property) {
String message = property.toString();
@@ -65,8 +65,8 @@
}
@Override
- public void execute(String issue, ActionRequest actionRequest,
- Set<Property> properties) throws IOException {
+ public void execute(String issue, ActionRequest actionRequest, Set<Property> properties)
+ throws IOException {
String levelParameter = actionRequest.getParameter(1);
if (levelParameter != null) {
levelParameter = levelParameter.toLowerCase();
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/its/ItsConfigTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/its/ItsConfigTest.java
index 1b9e1bb..8f349b3 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/its/ItsConfigTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/its/ItsConfigTest.java
@@ -36,13 +36,10 @@
import com.google.gerrit.server.project.ProjectState;
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.base.validation.ItsAssociationPolicy;
-
-import org.eclipse.jgit.lib.Config;
-
import java.util.Arrays;
+import org.eclipse.jgit.lib.Config;
public class ItsConfigTest extends LoggingMockingTestCase {
private Injector injector;
@@ -51,14 +48,13 @@
private PluginConfigFactory pluginConfigFactory;
private Config serverConfig;
- public void setupIsEnabled(String enabled, String parentEnabled,
- String[] branches) {
+ public void setupIsEnabled(String enabled, String parentEnabled, String[] branches) {
ProjectState projectState = createMock(ProjectState.class);
- expect(projectCache.get(new Project.NameKey("testProject")))
- .andReturn(projectState).anyTimes();
+ expect(projectCache.get(new Project.NameKey("testProject"))).andReturn(projectState).anyTimes();
expect(projectCache.get(new Project.NameKey("parentProject")))
- .andReturn(projectState).anyTimes();
+ .andReturn(projectState)
+ .anyTimes();
Iterable<ProjectState> parents;
if (parentEnabled == null) {
@@ -68,21 +64,21 @@
PluginConfig parentPluginConfig = createMock(PluginConfig.class);
- expect(pluginConfigFactory.getFromProjectConfig(
- parentProjectState, "ItsTestName")).andReturn(parentPluginConfig);
+ expect(pluginConfigFactory.getFromProjectConfig(parentProjectState, "ItsTestName"))
+ .andReturn(parentPluginConfig);
- expect(parentPluginConfig.getString("enabled", "false")).andReturn(parentEnabled)
- .anyTimes();
+ expect(parentPluginConfig.getString("enabled", "false")).andReturn(parentEnabled).anyTimes();
PluginConfig parentPluginConfigWI = createMock(PluginConfig.class);
- expect(pluginConfigFactory.getFromProjectConfigWithInheritance(
- parentProjectState, "ItsTestName")).andReturn(parentPluginConfigWI)
+ expect(
+ pluginConfigFactory.getFromProjectConfigWithInheritance(
+ parentProjectState, "ItsTestName"))
+ .andReturn(parentPluginConfigWI)
.anyTimes();
- String[] parentBranches = { "refs/heads/testBranch" };
- expect(parentPluginConfigWI.getStringList("branch"))
- .andReturn(parentBranches).anyTimes();
+ String[] parentBranches = {"refs/heads/testBranch"};
+ expect(parentPluginConfigWI.getStringList("branch")).andReturn(parentBranches).anyTimes();
parents = Arrays.asList(parentProjectState, projectState);
}
@@ -90,21 +86,21 @@
PluginConfig pluginConfig = createMock(PluginConfig.class);
- expect(pluginConfigFactory.getFromProjectConfig(
- projectState, "ItsTestName")).andReturn(pluginConfig).anyTimes();
+ expect(pluginConfigFactory.getFromProjectConfig(projectState, "ItsTestName"))
+ .andReturn(pluginConfig)
+ .anyTimes();
expect(pluginConfig.getString("enabled", "false")).andReturn(enabled).anyTimes();
PluginConfig pluginConfigWI = createMock(PluginConfig.class);
- expect(pluginConfigFactory.getFromProjectConfigWithInheritance(
- projectState, "ItsTestName")).andReturn(pluginConfigWI).anyTimes();
-
- expect(pluginConfigWI.getString("enabled", "false"))
- .andReturn(enabled).anyTimes();
-
- expect(pluginConfigWI.getStringList("branch")).andReturn(branches)
+ expect(pluginConfigFactory.getFromProjectConfigWithInheritance(projectState, "ItsTestName"))
+ .andReturn(pluginConfigWI)
.anyTimes();
+
+ expect(pluginConfigWI.getString("enabled", "false")).andReturn(enabled).anyTimes();
+
+ expect(pluginConfigWI.getStringList("branch")).andReturn(branches).anyTimes();
}
public void testIsEnabledRefNoParentNoBranchEnabled() {
@@ -291,8 +287,7 @@
String[] branches = {};
setupIsEnabled("true", null, branches);
- PatchSetCreatedEvent event =
- new PatchSetCreatedEvent(testChange("testProject", "testBranch"));
+ PatchSetCreatedEvent event = new PatchSetCreatedEvent(testChange("testProject", "testBranch"));
ItsConfig itsConfig = createItsConfig();
@@ -305,8 +300,7 @@
String[] branches = {"refs/heads/testBranch"};
setupIsEnabled("true", null, branches);
- PatchSetCreatedEvent event =
- new PatchSetCreatedEvent(testChange("testProject", "testBranch"));
+ PatchSetCreatedEvent event = new PatchSetCreatedEvent(testChange("testProject", "testBranch"));
ItsConfig itsConfig = createItsConfig();
@@ -319,8 +313,7 @@
String[] branches = {"^refs/heads/test.*"};
setupIsEnabled("true", null, branches);
- PatchSetCreatedEvent event =
- new PatchSetCreatedEvent(testChange("testProject", "testBranch"));
+ PatchSetCreatedEvent event = new PatchSetCreatedEvent(testChange("testProject", "testBranch"));
ItsConfig itsConfig = createItsConfig();
@@ -333,8 +326,7 @@
String[] branches = {"^refs/heads/foo.*"};
setupIsEnabled("true", null, branches);
- PatchSetCreatedEvent event =
- new PatchSetCreatedEvent(testChange("testProject", "testBranch"));
+ PatchSetCreatedEvent event = new PatchSetCreatedEvent(testChange("testProject", "testBranch"));
ItsConfig itsConfig = createItsConfig();
@@ -347,8 +339,7 @@
String[] branches = {"refs/heads/foo", "refs/heads/testBranch"};
setupIsEnabled("true", null, branches);
- PatchSetCreatedEvent event =
- new PatchSetCreatedEvent(testChange("testProject", "testBranch"));
+ PatchSetCreatedEvent event = new PatchSetCreatedEvent(testChange("testProject", "testBranch"));
ItsConfig itsConfig = createItsConfig();
@@ -361,8 +352,7 @@
String[] branches = {"^refs/heads/foo.*", "^refs/heads/test.*"};
setupIsEnabled("true", null, branches);
- PatchSetCreatedEvent event =
- new PatchSetCreatedEvent(testChange("testProject", "testBranch"));
+ PatchSetCreatedEvent event = new PatchSetCreatedEvent(testChange("testProject", "testBranch"));
ItsConfig itsConfig = createItsConfig();
@@ -375,8 +365,7 @@
String[] branches = {"refs/heads/testBranch", "refs/heads/foo.*"};
setupIsEnabled("true", null, branches);
- PatchSetCreatedEvent event =
- new PatchSetCreatedEvent(testChange("testProject", "testBranch"));
+ PatchSetCreatedEvent event = new PatchSetCreatedEvent(testChange("testProject", "testBranch"));
ItsConfig itsConfig = createItsConfig();
@@ -385,12 +374,11 @@
assertTrue(itsConfig.isEnabled(event));
}
-public void testIsEnabledEventMultiBranchMixedMatchRegExp() {
+ public void testIsEnabledEventMultiBranchMixedMatchRegExp() {
String[] branches = {"refs/heads/foo", "^refs/heads/test.*"};
setupIsEnabled("true", null, branches);
- PatchSetCreatedEvent event =
- new PatchSetCreatedEvent(testChange("testProject", "testBranch"));
+ PatchSetCreatedEvent event = new PatchSetCreatedEvent(testChange("testProject", "testBranch"));
ItsConfig itsConfig = createItsConfig();
@@ -403,8 +391,7 @@
String[] branches = {"^refs/heads/testBranch"};
setupIsEnabled("false", null, branches);
- PatchSetCreatedEvent event =
- new PatchSetCreatedEvent(testChange("testProject", "testBranch"));
+ PatchSetCreatedEvent event = new PatchSetCreatedEvent(testChange("testProject", "testBranch"));
ItsConfig itsConfig = createItsConfig();
@@ -417,8 +404,7 @@
String[] branches = {};
setupIsEnabled("true", null, branches);
- CommentAddedEvent event =
- new CommentAddedEvent(testChange("testProject", "testBranch"));
+ CommentAddedEvent event = new CommentAddedEvent(testChange("testProject", "testBranch"));
ItsConfig itsConfig = createItsConfig();
@@ -431,8 +417,7 @@
String[] branches = {};
setupIsEnabled("true", null, branches);
- ChangeMergedEvent event =
- new ChangeMergedEvent(testChange("testProject", "testBranch"));
+ ChangeMergedEvent event = new ChangeMergedEvent(testChange("testProject", "testBranch"));
ItsConfig itsConfig = createItsConfig();
@@ -445,8 +430,7 @@
String[] branches = {};
setupIsEnabled("true", null, branches);
- ChangeAbandonedEvent event =
- new ChangeAbandonedEvent(testChange("testProject", "testBranch"));
+ ChangeAbandonedEvent event = new ChangeAbandonedEvent(testChange("testProject", "testBranch"));
ItsConfig itsConfig = createItsConfig();
@@ -459,8 +443,7 @@
String[] branches = {};
setupIsEnabled("true", null, branches);
- ChangeRestoredEvent event =
- new ChangeRestoredEvent(testChange("testProject", "testBranch"));
+ ChangeRestoredEvent event = new ChangeRestoredEvent(testChange("testProject", "testBranch"));
ItsConfig itsConfig = createItsConfig();
@@ -473,8 +456,7 @@
String[] branches = {};
setupIsEnabled("true", null, branches);
- DraftPublishedEvent event =
- new DraftPublishedEvent(testChange("testProject", "testBranch"));
+ DraftPublishedEvent event = new DraftPublishedEvent(testChange("testProject", "testBranch"));
ItsConfig itsConfig = createItsConfig();
@@ -515,272 +497,321 @@
ItsConfig itsConfig = createItsConfig();
expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
- .andReturn(null).atLeastOnce();
+ .andReturn(null)
+ .atLeastOnce();
expect(serverConfig.getString("commentlink", "ItsTestName", "match"))
- .andReturn(null).atLeastOnce();
+ .andReturn(null)
+ .atLeastOnce();
replayMocks();
- assertNull("Pattern for null match is not null",
- itsConfig.getIssuePattern());
+ assertNull("Pattern for null match is not null", itsConfig.getIssuePattern());
}
public void testGetIssuePatternNullMatchWCommentLink() {
ItsConfig itsConfig = createItsConfig();
expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
- .andReturn("foo").atLeastOnce();
- expect(serverConfig.getString("commentlink", "foo", "match"))
- .andReturn(null).atLeastOnce();
+ .andReturn("foo")
+ .atLeastOnce();
+ expect(serverConfig.getString("commentlink", "foo", "match")).andReturn(null).atLeastOnce();
replayMocks();
- assertNull("Pattern for null match is not null",
- itsConfig.getIssuePattern());
+ assertNull("Pattern for null match is not null", itsConfig.getIssuePattern());
}
public void testGetIssuePattern() {
ItsConfig itsConfig = createItsConfig();
expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
- .andReturn(null).atLeastOnce();
+ .andReturn(null)
+ .atLeastOnce();
expect(serverConfig.getString("commentlink", "ItsTestName", "match"))
- .andReturn("TestPattern").atLeastOnce();
+ .andReturn("TestPattern")
+ .atLeastOnce();
replayMocks();
- assertEquals("Expected and generated pattern are not equal",
- "TestPattern", itsConfig.getIssuePattern().pattern());
+ assertEquals(
+ "Expected and generated pattern are not equal",
+ "TestPattern",
+ itsConfig.getIssuePattern().pattern());
}
public void testGetIssuePatternWCommentLink() {
ItsConfig itsConfig = createItsConfig();
expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
- .andReturn("foo").atLeastOnce();
+ .andReturn("foo")
+ .atLeastOnce();
expect(serverConfig.getString("commentlink", "foo", "match"))
- .andReturn("TestPattern").atLeastOnce();
+ .andReturn("TestPattern")
+ .atLeastOnce();
replayMocks();
- assertEquals("Expected and generated pattern are not equal",
- "TestPattern", itsConfig.getIssuePattern().pattern());
-
+ assertEquals(
+ "Expected and generated pattern are not equal",
+ "TestPattern",
+ itsConfig.getIssuePattern().pattern());
}
public void testGetIssuePatternGroupIndexGroupDefault() {
ItsConfig itsConfig = createItsConfig();
expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
- .andReturn(null).atLeastOnce();
+ .andReturn(null)
+ .atLeastOnce();
expect(serverConfig.getString("commentlink", "ItsTestName", "match"))
- .andReturn("(foo)(bar)(baz)").atLeastOnce();
+ .andReturn("(foo)(bar)(baz)")
+ .atLeastOnce();
expect(serverConfig.getInt("plugin", "ItsTestName", "commentlinkGroupIndex", 1))
- .andReturn(1).atLeastOnce();
+ .andReturn(1)
+ .atLeastOnce();
replayMocks();
- assertEquals("Expected and actual group index do not match",
- 1, itsConfig.getIssuePatternGroupIndex());
+ assertEquals(
+ "Expected and actual group index do not match", 1, itsConfig.getIssuePatternGroupIndex());
}
public void testGetIssuePatternGroupIndexGroupDefaultGroupless() {
ItsConfig itsConfig = createItsConfig();
expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
- .andReturn(null).atLeastOnce();
+ .andReturn(null)
+ .atLeastOnce();
expect(serverConfig.getString("commentlink", "ItsTestName", "match"))
- .andReturn("foo").atLeastOnce();
+ .andReturn("foo")
+ .atLeastOnce();
expect(serverConfig.getInt("plugin", "ItsTestName", "commentlinkGroupIndex", 1))
- .andReturn(1).atLeastOnce();
+ .andReturn(1)
+ .atLeastOnce();
replayMocks();
- assertEquals("Expected and actual group index do not match",
- 0, itsConfig.getIssuePatternGroupIndex());
+ assertEquals(
+ "Expected and actual group index do not match", 0, itsConfig.getIssuePatternGroupIndex());
}
public void testGetIssuePatternGroupIndexGroup1() {
ItsConfig itsConfig = createItsConfig();
expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
- .andReturn(null).atLeastOnce();
+ .andReturn(null)
+ .atLeastOnce();
expect(serverConfig.getString("commentlink", "ItsTestName", "match"))
- .andReturn("(foo)(bar)(baz)").atLeastOnce();
+ .andReturn("(foo)(bar)(baz)")
+ .atLeastOnce();
expect(serverConfig.getInt("plugin", "ItsTestName", "commentlinkGroupIndex", 1))
- .andReturn(1).atLeastOnce();
+ .andReturn(1)
+ .atLeastOnce();
replayMocks();
- assertEquals("Expected and actual group index do not match",
- 1, itsConfig.getIssuePatternGroupIndex());
+ assertEquals(
+ "Expected and actual group index do not match", 1, itsConfig.getIssuePatternGroupIndex());
}
public void testGetIssuePatternGroupIndexGroup3() {
ItsConfig itsConfig = createItsConfig();
expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
- .andReturn(null).atLeastOnce();
+ .andReturn(null)
+ .atLeastOnce();
expect(serverConfig.getString("commentlink", "ItsTestName", "match"))
- .andReturn("(foo)(bar)(baz)").atLeastOnce();
+ .andReturn("(foo)(bar)(baz)")
+ .atLeastOnce();
expect(serverConfig.getInt("plugin", "ItsTestName", "commentlinkGroupIndex", 1))
- .andReturn(3).atLeastOnce();
+ .andReturn(3)
+ .atLeastOnce();
replayMocks();
- assertEquals("Expected and actual group index do not match",
- 3, itsConfig.getIssuePatternGroupIndex());
+ assertEquals(
+ "Expected and actual group index do not match", 3, itsConfig.getIssuePatternGroupIndex());
}
public void testGetIssuePatternGroupIndexGroupTooHigh() {
ItsConfig itsConfig = createItsConfig();
expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
- .andReturn(null).atLeastOnce();
+ .andReturn(null)
+ .atLeastOnce();
expect(serverConfig.getString("commentlink", "ItsTestName", "match"))
- .andReturn("(foo)(bar)(baz)").atLeastOnce();
+ .andReturn("(foo)(bar)(baz)")
+ .atLeastOnce();
expect(serverConfig.getInt("plugin", "ItsTestName", "commentlinkGroupIndex", 1))
- .andReturn(5).atLeastOnce();
+ .andReturn(5)
+ .atLeastOnce();
replayMocks();
- assertEquals("Expected and actual group index do not match",
- 1, itsConfig.getIssuePatternGroupIndex());
+ assertEquals(
+ "Expected and actual group index do not match", 1, itsConfig.getIssuePatternGroupIndex());
}
public void testGetIssuePatternGroupIndexGroupTooHighGroupless() {
ItsConfig itsConfig = createItsConfig();
expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
- .andReturn(null).atLeastOnce();
+ .andReturn(null)
+ .atLeastOnce();
expect(serverConfig.getString("commentlink", "ItsTestName", "match"))
- .andReturn("foo").atLeastOnce();
+ .andReturn("foo")
+ .atLeastOnce();
expect(serverConfig.getInt("plugin", "ItsTestName", "commentlinkGroupIndex", 1))
- .andReturn(5).atLeastOnce();
+ .andReturn(5)
+ .atLeastOnce();
replayMocks();
- assertEquals("Expected and actual group index do not match",
- 0, itsConfig.getIssuePatternGroupIndex());
+ assertEquals(
+ "Expected and actual group index do not match", 0, itsConfig.getIssuePatternGroupIndex());
}
public void testGetItsAssociationPolicyOptional() {
ItsConfig itsConfig = createItsConfig();
expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
- .andReturn(null).atLeastOnce();
- expect(serverConfig.getEnum("commentlink", "ItsTestName", "association",
- ItsAssociationPolicy.OPTIONAL))
+ .andReturn(null)
+ .atLeastOnce();
+ expect(
+ serverConfig.getEnum(
+ "commentlink", "ItsTestName", "association", ItsAssociationPolicy.OPTIONAL))
.andReturn(ItsAssociationPolicy.OPTIONAL)
.atLeastOnce();
- expect(serverConfig.getEnum("plugin", "ItsTestName", "association",
- ItsAssociationPolicy.OPTIONAL))
+ expect(
+ serverConfig.getEnum(
+ "plugin", "ItsTestName", "association", ItsAssociationPolicy.OPTIONAL))
.andReturn(ItsAssociationPolicy.OPTIONAL)
.atLeastOnce();
replayMocks();
- assertEquals("Expected and generated associated policy do not match",
- ItsAssociationPolicy.OPTIONAL, itsConfig.getItsAssociationPolicy());
+ assertEquals(
+ "Expected and generated associated policy do not match",
+ ItsAssociationPolicy.OPTIONAL,
+ itsConfig.getItsAssociationPolicy());
}
public void testGetItsAssociationPolicyOptionalWCommentLink() {
ItsConfig itsConfig = createItsConfig();
expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
- .andReturn("foo").atLeastOnce();
- expect(serverConfig.getEnum("commentlink", "foo", "association",
- ItsAssociationPolicy.OPTIONAL))
+ .andReturn("foo")
+ .atLeastOnce();
+ expect(serverConfig.getEnum("commentlink", "foo", "association", ItsAssociationPolicy.OPTIONAL))
.andReturn(ItsAssociationPolicy.OPTIONAL)
.atLeastOnce();
- expect(serverConfig.getEnum("plugin", "ItsTestName", "association",
- ItsAssociationPolicy.OPTIONAL))
+ expect(
+ serverConfig.getEnum(
+ "plugin", "ItsTestName", "association", ItsAssociationPolicy.OPTIONAL))
.andReturn(ItsAssociationPolicy.OPTIONAL)
.atLeastOnce();
replayMocks();
- assertEquals("Expected and generated associated policy do not match",
- ItsAssociationPolicy.OPTIONAL, itsConfig.getItsAssociationPolicy());
+ assertEquals(
+ "Expected and generated associated policy do not match",
+ ItsAssociationPolicy.OPTIONAL,
+ itsConfig.getItsAssociationPolicy());
}
public void testGetItsAssociationPolicySuggested() {
ItsConfig itsConfig = createItsConfig();
expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
- .andReturn(null).atLeastOnce();
- expect(serverConfig.getEnum("commentlink", "ItsTestName", "association",
- ItsAssociationPolicy.OPTIONAL))
+ .andReturn(null)
+ .atLeastOnce();
+ expect(
+ serverConfig.getEnum(
+ "commentlink", "ItsTestName", "association", ItsAssociationPolicy.OPTIONAL))
.andReturn(ItsAssociationPolicy.SUGGESTED)
.atLeastOnce();
- expect(serverConfig.getEnum("plugin", "ItsTestName", "association",
- ItsAssociationPolicy.SUGGESTED))
+ expect(
+ serverConfig.getEnum(
+ "plugin", "ItsTestName", "association", ItsAssociationPolicy.SUGGESTED))
.andReturn(ItsAssociationPolicy.SUGGESTED)
.atLeastOnce();
replayMocks();
- assertEquals("Expected and generated associated policy do not match",
- ItsAssociationPolicy.SUGGESTED, itsConfig.getItsAssociationPolicy());
+ assertEquals(
+ "Expected and generated associated policy do not match",
+ ItsAssociationPolicy.SUGGESTED,
+ itsConfig.getItsAssociationPolicy());
}
public void testGetItsAssociationPolicySuggestedWCommentLink() {
ItsConfig itsConfig = createItsConfig();
expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
- .andReturn("foo").atLeastOnce();
- expect(serverConfig.getEnum("plugin", "ItsTestName", "association",
- ItsAssociationPolicy.SUGGESTED))
+ .andReturn("foo")
+ .atLeastOnce();
+ expect(
+ serverConfig.getEnum(
+ "plugin", "ItsTestName", "association", ItsAssociationPolicy.SUGGESTED))
.andReturn(ItsAssociationPolicy.SUGGESTED)
.atLeastOnce();
- expect(serverConfig.getEnum("commentlink", "foo", "association",
- ItsAssociationPolicy.OPTIONAL))
+ expect(serverConfig.getEnum("commentlink", "foo", "association", ItsAssociationPolicy.OPTIONAL))
.andReturn(ItsAssociationPolicy.SUGGESTED)
.atLeastOnce();
replayMocks();
- assertEquals("Expected and generated associated policy do not match",
- ItsAssociationPolicy.SUGGESTED, itsConfig.getItsAssociationPolicy());
+ assertEquals(
+ "Expected and generated associated policy do not match",
+ ItsAssociationPolicy.SUGGESTED,
+ itsConfig.getItsAssociationPolicy());
}
public void testGetItsAssociationPolicyMandatory() {
ItsConfig itsConfig = createItsConfig();
expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
- .andReturn(null).atLeastOnce();
- expect(serverConfig.getEnum("commentlink", "ItsTestName", "association",
- ItsAssociationPolicy.OPTIONAL))
+ .andReturn(null)
+ .atLeastOnce();
+ expect(
+ serverConfig.getEnum(
+ "commentlink", "ItsTestName", "association", ItsAssociationPolicy.OPTIONAL))
.andReturn(ItsAssociationPolicy.MANDATORY)
.atLeastOnce();
- expect(serverConfig.getEnum("plugin", "ItsTestName", "association",
- ItsAssociationPolicy.MANDATORY))
+ expect(
+ serverConfig.getEnum(
+ "plugin", "ItsTestName", "association", ItsAssociationPolicy.MANDATORY))
.andReturn(ItsAssociationPolicy.MANDATORY)
.atLeastOnce();
replayMocks();
- assertEquals("Expected and generated associated policy do not match",
- ItsAssociationPolicy.MANDATORY, itsConfig.getItsAssociationPolicy());
+ assertEquals(
+ "Expected and generated associated policy do not match",
+ ItsAssociationPolicy.MANDATORY,
+ itsConfig.getItsAssociationPolicy());
}
public void testGetItsAssociationPolicyMandatoryWCommentLink() {
ItsConfig itsConfig = createItsConfig();
expect(serverConfig.getString("plugin", "ItsTestName", "commentlink"))
- .andReturn("foo").atLeastOnce();
- expect(serverConfig.getEnum("commentlink", "foo", "association",
- ItsAssociationPolicy.OPTIONAL))
+ .andReturn("foo")
+ .atLeastOnce();
+ expect(serverConfig.getEnum("commentlink", "foo", "association", ItsAssociationPolicy.OPTIONAL))
.andReturn(ItsAssociationPolicy.MANDATORY)
.atLeastOnce();
- expect(serverConfig.getEnum("plugin", "ItsTestName", "association",
- ItsAssociationPolicy.MANDATORY))
+ expect(
+ serverConfig.getEnum(
+ "plugin", "ItsTestName", "association", ItsAssociationPolicy.MANDATORY))
.andReturn(ItsAssociationPolicy.MANDATORY)
.atLeastOnce();
replayMocks();
- assertEquals("Expected and generated associated policy do not match",
- ItsAssociationPolicy.MANDATORY, itsConfig.getItsAssociationPolicy());
+ assertEquals(
+ "Expected and generated associated policy do not match",
+ ItsAssociationPolicy.MANDATORY,
+ itsConfig.getItsAssociationPolicy());
}
private ItsConfig createItsConfig() {
@@ -802,12 +833,10 @@
pluginConfigFactory = createMock(PluginConfigFactory.class);
bind(PluginConfigFactory.class).toInstance(pluginConfigFactory);
- bind(String.class).annotatedWith(PluginName.class)
- .toInstance("ItsTestName");
+ bind(String.class).annotatedWith(PluginName.class).toInstance("ItsTestName");
serverConfig = createMock(Config.class);
- bind(Config.class).annotatedWith(GerritServerConfig.class)
- .toInstance(serverConfig);
+ bind(Config.class).annotatedWith(GerritServerConfig.class).toInstance(serverConfig);
}
}
}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/testutil/LoggingMockingTestCase.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/testutil/LoggingMockingTestCase.java
index 6af549e..b1d98e2 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/testutil/LoggingMockingTestCase.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/testutil/LoggingMockingTestCase.java
@@ -19,20 +19,17 @@
import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.Project;
-
import com.googlesource.gerrit.plugins.its.base.testutil.log.LogUtil;
-
+import java.sql.Timestamp;
+import java.util.Iterator;
import org.apache.log4j.Level;
import org.apache.log4j.spi.LoggingEvent;
import org.junit.After;
-import java.sql.Timestamp;
-import java.util.Iterator;
-
public abstract class LoggingMockingTestCase extends MockingTestCase {
- protected final Change.Key testChangeKey = new Change.Key(
- "Ic19f7bf6c8b4685c363a8204c32d827ffda52ec0");
+ protected final Change.Key testChangeKey =
+ new Change.Key("Ic19f7bf6c8b4685c363a8204c32d827ffda52ec0");
protected final Change.Id testChangeId = new Change.Id(1);
protected final Account.Id testAccountId = new Account.Id(1);
@@ -49,10 +46,9 @@
}
}
}
- assertNotNull("Could not find log message containing '" + needle + "'",
- hit);
- assertTrue("Could not remove log message containing '" + needle + "'",
- loggedEvents.remove(hit));
+ assertNotNull("Could not find log message containing '" + needle + "'", hit);
+ assertTrue(
+ "Could not remove log message containing '" + needle + "'", loggedEvents.remove(hit));
}
protected final void assertLogMessageContains(String needle) {
@@ -65,15 +61,14 @@
while (hit == null && iter.hasNext()) {
LoggingEvent event = iter.next();
- if (event.getThrowableInformation().getThrowable().toString()
- .contains(needle)) {
+ if (event.getThrowableInformation().getThrowable().toString().contains(needle)) {
hit = event;
}
}
- assertNotNull("Could not find log message with a Throwable containing '"
- + needle + "'", hit);
- assertTrue("Could not remove log message with a Throwable containing '"
- + needle + "'", loggedEvents.remove(hit));
+ assertNotNull("Could not find log message with a Throwable containing '" + needle + "'", hit);
+ assertTrue(
+ "Could not remove log message with a Throwable containing '" + needle + "'",
+ loggedEvents.remove(hit));
}
// As the PowerMock runner does not pass through runTest, we inject log
@@ -101,7 +96,7 @@
// and we can improve later to allow tests to specify which loggers are
// to check.
String logName = this.getClass().getCanonicalName();
- logName = logName.substring(0, logName.length()-4);
+ logName = logName.substring(0, logName.length() - 4);
LogUtil.logToCollection(logName, loggedEvents);
}
@@ -116,7 +111,10 @@
}
protected Change testChange(String project, String branch) {
- return new Change(testChangeKey, testChangeId, testAccountId,
+ return new Change(
+ testChangeKey,
+ testChangeId,
+ testAccountId,
new Branch.NameKey(new Project.NameKey(project), branch),
new Timestamp(System.currentTimeMillis()));
}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/testutil/MockingTestCase.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/testutil/MockingTestCase.java
index 2f045ef..d717024 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/testutil/MockingTestCase.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/testutil/MockingTestCase.java
@@ -14,8 +14,9 @@
package com.googlesource.gerrit.plugins.its.base.testutil;
+import java.util.ArrayList;
+import java.util.Collection;
import junit.framework.TestCase;
-
import org.easymock.Capture;
import org.easymock.EasyMock;
import org.easymock.IMocksControl;
@@ -24,12 +25,7 @@
import org.powermock.api.easymock.PowerMock;
import org.powermock.modules.junit4.PowerMockRunner;
-import java.util.ArrayList;
-import java.util.Collection;
-
-/**
- * Test case with some support for automatically verifying mocks.
- */
+/** Test case with some support for automatically verifying mocks. */
public abstract class MockingTestCase extends TestCase {
private Collection<Object> mocks;
private Collection<IMocksControl> mockControls;
@@ -50,8 +46,9 @@
/**
* Create and register a mock.
*
- * Creates a mock and registers it in the list of created mocks, so it gets
- * treated automatically upon {@code replay} and {@code verify};
+ * <p>Creates a mock and registers it in the list of created mocks, so it gets treated
+ * automatically upon {@code replay} and {@code verify};
+ *
* @param toMock The class to create a mock for.
* @return The mock instance.
*/
@@ -62,11 +59,11 @@
/**
* Create a mock for a mock control and register a mock.
*
- * Creates a mock and registers it in the list of created mocks, so it gets
- * treated automatically upon {@code replay} and {@code verify};
+ * <p>Creates a mock and registers it in the list of created mocks, so it gets treated
+ * automatically upon {@code replay} and {@code verify};
+ *
* @param toMock The class to create a mock for.
- * @param control The mock control to create the mock on. If null, do not use
- * a specific control.
+ * @param control The mock control to create the mock on. If null, do not use a specific control.
* @return The mock instance.
*/
protected final <T> T createMock(Class<T> toMock, IMocksControl control) {
@@ -78,17 +75,14 @@
} else {
mock = EasyMock.createMock(toMock);
}
- assertTrue("Adding " + toMock.getName() + " mock failed",
- mocks.add(mock));
+ assertTrue("Adding " + toMock.getName() + " mock failed", mocks.add(mock));
} else {
mock = control.createMock(toMock);
}
return mock;
}
- /**
- * Set all registered mocks to replay
- */
+ /** Set all registered mocks to replay */
protected final void replayMocks() {
assertFalse("Mocks have already been set to replay", mocksReplayed);
if (usePowerMock) {
@@ -105,17 +99,17 @@
/**
* Verify all registered mocks
*
- * This method is called automatically at the end of a test. Nevertheless,
- * it is safe to also call it beforehand, if this better meets the
- * verification part of a test.
+ * <p>This method is called automatically at the end of a test. Nevertheless, it is safe to also
+ * call it beforehand, if this better meets the verification part of a test.
*/
// As the PowerMock runner does not pass through runTest, we inject mock
// verification through @After
@After
public final void verifyMocks() {
if (!mocks.isEmpty() || !mockControls.isEmpty()) {
- assertTrue("Created mocks have not been set to replay. Call replayMocks "
- + "within the test", mocksReplayed);
+ assertTrue(
+ "Created mocks have not been set to replay. Call replayMocks " + "within the test",
+ mocksReplayed);
if (usePowerMock) {
PowerMock.verifyAll();
} else {
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/testutil/log/CollectionAppender.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/testutil/log/CollectionAppender.java
index a533f8c..c122676 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/testutil/log/CollectionAppender.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/testutil/log/CollectionAppender.java
@@ -15,16 +15,12 @@
package com.googlesource.gerrit.plugins.its.base.testutil.log;
import com.google.common.collect.Lists;
-
+import java.util.Collection;
+import java.util.LinkedList;
import org.apache.log4j.AppenderSkeleton;
import org.apache.log4j.spi.LoggingEvent;
-import java.util.Collection;
-import java.util.LinkedList;
-
-/**
- * Log4j appender that logs into a list
- */
+/** Log4j appender that logs into a list */
public class CollectionAppender extends AppenderSkeleton {
private Collection<LoggingEvent> events;
@@ -43,14 +39,13 @@
@Override
protected void append(LoggingEvent event) {
- if (! events.add(event)) {
+ if (!events.add(event)) {
throw new RuntimeException("Could not append event " + event);
}
}
@Override
- public void close() {
- }
+ public void close() {}
public Collection<LoggingEvent> getLoggedEvents() {
return Lists.newLinkedList(events);
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/testutil/log/LogUtil.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/testutil/log/LogUtil.java
index c5a6cb3..6cd633d 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/testutil/log/LogUtil.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/testutil/log/LogUtil.java
@@ -14,15 +14,14 @@
package com.googlesource.gerrit.plugins.its.base.testutil.log;
+import java.util.Collection;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.apache.log4j.spi.LoggingEvent;
-import java.util.Collection;
-
public class LogUtil {
- public static CollectionAppender logToCollection(String logName,
- Collection<LoggingEvent> collection) {
+ public static CollectionAppender logToCollection(
+ String logName, Collection<LoggingEvent> collection) {
Logger log = LogManager.getLogger(logName);
CollectionAppender listAppender = new CollectionAppender(collection);
log.removeAllAppenders();
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/util/IssueExtractorTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/util/IssueExtractorTest.java
index b79e764..349c155 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/util/IssueExtractorTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/util/IssueExtractorTest.java
@@ -26,22 +26,19 @@
import com.google.gwtorm.server.OrmException;
import com.google.inject.Guice;
import com.google.inject.Injector;
-
import com.googlesource.gerrit.plugins.its.base.its.ItsConfig;
import com.googlesource.gerrit.plugins.its.base.testutil.LoggingMockingTestCase;
-
-import org.junit.runner.RunWith;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
+import org.junit.runner.RunWith;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
-@PrepareForTest({PatchSet.class,RevId.class})
+@PrepareForTest({PatchSet.class, RevId.class})
public class IssueExtractorTest extends LoggingMockingTestCase {
private Injector injector;
private ItsConfig itsConfig;
@@ -51,8 +48,7 @@
public void testIssueIdsNullPattern() {
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- expect(itsConfig.getIssuePattern()).andReturn(null)
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(null).atLeastOnce();
replayMocks();
@@ -63,8 +59,7 @@
public void testIssueIdsNoMatch() {
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
replayMocks();
@@ -78,8 +73,7 @@
public void testIssueIdsEmptyGroup() {
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(X*)(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(X*)(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
replayMocks();
@@ -93,8 +87,7 @@
public void testIssueIdsFullMatch() {
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
replayMocks();
@@ -109,8 +102,7 @@
public void testIssueIdsMatch() {
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
replayMocks();
@@ -125,8 +117,7 @@
public void testIssueIdsGrouplessMatch() {
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#\\d+"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#\\d+")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(0).atLeastOnce();
replayMocks();
@@ -141,8 +132,7 @@
public void testIssueIdsMultiGroupMatchGroup1() {
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- expect(itsConfig.getIssuePattern())
- .andReturn(Pattern.compile("bug#(\\d)(\\d+)")).atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d)(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
replayMocks();
@@ -157,8 +147,7 @@
public void testIssueIdsMultiGroupMatchGroup2() {
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- expect(itsConfig.getIssuePattern())
- .andReturn(Pattern.compile("bug#(\\d)(\\d+)")).atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d)(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(2).atLeastOnce();
replayMocks();
@@ -173,8 +162,7 @@
public void testIssueIdsMulipleMatches() {
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
replayMocks();
@@ -192,14 +180,12 @@
public void testIssueIdsMulipleMatchesWithDuplicates() {
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
replayMocks();
- String ret[] = issueExtractor.getIssueIds("Foo bug#4711 bug#42 bar\n" +
- "bug#123 baz bug#42");
+ String ret[] = issueExtractor.getIssueIds("Foo bug#4711 bug#42 bar\n" + "bug#123 baz bug#42");
assertEquals("Number of found ids do not match", 3, ret.length);
List<String> retList = Arrays.asList(ret);
assertTrue("4711 not among the extracted ids", retList.contains("4711"));
@@ -210,23 +196,21 @@
}
public void testIssueIdsCommitSingleIssue() {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn(
- "bug#42\n" +
- "\n" +
- "Change-Id: I1234567891123456789212345678931234567894");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn("bug#42\n" + "\n" + "Change-Id: I1234567891123456789212345678931234567894");
replayMocks();
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894");
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds("testProject", "1234567891123456789212345678931234567894");
- Map<String,Set<String>> expected = Maps.newHashMap();
+ Map<String, Set<String>> expected = Maps.newHashMap();
expected.put("42", Sets.newHashSet("somewhere", "subject"));
assertEquals("Extracted issues do not match", expected, actual);
@@ -238,23 +222,24 @@
}
public void testIssueIdsCommitMultipleIssues() {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn(
- "bug#42, and bug#4711\n" +
- "\n" +
- "Change-Id: I1234567891123456789212345678931234567894");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn(
+ "bug#42, and bug#4711\n"
+ + "\n"
+ + "Change-Id: I1234567891123456789212345678931234567894");
replayMocks();
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894");
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds("testProject", "1234567891123456789212345678931234567894");
- Map<String,Set<String>> expected = Maps.newHashMap();
+ Map<String, Set<String>> expected = Maps.newHashMap();
expected.put("42", Sets.newHashSet("somewhere", "subject"));
expected.put("4711", Sets.newHashSet("somewhere", "subject"));
assertEquals("Extracted issues do not match", expected, actual);
@@ -267,23 +252,24 @@
}
public void testIssueIdsCommitMultipleIssuesMultipleTimes() {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn(
- "bug#42, bug#4711, bug#4711, bug#42, and bug#4711\n" +
- "\n" +
- "Change-Id: I1234567891123456789212345678931234567894");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn(
+ "bug#42, bug#4711, bug#4711, bug#42, and bug#4711\n"
+ + "\n"
+ + "Change-Id: I1234567891123456789212345678931234567894");
replayMocks();
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894");
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds("testProject", "1234567891123456789212345678931234567894");
- Map<String,Set<String>> expected = Maps.newHashMap();
+ Map<String, Set<String>> expected = Maps.newHashMap();
expected.put("42", Sets.newHashSet("somewhere", "subject"));
expected.put("4711", Sets.newHashSet("somewhere", "subject"));
assertEquals("Extracted issues do not match", expected, actual);
@@ -296,25 +282,26 @@
}
public void testIssueIdsCommitSingleIssueBody() {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn(
- "Subject does not reference a bug\n" +
- "Body references bug#42\n" +
- "\n" +
- "Footer: does not reference a bug\n" +
- "Change-Id: I1234567891123456789212345678931234567894");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn(
+ "Subject does not reference a bug\n"
+ + "Body references bug#42\n"
+ + "\n"
+ + "Footer: does not reference a bug\n"
+ + "Change-Id: I1234567891123456789212345678931234567894");
replayMocks();
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894");
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds("testProject", "1234567891123456789212345678931234567894");
- Map<String,Set<String>> expected = Maps.newHashMap();
+ Map<String, Set<String>> expected = Maps.newHashMap();
expected.put("42", Sets.newHashSet("somewhere", "body"));
assertEquals("Extracted issues do not match", expected, actual);
@@ -327,27 +314,27 @@
}
public void testIssueIdsCommitSingleIssueFooter() {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn(
- "Subject does not reference a bug\n" +
- "Body does not reference a bug\n" +
- "\n" +
- "Footer: references bug#42\n" +
- "Change-Id: I1234567891123456789212345678931234567894");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn(
+ "Subject does not reference a bug\n"
+ + "Body does not reference a bug\n"
+ + "\n"
+ + "Footer: references bug#42\n"
+ + "Change-Id: I1234567891123456789212345678931234567894");
replayMocks();
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894");
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds("testProject", "1234567891123456789212345678931234567894");
- Map<String,Set<String>> expected = Maps.newHashMap();
- expected.put("42", Sets.newHashSet("somewhere", "footer",
- "footer-Footer"));
+ Map<String, Set<String>> expected = Maps.newHashMap();
+ expected.put("42", Sets.newHashSet("somewhere", "footer", "footer-Footer"));
assertEquals("Extracted issues do not match", expected, actual);
assertLogMessageContains("Matching");
@@ -359,29 +346,30 @@
}
public void testIssueIdsCommitMultipleIssuesFooter() {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn(
- "Subject does not reference a bug\n" +
- "Body does not reference a bug\n" +
- "\n" +
- "KeyA: references bug#42\n" +
- "KeyB: does not reference bug\n" +
- "KeyC: references bug#176\n" +
- "Unkeyed reference to bug#4711\n" +
- "Change-Id: I1234567891123456789212345678931234567894\n" +
- "KeyZ: references bug#256" );
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn(
+ "Subject does not reference a bug\n"
+ + "Body does not reference a bug\n"
+ + "\n"
+ + "KeyA: references bug#42\n"
+ + "KeyB: does not reference bug\n"
+ + "KeyC: references bug#176\n"
+ + "Unkeyed reference to bug#4711\n"
+ + "Change-Id: I1234567891123456789212345678931234567894\n"
+ + "KeyZ: references bug#256");
replayMocks();
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894");
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds("testProject", "1234567891123456789212345678931234567894");
- Map<String,Set<String>> expected = Maps.newHashMap();
+ Map<String, Set<String>> expected = Maps.newHashMap();
expected.put("42", Sets.newHashSet("somewhere", "footer", "footer-KeyA"));
expected.put("176", Sets.newHashSet("somewhere", "footer", "footer-KeyC"));
expected.put("256", Sets.newHashSet("somewhere", "footer", "footer-KeyZ"));
@@ -400,26 +388,27 @@
}
public void testIssueIdsCommitDifferentParts() {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn(
- "Subject references bug#42.\n" +
- "Body references bug#16.\n" +
- "Body also references bug#176.\n" +
- "\n" +
- "Bug: bug#4711 in footer\n" +
- "Change-Id: I1234567891123456789212345678931234567894");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn(
+ "Subject references bug#42.\n"
+ + "Body references bug#16.\n"
+ + "Body also references bug#176.\n"
+ + "\n"
+ + "Bug: bug#4711 in footer\n"
+ + "Change-Id: I1234567891123456789212345678931234567894");
replayMocks();
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894");
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds("testProject", "1234567891123456789212345678931234567894");
- Map<String,Set<String>> expected = Maps.newHashMap();
+ Map<String, Set<String>> expected = Maps.newHashMap();
expected.put("16", Sets.newHashSet("somewhere", "body"));
expected.put("42", Sets.newHashSet("somewhere", "subject"));
expected.put("176", Sets.newHashSet("somewhere", "body"));
@@ -435,26 +424,27 @@
}
public void testIssueIdsCommitDifferentPartsEmptySubject() {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn(
- "\n" +
- "Body references bug#16.\n" +
- "Body also references bug#176.\n" +
- "\n" +
- "Bug: bug#4711 in footer\n" +
- "Change-Id: I1234567891123456789212345678931234567894");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn(
+ "\n"
+ + "Body references bug#16.\n"
+ + "Body also references bug#176.\n"
+ + "\n"
+ + "Bug: bug#4711 in footer\n"
+ + "Change-Id: I1234567891123456789212345678931234567894");
replayMocks();
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894");
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds("testProject", "1234567891123456789212345678931234567894");
- Map<String,Set<String>> expected = Maps.newHashMap();
+ Map<String, Set<String>> expected = Maps.newHashMap();
expected.put("16", Sets.newHashSet("somewhere", "body"));
expected.put("176", Sets.newHashSet("somewhere", "body"));
expected.put("4711", Sets.newHashSet("somewhere", "footer", "footer-Bug"));
@@ -469,26 +459,27 @@
}
public void testIssueIdsCommitDifferentPartsLinePastFooter() {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn(
- "Subject references bug#42.\n" +
- "Body references bug#16.\n" +
- "Body also references bug#176.\n" +
- "\n" +
- "Bug: bug#4711 in footer\n" +
- "Change-Id: I1234567891123456789212345678931234567894\n");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn(
+ "Subject references bug#42.\n"
+ + "Body references bug#16.\n"
+ + "Body also references bug#176.\n"
+ + "\n"
+ + "Bug: bug#4711 in footer\n"
+ + "Change-Id: I1234567891123456789212345678931234567894\n");
replayMocks();
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894");
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds("testProject", "1234567891123456789212345678931234567894");
- Map<String,Set<String>> expected = Maps.newHashMap();
+ Map<String, Set<String>> expected = Maps.newHashMap();
expected.put("16", Sets.newHashSet("somewhere", "body"));
expected.put("42", Sets.newHashSet("somewhere", "subject"));
expected.put("176", Sets.newHashSet("somewhere", "body"));
@@ -504,27 +495,28 @@
}
public void testIssueIdsCommitDifferentPartsLinesPastFooter() {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn(
- "Subject references bug#42.\n" +
- "Body references bug#16.\n" +
- "Body also references bug#176.\n" +
- "\n" +
- "Bug: bug#4711 in footer\n" +
- "Change-Id: I1234567891123456789212345678931234567894\n" +
- "\n");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn(
+ "Subject references bug#42.\n"
+ + "Body references bug#16.\n"
+ + "Body also references bug#176.\n"
+ + "\n"
+ + "Bug: bug#4711 in footer\n"
+ + "Change-Id: I1234567891123456789212345678931234567894\n"
+ + "\n");
replayMocks();
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894");
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds("testProject", "1234567891123456789212345678931234567894");
- Map<String,Set<String>> expected = Maps.newHashMap();
+ Map<String, Set<String>> expected = Maps.newHashMap();
expected.put("16", Sets.newHashSet("somewhere", "body"));
expected.put("42", Sets.newHashSet("somewhere", "subject"));
expected.put("176", Sets.newHashSet("somewhere", "body"));
@@ -540,23 +532,24 @@
}
public void testIssueIdsCommitDifferentPartsNoFooter() {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn(
- "Subject references bug#42.\n" +
- "Body references bug#16.\n" +
- "Body also references bug#176.");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn(
+ "Subject references bug#42.\n"
+ + "Body references bug#16.\n"
+ + "Body also references bug#176.");
replayMocks();
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894");
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds("testProject", "1234567891123456789212345678931234567894");
- Map<String,Set<String>> expected = Maps.newHashMap();
+ Map<String, Set<String>> expected = Maps.newHashMap();
expected.put("16", Sets.newHashSet("somewhere", "body"));
expected.put("42", Sets.newHashSet("somewhere", "subject"));
expected.put("176", Sets.newHashSet("somewhere", "body"));
@@ -568,23 +561,24 @@
}
public void testIssueIdsCommitDifferentPartsNoFooterTrailingLine() {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn(
- "Subject references bug#42.\n" +
- "Body references bug#16.\n" +
- "Body also references bug#176.\n");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn(
+ "Subject references bug#42.\n"
+ + "Body references bug#16.\n"
+ + "Body also references bug#176.\n");
replayMocks();
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894");
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds("testProject", "1234567891123456789212345678931234567894");
- Map<String,Set<String>> expected = Maps.newHashMap();
+ Map<String, Set<String>> expected = Maps.newHashMap();
expected.put("16", Sets.newHashSet("somewhere", "body"));
expected.put("42", Sets.newHashSet("somewhere", "subject"));
expected.put("176", Sets.newHashSet("somewhere", "body"));
@@ -596,24 +590,25 @@
}
public void testIssueIdsCommitDifferentPartsNoFooterTrailingLines() {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn(
- "Subject references bug#42.\n" +
- "Body references bug#16.\n" +
- "Body also references bug#176.\n" +
- "\n");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn(
+ "Subject references bug#42.\n"
+ + "Body references bug#16.\n"
+ + "Body also references bug#176.\n"
+ + "\n");
replayMocks();
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894");
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds("testProject", "1234567891123456789212345678931234567894");
- Map<String,Set<String>> expected = Maps.newHashMap();
+ Map<String, Set<String>> expected = Maps.newHashMap();
expected.put("16", Sets.newHashSet("somewhere", "body"));
expected.put("42", Sets.newHashSet("somewhere", "subject"));
expected.put("176", Sets.newHashSet("somewhere", "body"));
@@ -625,20 +620,21 @@
}
public void testIssueIdsCommitEmpty() {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn("");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn("");
replayMocks();
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894");
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds("testProject", "1234567891123456789212345678931234567894");
- Map<String,Set<String>> expected = Maps.newHashMap();
+ Map<String, Set<String>> expected = Maps.newHashMap();
assertEquals("Extracted issues do not match", expected, actual);
assertLogMessageContains("Matching");
@@ -647,96 +643,98 @@
}
public void testIssueIdsCommitBlankLine() {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn("\n");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn("\n");
replayMocks();
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894");
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds("testProject", "1234567891123456789212345678931234567894");
- Map<String,Set<String>> expected = Maps.newHashMap();
+ Map<String, Set<String>> expected = Maps.newHashMap();
assertEquals("Extracted issues do not match", expected, actual);
assertLogMessageContains("Matching");
}
public void testIssueIdsCommitBlankLines() {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn("\n\n");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn("\n\n");
replayMocks();
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894");
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds("testProject", "1234567891123456789212345678931234567894");
- Map<String,Set<String>> expected = Maps.newHashMap();
+ Map<String, Set<String>> expected = Maps.newHashMap();
assertEquals("Extracted issues do not match", expected, actual);
assertLogMessageContains("Matching");
}
public void testIssueIdsCommitMoreBlankLines() {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn("\n\n\n");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn("\n\n\n");
replayMocks();
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894");
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds("testProject", "1234567891123456789212345678931234567894");
- Map<String,Set<String>> expected = Maps.newHashMap();
+ Map<String, Set<String>> expected = Maps.newHashMap();
assertEquals("Extracted issues do not match", expected, actual);
assertLogMessageContains("Matching");
}
public void testIssueIdsCommitMixed() {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn(
- "Subject bug#42, bug#1984, and bug#16\n" +
- "\n" +
- "bug#4711 in body,\n" +
- "along with bug#1984, and bug#5150.\n" +
- "bug#4711 in body again, along with bug#16\n" +
- "\n" +
- "Bug: bug#176, bug#1984, and bug#5150\n" +
- "Change-Id: I1234567891123456789212345678931234567894");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn(
+ "Subject bug#42, bug#1984, and bug#16\n"
+ + "\n"
+ + "bug#4711 in body,\n"
+ + "along with bug#1984, and bug#5150.\n"
+ + "bug#4711 in body again, along with bug#16\n"
+ + "\n"
+ + "Bug: bug#176, bug#1984, and bug#5150\n"
+ + "Change-Id: I1234567891123456789212345678931234567894");
replayMocks();
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894");
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds("testProject", "1234567891123456789212345678931234567894");
- Map<String,Set<String>> expected = Maps.newHashMap();
+ Map<String, Set<String>> expected = Maps.newHashMap();
expected.put("16", Sets.newHashSet("somewhere", "subject", "body"));
expected.put("42", Sets.newHashSet("somewhere", "subject"));
expected.put("176", Sets.newHashSet("somewhere", "footer", "footer-Bug"));
- expected.put("1984", Sets.newHashSet("somewhere", "subject", "body",
- "footer", "footer-Bug"));
+ expected.put("1984", Sets.newHashSet("somewhere", "subject", "body", "footer", "footer-Bug"));
expected.put("4711", Sets.newHashSet("somewhere", "body"));
- expected.put("5150", Sets.newHashSet("somewhere", "body", "footer",
- "footer-Bug"));
+ expected.put("5150", Sets.newHashSet("somewhere", "body", "footer", "footer-Bug"));
assertEquals("Extracted issues do not match", expected, actual);
assertLogMessageContains("Matching");
@@ -748,21 +746,23 @@
}
public void testIssueIdsCommitWAddedEmptyFirst() {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn("");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn("");
replayMocks();
PatchSet.Id patchSetId = new PatchSet.Id(new Change.Id(4), 1);
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894", patchSetId);
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds(
+ "testProject", "1234567891123456789212345678931234567894", patchSetId);
- Map<String,Set<String>> expected = Maps.newHashMap();
+ Map<String, Set<String>> expected = Maps.newHashMap();
assertEquals("Extracted issues do not match", expected, actual);
assertLogMessageContains("Matching");
@@ -771,32 +771,29 @@
}
public void testIssueIdsCommitWAddedSingleSubjectIssueFirst() {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
Change.Id changeId = createMock(Change.Id.class);
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn(
- "bug#42\n" +
- "\n" +
- "Change-Id: I1234567891123456789212345678931234567894");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn("bug#42\n" + "\n" + "Change-Id: I1234567891123456789212345678931234567894");
PatchSet.Id currentPatchSetId = createMock(PatchSet.Id.class);
expect(currentPatchSetId.get()).andReturn(1).anyTimes();
- expect(currentPatchSetId.getParentKey()).andReturn(changeId)
- .anyTimes();
+ expect(currentPatchSetId.getParentKey()).andReturn(changeId).anyTimes();
replayMocks();
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894", currentPatchSetId);
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds(
+ "testProject", "1234567891123456789212345678931234567894", currentPatchSetId);
- Map<String,Set<String>> expected = Maps.newHashMap();
- expected.put("42", Sets.newHashSet("somewhere", "subject",
- "added@somewhere", "added@subject"));
+ Map<String, Set<String>> expected = Maps.newHashMap();
+ expected.put("42", Sets.newHashSet("somewhere", "subject", "added@somewhere", "added@subject"));
assertEquals("Extracted issues do not match", expected, actual);
assertLogMessageContains("Matching");
@@ -806,26 +803,22 @@
assertLogMessageContains("Matching");
}
- public void testIssueIdsCommitWAddedSingleSubjectIssueSecondEmpty()
- throws OrmException {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ public void testIssueIdsCommitWAddedSingleSubjectIssueSecondEmpty() throws OrmException {
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
Change.Id changeId = createMock(Change.Id.class);
// Call for current patch set
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn(
- "bug#42\n" +
- "\n" +
- "Change-Id: I1234567891123456789212345678931234567894");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn("bug#42\n" + "\n" + "Change-Id: I1234567891123456789212345678931234567894");
// Call for previous patch set
PatchSet.Id previousPatchSetId = new PatchSet.Id(changeId, 1);
RevId previousRevId = createMock(RevId.class);
- expect(previousRevId.get())
- .andReturn("9876543211987654321298765432139876543214").anyTimes();
+ expect(previousRevId.get()).andReturn("9876543211987654321298765432139876543214").anyTimes();
PatchSet previousPatchSet = createMock(PatchSet.class);
expect(previousPatchSet.getRevision()).andReturn(previousRevId).anyTimes();
@@ -833,28 +826,26 @@
PatchSetAccess patchSetAccess = createMock(PatchSetAccess.class);
expect(patchSetAccess.get(previousPatchSetId)).andReturn(previousPatchSet);
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "9876543211987654321298765432139876543214")).andReturn(
- "subject\n" +
- "\n" +
- "Change-Id: I9876543211987654321298765432139876543214");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "9876543211987654321298765432139876543214"))
+ .andReturn("subject\n" + "\n" + "Change-Id: I9876543211987654321298765432139876543214");
expect(db.patchSets()).andReturn(patchSetAccess);
PatchSet.Id currentPatchSetId = createMock(PatchSet.Id.class);
expect(currentPatchSetId.get()).andReturn(2).anyTimes();
- expect(currentPatchSetId.getParentKey()).andReturn(changeId)
- .anyTimes();
+ expect(currentPatchSetId.getParentKey()).andReturn(changeId).anyTimes();
replayMocks();
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894", currentPatchSetId);
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds(
+ "testProject", "1234567891123456789212345678931234567894", currentPatchSetId);
- Map<String,Set<String>> expected = Maps.newHashMap();
- expected.put("42", Sets.newHashSet("somewhere", "subject",
- "added@somewhere", "added@subject"));
+ Map<String, Set<String>> expected = Maps.newHashMap();
+ expected.put("42", Sets.newHashSet("somewhere", "subject", "added@somewhere", "added@subject"));
assertEquals("Extracted issues do not match", expected, actual);
assertLogMessageContains("Matching");
@@ -869,26 +860,22 @@
assertLogMessageContains("Matching");
}
- public void testIssueIdsCommitWAddedSingleSubjectIssueSecondSame()
- throws OrmException {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ public void testIssueIdsCommitWAddedSingleSubjectIssueSecondSame() throws OrmException {
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
Change.Id changeId = createMock(Change.Id.class);
// Call for current patch set
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn(
- "bug#42\n" +
- "\n" +
- "Change-Id: I1234567891123456789212345678931234567894");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn("bug#42\n" + "\n" + "Change-Id: I1234567891123456789212345678931234567894");
// Call for previous patch set
PatchSet.Id previousPatchSetId = new PatchSet.Id(changeId, 1);
RevId previousRevId = createMock(RevId.class);
- expect(previousRevId.get())
- .andReturn("9876543211987654321298765432139876543214").anyTimes();
+ expect(previousRevId.get()).andReturn("9876543211987654321298765432139876543214").anyTimes();
PatchSet previousPatchSet = createMock(PatchSet.class);
expect(previousPatchSet.getRevision()).andReturn(previousRevId).anyTimes();
@@ -896,26 +883,25 @@
PatchSetAccess patchSetAccess = createMock(PatchSetAccess.class);
expect(patchSetAccess.get(previousPatchSetId)).andReturn(previousPatchSet);
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "9876543211987654321298765432139876543214")).andReturn(
- "bug#42\n" +
- "\n" +
- "Change-Id: I9876543211987654321298765432139876543214");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "9876543211987654321298765432139876543214"))
+ .andReturn("bug#42\n" + "\n" + "Change-Id: I9876543211987654321298765432139876543214");
expect(db.patchSets()).andReturn(patchSetAccess);
PatchSet.Id currentPatchSetId = createMock(PatchSet.Id.class);
expect(currentPatchSetId.get()).andReturn(2).anyTimes();
- expect(currentPatchSetId.getParentKey()).andReturn(changeId)
- .anyTimes();
+ expect(currentPatchSetId.getParentKey()).andReturn(changeId).anyTimes();
replayMocks();
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894", currentPatchSetId);
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds(
+ "testProject", "1234567891123456789212345678931234567894", currentPatchSetId);
- Map<String,Set<String>> expected = Maps.newHashMap();
+ Map<String, Set<String>> expected = Maps.newHashMap();
expected.put("42", Sets.newHashSet("somewhere", "subject"));
assertEquals("Extracted issues do not match", expected, actual);
@@ -931,26 +917,22 @@
assertLogMessageContains("Matching");
}
- public void testIssueIdsCommitWAddedSingleSubjectIssueSecondBody()
- throws OrmException {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ public void testIssueIdsCommitWAddedSingleSubjectIssueSecondBody() throws OrmException {
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
Change.Id changeId = createMock(Change.Id.class);
// Call for current patch set
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn(
- "bug#42\n" +
- "\n" +
- "Change-Id: I1234567891123456789212345678931234567894");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn("bug#42\n" + "\n" + "Change-Id: I1234567891123456789212345678931234567894");
// Call for previous patch set
PatchSet.Id previousPatchSetId = new PatchSet.Id(changeId, 1);
RevId previousRevId = createMock(RevId.class);
- expect(previousRevId.get())
- .andReturn("9876543211987654321298765432139876543214").anyTimes();
+ expect(previousRevId.get()).andReturn("9876543211987654321298765432139876543214").anyTimes();
PatchSet previousPatchSet = createMock(PatchSet.class);
expect(previousPatchSet.getRevision()).andReturn(previousRevId).anyTimes();
@@ -958,27 +940,29 @@
PatchSetAccess patchSetAccess = createMock(PatchSetAccess.class);
expect(patchSetAccess.get(previousPatchSetId)).andReturn(previousPatchSet);
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "9876543211987654321298765432139876543214")).andReturn(
- "subject\n" +
- "bug#42\n" +
- "\n" +
- "Change-Id: I9876543211987654321298765432139876543214");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "9876543211987654321298765432139876543214"))
+ .andReturn(
+ "subject\n"
+ + "bug#42\n"
+ + "\n"
+ + "Change-Id: I9876543211987654321298765432139876543214");
expect(db.patchSets()).andReturn(patchSetAccess);
PatchSet.Id currentPatchSetId = createMock(PatchSet.Id.class);
expect(currentPatchSetId.get()).andReturn(2).anyTimes();
- expect(currentPatchSetId.getParentKey()).andReturn(changeId)
- .anyTimes();
+ expect(currentPatchSetId.getParentKey()).andReturn(changeId).anyTimes();
replayMocks();
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894", currentPatchSetId);
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds(
+ "testProject", "1234567891123456789212345678931234567894", currentPatchSetId);
- Map<String,Set<String>> expected = Maps.newHashMap();
+ Map<String, Set<String>> expected = Maps.newHashMap();
expected.put("42", Sets.newHashSet("somewhere", "subject", "added@subject"));
assertEquals("Extracted issues do not match", expected, actual);
@@ -994,27 +978,26 @@
assertLogMessageContains("Matching");
}
- public void testIssueIdsCommitWAddedSingleSubjectIssueSecondFooter()
- throws OrmException {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ public void testIssueIdsCommitWAddedSingleSubjectIssueSecondFooter() throws OrmException {
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
Change.Id changeId = createMock(Change.Id.class);
// Call for current patch set
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn(
- "subject\n" +
- "\n" +
- "Bug: bug#42\n" +
- "Change-Id: I1234567891123456789212345678931234567894");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn(
+ "subject\n"
+ + "\n"
+ + "Bug: bug#42\n"
+ + "Change-Id: I1234567891123456789212345678931234567894");
// Call for previous patch set
PatchSet.Id previousPatchSetId = new PatchSet.Id(changeId, 1);
RevId previousRevId = createMock(RevId.class);
- expect(previousRevId.get())
- .andReturn("9876543211987654321298765432139876543214").anyTimes();
+ expect(previousRevId.get()).andReturn("9876543211987654321298765432139876543214").anyTimes();
PatchSet previousPatchSet = createMock(PatchSet.class);
expect(previousPatchSet.getRevision()).andReturn(previousRevId).anyTimes();
@@ -1022,28 +1005,28 @@
PatchSetAccess patchSetAccess = createMock(PatchSetAccess.class);
expect(patchSetAccess.get(previousPatchSetId)).andReturn(previousPatchSet);
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "9876543211987654321298765432139876543214")).andReturn(
- "bug#42\n" +
- "\n" +
- "Change-Id: I9876543211987654321298765432139876543214");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "9876543211987654321298765432139876543214"))
+ .andReturn("bug#42\n" + "\n" + "Change-Id: I9876543211987654321298765432139876543214");
expect(db.patchSets()).andReturn(patchSetAccess);
PatchSet.Id currentPatchSetId = createMock(PatchSet.Id.class);
expect(currentPatchSetId.get()).andReturn(2).anyTimes();
- expect(currentPatchSetId.getParentKey()).andReturn(changeId)
- .anyTimes();
+ expect(currentPatchSetId.getParentKey()).andReturn(changeId).anyTimes();
replayMocks();
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894", currentPatchSetId);
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds(
+ "testProject", "1234567891123456789212345678931234567894", currentPatchSetId);
- Map<String,Set<String>> expected = Maps.newHashMap();
- expected.put("42", Sets.newHashSet("somewhere", "footer", "added@footer",
- "footer-Bug", "added@footer-Bug"));
+ Map<String, Set<String>> expected = Maps.newHashMap();
+ expected.put(
+ "42",
+ Sets.newHashSet("somewhere", "footer", "added@footer", "footer-Bug", "added@footer-Bug"));
assertEquals("Extracted issues do not match", expected, actual);
assertLogMessageContains("Matching");
@@ -1059,29 +1042,28 @@
assertLogMessageContains("Matching");
}
- public void testIssueIdsCommitWAddedSubjectFooter()
- throws OrmException {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ public void testIssueIdsCommitWAddedSubjectFooter() throws OrmException {
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
Change.Id changeId = createMock(Change.Id.class);
// Call for current patch set
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn(
- "subject bug#42\n" +
- "\n" +
- "body bug#42\n" +
- "\n" +
- "Bug: bug#42\n" +
- "Change-Id: I1234567891123456789212345678931234567894");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn(
+ "subject bug#42\n"
+ + "\n"
+ + "body bug#42\n"
+ + "\n"
+ + "Bug: bug#42\n"
+ + "Change-Id: I1234567891123456789212345678931234567894");
// Call for previous patch set
PatchSet.Id previousPatchSetId = new PatchSet.Id(changeId, 1);
RevId previousRevId = createMock(RevId.class);
- expect(previousRevId.get())
- .andReturn("9876543211987654321298765432139876543214").anyTimes();
+ expect(previousRevId.get()).andReturn("9876543211987654321298765432139876543214").anyTimes();
PatchSet previousPatchSet = createMock(PatchSet.class);
expect(previousPatchSet.getRevision()).andReturn(previousRevId).anyTimes();
@@ -1089,30 +1071,40 @@
PatchSetAccess patchSetAccess = createMock(PatchSetAccess.class);
expect(patchSetAccess.get(previousPatchSetId)).andReturn(previousPatchSet);
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "9876543211987654321298765432139876543214")).andReturn(
- "subject\n" +
- "bug#42\n" +
- "\n" +
- "Change-Id: I9876543211987654321298765432139876543214");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "9876543211987654321298765432139876543214"))
+ .andReturn(
+ "subject\n"
+ + "bug#42\n"
+ + "\n"
+ + "Change-Id: I9876543211987654321298765432139876543214");
expect(db.patchSets()).andReturn(patchSetAccess);
PatchSet.Id currentPatchSetId = createMock(PatchSet.Id.class);
expect(currentPatchSetId.get()).andReturn(2).anyTimes();
- expect(currentPatchSetId.getParentKey()).andReturn(changeId)
- .anyTimes();
+ expect(currentPatchSetId.getParentKey()).andReturn(changeId).anyTimes();
replayMocks();
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894", currentPatchSetId);
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds(
+ "testProject", "1234567891123456789212345678931234567894", currentPatchSetId);
- Map<String,Set<String>> expected = Maps.newHashMap();
- expected.put("42", Sets.newHashSet("somewhere", "subject", "added@subject",
- "body", "footer", "added@footer", "footer-Bug",
- "added@footer-Bug"));
+ Map<String, Set<String>> expected = Maps.newHashMap();
+ expected.put(
+ "42",
+ Sets.newHashSet(
+ "somewhere",
+ "subject",
+ "added@subject",
+ "body",
+ "footer",
+ "added@footer",
+ "footer-Bug",
+ "added@footer-Bug"));
assertEquals("Extracted issues do not match", expected, actual);
assertLogMessageContains("Matching");
@@ -1128,29 +1120,28 @@
assertLogMessageContains("Matching");
}
- public void testIssueIdsCommitWAddedMultiple()
- throws OrmException {
- expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)"))
- .atLeastOnce();
+ public void testIssueIdsCommitWAddedMultiple() throws OrmException {
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).atLeastOnce();
expect(itsConfig.getIssuePatternGroupIndex()).andReturn(1).atLeastOnce();
Change.Id changeId = createMock(Change.Id.class);
// Call for current patch set
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "1234567891123456789212345678931234567894")).andReturn(
- "subject bug#42\n" +
- "\n" +
- "body bug#42 bug#16\n" +
- "\n" +
- "Bug: bug#42\n" +
- "Change-Id: I1234567891123456789212345678931234567894");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "1234567891123456789212345678931234567894"))
+ .andReturn(
+ "subject bug#42\n"
+ + "\n"
+ + "body bug#42 bug#16\n"
+ + "\n"
+ + "Bug: bug#42\n"
+ + "Change-Id: I1234567891123456789212345678931234567894");
// Call for previous patch set
PatchSet.Id previousPatchSetId = new PatchSet.Id(changeId, 1);
RevId previousRevId = createMock(RevId.class);
- expect(previousRevId.get())
- .andReturn("9876543211987654321298765432139876543214").anyTimes();
+ expect(previousRevId.get()).andReturn("9876543211987654321298765432139876543214").anyTimes();
PatchSet previousPatchSet = createMock(PatchSet.class);
expect(previousPatchSet.getRevision()).andReturn(previousRevId).anyTimes();
@@ -1158,32 +1149,42 @@
PatchSetAccess patchSetAccess = createMock(PatchSetAccess.class);
expect(patchSetAccess.get(previousPatchSetId)).andReturn(previousPatchSet);
- expect(commitMessageFetcher.fetchGuarded("testProject",
- "9876543211987654321298765432139876543214")).andReturn(
- "subject\n" +
- "bug#42 bug#4711\n" +
- "\n" +
- "Bug: bug#16\n" +
- "Change-Id: I9876543211987654321298765432139876543214");
+ expect(
+ commitMessageFetcher.fetchGuarded(
+ "testProject", "9876543211987654321298765432139876543214"))
+ .andReturn(
+ "subject\n"
+ + "bug#42 bug#4711\n"
+ + "\n"
+ + "Bug: bug#16\n"
+ + "Change-Id: I9876543211987654321298765432139876543214");
expect(db.patchSets()).andReturn(patchSetAccess);
PatchSet.Id currentPatchSetId = createMock(PatchSet.Id.class);
expect(currentPatchSetId.get()).andReturn(2).anyTimes();
- expect(currentPatchSetId.getParentKey()).andReturn(changeId)
- .anyTimes();
+ expect(currentPatchSetId.getParentKey()).andReturn(changeId).anyTimes();
replayMocks();
IssueExtractor issueExtractor = injector.getInstance(IssueExtractor.class);
- Map<String,Set<String>> actual = issueExtractor.getIssueIds("testProject",
- "1234567891123456789212345678931234567894", currentPatchSetId);
+ Map<String, Set<String>> actual =
+ issueExtractor.getIssueIds(
+ "testProject", "1234567891123456789212345678931234567894", currentPatchSetId);
- Map<String,Set<String>> expected = Maps.newHashMap();
+ Map<String, Set<String>> expected = Maps.newHashMap();
expected.put("16", Sets.newHashSet("somewhere", "body", "added@body"));
- expected.put("42", Sets.newHashSet("somewhere", "subject", "added@subject",
- "body", "footer", "added@footer", "footer-Bug",
- "added@footer-Bug"));
+ expected.put(
+ "42",
+ Sets.newHashSet(
+ "somewhere",
+ "subject",
+ "added@subject",
+ "body",
+ "footer",
+ "added@footer",
+ "footer-Bug",
+ "added@footer-Bug"));
assertEquals("Extracted issues do not match", expected, actual);
assertLogMessageContains("Matching");
@@ -1220,4 +1221,4 @@
bind(ReviewDb.class).toInstance(db);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/util/PropertyAttributeExtractorTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/util/PropertyAttributeExtractorTest.java
index 64a824b..9ce8e5f 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/util/PropertyAttributeExtractorTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/util/PropertyAttributeExtractorTest.java
@@ -26,11 +26,9 @@
import com.google.gerrit.server.data.RefUpdateAttribute;
import com.google.inject.Guice;
import com.google.inject.Injector;
-
import com.googlesource.gerrit.plugins.its.base.its.ItsFacade;
import com.googlesource.gerrit.plugins.its.base.testutil.LoggingMockingTestCase;
import com.googlesource.gerrit.plugins.its.base.workflow.Property;
-
import java.util.Set;
public class PropertyAttributeExtractorTest extends LoggingMockingTestCase {
@@ -42,8 +40,7 @@
public void testAccountAttributeNull() {
replayMocks();
- PropertyAttributeExtractor extractor =
- injector.getInstance(PropertyAttributeExtractor.class);
+ PropertyAttributeExtractor extractor = injector.getInstance(PropertyAttributeExtractor.class);
Set<Property> actual = extractor.extractFrom(null, "prefix");
@@ -60,34 +57,27 @@
// deprecated, to be removed soon. migrate to ones without dash.
Property propertyEmail2 = createMock(Property.class);
- expect(propertyFactory.create("prefix-email", "testEmail"))
- .andReturn(propertyEmail2);
+ expect(propertyFactory.create("prefix-email", "testEmail")).andReturn(propertyEmail2);
Property propertyName2 = createMock(Property.class);
- expect(propertyFactory.create("prefix-name", "testName"))
- .andReturn(propertyName2);
+ expect(propertyFactory.create("prefix-name", "testName")).andReturn(propertyName2);
Property propertyUsername2 = createMock(Property.class);
- expect(propertyFactory.create("prefix-username", "testUsername"))
- .andReturn(propertyUsername2);
+ expect(propertyFactory.create("prefix-username", "testUsername")).andReturn(propertyUsername2);
// New style configs for vm and soy
- Property propertyEmail= createMock(Property.class);
- expect(propertyFactory.create("prefixEmail", "testEmail"))
- .andReturn(propertyEmail);
+ Property propertyEmail = createMock(Property.class);
+ expect(propertyFactory.create("prefixEmail", "testEmail")).andReturn(propertyEmail);
Property propertyName = createMock(Property.class);
- expect(propertyFactory.create("prefixName", "testName"))
- .andReturn(propertyName);
+ expect(propertyFactory.create("prefixName", "testName")).andReturn(propertyName);
Property propertyUsername = createMock(Property.class);
- expect(propertyFactory.create("prefixUsername", "testUsername"))
- .andReturn(propertyUsername);
+ expect(propertyFactory.create("prefixUsername", "testUsername")).andReturn(propertyUsername);
replayMocks();
- PropertyAttributeExtractor extractor =
- injector.getInstance(PropertyAttributeExtractor.class);
+ PropertyAttributeExtractor extractor = injector.getInstance(PropertyAttributeExtractor.class);
Set<Property> actual = extractor.extractFrom(accountAttribute, "prefix");
@@ -119,36 +109,28 @@
changeAttribute.commitMessage = "Commit Message";
Property propertyProject = createMock(Property.class);
- expect(propertyFactory.create("project", "testProject"))
- .andReturn(propertyProject);
+ expect(propertyFactory.create("project", "testProject")).andReturn(propertyProject);
Property propertyBranch = createMock(Property.class);
- expect(propertyFactory.create("branch", "testBranch"))
- .andReturn(propertyBranch);
+ expect(propertyFactory.create("branch", "testBranch")).andReturn(propertyBranch);
Property propertyTopic = createMock(Property.class);
- expect(propertyFactory.create("topic", "testTopic"))
- .andReturn(propertyTopic);
+ expect(propertyFactory.create("topic", "testTopic")).andReturn(propertyTopic);
Property propertySubject = createMock(Property.class);
- expect(propertyFactory.create("subject", "testSubject"))
- .andReturn(propertySubject);
+ expect(propertyFactory.create("subject", "testSubject")).andReturn(propertySubject);
Property propertyId2 = createMock(Property.class);
- expect(propertyFactory.create("change-id", "testId"))
- .andReturn(propertyId2);
+ expect(propertyFactory.create("change-id", "testId")).andReturn(propertyId2);
Property propertyId = createMock(Property.class);
- expect(propertyFactory.create("changeId", "testId"))
- .andReturn(propertyId);
+ expect(propertyFactory.create("changeId", "testId")).andReturn(propertyId);
Property propertyNumber2 = createMock(Property.class);
- expect(propertyFactory.create("change-number", "4711"))
- .andReturn(propertyNumber2);
+ expect(propertyFactory.create("change-number", "4711")).andReturn(propertyNumber2);
Property propertyNumber = createMock(Property.class);
- expect(propertyFactory.create("changeNumber", "4711"))
- .andReturn(propertyNumber);
+ expect(propertyFactory.create("changeNumber", "4711")).andReturn(propertyNumber);
Property propertyUrl2 = createMock(Property.class);
expect(propertyFactory.create("change-url", "http://www.example.org/test"))
@@ -159,36 +141,29 @@
.andReturn(propertyUrl);
Property propertyStatus = createMock(Property.class);
- expect(propertyFactory.create("status", null))
- .andReturn(propertyStatus);
+ expect(propertyFactory.create("status", null)).andReturn(propertyStatus);
Property propertyEmail = createMock(Property.class);
- expect(propertyFactory.create("ownerEmail", "testEmail"))
- .andReturn(propertyEmail);
+ expect(propertyFactory.create("ownerEmail", "testEmail")).andReturn(propertyEmail);
Property propertyName = createMock(Property.class);
- expect(propertyFactory.create("ownerName", "testName"))
- .andReturn(propertyName);
+ expect(propertyFactory.create("ownerName", "testName")).andReturn(propertyName);
Property propertyUsername = createMock(Property.class);
- expect(propertyFactory.create("ownerUsername", "testUsername"))
- .andReturn(propertyUsername);
+ expect(propertyFactory.create("ownerUsername", "testUsername")).andReturn(propertyUsername);
Property propertyCommitMessage = createMock(Property.class);
expect(propertyFactory.create("commitMessage", "Commit Message"))
.andReturn(propertyCommitMessage);
Property propertyEmail2 = createMock(Property.class);
- expect(propertyFactory.create("owner-email", "testEmail"))
- .andReturn(propertyEmail2);
+ expect(propertyFactory.create("owner-email", "testEmail")).andReturn(propertyEmail2);
Property propertyName2 = createMock(Property.class);
- expect(propertyFactory.create("owner-name", "testName"))
- .andReturn(propertyName2);
+ expect(propertyFactory.create("owner-name", "testName")).andReturn(propertyName2);
Property propertyUsername2 = createMock(Property.class);
- expect(propertyFactory.create("owner-username", "testUsername"))
- .andReturn(propertyUsername2);
+ expect(propertyFactory.create("owner-username", "testUsername")).andReturn(propertyUsername2);
Property propertyCommitMessage2 = createMock(Property.class);
expect(propertyFactory.create("commit-message", "Commit Message"))
@@ -203,8 +178,7 @@
replayMocks();
- PropertyAttributeExtractor extractor =
- injector.getInstance(PropertyAttributeExtractor.class);
+ PropertyAttributeExtractor extractor = injector.getInstance(PropertyAttributeExtractor.class);
Set<Property> actual = extractor.extractFrom(changeAttribute);
@@ -251,76 +225,61 @@
changeAttribute.commitMessage = "Commit Message";
Property propertyProject = createMock(Property.class);
- expect(propertyFactory.create("project", "testProject"))
- .andReturn(propertyProject);
+ expect(propertyFactory.create("project", "testProject")).andReturn(propertyProject);
Property propertyBranch = createMock(Property.class);
- expect(propertyFactory.create("branch", "testBranch"))
- .andReturn(propertyBranch);
+ expect(propertyFactory.create("branch", "testBranch")).andReturn(propertyBranch);
Property propertyTopic = createMock(Property.class);
- expect(propertyFactory.create("topic", "testTopic"))
- .andReturn(propertyTopic);
+ expect(propertyFactory.create("topic", "testTopic")).andReturn(propertyTopic);
Property propertySubject = createMock(Property.class);
- expect(propertyFactory.create("subject", "testSubject"))
- .andReturn(propertySubject);
+ expect(propertyFactory.create("subject", "testSubject")).andReturn(propertySubject);
Property propertyId = createMock(Property.class);
- expect(propertyFactory.create("changeId", "testId"))
- .andReturn(propertyId);
+ expect(propertyFactory.create("changeId", "testId")).andReturn(propertyId);
Property propertyNumber = createMock(Property.class);
- expect(propertyFactory.create("changeNumber", "4711"))
- .andReturn(propertyNumber);
+ expect(propertyFactory.create("changeNumber", "4711")).andReturn(propertyNumber);
Property propertyUrl = createMock(Property.class);
expect(propertyFactory.create("changeUrl", "http://www.example.org/test"))
.andReturn(propertyUrl);
Property propertyId2 = createMock(Property.class);
- expect(propertyFactory.create("change-id", "testId"))
- .andReturn(propertyId2);
+ expect(propertyFactory.create("change-id", "testId")).andReturn(propertyId2);
Property propertyNumber2 = createMock(Property.class);
- expect(propertyFactory.create("change-number", "4711"))
- .andReturn(propertyNumber2);
+ expect(propertyFactory.create("change-number", "4711")).andReturn(propertyNumber2);
Property propertyUrl2 = createMock(Property.class);
expect(propertyFactory.create("change-url", "http://www.example.org/test"))
.andReturn(propertyUrl2);
Property propertyStatus = createMock(Property.class);
- expect(propertyFactory.create("status", "ABANDONED"))
- .andReturn(propertyStatus);
+ expect(propertyFactory.create("status", "ABANDONED")).andReturn(propertyStatus);
- Property propertyEmail= createMock(Property.class);
- expect(propertyFactory.create("ownerEmail", "testEmail"))
- .andReturn(propertyEmail);
+ Property propertyEmail = createMock(Property.class);
+ expect(propertyFactory.create("ownerEmail", "testEmail")).andReturn(propertyEmail);
Property propertyName = createMock(Property.class);
- expect(propertyFactory.create("ownerName", "testName"))
- .andReturn(propertyName);
+ expect(propertyFactory.create("ownerName", "testName")).andReturn(propertyName);
Property propertyUsername = createMock(Property.class);
- expect(propertyFactory.create("ownerUsername", "testUsername"))
- .andReturn(propertyUsername);
+ expect(propertyFactory.create("ownerUsername", "testUsername")).andReturn(propertyUsername);
Property propertyCommitMessage = createMock(Property.class);
expect(propertyFactory.create("commitMessage", "Commit Message"))
.andReturn(propertyCommitMessage);
- Property propertyEmail2= createMock(Property.class);
- expect(propertyFactory.create("owner-email", "testEmail"))
- .andReturn(propertyEmail2);
+ Property propertyEmail2 = createMock(Property.class);
+ expect(propertyFactory.create("owner-email", "testEmail")).andReturn(propertyEmail2);
Property propertyName2 = createMock(Property.class);
- expect(propertyFactory.create("owner-name", "testName"))
- .andReturn(propertyName2);
+ expect(propertyFactory.create("owner-name", "testName")).andReturn(propertyName2);
Property propertyUsername2 = createMock(Property.class);
- expect(propertyFactory.create("owner-username", "testUsername"))
- .andReturn(propertyUsername2);
+ expect(propertyFactory.create("owner-username", "testUsername")).andReturn(propertyUsername2);
Property propertyCommitMessage2 = createMock(Property.class);
expect(propertyFactory.create("commit-message", "Commit Message"))
@@ -333,11 +292,9 @@
expect(facade.createLinkForWebui("http://www.example.org/test", "http://www.example.org/test"))
.andReturn("http://www.example.org/test");
-
replayMocks();
- PropertyAttributeExtractor extractor =
- injector.getInstance(PropertyAttributeExtractor.class);
+ PropertyAttributeExtractor extractor = injector.getInstance(PropertyAttributeExtractor.class);
Set<Property> actual = extractor.extractFrom(changeAttribute);
@@ -389,57 +346,44 @@
patchSetAttribute.author = author;
Property propertyRevision = createMock(Property.class);
- expect(propertyFactory.create("revision",
- "1234567891123456789212345678931234567894"))
+ expect(propertyFactory.create("revision", "1234567891123456789212345678931234567894"))
.andReturn(propertyRevision);
Property propertyNumber = createMock(Property.class);
- expect(propertyFactory.create("patchSetNumber", "42"))
- .andReturn(propertyNumber);
+ expect(propertyFactory.create("patchSetNumber", "42")).andReturn(propertyNumber);
Property propertyNumber2 = createMock(Property.class);
- expect(propertyFactory.create("patch-set-number", "42"))
- .andReturn(propertyNumber2);
+ expect(propertyFactory.create("patch-set-number", "42")).andReturn(propertyNumber2);
Property propertyRef = createMock(Property.class);
- expect(propertyFactory.create("ref", "testRef"))
- .andReturn(propertyRef);
+ expect(propertyFactory.create("ref", "testRef")).andReturn(propertyRef);
Property propertyCreatedOn = createMock(Property.class);
- expect(propertyFactory.create("createdOn", "1234567890"))
- .andReturn(propertyCreatedOn);
+ expect(propertyFactory.create("createdOn", "1234567890")).andReturn(propertyCreatedOn);
Property propertyCreatedOn2 = createMock(Property.class);
- expect(propertyFactory.create("created-on", "1234567890"))
- .andReturn(propertyCreatedOn2);
+ expect(propertyFactory.create("created-on", "1234567890")).andReturn(propertyCreatedOn2);
Property propertyParents = createMock(Property.class);
- expect(propertyFactory.create("parents", "[parent1, parent2]"))
- .andReturn(propertyParents);
+ expect(propertyFactory.create("parents", "[parent1, parent2]")).andReturn(propertyParents);
Property propertyDeletions = createMock(Property.class);
- expect(propertyFactory.create("deletions", "7"))
- .andReturn(propertyDeletions);
+ expect(propertyFactory.create("deletions", "7")).andReturn(propertyDeletions);
Property propertyInsertions = createMock(Property.class);
- expect(propertyFactory.create("insertions", "12"))
- .andReturn(propertyInsertions);
+ expect(propertyFactory.create("insertions", "12")).andReturn(propertyInsertions);
- Property propertyIsDraft= createMock(Property.class);
- expect(propertyFactory.create("is-draft", "true"))
- .andReturn(propertyIsDraft);
+ Property propertyIsDraft = createMock(Property.class);
+ expect(propertyFactory.create("is-draft", "true")).andReturn(propertyIsDraft);
- Property propertyIsDraft2= createMock(Property.class);
- expect(propertyFactory.create("isDraft", "true"))
- .andReturn(propertyIsDraft2);
+ Property propertyIsDraft2 = createMock(Property.class);
+ expect(propertyFactory.create("isDraft", "true")).andReturn(propertyIsDraft2);
Property propertyUploaderEmail = createMock(Property.class);
- expect(propertyFactory.create("uploaderEmail", "testEmail1"))
- .andReturn(propertyUploaderEmail);
+ expect(propertyFactory.create("uploaderEmail", "testEmail1")).andReturn(propertyUploaderEmail);
Property propertyUploaderName = createMock(Property.class);
- expect(propertyFactory.create("uploaderName", "testName1"))
- .andReturn(propertyUploaderName);
+ expect(propertyFactory.create("uploaderName", "testName1")).andReturn(propertyUploaderName);
Property propertyUploaderUsername = createMock(Property.class);
expect(propertyFactory.create("uploaderUsername", "testUsername1"))
@@ -450,42 +394,35 @@
.andReturn(propertyUploaderEmail2);
Property propertyUploaderName2 = createMock(Property.class);
- expect(propertyFactory.create("uploader-name", "testName1"))
- .andReturn(propertyUploaderName2);
+ expect(propertyFactory.create("uploader-name", "testName1")).andReturn(propertyUploaderName2);
Property propertyUploaderUsername2 = createMock(Property.class);
expect(propertyFactory.create("uploader-username", "testUsername1"))
.andReturn(propertyUploaderUsername2);
Property propertyAuthorEmail = createMock(Property.class);
- expect(propertyFactory.create("authorEmail", "testEmail2"))
- .andReturn(propertyAuthorEmail);
+ expect(propertyFactory.create("authorEmail", "testEmail2")).andReturn(propertyAuthorEmail);
Property propertyAuthorName = createMock(Property.class);
- expect(propertyFactory.create("authorName", "testName2"))
- .andReturn(propertyAuthorName);
+ expect(propertyFactory.create("authorName", "testName2")).andReturn(propertyAuthorName);
Property propertyAuthorUsername = createMock(Property.class);
expect(propertyFactory.create("authorUsername", "testUsername2"))
.andReturn(propertyAuthorUsername);
Property propertyAuthorEmail2 = createMock(Property.class);
- expect(propertyFactory.create("author-email", "testEmail2"))
- .andReturn(propertyAuthorEmail2);
+ expect(propertyFactory.create("author-email", "testEmail2")).andReturn(propertyAuthorEmail2);
Property propertyAuthorName2 = createMock(Property.class);
- expect(propertyFactory.create("author-name", "testName2"))
- .andReturn(propertyAuthorName2);
+ expect(propertyFactory.create("author-name", "testName2")).andReturn(propertyAuthorName2);
Property propertyAuthorUsername2 = createMock(Property.class);
expect(propertyFactory.create("author-username", "testUsername2"))
.andReturn(propertyAuthorUsername2);
-
replayMocks();
- PropertyAttributeExtractor extractor =
- injector.getInstance(PropertyAttributeExtractor.class);
+ PropertyAttributeExtractor extractor = injector.getInstance(PropertyAttributeExtractor.class);
Set<Property> actual = extractor.extractFrom(patchSetAttribute);
@@ -524,32 +461,26 @@
refUpdateAttribute.refName = "testRef";
Property propertyRevision = createMock(Property.class);
- expect(propertyFactory.create("revision",
- "1234567891123456789212345678931234567894"))
+ expect(propertyFactory.create("revision", "1234567891123456789212345678931234567894"))
.andReturn(propertyRevision);
Property propertyRevisionOld = createMock(Property.class);
- expect(propertyFactory.create("revisionOld",
- "9876543211987654321298765432139876543214"))
+ expect(propertyFactory.create("revisionOld", "9876543211987654321298765432139876543214"))
.andReturn(propertyRevisionOld);
Property propertyRevisionOld2 = createMock(Property.class);
- expect(propertyFactory.create("revision-old",
- "9876543211987654321298765432139876543214"))
+ expect(propertyFactory.create("revision-old", "9876543211987654321298765432139876543214"))
.andReturn(propertyRevisionOld2);
Property propertyProject = createMock(Property.class);
- expect(propertyFactory.create("project", "testProject"))
- .andReturn(propertyProject);
+ expect(propertyFactory.create("project", "testProject")).andReturn(propertyProject);
Property propertyRef = createMock(Property.class);
- expect(propertyFactory.create("ref", "testRef"))
- .andReturn(propertyRef);
+ expect(propertyFactory.create("ref", "testRef")).andReturn(propertyRef);
replayMocks();
- PropertyAttributeExtractor extractor =
- injector.getInstance(PropertyAttributeExtractor.class);
+ PropertyAttributeExtractor extractor = injector.getInstance(PropertyAttributeExtractor.class);
Set<Property> actual = extractor.extractFrom(refUpdateAttribute);
@@ -568,18 +499,14 @@
approvalAttribute.value = "TestValue";
Property propertyApproval = createMock(Property.class);
- expect(propertyFactory.create("approvalTestType", "TestValue"))
- .andReturn(propertyApproval);
+ expect(propertyFactory.create("approvalTestType", "TestValue")).andReturn(propertyApproval);
Property propertyApproval2 = createMock(Property.class);
- expect(propertyFactory.create("approval-TestType", "TestValue"))
- .andReturn(propertyApproval2);
-
+ expect(propertyFactory.create("approval-TestType", "TestValue")).andReturn(propertyApproval2);
replayMocks();
- PropertyAttributeExtractor extractor =
- injector.getInstance(PropertyAttributeExtractor.class);
+ PropertyAttributeExtractor extractor = injector.getInstance(PropertyAttributeExtractor.class);
Set<Property> actual = extractor.extractFrom(approvalAttribute);
@@ -595,18 +522,14 @@
approvalAttribute.value = "TestValue";
Property propertyApproval = createMock(Property.class);
- expect(propertyFactory.create("approvalTestType", "TestValue"))
- .andReturn(propertyApproval);
+ expect(propertyFactory.create("approvalTestType", "TestValue")).andReturn(propertyApproval);
Property propertyApproval2 = createMock(Property.class);
- expect(propertyFactory.create("approval-Test-Type", "TestValue"))
- .andReturn(propertyApproval2);
-
+ expect(propertyFactory.create("approval-Test-Type", "TestValue")).andReturn(propertyApproval2);
replayMocks();
- PropertyAttributeExtractor extractor =
- injector.getInstance(PropertyAttributeExtractor.class);
+ PropertyAttributeExtractor extractor = injector.getInstance(PropertyAttributeExtractor.class);
Set<Property> actual = extractor.extractFrom(approvalAttribute);
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/util/PropertyExtractorTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/util/PropertyExtractorTest.java
index 4561b42..52b689e 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/util/PropertyExtractorTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/util/PropertyExtractorTest.java
@@ -37,10 +37,8 @@
import com.google.gerrit.server.events.RefUpdatedEvent;
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.base.workflow.Property;
-
import java.util.HashMap;
import java.util.Set;
@@ -52,26 +50,26 @@
private PropertyAttributeExtractor propertyAttributeExtractor;
public void testDummyChangeEvent() {
- PropertyExtractor propertyExtractor = injector.getInstance(
- PropertyExtractor.class);
+ PropertyExtractor propertyExtractor = injector.getInstance(PropertyExtractor.class);
Property property1 = createMock(Property.class);
- expect(propertyFactory.create("event", "com.googlesource.gerrit.plugins." +
- "its.base.util.PropertyExtractorTest$DummyEvent"))
+ expect(
+ propertyFactory.create(
+ "event",
+ "com.googlesource.gerrit.plugins."
+ + "its.base.util.PropertyExtractorTest$DummyEvent"))
.andReturn(property1);
replayMocks();
- Set<Set<Property>> actual = propertyExtractor.extractFrom(
- new DummyEvent());
+ Set<Set<Property>> actual = propertyExtractor.extractFrom(new DummyEvent());
Set<Set<Property>> expected = Sets.newHashSet();
assertEquals("Properties do not match", expected, actual);
}
public void testChangeAbandonedEvent() {
- ChangeAbandonedEvent event =
- new ChangeAbandonedEvent(testChange("testProject", "testBranch"));
+ ChangeAbandonedEvent event = new ChangeAbandonedEvent(testChange("testProject", "testBranch"));
ChangeAttribute changeAttribute = createMock(ChangeAttribute.class);
event.change = Suppliers.ofInstance(changeAttribute);
@@ -80,10 +78,10 @@
.andReturn(Sets.newHashSet(propertyChange));
AccountAttribute accountAttribute = createMock(AccountAttribute.class);
- event.abandoner= Suppliers.ofInstance(accountAttribute);
+ event.abandoner = Suppliers.ofInstance(accountAttribute);
Property propertySubmitter = createMock(Property.class);
- expect(propertyAttributeExtractor.extractFrom(accountAttribute,
- "abandoner")).andReturn(Sets.newHashSet(propertySubmitter));
+ expect(propertyAttributeExtractor.extractFrom(accountAttribute, "abandoner"))
+ .andReturn(Sets.newHashSet(propertySubmitter));
PatchSetAttribute patchSetAttribute = createMock(PatchSetAttribute.class);
event.patchSet = Suppliers.ofInstance(patchSetAttribute);
@@ -93,8 +91,7 @@
event.reason = "testReason";
Property propertyReason = createMock(Property.class);
- expect(propertyFactory.create("reason", "testReason"))
- .andReturn(propertyReason);
+ expect(propertyFactory.create("reason", "testReason")).andReturn(propertyReason);
changeAttribute.project = "testProject";
changeAttribute.number = 176;
@@ -107,13 +104,11 @@
common.add(propertyPatchSet);
common.add(propertyReason);
- eventHelper(event, "ChangeAbandonedEvent", "change-abandoned", common,
- true);
+ eventHelper(event, "ChangeAbandonedEvent", "change-abandoned", common, true);
}
public void testChangeMergedEvent() {
- ChangeMergedEvent event =
- new ChangeMergedEvent(testChange("testProject", "testBranch"));
+ ChangeMergedEvent event = new ChangeMergedEvent(testChange("testProject", "testBranch"));
ChangeAttribute changeAttribute = createMock(ChangeAttribute.class);
event.change = Suppliers.ofInstance(changeAttribute);
@@ -124,8 +119,8 @@
AccountAttribute accountAttribute = createMock(AccountAttribute.class);
event.submitter = Suppliers.ofInstance(accountAttribute);
Property propertySubmitter = createMock(Property.class);
- expect(propertyAttributeExtractor.extractFrom(accountAttribute,
- "submitter")).andReturn(Sets.newHashSet(propertySubmitter));
+ expect(propertyAttributeExtractor.extractFrom(accountAttribute, "submitter"))
+ .andReturn(Sets.newHashSet(propertySubmitter));
PatchSetAttribute patchSetAttribute = createMock(PatchSetAttribute.class);
event.patchSet = Suppliers.ofInstance(patchSetAttribute);
@@ -147,8 +142,7 @@
}
public void testChangeRestoredEvent() {
- ChangeRestoredEvent event =
- new ChangeRestoredEvent(testChange("testProject", "testBranch"));
+ ChangeRestoredEvent event = new ChangeRestoredEvent(testChange("testProject", "testBranch"));
ChangeAttribute changeAttribute = createMock(ChangeAttribute.class);
event.change = Suppliers.ofInstance(changeAttribute);
@@ -159,8 +153,8 @@
AccountAttribute accountAttribute = createMock(AccountAttribute.class);
event.restorer = Suppliers.ofInstance(accountAttribute);
Property propertySubmitter = createMock(Property.class);
- expect(propertyAttributeExtractor.extractFrom(accountAttribute,
- "restorer")).andReturn(Sets.newHashSet(propertySubmitter));
+ expect(propertyAttributeExtractor.extractFrom(accountAttribute, "restorer"))
+ .andReturn(Sets.newHashSet(propertySubmitter));
PatchSetAttribute patchSetAttribute = createMock(PatchSetAttribute.class);
event.patchSet = Suppliers.ofInstance(patchSetAttribute);
@@ -170,8 +164,7 @@
event.reason = "testReason";
Property propertyReason = createMock(Property.class);
- expect(propertyFactory.create("reason", "testReason"))
- .andReturn(propertyReason);
+ expect(propertyFactory.create("reason", "testReason")).andReturn(propertyReason);
changeAttribute.project = "testProject";
changeAttribute.number = 176;
@@ -188,8 +181,7 @@
}
public void testCommentAddedEventWOApprovals() {
- CommentAddedEvent event =
- new CommentAddedEvent(testChange("testProject", "testBranch"));
+ CommentAddedEvent event = new CommentAddedEvent(testChange("testProject", "testBranch"));
ChangeAttribute changeAttribute = createMock(ChangeAttribute.class);
event.change = Suppliers.ofInstance(changeAttribute);
@@ -200,8 +192,8 @@
AccountAttribute accountAttribute = createMock(AccountAttribute.class);
event.author = Suppliers.ofInstance(accountAttribute);
Property propertySubmitter = createMock(Property.class);
- expect(propertyAttributeExtractor.extractFrom(accountAttribute,
- "commenter")).andReturn(Sets.newHashSet(propertySubmitter));
+ expect(propertyAttributeExtractor.extractFrom(accountAttribute, "commenter"))
+ .andReturn(Sets.newHashSet(propertySubmitter));
PatchSetAttribute patchSetAttribute = createMock(PatchSetAttribute.class);
event.patchSet = Suppliers.ofInstance(patchSetAttribute);
@@ -211,8 +203,7 @@
event.comment = "testComment";
Property propertyComment = createMock(Property.class);
- expect(propertyFactory.create("comment", "testComment"))
- .andReturn(propertyComment);
+ expect(propertyFactory.create("comment", "testComment")).andReturn(propertyComment);
changeAttribute.project = "testProject";
changeAttribute.number = 176;
@@ -229,8 +220,7 @@
}
public void testCommentAddedEventWApprovals() {
- CommentAddedEvent event =
- new CommentAddedEvent(testChange("testProject", "testBranch"));
+ CommentAddedEvent event = new CommentAddedEvent(testChange("testProject", "testBranch"));
ChangeAttribute changeAttribute = createMock(ChangeAttribute.class);
event.change = Suppliers.ofInstance(changeAttribute);
@@ -241,8 +231,8 @@
AccountAttribute accountAttribute = createMock(AccountAttribute.class);
event.author = Suppliers.ofInstance(accountAttribute);
Property propertySubmitter = createMock(Property.class);
- expect(propertyAttributeExtractor.extractFrom(accountAttribute,
- "commenter")).andReturn(Sets.newHashSet(propertySubmitter));
+ expect(propertyAttributeExtractor.extractFrom(accountAttribute, "commenter"))
+ .andReturn(Sets.newHashSet(propertySubmitter));
PatchSetAttribute patchSetAttribute = createMock(PatchSetAttribute.class);
event.patchSet = Suppliers.ofInstance(patchSetAttribute);
@@ -258,14 +248,12 @@
Property propertyApproval2 = createMock(Property.class);
expect(propertyAttributeExtractor.extractFrom(approvalAttribute2))
.andReturn(Sets.newHashSet(propertyApproval2));
- ApprovalAttribute approvalAttributes[] = { approvalAttribute1,
- approvalAttribute2 };
+ ApprovalAttribute approvalAttributes[] = {approvalAttribute1, approvalAttribute2};
event.approvals = Suppliers.ofInstance(approvalAttributes);
event.comment = "testComment";
Property propertyComment = createMock(Property.class);
- expect(propertyFactory.create("comment", "testComment"))
- .andReturn(propertyComment);
+ expect(propertyFactory.create("comment", "testComment")).andReturn(propertyComment);
changeAttribute.project = "testProject";
changeAttribute.number = 176;
@@ -284,8 +272,7 @@
}
public void testDraftPublishedEvent() {
- DraftPublishedEvent event =
- new DraftPublishedEvent(testChange("testProject", "testBranch"));
+ DraftPublishedEvent event = new DraftPublishedEvent(testChange("testProject", "testBranch"));
ChangeAttribute changeAttribute = createMock(ChangeAttribute.class);
event.change = Suppliers.ofInstance(changeAttribute);
@@ -296,8 +283,8 @@
AccountAttribute accountAttribute = createMock(AccountAttribute.class);
event.uploader = Suppliers.ofInstance(accountAttribute);
Property propertySubmitter = createMock(Property.class);
- expect(propertyAttributeExtractor.extractFrom(accountAttribute,
- "uploader")).andReturn(Sets.newHashSet(propertySubmitter));
+ expect(propertyAttributeExtractor.extractFrom(accountAttribute, "uploader"))
+ .andReturn(Sets.newHashSet(propertySubmitter));
PatchSetAttribute patchSetAttribute = createMock(PatchSetAttribute.class);
event.patchSet = Suppliers.ofInstance(patchSetAttribute);
@@ -315,13 +302,11 @@
common.add(propertySubmitter);
common.add(propertyPatchSet);
- eventHelper(event, "DraftPublishedEvent", "draft-published", common,
- true);
+ eventHelper(event, "DraftPublishedEvent", "draft-published", common, true);
}
public void testPatchSetCreatedEvent() {
- PatchSetCreatedEvent event =
- new PatchSetCreatedEvent(testChange("testProject", "testBranch"));
+ PatchSetCreatedEvent event = new PatchSetCreatedEvent(testChange("testProject", "testBranch"));
ChangeAttribute changeAttribute = createMock(ChangeAttribute.class);
event.change = Suppliers.ofInstance(changeAttribute);
@@ -332,8 +317,8 @@
AccountAttribute accountAttribute = createMock(AccountAttribute.class);
event.uploader = Suppliers.ofInstance(accountAttribute);
Property propertySubmitter = createMock(Property.class);
- expect(propertyAttributeExtractor.extractFrom(accountAttribute,
- "uploader")).andReturn(Sets.newHashSet(propertySubmitter));
+ expect(propertyAttributeExtractor.extractFrom(accountAttribute, "uploader"))
+ .andReturn(Sets.newHashSet(propertySubmitter));
PatchSetAttribute patchSetAttribute = createMock(PatchSetAttribute.class);
event.patchSet = Suppliers.ofInstance(patchSetAttribute);
@@ -351,8 +336,7 @@
common.add(propertySubmitter);
common.add(propertyPatchSet);
- eventHelper(event, "PatchSetCreatedEvent", "patchset-created", common,
- true);
+ eventHelper(event, "PatchSetCreatedEvent", "patchset-created", common, true);
}
public void testRefUpdatedEvent() {
@@ -361,11 +345,10 @@
AccountAttribute accountAttribute = createMock(AccountAttribute.class);
event.submitter = Suppliers.ofInstance(accountAttribute);
Property propertySubmitter = createMock(Property.class);
- expect(propertyAttributeExtractor.extractFrom(accountAttribute,
- "submitter")).andReturn(Sets.newHashSet(propertySubmitter));
+ expect(propertyAttributeExtractor.extractFrom(accountAttribute, "submitter"))
+ .andReturn(Sets.newHashSet(propertySubmitter));
- RefUpdateAttribute refUpdateAttribute =
- createMock(RefUpdateAttribute.class);
+ RefUpdateAttribute refUpdateAttribute = createMock(RefUpdateAttribute.class);
event.refUpdate = Suppliers.ofInstance(refUpdateAttribute);
Property propertyRefUpdated = createMock(Property.class);
expect(propertyAttributeExtractor.extractFrom(refUpdateAttribute))
@@ -381,53 +364,46 @@
eventHelper(event, "RefUpdatedEvent", "ref-updated", common, false);
}
- private void eventHelper(Event event, String className, String type,
- Set<Property> common, boolean withRevision) {
- PropertyExtractor propertyExtractor = injector.getInstance(
- PropertyExtractor.class);
+ private void eventHelper(
+ Event event, String className, String type, Set<Property> common, boolean withRevision) {
+ PropertyExtractor propertyExtractor = injector.getInstance(PropertyExtractor.class);
Property propertyItsName = createMock(Property.class);
- expect(propertyFactory.create("its-name", "ItsTestName"))
- .andReturn(propertyItsName).anyTimes();
+ expect(propertyFactory.create("its-name", "ItsTestName")).andReturn(propertyItsName).anyTimes();
Property propertyEvent = createMock(Property.class);
- expect(propertyFactory.create("event", "com.google.gerrit.server.events." +
- className)).andReturn(propertyEvent);
+ expect(propertyFactory.create("event", "com.google.gerrit.server.events." + className))
+ .andReturn(propertyEvent);
Property propertyEventType = createMock(Property.class);
- expect(propertyFactory.create("event-type", type))
- .andReturn(propertyEventType);
+ expect(propertyFactory.create("event-type", type)).andReturn(propertyEventType);
Property propertyAssociationFooter = createMock(Property.class);
- expect(propertyFactory.create("association", "footer"))
- .andReturn(propertyAssociationFooter);
+ expect(propertyFactory.create("association", "footer")).andReturn(propertyAssociationFooter);
Property propertyAssociationAnywhere = createMock(Property.class);
expect(propertyFactory.create("association", "anywhere"))
- .andReturn(propertyAssociationAnywhere).times(2);
+ .andReturn(propertyAssociationAnywhere)
+ .times(2);
Property propertyAssociationBody = createMock(Property.class);
- expect(propertyFactory.create("association", "body"))
- .andReturn(propertyAssociationBody);
+ expect(propertyFactory.create("association", "body")).andReturn(propertyAssociationBody);
Property propertyIssue42 = createMock(Property.class);
- expect(propertyFactory.create("issue", "42"))
- .andReturn(propertyIssue42);
+ expect(propertyFactory.create("issue", "42")).andReturn(propertyIssue42);
Property propertyIssue4711 = createMock(Property.class);
- expect(propertyFactory.create("issue", "4711"))
- .andReturn(propertyIssue4711);
+ expect(propertyFactory.create("issue", "4711")).andReturn(propertyIssue4711);
- HashMap<String,Set<String>> issueMap = Maps.newHashMap();
+ HashMap<String, Set<String>> issueMap = Maps.newHashMap();
issueMap.put("4711", Sets.newHashSet("body", "anywhere"));
issueMap.put("42", Sets.newHashSet("footer", "anywhere"));
if (withRevision) {
PatchSet.Id patchSetId = new PatchSet.Id(new Change.Id(176), 3);
- expect(issueExtractor.getIssueIds("testProject", "testRevision",
- patchSetId)).andReturn(issueMap);
+ expect(issueExtractor.getIssueIds("testProject", "testRevision", patchSetId))
+ .andReturn(issueMap);
} else {
- expect(issueExtractor.getIssueIds("testProject", "testRevision"))
- .andReturn(issueMap);
+ expect(issueExtractor.getIssueIds("testProject", "testRevision")).andReturn(issueMap);
}
replayMocks();
@@ -466,15 +442,13 @@
private class TestModule extends FactoryModule {
@Override
protected void configure() {
- bind(String.class).annotatedWith(PluginName.class)
- .toInstance("ItsTestName");
+ bind(String.class).annotatedWith(PluginName.class).toInstance("ItsTestName");
issueExtractor = createMock(IssueExtractor.class);
bind(IssueExtractor.class).toInstance(issueExtractor);
propertyAttributeExtractor = createMock(PropertyAttributeExtractor.class);
- bind(PropertyAttributeExtractor.class).toInstance(
- propertyAttributeExtractor);
+ bind(PropertyAttributeExtractor.class).toInstance(propertyAttributeExtractor);
propertyFactory = createMock(Property.Factory.class);
bind(Property.Factory.class).toInstance(propertyFactory);
@@ -487,4 +461,4 @@
super(null);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/validation/ItsValidateCommentTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/validation/ItsValidateCommentTest.java
index ea38875..5573878 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/validation/ItsValidateCommentTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/validation/ItsValidateCommentTest.java
@@ -24,22 +24,19 @@
import com.google.gerrit.server.git.validators.CommitValidationMessage;
import com.google.inject.Guice;
import com.google.inject.Injector;
-
import com.googlesource.gerrit.plugins.its.base.its.ItsConfig;
import com.googlesource.gerrit.plugins.its.base.its.ItsFacade;
import com.googlesource.gerrit.plugins.its.base.testutil.LoggingMockingTestCase;
import com.googlesource.gerrit.plugins.its.base.util.IssueExtractor;
-
+import java.io.IOException;
+import java.util.List;
+import java.util.regex.Pattern;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.transport.ReceiveCommand;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
-import java.io.IOException;
-import java.util.List;
-import java.util.regex.Pattern;
-
@RunWith(PowerMockRunner.class)
@PrepareForTest({RevCommit.class})
public class ItsValidateCommentTest extends LoggingMockingTestCase {
@@ -55,11 +52,11 @@
ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
ReceiveCommand command = createMock(ReceiveCommand.class);
RevCommit commit = createMock(RevCommit.class);
- CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
- commit, null);
+ CommitReceivedEvent event = newCommitReceivedEvent(command, project, null, commit, null);
expect(itsConfig.getItsAssociationPolicy())
- .andReturn(ItsAssociationPolicy.OPTIONAL).atLeastOnce();
+ .andReturn(ItsAssociationPolicy.OPTIONAL)
+ .atLeastOnce();
replayMocks();
@@ -73,41 +70,39 @@
ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
ReceiveCommand command = createMock(ReceiveCommand.class);
RevCommit commit = createMock(RevCommit.class);
- CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
- commit, null);
+ CommitReceivedEvent event = newCommitReceivedEvent(command, project, null, commit, null);
expect(itsConfig.getItsAssociationPolicy())
- .andReturn(ItsAssociationPolicy.SUGGESTED).atLeastOnce();
+ .andReturn(ItsAssociationPolicy.SUGGESTED)
+ .atLeastOnce();
expect(commit.getFullMessage()).andReturn("TestMessage").atLeastOnce();
expect(commit.getId()).andReturn(commit).anyTimes();
expect(commit.getName()).andReturn("TestCommit").anyTimes();
- expect(issueExtractor.getIssueIds("TestMessage")).andReturn(
- new String[] {}).atLeastOnce();
+ expect(issueExtractor.getIssueIds("TestMessage")).andReturn(new String[] {}).atLeastOnce();
replayMocks();
ret = ivc.onCommitReceived(event);
- assertEquals("Size of returned CommitValidationMessages does not match",
- 1, ret.size());
- assertTrue("First CommitValidationMessages does not contain 'Missing " +
- "issue'",ret.get(0).getMessage().contains("Missing issue"));
+ assertEquals("Size of returned CommitValidationMessages does not match", 1, ret.size());
+ assertTrue(
+ "First CommitValidationMessages does not contain 'Missing " + "issue'",
+ ret.get(0).getMessage().contains("Missing issue"));
}
public void testMandatoryNonMatching() {
ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
ReceiveCommand command = createMock(ReceiveCommand.class);
RevCommit commit = createMock(RevCommit.class);
- CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
- commit, null);
+ CommitReceivedEvent event = newCommitReceivedEvent(command, project, null, commit, null);
expect(itsConfig.getItsAssociationPolicy())
- .andReturn(ItsAssociationPolicy.MANDATORY).atLeastOnce();
+ .andReturn(ItsAssociationPolicy.MANDATORY)
+ .atLeastOnce();
expect(commit.getFullMessage()).andReturn("TestMessage").atLeastOnce();
expect(commit.getId()).andReturn(commit).anyTimes();
expect(commit.getName()).andReturn("TestCommit").anyTimes();
- expect(issueExtractor.getIssueIds("TestMessage")).andReturn(
- new String[] {}).atLeastOnce();
+ expect(issueExtractor.getIssueIds("TestMessage")).andReturn(new String[] {}).atLeastOnce();
replayMocks();
@@ -115,27 +110,25 @@
ivc.onCommitReceived(event);
fail("onCommitReceived did not throw any exception");
} catch (CommitValidationException e) {
- assertTrue("Message of thrown CommitValidationException does not "
- + "contain 'Missing issue'",
+ assertTrue(
+ "Message of thrown CommitValidationException does not " + "contain 'Missing issue'",
e.getMessage().contains("Missing issue"));
}
}
- public void testSuggestedMatchingSingleExisting()
- throws CommitValidationException, IOException {
+ public void testSuggestedMatchingSingleExisting() throws CommitValidationException, IOException {
List<CommitValidationMessage> ret;
ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
ReceiveCommand command = createMock(ReceiveCommand.class);
RevCommit commit = createMock(RevCommit.class);
- CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
- commit, null);
+ CommitReceivedEvent event = newCommitReceivedEvent(command, project, null, commit, null);
expect(itsConfig.getItsAssociationPolicy())
- .andReturn(ItsAssociationPolicy.SUGGESTED).atLeastOnce();
+ .andReturn(ItsAssociationPolicy.SUGGESTED)
+ .atLeastOnce();
expect(commit.getFullMessage()).andReturn("bug#4711").atLeastOnce();
expect(commit.getId()).andReturn(commit).anyTimes();
expect(commit.getName()).andReturn("TestCommit").anyTimes();
- expect(issueExtractor.getIssueIds("bug#4711")).andReturn(
- new String[] {"4711"}).atLeastOnce();
+ expect(issueExtractor.getIssueIds("bug#4711")).andReturn(new String[] {"4711"}).atLeastOnce();
expect(itsFacade.exists("4711")).andReturn(true).atLeastOnce();
replayMocks();
@@ -145,22 +138,20 @@
assertEmptyList(ret);
}
- public void testMandatoryMatchingSingleExisting()
- throws CommitValidationException, IOException {
+ public void testMandatoryMatchingSingleExisting() throws CommitValidationException, IOException {
List<CommitValidationMessage> ret;
ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
ReceiveCommand command = createMock(ReceiveCommand.class);
RevCommit commit = createMock(RevCommit.class);
- CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
- commit, null);
+ CommitReceivedEvent event = newCommitReceivedEvent(command, project, null, commit, null);
expect(itsConfig.getItsAssociationPolicy())
- .andReturn(ItsAssociationPolicy.MANDATORY).atLeastOnce();
+ .andReturn(ItsAssociationPolicy.MANDATORY)
+ .atLeastOnce();
expect(commit.getFullMessage()).andReturn("bug#4711").atLeastOnce();
expect(commit.getId()).andReturn(commit).anyTimes();
expect(commit.getName()).andReturn("TestCommit").anyTimes();
- expect(issueExtractor.getIssueIds("bug#4711")).andReturn(
- new String[] {"4711"}).atLeastOnce();
+ expect(issueExtractor.getIssueIds("bug#4711")).andReturn(new String[] {"4711"}).atLeastOnce();
expect(itsFacade.exists("4711")).andReturn(true).atLeastOnce();
replayMocks();
@@ -176,45 +167,43 @@
ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
ReceiveCommand command = createMock(ReceiveCommand.class);
RevCommit commit = createMock(RevCommit.class);
- CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
- commit, null);
+ CommitReceivedEvent event = newCommitReceivedEvent(command, project, null, commit, null);
expect(itsConfig.getItsAssociationPolicy())
- .andReturn(ItsAssociationPolicy.SUGGESTED).atLeastOnce();
+ .andReturn(ItsAssociationPolicy.SUGGESTED)
+ .atLeastOnce();
expect(commit.getFullMessage()).andReturn("bug#4711").atLeastOnce();
expect(commit.getId()).andReturn(commit).anyTimes();
expect(commit.getName()).andReturn("TestCommit").anyTimes();
- expect(issueExtractor.getIssueIds("bug#4711")).andReturn(
- new String[] {"4711"}).atLeastOnce();
+ expect(issueExtractor.getIssueIds("bug#4711")).andReturn(new String[] {"4711"}).atLeastOnce();
expect(itsFacade.exists("4711")).andReturn(false).atLeastOnce();
replayMocks();
ret = ivc.onCommitReceived(event);
- assertEquals("Size of returned CommitValidationMessages does not match",
- 1, ret.size());
- assertTrue("First CommitValidationMessages does not contain " +
- "'Non-existing'",ret.get(0).getMessage().contains("Non-existing"));
- assertTrue("First CommitValidationMessages does not contain '4711'",
+ assertEquals("Size of returned CommitValidationMessages does not match", 1, ret.size());
+ assertTrue(
+ "First CommitValidationMessages does not contain " + "'Non-existing'",
+ ret.get(0).getMessage().contains("Non-existing"));
+ assertTrue(
+ "First CommitValidationMessages does not contain '4711'",
ret.get(0).getMessage().contains("4711"));
}
- public void testMandatoryMatchingSingleNonExisting()
- throws IOException {
+ public void testMandatoryMatchingSingleNonExisting() throws IOException {
ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
ReceiveCommand command = createMock(ReceiveCommand.class);
RevCommit commit = createMock(RevCommit.class);
- CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
- commit, null);
+ CommitReceivedEvent event = newCommitReceivedEvent(command, project, null, commit, null);
expect(itsConfig.getItsAssociationPolicy())
- .andReturn(ItsAssociationPolicy.MANDATORY).atLeastOnce();
+ .andReturn(ItsAssociationPolicy.MANDATORY)
+ .atLeastOnce();
expect(commit.getFullMessage()).andReturn("bug#4711").atLeastOnce();
expect(commit.getId()).andReturn(commit).anyTimes();
expect(commit.getName()).andReturn("TestCommit").anyTimes();
- expect(issueExtractor.getIssueIds("bug#4711")).andReturn(
- new String[] {"4711"}).atLeastOnce();
+ expect(issueExtractor.getIssueIds("bug#4711")).andReturn(new String[] {"4711"}).atLeastOnce();
expect(itsFacade.exists("4711")).andReturn(false).atLeastOnce();
replayMocks();
@@ -223,28 +212,28 @@
ivc.onCommitReceived(event);
fail("onCommitReceived did not throw any exception");
} catch (CommitValidationException e) {
- assertTrue("Message of thrown CommitValidationException does not "
- + "contain 'Non-existing'", e.getMessage().contains("Non-existing"));
+ assertTrue(
+ "Message of thrown CommitValidationException does not " + "contain 'Non-existing'",
+ e.getMessage().contains("Non-existing"));
}
}
- public void testSuggestedMatchingMultiple()
- throws CommitValidationException, IOException {
+ public void testSuggestedMatchingMultiple() throws CommitValidationException, IOException {
List<CommitValidationMessage> ret;
ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
ReceiveCommand command = createMock(ReceiveCommand.class);
RevCommit commit = createMock(RevCommit.class);
- CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
- commit, null);
+ CommitReceivedEvent event = newCommitReceivedEvent(command, project, null, commit, null);
expect(itsConfig.getItsAssociationPolicy())
- .andReturn(ItsAssociationPolicy.SUGGESTED).atLeastOnce();
- expect(commit.getFullMessage()).andReturn("bug#4711, bug#42")
+ .andReturn(ItsAssociationPolicy.SUGGESTED)
.atLeastOnce();
+ expect(commit.getFullMessage()).andReturn("bug#4711, bug#42").atLeastOnce();
expect(commit.getId()).andReturn(commit).anyTimes();
expect(commit.getName()).andReturn("TestCommit").anyTimes();
- expect(issueExtractor.getIssueIds("bug#4711, bug#42")).andReturn(
- new String[] {"4711", "42"}).atLeastOnce();
+ expect(issueExtractor.getIssueIds("bug#4711, bug#42"))
+ .andReturn(new String[] {"4711", "42"})
+ .atLeastOnce();
expect(itsFacade.exists("4711")).andReturn(true).atLeastOnce();
expect(itsFacade.exists("42")).andReturn(true).atLeastOnce();
@@ -255,23 +244,22 @@
assertEmptyList(ret);
}
- public void testMandatoryMatchingMultiple()
- throws CommitValidationException, IOException {
+ public void testMandatoryMatchingMultiple() throws CommitValidationException, IOException {
List<CommitValidationMessage> ret;
ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
ReceiveCommand command = createMock(ReceiveCommand.class);
RevCommit commit = createMock(RevCommit.class);
- CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
- commit, null);
+ CommitReceivedEvent event = newCommitReceivedEvent(command, project, null, commit, null);
expect(itsConfig.getItsAssociationPolicy())
- .andReturn(ItsAssociationPolicy.MANDATORY).atLeastOnce();
- expect(commit.getFullMessage()).andReturn("bug#4711, bug#42")
+ .andReturn(ItsAssociationPolicy.MANDATORY)
.atLeastOnce();
+ expect(commit.getFullMessage()).andReturn("bug#4711, bug#42").atLeastOnce();
expect(commit.getId()).andReturn(commit).anyTimes();
expect(commit.getName()).andReturn("TestCommit").anyTimes();
- expect(issueExtractor.getIssueIds("bug#4711, bug#42")).andReturn(
- new String[] {"4711", "42"}).atLeastOnce();
+ expect(issueExtractor.getIssueIds("bug#4711, bug#42"))
+ .andReturn(new String[] {"4711", "42"})
+ .atLeastOnce();
expect(itsFacade.exists("4711")).andReturn(true).atLeastOnce();
expect(itsFacade.exists("42")).andReturn(true).atLeastOnce();
@@ -288,17 +276,17 @@
ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
ReceiveCommand command = createMock(ReceiveCommand.class);
RevCommit commit = createMock(RevCommit.class);
- CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
- commit, null);
+ CommitReceivedEvent event = newCommitReceivedEvent(command, project, null, commit, null);
expect(itsConfig.getItsAssociationPolicy())
- .andReturn(ItsAssociationPolicy.SUGGESTED).atLeastOnce();
- expect(commit.getFullMessage()).andReturn("bug#4711, bug#42")
+ .andReturn(ItsAssociationPolicy.SUGGESTED)
.atLeastOnce();
+ expect(commit.getFullMessage()).andReturn("bug#4711, bug#42").atLeastOnce();
expect(commit.getId()).andReturn(commit).anyTimes();
expect(commit.getName()).andReturn("TestCommit").anyTimes();
- expect(issueExtractor.getIssueIds("bug#4711, bug#42")).andReturn(
- new String[] {"4711", "42"}).atLeastOnce();
+ expect(issueExtractor.getIssueIds("bug#4711, bug#42"))
+ .andReturn(new String[] {"4711", "42"})
+ .atLeastOnce();
expect(itsFacade.exists("4711")).andReturn(false).atLeastOnce();
expect(itsFacade.exists("42")).andReturn(true).atLeastOnce();
@@ -306,32 +294,33 @@
ret = ivc.onCommitReceived(event);
- assertEquals("Size of returned CommitValidationMessages does not match",
- 1, ret.size());
- assertTrue("First CommitValidationMessages does not contain " +
- "'Non-existing'",ret.get(0).getMessage().contains("Non-existing"));
- assertTrue("First CommitValidationMessages does not contain '4711'",
+ assertEquals("Size of returned CommitValidationMessages does not match", 1, ret.size());
+ assertTrue(
+ "First CommitValidationMessages does not contain " + "'Non-existing'",
+ ret.get(0).getMessage().contains("Non-existing"));
+ assertTrue(
+ "First CommitValidationMessages does not contain '4711'",
ret.get(0).getMessage().contains("4711"));
- assertFalse("First CommitValidationMessages contains '42', although " +
- "that bug exists", ret.get(0).getMessage().contains("42"));
+ assertFalse(
+ "First CommitValidationMessages contains '42', although " + "that bug exists",
+ ret.get(0).getMessage().contains("42"));
}
- public void testMandatoryMatchingMultipleOneNonExsting()
- throws IOException {
+ public void testMandatoryMatchingMultipleOneNonExsting() throws IOException {
ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
ReceiveCommand command = createMock(ReceiveCommand.class);
RevCommit commit = createMock(RevCommit.class);
- CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
- commit, null);
+ CommitReceivedEvent event = newCommitReceivedEvent(command, project, null, commit, null);
expect(itsConfig.getItsAssociationPolicy())
- .andReturn(ItsAssociationPolicy.MANDATORY).atLeastOnce();
- expect(commit.getFullMessage()).andReturn("bug#4711, bug#42")
+ .andReturn(ItsAssociationPolicy.MANDATORY)
.atLeastOnce();
+ expect(commit.getFullMessage()).andReturn("bug#4711, bug#42").atLeastOnce();
expect(commit.getId()).andReturn(commit).anyTimes();
expect(commit.getName()).andReturn("TestCommit").anyTimes();
- expect(issueExtractor.getIssueIds("bug#4711, bug#42")).andReturn(
- new String[] {"4711", "42"}).atLeastOnce();
+ expect(issueExtractor.getIssueIds("bug#4711, bug#42"))
+ .andReturn(new String[] {"4711", "42"})
+ .atLeastOnce();
expect(itsFacade.exists("4711")).andReturn(false).atLeastOnce();
expect(itsFacade.exists("42")).andReturn(true).atLeastOnce();
@@ -341,8 +330,9 @@
ivc.onCommitReceived(event);
fail("onCommitReceived did not throw any exception");
} catch (CommitValidationException e) {
- assertTrue("Message of thrown CommitValidationException does not "
- + "contain 'Non-existing'", e.getMessage().contains("Non-existing"));
+ assertTrue(
+ "Message of thrown CommitValidationException does not " + "contain 'Non-existing'",
+ e.getMessage().contains("Non-existing"));
}
}
@@ -352,17 +342,17 @@
ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
ReceiveCommand command = createMock(ReceiveCommand.class);
RevCommit commit = createMock(RevCommit.class);
- CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
- commit, null);
+ CommitReceivedEvent event = newCommitReceivedEvent(command, project, null, commit, null);
expect(itsConfig.getItsAssociationPolicy())
- .andReturn(ItsAssociationPolicy.SUGGESTED).atLeastOnce();
- expect(commit.getFullMessage()).andReturn("bug#4711, bug#42")
+ .andReturn(ItsAssociationPolicy.SUGGESTED)
.atLeastOnce();
+ expect(commit.getFullMessage()).andReturn("bug#4711, bug#42").atLeastOnce();
expect(commit.getId()).andReturn(commit).anyTimes();
expect(commit.getName()).andReturn("TestCommit").anyTimes();
- expect(issueExtractor.getIssueIds("bug#4711, bug#42")).andReturn(
- new String[] {"4711", "42"}).atLeastOnce();
+ expect(issueExtractor.getIssueIds("bug#4711, bug#42"))
+ .andReturn(new String[] {"4711", "42"})
+ .atLeastOnce();
expect(itsFacade.exists("4711")).andReturn(false).atLeastOnce();
expect(itsFacade.exists("42")).andReturn(false).atLeastOnce();
@@ -370,32 +360,33 @@
ret = ivc.onCommitReceived(event);
- assertEquals("Size of returned CommitValidationMessages does not match",
- 1, ret.size());
- assertTrue("First CommitValidationMessages does not contain " +
- "'Non-existing'",ret.get(0).getMessage().contains("Non-existing"));
- assertTrue("First CommitValidationMessages does not contain '4711'",
+ assertEquals("Size of returned CommitValidationMessages does not match", 1, ret.size());
+ assertTrue(
+ "First CommitValidationMessages does not contain " + "'Non-existing'",
+ ret.get(0).getMessage().contains("Non-existing"));
+ assertTrue(
+ "First CommitValidationMessages does not contain '4711'",
ret.get(0).getMessage().contains("4711"));
- assertTrue("First CommitValidationMessages does not contain '42'",
+ assertTrue(
+ "First CommitValidationMessages does not contain '42'",
ret.get(0).getMessage().contains("42"));
}
- public void testMandatoryMatchingMultipleSomeNonExsting()
- throws IOException {
+ public void testMandatoryMatchingMultipleSomeNonExsting() throws IOException {
ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
ReceiveCommand command = createMock(ReceiveCommand.class);
RevCommit commit = createMock(RevCommit.class);
- CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
- commit, null);
+ CommitReceivedEvent event = newCommitReceivedEvent(command, project, null, commit, null);
expect(itsConfig.getItsAssociationPolicy())
- .andReturn(ItsAssociationPolicy.MANDATORY).atLeastOnce();
- expect(commit.getFullMessage()).andReturn("bug#4711, bug#42")
+ .andReturn(ItsAssociationPolicy.MANDATORY)
.atLeastOnce();
+ expect(commit.getFullMessage()).andReturn("bug#4711, bug#42").atLeastOnce();
expect(commit.getId()).andReturn(commit).anyTimes();
expect(commit.getName()).andReturn("TestCommit").anyTimes();
- expect(issueExtractor.getIssueIds("bug#4711, bug#42")).andReturn(
- new String[] {"4711", "42"}).atLeastOnce();
+ expect(issueExtractor.getIssueIds("bug#4711, bug#42"))
+ .andReturn(new String[] {"4711", "42"})
+ .atLeastOnce();
expect(itsFacade.exists("4711")).andReturn(false).atLeastOnce();
expect(itsFacade.exists("42")).andReturn(false).atLeastOnce();
@@ -405,8 +396,9 @@
ivc.onCommitReceived(event);
fail("onCommitReceived did not throw any exception");
} catch (CommitValidationException e) {
- assertTrue("Message of thrown CommitValidationException does not "
- + "contain 'Non-existing'", e.getMessage().contains("Non-existing"));
+ assertTrue(
+ "Message of thrown CommitValidationException does not " + "contain 'Non-existing'",
+ e.getMessage().contains("Non-existing"));
}
}
@@ -416,38 +408,42 @@
ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
ReceiveCommand command = createMock(ReceiveCommand.class);
RevCommit commit = createMock(RevCommit.class);
- CommitReceivedEvent event = newCommitReceivedEvent(command, project, null,
- commit, null);
+ CommitReceivedEvent event = newCommitReceivedEvent(command, project, null, commit, null);
expect(itsConfig.getItsAssociationPolicy())
- .andReturn(ItsAssociationPolicy.SUGGESTED).atLeastOnce();
- expect(commit.getFullMessage()).andReturn("bug#4711, bug#42")
+ .andReturn(ItsAssociationPolicy.SUGGESTED)
.atLeastOnce();
+ expect(commit.getFullMessage()).andReturn("bug#4711, bug#42").atLeastOnce();
expect(commit.getId()).andReturn(commit).anyTimes();
expect(commit.getName()).andReturn("TestCommit").anyTimes();
expect(issueExtractor.getIssueIds("bug#4711, bug#42"))
- .andReturn(new String[] {"4711", "42"}).atLeastOnce();
- expect(itsFacade.exists("4711")).andThrow(new IOException("InjectedEx1"))
+ .andReturn(new String[] {"4711", "42"})
.atLeastOnce();
+ expect(itsFacade.exists("4711")).andThrow(new IOException("InjectedEx1")).atLeastOnce();
expect(itsFacade.exists("42")).andReturn(false).atLeastOnce();
replayMocks();
ret = ivc.onCommitReceived(event);
- assertEquals("Size of returned CommitValidationMessages does not match",
- 2, ret.size());
- assertTrue("First CommitValidationMessages does not contain " +
- "'Failed'",ret.get(0).getMessage().contains("Failed"));
- assertTrue("First CommitValidationMessages does not contain '4711'",
+ assertEquals("Size of returned CommitValidationMessages does not match", 2, ret.size());
+ assertTrue(
+ "First CommitValidationMessages does not contain " + "'Failed'",
+ ret.get(0).getMessage().contains("Failed"));
+ assertTrue(
+ "First CommitValidationMessages does not contain '4711'",
ret.get(0).getMessage().contains("4711"));
- assertFalse("First CommitValidationMessages contains '42', although " +
- "that bug exists", ret.get(0).getMessage().contains("42"));
- assertTrue("Second CommitValidationMessages does not contain " +
- "'Non-existing'",ret.get(1).getMessage().contains("Non-existing"));
- assertTrue("Second CommitValidationMessages does not contain '4711'",
+ assertFalse(
+ "First CommitValidationMessages contains '42', although " + "that bug exists",
+ ret.get(0).getMessage().contains("42"));
+ assertTrue(
+ "Second CommitValidationMessages does not contain " + "'Non-existing'",
+ ret.get(1).getMessage().contains("Non-existing"));
+ assertTrue(
+ "Second CommitValidationMessages does not contain '4711'",
ret.get(1).getMessage().contains("4711"));
- assertTrue("Second CommitValidationMessages does not contain '42'",
+ assertTrue(
+ "Second CommitValidationMessages does not contain '42'",
ret.get(1).getMessage().contains("42"));
assertLogMessageContains("4711");
@@ -466,11 +462,9 @@
}
private void setupCommonMocks() {
- expect(itsConfig.getIssuePattern())
- .andReturn(Pattern.compile("bug#(\\d+)")).anyTimes();
+ expect(itsConfig.getIssuePattern()).andReturn(Pattern.compile("bug#(\\d+)")).anyTimes();
Project.NameKey projectNK = new Project.NameKey("myProject");
- expect(itsConfig.isEnabled(projectNK, null)).andReturn(true)
- .anyTimes();
+ expect(itsConfig.isEnabled(projectNK, null)).andReturn(true).anyTimes();
}
@Override
@@ -502,8 +496,7 @@
private class TestModule extends FactoryModule {
@Override
protected void configure() {
- bind(String.class).annotatedWith(PluginName.class)
- .toInstance("ItsTestName");
+ bind(String.class).annotatedWith(PluginName.class).toInstance("ItsTestName");
issueExtractor = createMock(IssueExtractor.class);
bind(IssueExtractor.class).toInstance(issueExtractor);
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/ActionControllerTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/ActionControllerTest.java
index e62184a..d2926f9 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/ActionControllerTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/ActionControllerTest.java
@@ -23,11 +23,9 @@
import com.google.gerrit.server.events.Event;
import com.google.inject.Guice;
import com.google.inject.Injector;
-
import com.googlesource.gerrit.plugins.its.base.its.ItsConfig;
import com.googlesource.gerrit.plugins.its.base.testutil.LoggingMockingTestCase;
import com.googlesource.gerrit.plugins.its.base.util.PropertyExtractor;
-
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
@@ -46,8 +44,7 @@
ChangeEvent event = createMock(ChangeEvent.class);
Set<Set<Property>> propertySets = Collections.emptySet();
- expect(propertyExtractor.extractFrom(event)).andReturn(propertySets)
- .anyTimes();
+ expect(propertyExtractor.extractFrom(event)).andReturn(propertySets).anyTimes();
replayMocks();
@@ -63,8 +60,7 @@
Set<Property> propertySet = Collections.emptySet();
propertySets.add(propertySet);
- expect(propertyExtractor.extractFrom(event)).andReturn(propertySets)
- .anyTimes();
+ expect(propertyExtractor.extractFrom(event)).andReturn(propertySets).anyTimes();
Collection<ActionRequest> actions = Collections.emptySet();
expect(ruleBase.actionRequestsFor(propertySet)).andReturn(actions).once();
@@ -83,8 +79,7 @@
Set<Property> propertySet = Collections.emptySet();
propertySets.add(propertySet);
- expect(propertyExtractor.extractFrom(event)).andReturn(propertySets)
- .anyTimes();
+ expect(propertyExtractor.extractFrom(event)).andReturn(propertySets).anyTimes();
Collection<ActionRequest> actions = Lists.newArrayListWithCapacity(1);
ActionRequest action1 = createMock(ActionRequest.class);
@@ -111,15 +106,12 @@
Set<Set<Property>> propertySets = Sets.newHashSet();
propertySets.add(propertySet);
- expect(propertyExtractor.extractFrom(event)).andReturn(propertySets)
- .anyTimes();
+ expect(propertyExtractor.extractFrom(event)).andReturn(propertySets).anyTimes();
- Collection<ActionRequest> actionRequests =
- Lists.newArrayListWithCapacity(1);
+ Collection<ActionRequest> actionRequests = Lists.newArrayListWithCapacity(1);
ActionRequest actionRequest1 = createMock(ActionRequest.class);
actionRequests.add(actionRequest1);
- expect(ruleBase.actionRequestsFor(propertySet)).andReturn(actionRequests)
- .once();
+ expect(ruleBase.actionRequestsFor(propertySet)).andReturn(actionRequests).once();
actionExecutor.execute("testIssue", actionRequests, propertySet);
@@ -152,25 +144,20 @@
propertySets.add(propertySet1);
propertySets.add(propertySet2);
- expect(propertyExtractor.extractFrom(event)).andReturn(propertySets)
- .anyTimes();
+ expect(propertyExtractor.extractFrom(event)).andReturn(propertySets).anyTimes();
- Collection<ActionRequest> actionRequests1 =
- Lists.newArrayListWithCapacity(1);
+ Collection<ActionRequest> actionRequests1 = Lists.newArrayListWithCapacity(1);
ActionRequest actionRequest1 = createMock(ActionRequest.class);
actionRequests1.add(actionRequest1);
- Collection<ActionRequest> actionRequests2 =
- Lists.newArrayListWithCapacity(2);
+ Collection<ActionRequest> actionRequests2 = Lists.newArrayListWithCapacity(2);
ActionRequest actionRequest2 = createMock(ActionRequest.class);
actionRequests2.add(actionRequest2);
ActionRequest actionRequest3 = createMock(ActionRequest.class);
actionRequests2.add(actionRequest3);
- expect(ruleBase.actionRequestsFor(propertySet1)).andReturn(actionRequests1)
- .once();
- expect(ruleBase.actionRequestsFor(propertySet2)).andReturn(actionRequests2)
- .once();
+ expect(ruleBase.actionRequestsFor(propertySet1)).andReturn(actionRequests1).once();
+ expect(ruleBase.actionRequestsFor(propertySet2)).andReturn(actionRequests2).once();
actionExecutor.execute("testIssue", actionRequests1, propertySet1);
actionExecutor.execute("testIssue", actionRequests2, propertySet2);
@@ -180,13 +167,13 @@
actionController.onEvent(event);
}
+
private ActionController createActionController() {
return injector.getInstance(ActionController.class);
}
private void setupCommonMocks() {
- expect(itsConfig.isEnabled(anyObject(Event.class))).andReturn(true)
- .anyTimes();
+ expect(itsConfig.isEnabled(anyObject(Event.class))).andReturn(true).anyTimes();
}
@Override
@@ -213,4 +200,4 @@
bind(ItsConfig.class).toInstance(itsConfig);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/ActionExecutorTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/ActionExecutorTest.java
index f3f5916..f2b6a55 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/ActionExecutorTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/ActionExecutorTest.java
@@ -20,7 +20,6 @@
import com.google.gerrit.extensions.config.FactoryModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
-
import com.googlesource.gerrit.plugins.its.base.its.ItsFacade;
import com.googlesource.gerrit.plugins.its.base.testutil.LoggingMockingTestCase;
import com.googlesource.gerrit.plugins.its.base.workflow.action.AddComment;
@@ -28,7 +27,6 @@
import com.googlesource.gerrit.plugins.its.base.workflow.action.AddStandardComment;
import com.googlesource.gerrit.plugins.its.base.workflow.action.AddVelocityComment;
import com.googlesource.gerrit.plugins.its.base.workflow.action.LogEvent;
-
import java.io.IOException;
import java.util.Collections;
import java.util.Set;
@@ -93,8 +91,7 @@
replayMocks();
ActionExecutor actionExecutor = createActionExecutor();
- actionExecutor.execute("4711", Sets.newHashSet(
- actionRequest1, actionRequest2), properties);
+ actionExecutor.execute("4711", Sets.newHashSet(actionRequest1, actionRequest2), properties);
}
public void testExecuteIterableExceptions() throws IOException {
@@ -121,8 +118,8 @@
replayMocks();
ActionExecutor actionExecutor = createActionExecutor();
- actionExecutor.execute("4711", Sets.newHashSet(
- actionRequest1, actionRequest2, actionRequest3), properties);
+ actionExecutor.execute(
+ "4711", Sets.newHashSet(actionRequest1, actionRequest2, actionRequest3), properties);
assertLogThrowableMessageContains("injected exception 1");
assertLogThrowableMessageContains("injected exception 3");
@@ -151,8 +148,7 @@
Set<Property> properties = Collections.emptySet();
- AddSoyComment addSoyComment =
- createMock(AddSoyComment.class);
+ AddSoyComment addSoyComment = createMock(AddSoyComment.class);
expect(addSoyCommentFactory.create()).andReturn(addSoyComment);
addSoyComment.execute("4711", actionRequest, properties);
@@ -169,8 +165,7 @@
Set<Property> properties = Collections.emptySet();
- AddStandardComment addStandardComment =
- createMock(AddStandardComment.class);
+ AddStandardComment addStandardComment = createMock(AddStandardComment.class);
expect(addStandardCommentFactory.create()).andReturn(addStandardComment);
addStandardComment.execute("4711", actionRequest, properties);
@@ -187,8 +182,7 @@
Set<Property> properties = Collections.emptySet();
- AddVelocityComment addVelocityComment =
- createMock(AddVelocityComment.class);
+ AddVelocityComment addVelocityComment = createMock(AddVelocityComment.class);
expect(addVelocityCommentFactory.create()).andReturn(addVelocityComment);
addVelocityComment.execute("4711", actionRequest, properties);
@@ -236,19 +230,16 @@
bind(AddComment.Factory.class).toInstance(addCommentFactory);
addSoyCommentFactory = createMock(AddSoyComment.Factory.class);
- bind(AddSoyComment.Factory.class).toInstance(
- addSoyCommentFactory);
+ bind(AddSoyComment.Factory.class).toInstance(addSoyCommentFactory);
addStandardCommentFactory = createMock(AddStandardComment.Factory.class);
- bind(AddStandardComment.Factory.class).toInstance(
- addStandardCommentFactory);
+ bind(AddStandardComment.Factory.class).toInstance(addStandardCommentFactory);
addVelocityCommentFactory = createMock(AddVelocityComment.Factory.class);
- bind(AddVelocityComment.Factory.class).toInstance(
- addVelocityCommentFactory);
+ bind(AddVelocityComment.Factory.class).toInstance(addVelocityCommentFactory);
logEventFactory = createMock(LogEvent.Factory.class);
bind(LogEvent.Factory.class).toInstance(logEventFactory);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/ActionRequestTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/ActionRequestTest.java
index d2461dc..e6de999 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/ActionRequestTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/ActionRequestTest.java
@@ -16,9 +16,7 @@
import com.google.gerrit.extensions.config.FactoryModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
-
import com.googlesource.gerrit.plugins.its.base.testutil.LoggingMockingTestCase;
-
import java.util.Arrays;
public class ActionRequestTest extends LoggingMockingTestCase {
@@ -28,146 +26,127 @@
replayMocks();
ActionRequest actionRequest = createActionRequest("action");
- assertEquals("Unparsed string does not match", "action",
- actionRequest.getUnparsed());
+ assertEquals("Unparsed string does not match", "action", actionRequest.getUnparsed());
}
public void testUnparsedNull() {
replayMocks();
ActionRequest actionRequest = createActionRequest(null);
- assertEquals("Unparsed string does not match", "",
- actionRequest.getUnparsed());
+ assertEquals("Unparsed string does not match", "", actionRequest.getUnparsed());
}
public void testUnparsedSingleParameter() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action param");
- assertEquals("Unparsed string does not match", "action param",
- actionRequest.getUnparsed());
+ assertEquals("Unparsed string does not match", "action param", actionRequest.getUnparsed());
}
public void testUnparsedMultipleParameters() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action param1 param2");
- assertEquals("Unparsed string does not match", "action param1 param2",
- actionRequest.getUnparsed());
+ assertEquals(
+ "Unparsed string does not match", "action param1 param2", actionRequest.getUnparsed());
}
public void testNameParameterless() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action");
- assertEquals("Unparsed string does not match", "action",
- actionRequest.getName());
+ assertEquals("Unparsed string does not match", "action", actionRequest.getName());
}
public void testNameSingleParameter() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action param");
- assertEquals("Unparsed string does not match", "action",
- actionRequest.getName());
+ assertEquals("Unparsed string does not match", "action", actionRequest.getName());
}
public void testNameMultipleParameters() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action param1 param2");
- assertEquals("Unparsed string does not match", "action",
- actionRequest.getName());
+ assertEquals("Unparsed string does not match", "action", actionRequest.getName());
}
public void testNameNull() {
replayMocks();
ActionRequest actionRequest = createActionRequest(null);
- assertEquals("Unparsed string does not match", "",
- actionRequest.getName());
+ assertEquals("Unparsed string does not match", "", actionRequest.getName());
}
public void testParameter1Parameterless() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action");
- assertEquals("Unparsed string does not match", "",
- actionRequest.getParameter(1));
+ assertEquals("Unparsed string does not match", "", actionRequest.getParameter(1));
}
public void testParameter1Null() {
replayMocks();
ActionRequest actionRequest = createActionRequest(null);
- assertEquals("Unparsed string does not match", "",
- actionRequest.getParameter(1));
+ assertEquals("Unparsed string does not match", "", actionRequest.getParameter(1));
}
public void testParameter1SingleParameter() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action param");
- assertEquals("Unparsed string does not match", "param",
- actionRequest.getParameter(1));
+ assertEquals("Unparsed string does not match", "param", actionRequest.getParameter(1));
}
public void testParemeter1MultipleParameters() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action param1 param2");
- assertEquals("Unparsed string does not match", "param1",
- actionRequest.getParameter(1));
+ assertEquals("Unparsed string does not match", "param1", actionRequest.getParameter(1));
}
public void testParameter3Parameterless() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action");
- assertEquals("Unparsed string does not match", "",
- actionRequest.getParameter(3));
+ assertEquals("Unparsed string does not match", "", actionRequest.getParameter(3));
}
public void testParameter3Null() {
replayMocks();
ActionRequest actionRequest = createActionRequest(null);
- assertEquals("Unparsed string does not match", "",
- actionRequest.getParameter(3));
+ assertEquals("Unparsed string does not match", "", actionRequest.getParameter(3));
}
public void testParameter3SingleParameter() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action param");
- assertEquals("Unparsed string does not match", "",
- actionRequest.getParameter(3));
+ assertEquals("Unparsed string does not match", "", actionRequest.getParameter(3));
}
public void testParemeter3With2Parameters() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action param1 param2");
- assertEquals("Unparsed string does not match", "",
- actionRequest.getParameter(3));
+ assertEquals("Unparsed string does not match", "", actionRequest.getParameter(3));
}
public void testParemeter3With3Parameters() {
replayMocks();
- ActionRequest actionRequest = createActionRequest("action param1 param2 " +
- "param3");
- assertEquals("Unparsed string does not match", "param3",
- actionRequest.getParameter(3));
+ ActionRequest actionRequest = createActionRequest("action param1 param2 " + "param3");
+ assertEquals("Unparsed string does not match", "param3", actionRequest.getParameter(3));
}
public void testParemeter3With4Parameters() {
replayMocks();
- ActionRequest actionRequest = createActionRequest("action param1 param2 " +
- "param3 param4");
- assertEquals("Unparsed string does not match", "param3",
- actionRequest.getParameter(3));
+ ActionRequest actionRequest = createActionRequest("action param1 param2 " + "param3 param4");
+ assertEquals("Unparsed string does not match", "param3", actionRequest.getParameter(3));
}
public void testParametersParameterless() {
@@ -176,7 +155,9 @@
ActionRequest actionRequest = createActionRequest("action");
String[] expected = new String[0];
- assertEquals("Parameters do not match", Arrays.asList(expected),
+ assertEquals(
+ "Parameters do not match",
+ Arrays.asList(expected),
Arrays.asList(actionRequest.getParameters()));
}
@@ -186,7 +167,9 @@
ActionRequest actionRequest = createActionRequest(null);
String[] expected = new String[0];
- assertEquals("Parameters do not match", Arrays.asList(expected),
+ assertEquals(
+ "Parameters do not match",
+ Arrays.asList(expected),
Arrays.asList(actionRequest.getParameters()));
}
@@ -195,25 +178,27 @@
ActionRequest actionRequest = createActionRequest("action param");
- String[] expected = new String[] { "param" };
- assertEquals("Parameters do not match", Arrays.asList(expected),
+ String[] expected = new String[] {"param"};
+ assertEquals(
+ "Parameters do not match",
+ Arrays.asList(expected),
Arrays.asList(actionRequest.getParameters()));
}
public void testParameters3Parameter() {
replayMocks();
- ActionRequest actionRequest = createActionRequest("action param1 param2 " +
- "param3");
+ ActionRequest actionRequest = createActionRequest("action param1 param2 " + "param3");
- String[] expected = new String[] { "param1", "param2", "param3" };
- assertEquals("Parameters do not match", Arrays.asList(expected),
+ String[] expected = new String[] {"param1", "param2", "param3"};
+ assertEquals(
+ "Parameters do not match",
+ Arrays.asList(expected),
Arrays.asList(actionRequest.getParameters()));
}
private ActionRequest createActionRequest(String specification) {
- ActionRequest.Factory factory = injector.getInstance(
- ActionRequest.Factory.class);
+ ActionRequest.Factory factory = injector.getInstance(ActionRequest.Factory.class);
return factory.create(specification);
}
@@ -229,4 +214,4 @@
factory(ActionRequest.Factory.class);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/ConditionTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/ConditionTest.java
index 5f58dcc..c1a6a8d 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/ConditionTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/ConditionTest.java
@@ -19,13 +19,11 @@
import com.google.gerrit.extensions.config.FactoryModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
-
import com.googlesource.gerrit.plugins.its.base.testutil.LoggingMockingTestCase;
-
import java.util.Collection;
import java.util.Collections;
-public class ConditionTest extends LoggingMockingTestCase {
+public class ConditionTest extends LoggingMockingTestCase {
private Injector injector;
public void testGetKeyNull() {
@@ -351,4 +349,4 @@
factory(Condition.Factory.class);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/PropertyTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/PropertyTest.java
index dcffab4..06ac41a 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/PropertyTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/PropertyTest.java
@@ -16,10 +16,9 @@
import com.google.gerrit.extensions.config.FactoryModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
-
import com.googlesource.gerrit.plugins.its.base.testutil.LoggingMockingTestCase;
-public class PropertyTest extends LoggingMockingTestCase {
+public class PropertyTest extends LoggingMockingTestCase {
private Injector injector;
public void testGetKeyNull() {
@@ -61,36 +60,31 @@
public void testEqualsNulledKey() {
Property propertyA = new Property(null, "testValue");
Property propertyB = createProperty("testKey", "testValue");
- assertFalse("Single nulled key does match",
- propertyA.equals(propertyB));
+ assertFalse("Single nulled key does match", propertyA.equals(propertyB));
}
public void testEqualsNulledKey2() {
Property propertyA = createProperty("testKey", "testValue");
Property propertyB = new Property(null, "testValue");
- assertFalse("Single nulled key does match",
- propertyA.equals(propertyB));
+ assertFalse("Single nulled key does match", propertyA.equals(propertyB));
}
public void testEqualsNulledValue() {
Property propertyA = createProperty("testKey", "testValue");
Property propertyB = createProperty("testKey", null);
- assertFalse("Single nulled value does match",
- propertyA.equals(propertyB));
+ assertFalse("Single nulled value does match", propertyA.equals(propertyB));
}
public void testEqualsNulledValue2() {
Property propertyA = createProperty("testKey", null);
Property propertyB = createProperty("testKey", "testValue");
- assertFalse("Single nulled value does match",
- propertyA.equals(propertyB));
+ assertFalse("Single nulled value does match", propertyA.equals(propertyB));
}
public void testHashCodeEquals() {
Property propertyA = createProperty("testKey", "testValue");
Property propertyB = createProperty("testKey", "testValue");
- assertEquals("Hash codes do not match", propertyA.hashCode(),
- propertyB.hashCode());
+ assertEquals("Hash codes do not match", propertyA.hashCode(), propertyB.hashCode());
}
public void testHashCodeNullKey() {
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/RuleBaseTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/RuleBaseTest.java
index 596afc7..80e12fb 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/RuleBaseTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/RuleBaseTest.java
@@ -21,11 +21,7 @@
import com.google.gerrit.server.config.SitePath;
import com.google.inject.Guice;
import com.google.inject.Injector;
-
import com.googlesource.gerrit.plugins.its.base.testutil.LoggingMockingTestCase;
-
-import org.eclipse.jgit.util.FileUtils;
-
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
@@ -37,6 +33,7 @@
import java.util.Collections;
import java.util.List;
import java.util.UUID;
+import org.eclipse.jgit.util.FileUtils;
public class RuleBaseTest extends LoggingMockingTestCase {
private Injector injector;
@@ -49,9 +46,9 @@
private boolean cleanupSitePath;
private enum RuleBaseKind {
- GLOBAL,
- ITS,
- FAULTY
+ GLOBAL,
+ ITS,
+ FAULTY
}
public void testWarnNonExistingRuleBase() {
@@ -71,9 +68,7 @@
}
public void testSimpleRuleBase() throws IOException {
- injectRuleBase("[rule \"rule1\"]\n" +
- "\tconditionA = value1\n" +
- "\taction = action1");
+ injectRuleBase("[rule \"rule1\"]\n" + "\tconditionA = value1\n" + "\taction = action1");
Rule rule1 = createMock(Rule.class);
expect(ruleFactory.create("rule1")).andReturn(rule1);
@@ -92,36 +87,34 @@
}
public void testBasicRuleBase() throws IOException {
- injectRuleBase("[rule \"rule1\"]\n" +
- "\tconditionA = value1,value2\n" +
- "\tconditionA = value3,value of 4\n" +
- "\tconditionB = value5\n" +
- "\taction = action1\n" +
- "\taction = action2 param\n" +
- "\n" +
- "[ruleXZ \"nonrule\"]\n" +
- "\tconditionA = value1\n" +
- "\taction = action2\n" +
- "[rule \"rule2\"]\n" +
- "\tconditionC = value6\n" +
- "\taction = action3");
+ injectRuleBase(
+ "[rule \"rule1\"]\n"
+ + "\tconditionA = value1,value2\n"
+ + "\tconditionA = value3,value of 4\n"
+ + "\tconditionB = value5\n"
+ + "\taction = action1\n"
+ + "\taction = action2 param\n"
+ + "\n"
+ + "[ruleXZ \"nonrule\"]\n"
+ + "\tconditionA = value1\n"
+ + "\taction = action2\n"
+ + "[rule \"rule2\"]\n"
+ + "\tconditionC = value6\n"
+ + "\taction = action3");
Rule rule1 = createMock(Rule.class);
expect(ruleFactory.create("rule1")).andReturn(rule1);
Condition condition1 = createMock(Condition.class);
- expect(conditionFactory.create("conditionA", "value1,value2")).
- andReturn(condition1);
+ expect(conditionFactory.create("conditionA", "value1,value2")).andReturn(condition1);
rule1.addCondition(condition1);
Condition condition2 = createMock(Condition.class);
- expect(conditionFactory.create("conditionA", "value3,value of 4")).
- andReturn(condition2);
+ expect(conditionFactory.create("conditionA", "value3,value of 4")).andReturn(condition2);
rule1.addCondition(condition2);
Condition condition3 = createMock(Condition.class);
- expect(conditionFactory.create("conditionB", "value5")).
- andReturn(condition3);
+ expect(conditionFactory.create("conditionB", "value5")).andReturn(condition3);
rule1.addCondition(condition3);
ActionRequest actionRequest1 = createMock(ActionRequest.class);
@@ -136,8 +129,7 @@
expect(ruleFactory.create("rule2")).andReturn(rule2);
Condition condition4 = createMock(Condition.class);
- expect(conditionFactory.create("conditionC", "value6")).
- andReturn(condition4);
+ expect(conditionFactory.create("conditionC", "value6")).andReturn(condition4);
rule2.addCondition(condition4);
ActionRequest actionRequest3 = createMock(ActionRequest.class);
@@ -150,8 +142,7 @@
}
public void testActionRequestsForSimple() throws IOException {
- injectRuleBase("[rule \"rule1\"]\n" +
- "\taction = action1");
+ injectRuleBase("[rule \"rule1\"]\n" + "\taction = action1");
Rule rule1 = createMock(Rule.class);
expect(ruleFactory.create("rule1")).andReturn(rule1);
@@ -178,12 +169,13 @@
}
public void testActionRequestsForExtended() throws IOException {
- injectRuleBase("[rule \"rule1\"]\n" +
- "\taction = action1\n" +
- "\taction = action2\n" +
- "\n" +
- "[rule \"rule2\"]\n" +
- "\taction = action3");
+ injectRuleBase(
+ "[rule \"rule1\"]\n"
+ + "\taction = action1\n"
+ + "\taction = action2\n"
+ + "\n"
+ + "[rule \"rule2\"]\n"
+ + "\taction = action3");
Rule rule1 = createMock(Rule.class);
expect(ruleFactory.create("rule1")).andReturn(rule1);
@@ -241,9 +233,9 @@
}
public void testSimpleFaultyNameRuleBase() throws IOException {
- injectRuleBase("[rule \"rule1\"]\n" +
- "\tconditionA = value1\n" +
- "\taction = action1", RuleBaseKind.FAULTY);
+ injectRuleBase(
+ "[rule \"rule1\"]\n" + "\tconditionA = value1\n" + "\taction = action1",
+ RuleBaseKind.FAULTY);
Rule rule1 = createMock(Rule.class);
expect(ruleFactory.create("rule1")).andReturn(rule1);
@@ -265,9 +257,8 @@
}
public void testSimpleItsRuleBase() throws IOException {
- injectRuleBase("[rule \"rule1\"]\n" +
- "\tconditionA = value1\n" +
- "\taction = action1", RuleBaseKind.ITS);
+ injectRuleBase(
+ "[rule \"rule1\"]\n" + "\tconditionA = value1\n" + "\taction = action1", RuleBaseKind.ITS);
Rule rule1 = createMock(Rule.class);
expect(ruleFactory.create("rule1")).andReturn(rule1);
@@ -286,14 +277,11 @@
}
public void testAllRuleBaseFilesAreLoaded() throws IOException {
- injectRuleBase("[rule \"rule1\"]\n" +
- "\taction = action1", RuleBaseKind.FAULTY);
+ injectRuleBase("[rule \"rule1\"]\n" + "\taction = action1", RuleBaseKind.FAULTY);
- injectRuleBase("[rule \"rule2\"]\n" +
- "\taction = action2", RuleBaseKind.GLOBAL);
+ injectRuleBase("[rule \"rule2\"]\n" + "\taction = action2", RuleBaseKind.GLOBAL);
- injectRuleBase("[rule \"rule3\"]\n" +
- "\taction = action3", RuleBaseKind.ITS);
+ injectRuleBase("[rule \"rule3\"]\n" + "\taction = action3", RuleBaseKind.ITS);
Collection<Property> properties = Collections.emptySet();
@@ -369,14 +357,16 @@
default:
fail("Unknown ruleBaseKind");
}
- File ruleBaseFile = new File(sitePath.toFile(),
- "etc" + File.separatorChar + "its" + File.separator +
- baseName + ".config");
+ File ruleBaseFile =
+ new File(
+ sitePath.toFile(),
+ "etc" + File.separatorChar + "its" + File.separator + baseName + ".config");
File ruleBaseParentFile = ruleBaseFile.getParentFile();
if (!ruleBaseParentFile.exists()) {
- assertTrue("Failed to create parent (" + ruleBaseParentFile + ") for " +
- "rule base", ruleBaseParentFile.mkdirs());
+ assertTrue(
+ "Failed to create parent (" + ruleBaseParentFile + ") for " + "rule base",
+ ruleBaseParentFile.mkdirs());
}
try (FileWriter unbufferedWriter = new FileWriter(ruleBaseFile);
BufferedWriter writer = new BufferedWriter(unbufferedWriter)) {
@@ -409,12 +399,10 @@
@Override
protected void configure() {
- bind(String.class).annotatedWith(PluginName.class)
- .toInstance("ItsTestName");
+ bind(String.class).annotatedWith(PluginName.class).toInstance("ItsTestName");
sitePath = randomTargetPath();
- assertFalse("sitePath already (" + sitePath + ") already exists",
- Files.exists(sitePath));
+ assertFalse("sitePath already (" + sitePath + ") already exists", Files.exists(sitePath));
cleanupSitePath = true;
bind(Path.class).annotatedWith(SitePath.class).toInstance(sitePath);
@@ -429,4 +417,4 @@
bind(ActionRequest.Factory.class).toInstance(actionRequestFactory);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/RuleTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/RuleTest.java
index 4b31618..6d4d234 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/RuleTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/RuleTest.java
@@ -19,9 +19,7 @@
import com.google.gerrit.extensions.config.FactoryModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
-
import com.googlesource.gerrit.plugins.its.base.testutil.LoggingMockingTestCase;
-
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -133,4 +131,4 @@
factory(Rule.Factory.class);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddCommentTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddCommentTest.java
index a86798e..912f4d1 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddCommentTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddCommentTest.java
@@ -18,12 +18,10 @@
import com.google.gerrit.extensions.config.FactoryModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
-
import com.googlesource.gerrit.plugins.its.base.its.ItsFacade;
import com.googlesource.gerrit.plugins.its.base.testutil.LoggingMockingTestCase;
import com.googlesource.gerrit.plugins.its.base.workflow.ActionRequest;
import com.googlesource.gerrit.plugins.its.base.workflow.Property;
-
import java.io.IOException;
import java.util.HashSet;
@@ -34,8 +32,7 @@
public void testEmpty() throws IOException {
ActionRequest actionRequest = createMock(ActionRequest.class);
- expect(actionRequest.getParameters()).andReturn(
- new String[] {});
+ expect(actionRequest.getParameters()).andReturn(new String[] {});
replayMocks();
@@ -45,8 +42,7 @@
public void testPlain() throws IOException {
ActionRequest actionRequest = createMock(ActionRequest.class);
- expect(actionRequest.getParameters()).andReturn(
- new String[] {"Some", "test", "comment"});
+ expect(actionRequest.getParameters()).andReturn(new String[] {"Some", "test", "comment"});
its.addComment("4711", "Some test comment");
@@ -73,4 +69,4 @@
bind(ItsFacade.class).toInstance(its);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddStandardCommentTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddStandardCommentTest.java
index df42702..cfcda01 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddStandardCommentTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddStandardCommentTest.java
@@ -19,12 +19,10 @@
import com.google.gerrit.extensions.config.FactoryModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
-
import com.googlesource.gerrit.plugins.its.base.its.ItsFacade;
import com.googlesource.gerrit.plugins.its.base.testutil.LoggingMockingTestCase;
import com.googlesource.gerrit.plugins.its.base.workflow.ActionRequest;
import com.googlesource.gerrit.plugins.its.base.workflow.Property;
-
import java.io.IOException;
import java.util.Set;
@@ -66,30 +64,29 @@
properties.add(propertySubject);
Property propertyChangeNumber = createMock(Property.class);
- expect(propertyChangeNumber.getKey()).andReturn("changeNumber")
- .anyTimes();
+ expect(propertyChangeNumber.getKey()).andReturn("changeNumber").anyTimes();
expect(propertyChangeNumber.getValue()).andReturn("4711").anyTimes();
properties.add(propertyChangeNumber);
Property propertySubmitterName = createMock(Property.class);
- expect(propertySubmitterName.getKey()).andReturn("submitterName")
- .anyTimes();
+ expect(propertySubmitterName.getKey()).andReturn("submitterName").anyTimes();
expect(propertySubmitterName.getValue()).andReturn("John Doe").anyTimes();
properties.add(propertySubmitterName);
- Property propertyChangeUrl= createMock(Property.class);
+ Property propertyChangeUrl = createMock(Property.class);
expect(propertyChangeUrl.getKey()).andReturn("changeUrl").anyTimes();
- expect(propertyChangeUrl.getValue()).andReturn("http://example.org/change")
- .anyTimes();
+ expect(propertyChangeUrl.getValue()).andReturn("http://example.org/change").anyTimes();
properties.add(propertyChangeUrl);
- expect(its.createLinkForWebui("http://example.org/change",
- "http://example.org/change")).andReturn("HtTp://ExAmPlE.OrG/ChAnGe");
+ expect(its.createLinkForWebui("http://example.org/change", "http://example.org/change"))
+ .andReturn("HtTp://ExAmPlE.OrG/ChAnGe");
- its.addComment("176", "Change 4711 merged by John Doe:\n" +
- "Test-Change-Subject\n" +
- "\n" +
- "HtTp://ExAmPlE.OrG/ChAnGe");
+ its.addComment(
+ "176",
+ "Change 4711 merged by John Doe:\n"
+ + "Test-Change-Subject\n"
+ + "\n"
+ + "HtTp://ExAmPlE.OrG/ChAnGe");
replayMocks();
Action action = injector.getInstance(AddStandardComment.class);
@@ -134,33 +131,32 @@
properties.add(propertySubject);
Property propertyChangeNumber = createMock(Property.class);
- expect(propertyChangeNumber.getKey()).andReturn("changeNumber")
- .anyTimes();
+ expect(propertyChangeNumber.getKey()).andReturn("changeNumber").anyTimes();
expect(propertyChangeNumber.getValue()).andReturn("4711").anyTimes();
properties.add(propertyChangeNumber);
Property propertySubmitterName = createMock(Property.class);
- expect(propertySubmitterName.getKey()).andReturn("abandonerName")
- .anyTimes();
+ expect(propertySubmitterName.getKey()).andReturn("abandonerName").anyTimes();
expect(propertySubmitterName.getValue()).andReturn("John Doe").anyTimes();
properties.add(propertySubmitterName);
- Property propertyChangeUrl= createMock(Property.class);
+ Property propertyChangeUrl = createMock(Property.class);
expect(propertyChangeUrl.getKey()).andReturn("changeUrl").anyTimes();
- expect(propertyChangeUrl.getValue()).andReturn("http://example.org/change")
- .anyTimes();
+ expect(propertyChangeUrl.getValue()).andReturn("http://example.org/change").anyTimes();
properties.add(propertyChangeUrl);
- expect(its.createLinkForWebui("http://example.org/change",
- "http://example.org/change")).andReturn("HtTp://ExAmPlE.OrG/ChAnGe");
+ expect(its.createLinkForWebui("http://example.org/change", "http://example.org/change"))
+ .andReturn("HtTp://ExAmPlE.OrG/ChAnGe");
- its.addComment("176", "Change 4711 abandoned by John Doe:\n" +
- "Test-Change-Subject\n" +
- "\n" +
- "Reason:\n" +
- "Test-Reason\n" +
- "\n" +
- "HtTp://ExAmPlE.OrG/ChAnGe");
+ its.addComment(
+ "176",
+ "Change 4711 abandoned by John Doe:\n"
+ + "Test-Change-Subject\n"
+ + "\n"
+ + "Reason:\n"
+ + "Test-Reason\n"
+ + "\n"
+ + "HtTp://ExAmPlE.OrG/ChAnGe");
replayMocks();
Action action = injector.getInstance(AddStandardComment.class);
@@ -205,33 +201,32 @@
properties.add(propertySubject);
Property propertyChangeNumber = createMock(Property.class);
- expect(propertyChangeNumber.getKey()).andReturn("changeNumber")
- .anyTimes();
+ expect(propertyChangeNumber.getKey()).andReturn("changeNumber").anyTimes();
expect(propertyChangeNumber.getValue()).andReturn("4711").anyTimes();
properties.add(propertyChangeNumber);
Property propertySubmitterName = createMock(Property.class);
- expect(propertySubmitterName.getKey()).andReturn("restorerName")
- .anyTimes();
+ expect(propertySubmitterName.getKey()).andReturn("restorerName").anyTimes();
expect(propertySubmitterName.getValue()).andReturn("John Doe").anyTimes();
properties.add(propertySubmitterName);
- Property propertyChangeUrl= createMock(Property.class);
+ Property propertyChangeUrl = createMock(Property.class);
expect(propertyChangeUrl.getKey()).andReturn("changeUrl").anyTimes();
- expect(propertyChangeUrl.getValue()).andReturn("http://example.org/change")
- .anyTimes();
+ expect(propertyChangeUrl.getValue()).andReturn("http://example.org/change").anyTimes();
properties.add(propertyChangeUrl);
- expect(its.createLinkForWebui("http://example.org/change",
- "http://example.org/change")).andReturn("HtTp://ExAmPlE.OrG/ChAnGe");
+ expect(its.createLinkForWebui("http://example.org/change", "http://example.org/change"))
+ .andReturn("HtTp://ExAmPlE.OrG/ChAnGe");
- its.addComment("176", "Change 4711 restored by John Doe:\n" +
- "Test-Change-Subject\n" +
- "\n" +
- "Reason:\n" +
- "Test-Reason\n" +
- "\n" +
- "HtTp://ExAmPlE.OrG/ChAnGe");
+ its.addComment(
+ "176",
+ "Change 4711 restored by John Doe:\n"
+ + "Test-Change-Subject\n"
+ + "\n"
+ + "Reason:\n"
+ + "Test-Reason\n"
+ + "\n"
+ + "HtTp://ExAmPlE.OrG/ChAnGe");
replayMocks();
Action action = injector.getInstance(AddStandardComment.class);
@@ -271,31 +266,30 @@
properties.add(propertySubject);
Property propertyChangeNumber = createMock(Property.class);
- expect(propertyChangeNumber.getKey()).andReturn("changeNumber")
- .anyTimes();
+ expect(propertyChangeNumber.getKey()).andReturn("changeNumber").anyTimes();
expect(propertyChangeNumber.getValue()).andReturn("4711").anyTimes();
properties.add(propertyChangeNumber);
Property propertySubmitterName = createMock(Property.class);
- expect(propertySubmitterName.getKey()).andReturn("uploaderName")
- .anyTimes();
+ expect(propertySubmitterName.getKey()).andReturn("uploaderName").anyTimes();
expect(propertySubmitterName.getValue()).andReturn("John Doe").anyTimes();
properties.add(propertySubmitterName);
- Property propertyChangeUrl= createMock(Property.class);
+ Property propertyChangeUrl = createMock(Property.class);
expect(propertyChangeUrl.getKey()).andReturn("changeUrl").anyTimes();
- expect(propertyChangeUrl.getValue()).andReturn("http://example.org/change")
- .anyTimes();
+ expect(propertyChangeUrl.getValue()).andReturn("http://example.org/change").anyTimes();
properties.add(propertyChangeUrl);
- expect(its.createLinkForWebui("http://example.org/change",
- "http://example.org/change")).andReturn("HtTp://ExAmPlE.OrG/ChAnGe");
+ expect(its.createLinkForWebui("http://example.org/change", "http://example.org/change"))
+ .andReturn("HtTp://ExAmPlE.OrG/ChAnGe");
- its.addComment("176", "Change 4711 had a related patch set uploaded by " +
- "John Doe:\n" +
- "Test-Change-Subject\n" +
- "\n" +
- "HtTp://ExAmPlE.OrG/ChAnGe");
+ its.addComment(
+ "176",
+ "Change 4711 had a related patch set uploaded by "
+ + "John Doe:\n"
+ + "Test-Change-Subject\n"
+ + "\n"
+ + "HtTp://ExAmPlE.OrG/ChAnGe");
replayMocks();
Action action = injector.getInstance(AddStandardComment.class);
@@ -316,4 +310,4 @@
bind(ItsFacade.class).toInstance(its);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddVelocityCommentTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddVelocityCommentTest.java
index 5a33db6..a8ca659 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddVelocityCommentTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/action/AddVelocityCommentTest.java
@@ -23,20 +23,11 @@
import com.google.gerrit.server.config.SitePath;
import com.google.inject.Guice;
import com.google.inject.Injector;
-
import com.googlesource.gerrit.plugins.its.base.its.ItsFacade;
import com.googlesource.gerrit.plugins.its.base.testutil.LoggingMockingTestCase;
import com.googlesource.gerrit.plugins.its.base.workflow.ActionRequest;
import com.googlesource.gerrit.plugins.its.base.workflow.Property;
import com.googlesource.gerrit.plugins.its.base.workflow.action.AddVelocityComment.VelocityAdapterItsFacade;
-
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.runtime.RuntimeInstance;
-import org.easymock.Capture;
-import org.easymock.EasyMock;
-import org.easymock.IAnswer;
-import org.eclipse.jgit.util.FileUtils;
-
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
@@ -48,6 +39,12 @@
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.runtime.RuntimeInstance;
+import org.easymock.Capture;
+import org.easymock.EasyMock;
+import org.easymock.IAnswer;
+import org.eclipse.jgit.util.FileUtils;
public class AddVelocityCommentTest extends LoggingMockingTestCase {
private Injector injector;
@@ -72,12 +69,15 @@
public void testInlinePlain() throws IOException {
ActionRequest actionRequest = createMock(ActionRequest.class);
expect(actionRequest.getParameter(1)).andReturn("inline");
- expect(actionRequest.getParameters()).andReturn(
- new String[] {"inline", "Simple-text"});
+ expect(actionRequest.getParameters()).andReturn(new String[] {"inline", "Simple-text"});
IAnswer<Boolean> answer = new VelocityWriterFiller("Simple-text");
- expect(velocityRuntime.evaluate((VelocityContext)anyObject(),
- (Writer)anyObject(), (String)anyObject(), eq("Simple-text")))
+ expect(
+ velocityRuntime.evaluate(
+ (VelocityContext) anyObject(),
+ (Writer) anyObject(),
+ (String) anyObject(),
+ eq("Simple-text")))
.andAnswer(answer);
its.addComment("4711", "Simple-text");
@@ -91,14 +91,17 @@
public void testInlineWithMultipleParameters() throws IOException {
ActionRequest actionRequest = createMock(ActionRequest.class);
expect(actionRequest.getParameter(1)).andReturn("inline");
- expect(actionRequest.getParameters()).andReturn(
- new String[] {"inline", "Param2", "Param3"});
+ expect(actionRequest.getParameters()).andReturn(new String[] {"inline", "Param2", "Param3"});
Set<Property> properties = Sets.newHashSet();
IAnswer<Boolean> answer = new VelocityWriterFiller("Param2 Param3");
- expect(velocityRuntime.evaluate((VelocityContext)anyObject(),
- (Writer)anyObject(), (String)anyObject(), eq("Param2 Param3")))
+ expect(
+ velocityRuntime.evaluate(
+ (VelocityContext) anyObject(),
+ (Writer) anyObject(),
+ (String) anyObject(),
+ eq("Param2 Param3")))
.andAnswer(answer);
its.addComment("4711", "Param2 Param3");
@@ -112,8 +115,7 @@
public void testInlineWithSingleProperty() throws IOException {
ActionRequest actionRequest = createMock(ActionRequest.class);
expect(actionRequest.getParameter(1)).andReturn("inline");
- expect(actionRequest.getParameters()).andReturn(
- new String[] {"inline", "${subject}"});
+ expect(actionRequest.getParameters()).andReturn(new String[] {"inline", "${subject}"});
Set<Property> properties = Sets.newHashSet();
@@ -124,8 +126,12 @@
IAnswer<Boolean> answer = new VelocityWriterFiller("Rosebud");
Capture<VelocityContext> contextCapture = createCapture();
- expect(velocityRuntime.evaluate(capture(contextCapture),
- (Writer)anyObject(), (String)anyObject(), eq("${subject}")))
+ expect(
+ velocityRuntime.evaluate(
+ capture(contextCapture),
+ (Writer) anyObject(),
+ (String) anyObject(),
+ eq("${subject}")))
.andAnswer(answer);
its.addComment("4711", "Rosebud");
@@ -136,15 +142,13 @@
addVelocityComment.execute("4711", actionRequest, properties);
VelocityContext context = contextCapture.getValue();
- assertEquals("Subject property of context did not match", "Rosebud",
- context.get("subject"));
+ assertEquals("Subject property of context did not match", "Rosebud", context.get("subject"));
}
public void testInlineWithUnusedProperty() throws IOException {
ActionRequest actionRequest = createMock(ActionRequest.class);
expect(actionRequest.getParameter(1)).andReturn("inline");
- expect(actionRequest.getParameters()).andReturn(
- new String[] {"inline", "Test"});
+ expect(actionRequest.getParameters()).andReturn(new String[] {"inline", "Test"});
Set<Property> properties = Sets.newHashSet();
@@ -154,8 +158,12 @@
properties.add(propertySubject);
IAnswer<Boolean> answer = new VelocityWriterFiller("Test");
- expect(velocityRuntime.evaluate((VelocityContext)anyObject(),
- (Writer)anyObject(), (String)anyObject(), eq("Test")))
+ expect(
+ velocityRuntime.evaluate(
+ (VelocityContext) anyObject(),
+ (Writer) anyObject(),
+ (String) anyObject(),
+ eq("Test")))
.andAnswer(answer);
its.addComment("4711", "Test");
@@ -169,8 +177,8 @@
public void testInlineWithMultipleProperties() throws IOException {
ActionRequest actionRequest = createMock(ActionRequest.class);
expect(actionRequest.getParameter(1)).andReturn("inline");
- expect(actionRequest.getParameters()).andReturn(
- new String[] {"inline", "${subject}", "${reason}", "${subject}"});
+ expect(actionRequest.getParameters())
+ .andReturn(new String[] {"inline", "${subject}", "${reason}", "${subject}"});
Set<Property> properties = Sets.newHashSet();
@@ -186,9 +194,13 @@
IAnswer<Boolean> answer = new VelocityWriterFiller("Rosebud Life Rosebud");
Capture<VelocityContext> contextCapture = createCapture();
- expect(velocityRuntime.evaluate(capture(contextCapture),
- (Writer)anyObject(), (String)anyObject(),
- eq("${subject} ${reason} ${subject}"))).andAnswer(answer);
+ expect(
+ velocityRuntime.evaluate(
+ capture(contextCapture),
+ (Writer) anyObject(),
+ (String) anyObject(),
+ eq("${subject} ${reason} ${subject}")))
+ .andAnswer(answer);
its.addComment("4711", "Rosebud Life Rosebud");
@@ -198,29 +210,30 @@
addVelocityComment.execute("4711", actionRequest, properties);
VelocityContext context = contextCapture.getValue();
- assertEquals("Subject property of context did not match", "Rosebud",
- context.get("subject"));
- assertEquals("Reason property of context did not match", "Life",
- context.get("reason"));
+ assertEquals("Subject property of context did not match", "Rosebud", context.get("subject"));
+ assertEquals("Reason property of context did not match", "Life", context.get("reason"));
}
- public void testItsWrapperFormatLink1Parameter() throws IOException,
- SecurityException, IllegalArgumentException {
+ public void testItsWrapperFormatLink1Parameter()
+ throws IOException, SecurityException, IllegalArgumentException {
ActionRequest actionRequest = createMock(ActionRequest.class);
expect(actionRequest.getParameter(1)).andReturn("inline");
- expect(actionRequest.getParameters()).andReturn(
- new String[] {"inline", "Simple-Text"});
+ expect(actionRequest.getParameters()).andReturn(new String[] {"inline", "Simple-Text"});
IAnswer<Boolean> answer = new VelocityWriterFiller("Simple-Text");
Capture<VelocityContext> contextCapture = createCapture();
- expect(velocityRuntime.evaluate(capture(contextCapture),
- (Writer)anyObject(), (String)anyObject(), eq("Simple-Text")))
+ expect(
+ velocityRuntime.evaluate(
+ capture(contextCapture),
+ (Writer) anyObject(),
+ (String) anyObject(),
+ eq("Simple-Text")))
.andAnswer(answer);
its.addComment("4711", "Simple-Text");
- expect(its.createLinkForWebui("http://www.example.org/",
- "http://www.example.org/")) .andReturn("Formatted Link");
+ expect(its.createLinkForWebui("http://www.example.org/", "http://www.example.org/"))
+ .andReturn("Formatted Link");
replayMocks();
@@ -230,26 +243,28 @@
VelocityContext context = contextCapture.getValue();
Object itsAdapterObj = context.get("its");
assertNotNull("its property is null", itsAdapterObj);
- assertTrue("Its is not a VelocityAdapterItsFacade instance",
+ assertTrue(
+ "Its is not a VelocityAdapterItsFacade instance",
itsAdapterObj instanceof VelocityAdapterItsFacade);
- VelocityAdapterItsFacade itsAdapter =
- (VelocityAdapterItsFacade) itsAdapterObj;
+ VelocityAdapterItsFacade itsAdapter = (VelocityAdapterItsFacade) itsAdapterObj;
String formattedLink = itsAdapter.formatLink("http://www.example.org/");
- assertEquals("Result of formatLink does not match", "Formatted Link",
- formattedLink);
+ assertEquals("Result of formatLink does not match", "Formatted Link", formattedLink);
}
- public void testItsWrapperFormatLink2Parameters() throws IOException,
- SecurityException, IllegalArgumentException {
+ public void testItsWrapperFormatLink2Parameters()
+ throws IOException, SecurityException, IllegalArgumentException {
ActionRequest actionRequest = createMock(ActionRequest.class);
expect(actionRequest.getParameter(1)).andReturn("inline");
- expect(actionRequest.getParameters()).andReturn(
- new String[] {"inline", "Simple-Text"});
+ expect(actionRequest.getParameters()).andReturn(new String[] {"inline", "Simple-Text"});
IAnswer<Boolean> answer = new VelocityWriterFiller("Simple-Text");
Capture<VelocityContext> contextCapture = createCapture();
- expect(velocityRuntime.evaluate(capture(contextCapture),
- (Writer)anyObject(), (String)anyObject(), eq("Simple-Text")))
+ expect(
+ velocityRuntime.evaluate(
+ capture(contextCapture),
+ (Writer) anyObject(),
+ (String) anyObject(),
+ eq("Simple-Text")))
.andAnswer(answer);
its.addComment("4711", "Simple-Text");
@@ -265,14 +280,12 @@
VelocityContext context = contextCapture.getValue();
Object itsAdapterObj = context.get("its");
assertNotNull("its property is null", itsAdapterObj);
- assertTrue("Its is not a VelocityAdapterItsFacade instance",
+ assertTrue(
+ "Its is not a VelocityAdapterItsFacade instance",
itsAdapterObj instanceof VelocityAdapterItsFacade);
- VelocityAdapterItsFacade itsAdapter =
- (VelocityAdapterItsFacade) itsAdapterObj;
- String formattedLink = itsAdapter.formatLink("http://www.example.org/",
- "Caption");
- assertEquals("Result of formatLink does not match", "Formatted Link",
- formattedLink);
+ VelocityAdapterItsFacade itsAdapter = (VelocityAdapterItsFacade) itsAdapterObj;
+ String formattedLink = itsAdapter.formatLink("http://www.example.org/", "Caption");
+ assertEquals("Result of formatLink does not match", "Formatted Link", formattedLink);
}
public void testWarnTemplateNotFound() throws IOException {
@@ -294,9 +307,13 @@
injectTestTemplate("Simple Test Template");
IAnswer<Boolean> answer = new VelocityWriterFiller("Simple Test Template");
- expect(velocityRuntime.evaluate((VelocityContext)anyObject(),
- (Writer)anyObject(), (String)anyObject(),
- eq("Simple Test Template"))).andAnswer(answer);
+ expect(
+ velocityRuntime.evaluate(
+ (VelocityContext) anyObject(),
+ (Writer) anyObject(),
+ (String) anyObject(),
+ eq("Simple Test Template")))
+ .andAnswer(answer);
its.addComment("4711", "Simple Test Template");
@@ -322,20 +339,25 @@
expect(propertyReason.getValue()).andReturn("Life").anyTimes();
properties.add(propertyReason);
- injectTestTemplate("Test Template with subject: ${subject}.\n" +
- "${reason} is the reason for ${subject}.");
+ injectTestTemplate(
+ "Test Template with subject: ${subject}.\n" + "${reason} is the reason for ${subject}.");
- IAnswer<Boolean> answer = new VelocityWriterFiller(
- "Test Template with subject: Rosebud.\n" +
- "Life is the reason for Rosebud.");
+ IAnswer<Boolean> answer =
+ new VelocityWriterFiller(
+ "Test Template with subject: Rosebud.\n" + "Life is the reason for Rosebud.");
Capture<VelocityContext> contextCapture = createCapture();
- expect(velocityRuntime.evaluate(capture(contextCapture),
- (Writer)anyObject(), (String)anyObject(),
- eq("Test Template with subject: ${subject}.\n" +
- "${reason} is the reason for ${subject}."))).andAnswer(answer);
+ expect(
+ velocityRuntime.evaluate(
+ capture(contextCapture),
+ (Writer) anyObject(),
+ (String) anyObject(),
+ eq(
+ "Test Template with subject: ${subject}.\n"
+ + "${reason} is the reason for ${subject}.")))
+ .andAnswer(answer);
- its.addComment("4711", "Test Template with subject: Rosebud.\n" +
- "Life is the reason for Rosebud.");
+ its.addComment(
+ "4711", "Test Template with subject: Rosebud.\n" + "Life is the reason for Rosebud.");
replayMocks();
@@ -343,10 +365,8 @@
addVelocityComment.execute("4711", actionRequest, properties);
VelocityContext context = contextCapture.getValue();
- assertEquals("Subject property of context did not match", "Rosebud",
- context.get("subject"));
- assertEquals("Reason property of context did not match", "Life",
- context.get("reason"));
+ assertEquals("Subject property of context did not match", "Rosebud", context.get("subject"));
+ assertEquals("Reason property of context did not match", "Life", context.get("reason"));
}
private AddVelocityComment createAddVelocityComment() {
@@ -354,10 +374,12 @@
}
private void injectTestTemplate(String template) throws IOException {
- File templateParentFile = new File(sitePath.toFile(), "etc" +
- File.separatorChar + "its" + File.separator + "templates");
- assertTrue("Failed to create parent (" + templateParentFile + ") for " +
- "rule base", templateParentFile.mkdirs());
+ File templateParentFile =
+ new File(
+ sitePath.toFile(), "etc" + File.separatorChar + "its" + File.separator + "templates");
+ assertTrue(
+ "Failed to create parent (" + templateParentFile + ") for " + "rule base",
+ templateParentFile.mkdirs());
File templateFile = new File(templateParentFile, "test-template.vm");
try (FileWriter unbufferedWriter = new FileWriter(templateFile);
@@ -391,8 +413,7 @@
@Override
protected void configure() {
sitePath = randomTargetPath();
- assertFalse("sitePath already (" + sitePath + ") already exists",
- Files.exists(sitePath));
+ assertFalse("sitePath already (" + sitePath + ") already exists", Files.exists(sitePath));
cleanupSitePath = true;
bind(Path.class).annotatedWith(SitePath.class).toInstance(sitePath);
@@ -426,4 +447,4 @@
return returnValue;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/action/LogEventTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/action/LogEventTest.java
index 3d147a9..22a4288 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/action/LogEventTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/base/workflow/action/LogEventTest.java
@@ -19,16 +19,13 @@
import com.google.gerrit.extensions.config.FactoryModule;
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.base.workflow.ActionRequest;
import com.googlesource.gerrit.plugins.its.base.workflow.Property;
-
-import org.apache.log4j.Level;
-
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
+import org.apache.log4j.Level;
public class LogEventTest extends LoggingMockingTestCase {
private Injector injector;
@@ -117,7 +114,6 @@
ActionRequest actionRequest = createMock(ActionRequest.class);
expect(actionRequest.getParameter(1)).andReturn("info");
-
Set<Property> properties = Sets.newHashSet();
properties.add(new PropertyMock("KeyA", "ValueA", "PropertyA"));
properties.add(new PropertyMock("KeyB", "ValueB", "PropertyB"));
@@ -144,8 +140,7 @@
private class TestModule extends FactoryModule {
@Override
- protected void configure() {
- }
+ protected void configure() {}
}
private class PropertyMock extends Property {
@@ -161,4 +156,4 @@
return toString;
}
}
-}
\ No newline at end of file
+}