Merge "Remove Maven build"
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
index 2a585e4..258f774 100644
--- a/.settings/org.eclipse.jdt.core.prefs
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -1,12 +1,20 @@
eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=ignore
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
org.eclipse.jdt.core.compiler.problem.deadCode=warning
@@ -14,7 +22,8 @@
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
@@ -33,13 +42,14 @@
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
org.eclipse.jdt.core.compiler.problem.nullReference=warning
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
@@ -52,7 +62,7 @@
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
@@ -60,6 +70,7 @@
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
@@ -70,7 +81,7 @@
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
@@ -83,6 +94,7 @@
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.source=1.7
diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs
index d4218a5..7397758 100644
--- a/.settings/org.eclipse.jdt.ui.prefs
+++ b/.settings/org.eclipse.jdt.ui.prefs
@@ -1,10 +1,9 @@
-#Wed Jul 29 11:31:38 PDT 2009
eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
formatter_profile=_Google Format
formatter_settings_version=11
org.eclipse.jdt.ui.ignorelowercasenames=true
-org.eclipse.jdt.ui.importorder=com.google;com;junit;net;org;java;javax;
+org.eclipse.jdt.ui.importorder=\#;com.google;com;dk;eu;junit;net;org;java;javax;
org.eclipse.jdt.ui.ondemandthreshold=99
org.eclipse.jdt.ui.staticondemandthreshold=99
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates/>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/its/InitIts.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/its/InitIts.java
index 4c59b5c..85ab85f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/its/InitIts.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/its/InitIts.java
@@ -18,9 +18,9 @@
import com.google.gerrit.common.data.RefConfigSection;
import com.google.gerrit.pgm.init.api.AllProjectsConfig;
import com.google.gerrit.pgm.init.api.AllProjectsNameOnInitProvider;
+import com.google.gerrit.pgm.init.api.ConsoleUI;
import com.google.gerrit.pgm.init.api.InitStep;
import com.google.gerrit.pgm.init.api.Section;
-import com.google.gerrit.pgm.init.api.ConsoleUI;
import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.lib.Config;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/its/NoopItsFacade.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/its/NoopItsFacade.java
index b7bfe44..b663b32 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/its/NoopItsFacade.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/its/NoopItsFacade.java
@@ -14,12 +14,12 @@
package com.googlesource.gerrit.plugins.hooks.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
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/util/CommitMessageFetcher.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/util/CommitMessageFetcher.java
index 02ea502..a4a80c3 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/util/CommitMessageFetcher.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/util/CommitMessageFetcher.java
@@ -1,7 +1,5 @@
package com.googlesource.gerrit.plugins.hooks.util;
-import java.io.IOException;
-
import com.google.gerrit.reviewdb.client.Project.NameKey;
import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.inject.Inject;
@@ -13,6 +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);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/util/IssueExtractor.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/util/IssueExtractor.java
index cdf4a09..1d57c2a 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/util/IssueExtractor.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/util/IssueExtractor.java
@@ -1,10 +1,5 @@
package com.googlesource.gerrit.plugins.hooks.util;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.gerrit.extensions.annotations.PluginName;
@@ -16,10 +11,14 @@
import org.apache.commons.lang.StringUtils;
import org.eclipse.jgit.lib.Config;
-
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;
+
public class IssueExtractor {
private static final Logger log = LoggerFactory.getLogger(
IssueExtractor.class);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/util/PropertyAttributeExtractor.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/util/PropertyAttributeExtractor.java
index e6dfe7a..a882829 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/util/PropertyAttributeExtractor.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/util/PropertyAttributeExtractor.java
@@ -1,21 +1,19 @@
-//Copyright (C) 2013 The Android Open Source Project
+// Copyright (C) 2013 The Android Open Source Project
//
-//Licensed under the Apache License, Version 2.0 (the "License");
-//you may not use this file except in compliance with the License.
-//You may obtain a copy of the License at
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
//
-//http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0
//
-//Unless required by applicable law or agreed to in writing, software
-//distributed under the License is distributed on an "AS IS" BASIS,
-//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-//See the License for the specific language governing permissions and
-//limitations under the License.
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
package com.googlesource.gerrit.plugins.hooks.util;
-import java.util.Set;
-
import com.google.common.collect.Sets;
import com.google.gerrit.server.data.AccountAttribute;
import com.google.gerrit.server.data.ApprovalAttribute;
@@ -26,6 +24,8 @@
import com.googlesource.gerrit.plugins.hooks.workflow.Property;
+import java.util.Set;
+
/**
* Extractor to translate the various {@code *Attribute}s to
* {@link Property Properties}.
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/util/PropertyExtractor.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/util/PropertyExtractor.java
index 0f6f937..53e22c0 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/util/PropertyExtractor.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/util/PropertyExtractor.java
@@ -1,22 +1,19 @@
-//Copyright (C) 2013 The Android Open Source Project
+// Copyright (C) 2013 The Android Open Source Project
//
-//Licensed under the Apache License, Version 2.0 (the "License");
-//you may not use this file except in compliance with the License.
-//You may obtain a copy of the License at
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
//
-//http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0
//
-//Unless required by applicable law or agreed to in writing, software
-//distributed under the License is distributed on an "AS IS" BASIS,
-//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-//See the License for the specific language governing permissions and
-//limitations under the License.
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
package com.googlesource.gerrit.plugins.hooks.util;
-import java.util.Map;
-import java.util.Set;
-
import com.google.common.collect.Sets;
import com.google.gerrit.reviewdb.client.Change;
import com.google.gerrit.reviewdb.client.PatchSet;
@@ -34,6 +31,9 @@
import com.googlesource.gerrit.plugins.hooks.workflow.Property;
+import java.util.Map;
+import java.util.Set;
+
/**
* Extractor to translate an {@link ChangeEvent} to
* {@link Property Properties}.
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/validation/ItsValidateComment.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/validation/ItsValidateComment.java
index bd8ed2c..a396ed9 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/validation/ItsValidateComment.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/validation/ItsValidateComment.java
@@ -14,16 +14,6 @@
package com.googlesource.gerrit.plugins.hooks.validation;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.jgit.lib.Config;
-import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.jgit.transport.ReceiveCommand;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import com.google.common.collect.Lists;
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.server.config.GerritServerConfig;
@@ -37,6 +27,16 @@
import com.googlesource.gerrit.plugins.hooks.its.ItsFacade;
import com.googlesource.gerrit.plugins.hooks.util.IssueExtractor;
+import org.eclipse.jgit.lib.Config;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.transport.ReceiveCommand;
+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
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionExecutor.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionExecutor.java
index 99ccf85..e3f6ee7 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionExecutor.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionExecutor.java
@@ -1,26 +1,21 @@
-//Copyright (C) 2013 The Android Open Source Project
+// Copyright (C) 2013 The Android Open Source Project
//
-//Licensed under the Apache License, Version 2.0 (the "License");
-//you may not use this file except in compliance with the License.
-//You may obtain a copy of the License at
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
//
-//http://www.apache.org/licenses/LICENSE-2.0
+// http://www.apache.org/licenses/LICENSE-2.0
//
-//Unless required by applicable law or agreed to in writing, software
-//distributed under the License is distributed on an "AS IS" BASIS,
-//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-//See the License for the specific language governing permissions and
-//limitations under the License.
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
package com.googlesource.gerrit.plugins.hooks.workflow;
-import java.io.IOException;
-import java.util.Set;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import com.google.inject.Inject;
+
import com.googlesource.gerrit.plugins.hooks.its.ItsFacade;
import com.googlesource.gerrit.plugins.hooks.workflow.action.Action;
import com.googlesource.gerrit.plugins.hooks.workflow.action.AddComment;
@@ -28,6 +23,12 @@
import com.googlesource.gerrit.plugins.hooks.workflow.action.AddVelocityComment;
import com.googlesource.gerrit.plugins.hooks.workflow.action.LogEvent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.Set;
+
/**
* Executes an {@link ActionRequest}
*/
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionRequest.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionRequest.java
index bd81cb1..197832b 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionRequest.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionRequest.java
@@ -14,11 +14,11 @@
package com.googlesource.gerrit.plugins.hooks.workflow;
-import java.util.Arrays;
-
+import com.google.gerrit.common.Nullable;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
-import com.google.gerrit.common.Nullable;
+
+import java.util.Arrays;
/**
* An action to take for an {@code ChangeEvent}.
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/Condition.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/Condition.java
index aca340e..2c5e390 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/Condition.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/Condition.java
@@ -14,10 +14,6 @@
package com.googlesource.gerrit.plugins.hooks.workflow;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.gerrit.common.Nullable;
@@ -26,6 +22,10 @@
import com.googlesource.gerrit.plugins.hooks.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>
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilter.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilter.java
index da062bc..d559bc3 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilter.java
@@ -47,24 +47,55 @@
return commitMessageFetcher.fetch(projectName, commitId);
}
+ /**
+ * Filter patch set created event.
+ * @param hook
+ * @throws IOException
+ * @throws OrmException
+ */
public void doFilter(PatchSetCreatedEvent hook) throws IOException,
OrmException {
}
+ /**
+ * Filter comment added event.
+ * @param hook
+ * @throws IOException
+ */
public void doFilter(CommentAddedEvent hook) throws IOException {
}
+ /**
+ * Filter change merged event.
+ * @param hook
+ * @throws IOException
+ */
public void doFilter(ChangeMergedEvent hook) throws IOException {
}
+ /**
+ * Filter change abandoned event.
+ * @param changeAbandonedHook
+ * @throws IOException
+ */
public void doFilter(ChangeAbandonedEvent changeAbandonedHook)
throws IOException {
}
+ /**
+ * Filter change restored event.
+ * @param changeRestoredHook
+ * @throws IOException
+ */
public void doFilter(ChangeRestoredEvent changeRestoredHook)
throws IOException {
}
+ /**
+ * Filter ref updated event.
+ * @param refUpdatedHook
+ * @throws IOException
+ */
public void doFilter(RefUpdatedEvent refUpdatedHook) throws IOException {
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilterAddComment.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilterAddComment.java
index 123f119..8f2d873 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilterAddComment.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilterAddComment.java
@@ -14,10 +14,6 @@
package com.googlesource.gerrit.plugins.hooks.workflow;
-import java.io.IOException;
-
-import org.eclipse.jgit.lib.Config;
-
import com.google.common.base.Strings;
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.server.config.AnonymousCowardName;
@@ -35,6 +31,10 @@
import com.googlesource.gerrit.plugins.hooks.its.ItsFacade;
import com.googlesource.gerrit.plugins.hooks.util.IssueExtractor;
+import org.eclipse.jgit.lib.Config;
+
+import java.io.IOException;
+
public class GerritHookFilterAddComment extends GerritHookFilter {
@Inject
@@ -170,7 +170,7 @@
private void addComment(ChangeAttribute change, String comment)
throws IOException {
- String gitComment = change.subject;;
+ String gitComment = change.subject;
String[] issues = issueExtractor.getIssueIds(gitComment);
for (String issue : issues) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilterAddRelatedLinkToChangeId.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilterAddRelatedLinkToChangeId.java
index 8d6b4ca..19ba344 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilterAddRelatedLinkToChangeId.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilterAddRelatedLinkToChangeId.java
@@ -14,15 +14,6 @@
package com.googlesource.gerrit.plugins.hooks.workflow;
-import java.io.IOException;
-import java.net.URL;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jgit.lib.Config;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import com.google.common.collect.Lists;
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.reviewdb.client.Change;
@@ -37,6 +28,15 @@
import com.googlesource.gerrit.plugins.hooks.its.ItsFacade;
import com.googlesource.gerrit.plugins.hooks.util.IssueExtractor;
+import org.eclipse.jgit.lib.Config;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.List;
+
public class GerritHookFilterAddRelatedLinkToChangeId extends
GerritHookFilter {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilterAddRelatedLinkToGitWeb.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilterAddRelatedLinkToGitWeb.java
index cee6d79..9e806d2 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilterAddRelatedLinkToGitWeb.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilterAddRelatedLinkToGitWeb.java
@@ -14,18 +14,6 @@
package com.googlesource.gerrit.plugins.hooks.workflow;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLEncoder;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jgit.lib.Config;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import com.google.gerrit.common.data.GitWebType;
import com.google.gerrit.common.data.ParameterizedString;
import com.google.gerrit.extensions.annotations.PluginName;
@@ -37,6 +25,18 @@
import com.googlesource.gerrit.plugins.hooks.its.ItsFacade;
import com.googlesource.gerrit.plugins.hooks.util.IssueExtractor;
+import org.eclipse.jgit.lib.Config;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.util.HashMap;
+import java.util.Map;
+
public class GerritHookFilterAddRelatedLinkToGitWeb extends GerritHookFilter {
Logger log = LoggerFactory
@@ -115,7 +115,7 @@
String revUrl = gitWebType.getRevision();
ParameterizedString pattern = new ParameterizedString(revUrl);
- final Map<String, String> p = new HashMap<String, String>();
+ final Map<String, String> p = new HashMap<>();
p.put("project", URLEncoder.encode(
gitWebType.replacePathSeparator(hook.refUpdate.project), "US-ASCII"));
p.put("commit", hook.refUpdate.newRev);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilterChangeState.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilterChangeState.java
index 9056357..d14278c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilterChangeState.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/GerritHookFilterChangeState.java
@@ -14,19 +14,6 @@
package com.googlesource.gerrit.plugins.hooks.workflow;
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-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 com.google.gerrit.server.config.SitePath;
import com.google.gerrit.server.data.ApprovalAttribute;
@@ -37,10 +24,26 @@
import com.google.gerrit.server.events.CommentAddedEvent;
import com.google.gerrit.server.events.PatchSetCreatedEvent;
import com.google.inject.Inject;
+
import com.googlesource.gerrit.plugins.hooks.its.InvalidTransitionException;
import com.googlesource.gerrit.plugins.hooks.its.ItsFacade;
import com.googlesource.gerrit.plugins.hooks.util.IssueExtractor;
+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.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
public class GerritHookFilterChangeState extends GerritHookFilter {
private static final Logger log = LoggerFactory
.getLogger(GerritHookFilterChangeState.class);
@@ -50,7 +53,7 @@
@Inject
@SitePath
- private File sitePath;
+ private Path sitePath;
@Inject
private IssueExtractor issueExtractor;
@@ -63,7 +66,7 @@
@Override
public void doFilter(CommentAddedEvent hook) throws IOException {
try {
- List<Condition> conditions = new ArrayList<Condition>();
+ List<Condition> conditions = new ArrayList<>();
conditions.add(new Condition("change", "commented"));
if (hook.approvals != null) {
@@ -150,7 +153,7 @@
}
private List<Transition> loadTransitions() {
- File configFile = new File(sitePath, "etc/issue-state-transition.config");
+ File configFile = new File(sitePath.toFile(), "etc/issue-state-transition.config");
FileBasedConfig cfg = new FileBasedConfig(configFile, FS.DETECTED);
try {
cfg.load();
@@ -162,10 +165,10 @@
return Collections.emptyList();
}
- List<Transition> transitions = new ArrayList<Transition>();
+ List<Transition> transitions = new ArrayList<>();
Set<String> sections = cfg.getSubsections("action");
for (String section : sections) {
- List<Condition> conditions = new ArrayList<Condition>();
+ List<Condition> conditions = new ArrayList<>();
Set<String> keys = cfg.getNames("action", section);
for (String key : keys) {
String val = cfg.getString("action", section, key);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/Property.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/Property.java
index 8b582d6..82481a9 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/Property.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/Property.java
@@ -14,9 +14,9 @@
package com.googlesource.gerrit.plugins.hooks.workflow;
+import com.google.gerrit.common.Nullable;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
-import com.google.gerrit.common.Nullable;
/**
* A property to match against {@code Condition}s.
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/Rule.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/Rule.java
index 5fb58d1..e7e403c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/Rule.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/Rule.java
@@ -14,16 +14,16 @@
package com.googlesource.gerrit.plugins.hooks.workflow;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
import com.google.common.collect.Lists;
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.
*/
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/RuleBase.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/RuleBase.java
index cfa70ac..346946f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/RuleBase.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/RuleBase.java
@@ -14,9 +14,6 @@
package com.googlesource.gerrit.plugins.hooks.workflow;
-import java.io.File;
-import java.io.IOException;
-import java.util.Collection;
import com.google.common.collect.Lists;
import com.google.gerrit.extensions.annotations.PluginName;
@@ -29,6 +26,11 @@
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.
*/
@@ -56,7 +58,7 @@
*/
private static final String ACTION_KEY = "action";
- private final File sitePath;
+ private final Path sitePath;
private final Rule.Factory ruleFactory;
private final Condition.Factory conditionFactory;
private final ActionRequest.Factory actionRequestFactory;
@@ -69,7 +71,7 @@
}
@Inject
- public RuleBase(@SitePath File sitePath, Rule.Factory ruleFactory,
+ public RuleBase(@SitePath Path sitePath, Rule.Factory ruleFactory,
Condition.Factory conditionFactory,
ActionRequest.Factory actionRequestFactory,
@PluginName String pluginName) {
@@ -135,7 +137,7 @@
// "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, "etc" + File.separatorChar
+ 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 "
@@ -145,12 +147,12 @@
}
// Add global rules
- File globalRuleFile = new File(sitePath, ITS_CONFIG_FILE_START +
+ 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, ITS_CONFIG_FILE_START + "-" +
+ File itsSpecificRuleFile = new File(sitePath.toFile(), ITS_CONFIG_FILE_START + "-" +
pluginName + ITS_CONFIG_FILE_END);
addRulesFromFile(itsSpecificRuleFile);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/action/Action.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/action/Action.java
index 7e0595c..987b397 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/action/Action.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/action/Action.java
@@ -14,12 +14,12 @@
package com.googlesource.gerrit.plugins.hooks.workflow.action;
-import java.io.IOException;
-import java.util.Set;
-
import com.googlesource.gerrit.plugins.hooks.workflow.ActionRequest;
import com.googlesource.gerrit.plugins.hooks.workflow.Property;
+import java.io.IOException;
+import java.util.Set;
+
/**
* Interface for actions on an issue tracking system
*/
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddComment.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddComment.java
index b83d205..2006c2f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddComment.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddComment.java
@@ -14,17 +14,18 @@
package com.googlesource.gerrit.plugins.hooks.workflow.action;
-import java.io.IOException;
-import java.util.Set;
-
-import org.apache.commons.lang.StringUtils;
-
import com.google.common.base.Strings;
import com.google.inject.Inject;
+
import com.googlesource.gerrit.plugins.hooks.its.ItsFacade;
import com.googlesource.gerrit.plugins.hooks.workflow.ActionRequest;
import com.googlesource.gerrit.plugins.hooks.workflow.Property;
+import org.apache.commons.lang.StringUtils;
+
+import java.io.IOException;
+import java.util.Set;
+
/**
* Adds a fixed comment to an issue.
*
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddStandardComment.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddStandardComment.java
index 8cdeef7..8e4675c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddStandardComment.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddStandardComment.java
@@ -14,17 +14,18 @@
package com.googlesource.gerrit.plugins.hooks.workflow.action;
-import java.io.IOException;
-import java.util.Map;
-import java.util.Set;
-
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import com.google.inject.Inject;
+
import com.googlesource.gerrit.plugins.hooks.its.ItsFacade;
import com.googlesource.gerrit.plugins.hooks.workflow.ActionRequest;
import com.googlesource.gerrit.plugins.hooks.workflow.Property;
+import java.io.IOException;
+import java.util.Map;
+import java.util.Set;
+
/**
* Adds a short predefined comments to an issue.
*
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddVelocityComment.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddVelocityComment.java
index e2db316..cec9d3d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddVelocityComment.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddVelocityComment.java
@@ -14,11 +14,13 @@
package com.googlesource.gerrit.plugins.hooks.workflow.action;
-import java.io.File;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.util.Arrays;
-import java.util.Set;
+import com.google.common.base.Strings;
+import com.google.gerrit.server.config.SitePath;
+import com.google.inject.Inject;
+
+import com.googlesource.gerrit.plugins.hooks.its.ItsFacade;
+import com.googlesource.gerrit.plugins.hooks.workflow.ActionRequest;
+import com.googlesource.gerrit.plugins.hooks.workflow.Property;
import org.apache.commons.lang.StringUtils;
import org.apache.velocity.VelocityContext;
@@ -27,12 +29,12 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Strings;
-import com.google.gerrit.server.config.SitePath;
-import com.google.inject.Inject;
-import com.googlesource.gerrit.plugins.hooks.its.ItsFacade;
-import com.googlesource.gerrit.plugins.hooks.workflow.ActionRequest;
-import com.googlesource.gerrit.plugins.hooks.workflow.Property;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.Set;
/**
* Adds a short predefined comments to an issue.
@@ -55,11 +57,11 @@
"its" + File.separator + "templates";
private final ItsFacade its;
- private final File sitePath;
+ private final Path sitePath;
private final RuntimeInstance velocityRuntime;
@Inject
- public AddVelocityComment(RuntimeInstance velocityRuntime, @SitePath File sitePath, ItsFacade its) {
+ public AddVelocityComment(RuntimeInstance velocityRuntime, @SitePath Path sitePath, ItsFacade its) {
this.velocityRuntime = velocityRuntime;
this.sitePath = sitePath;
this.its = its;
@@ -82,7 +84,7 @@
return velocityContext;
}
- private String velocify(String template, Set<Property> properties) throws IOException {
+ private String velocify(String template, Set<Property> properties) {
VelocityContext context = getVelocityContext(properties);
StringWriter w = new StringWriter();
velocityRuntime.evaluate(context, w, "ItsComment", template);
@@ -103,7 +105,7 @@
if (templateName.isEmpty()) {
log.error("No template name given in " + actionRequest);
} else {
- File templateFile = new File(sitePath, ITS_TEMPLATE_DIR +
+ File templateFile = new File(sitePath.toFile(), ITS_TEMPLATE_DIR +
File.separator + templateName + ".vm");
if (templateFile.canRead()) {
template = FileUtils.readAllText(templateFile);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/action/LogEvent.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/action/LogEvent.java
index 17b891d..45aabe4 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/action/LogEvent.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/workflow/action/LogEvent.java
@@ -14,15 +14,16 @@
package com.googlesource.gerrit.plugins.hooks.workflow.action;
-import java.io.IOException;
-import java.util.Set;
+import com.google.inject.Inject;
+
+import com.googlesource.gerrit.plugins.hooks.workflow.ActionRequest;
+import com.googlesource.gerrit.plugins.hooks.workflow.Property;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.inject.Inject;
-import com.googlesource.gerrit.plugins.hooks.workflow.ActionRequest;
-import com.googlesource.gerrit.plugins.hooks.workflow.Property;
+import java.io.IOException;
+import java.util.Set;
/**
* Dumps the event's properties to the log.
@@ -33,7 +34,7 @@
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();
diff --git a/src/test/java/com/googlesource/gerrit/plugins/hooks/testutil/LoggingMockingTestCase.java b/src/test/java/com/googlesource/gerrit/plugins/hooks/testutil/LoggingMockingTestCase.java
index 4878c40..9177f1e 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/hooks/testutil/LoggingMockingTestCase.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/hooks/testutil/LoggingMockingTestCase.java
@@ -15,13 +15,14 @@
package com.googlesource.gerrit.plugins.hooks.testutil;
import com.google.common.collect.Lists;
+
import com.googlesource.gerrit.plugins.hooks.testutil.log.LogUtil;
+import org.apache.log4j.Level;
import org.apache.log4j.spi.LoggingEvent;
import org.junit.After;
import java.util.Iterator;
-import org.apache.log4j.Level;
public abstract class LoggingMockingTestCase extends MockingTestCase {
diff --git a/src/test/java/com/googlesource/gerrit/plugins/hooks/testutil/MockingTestCase.java b/src/test/java/com/googlesource/gerrit/plugins/hooks/testutil/MockingTestCase.java
index 819b138..5a09ccd 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/hooks/testutil/MockingTestCase.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/hooks/testutil/MockingTestCase.java
@@ -136,8 +136,8 @@
usePowerMock = PowerMockRunner.class.isAssignableFrom(runWith.value());
}
- mocks = new ArrayList<Object>();
- mockControls = new ArrayList<IMocksControl>();
+ mocks = new ArrayList<>();
+ mockControls = new ArrayList<>();
mocksReplayed = false;
}
diff --git a/src/test/java/com/googlesource/gerrit/plugins/hooks/testutil/log/CollectionAppender.java b/src/test/java/com/googlesource/gerrit/plugins/hooks/testutil/log/CollectionAppender.java
index f63c7c3..a80fe4e 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/hooks/testutil/log/CollectionAppender.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/hooks/testutil/log/CollectionAppender.java
@@ -29,7 +29,7 @@
private Collection<LoggingEvent> events;
public CollectionAppender() {
- events = new LinkedList<LoggingEvent>();
+ events = new LinkedList<>();
}
public CollectionAppender(Collection<LoggingEvent> events) {
diff --git a/src/test/java/com/googlesource/gerrit/plugins/hooks/testutil/log/LogUtil.java b/src/test/java/com/googlesource/gerrit/plugins/hooks/testutil/log/LogUtil.java
index 57d98c7..efdbe04 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/hooks/testutil/log/LogUtil.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/hooks/testutil/log/LogUtil.java
@@ -18,7 +18,6 @@
import org.apache.log4j.Logger;
import org.apache.log4j.spi.LoggingEvent;
-
import java.util.Collection;
public class LogUtil {
diff --git a/src/test/java/com/googlesource/gerrit/plugins/hooks/util/IssueExtractorTest.java b/src/test/java/com/googlesource/gerrit/plugins/hooks/util/IssueExtractorTest.java
index e400a95..a18a1ef 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/hooks/util/IssueExtractorTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/hooks/util/IssueExtractorTest.java
@@ -15,16 +15,6 @@
import static org.easymock.EasyMock.expect;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.jgit.lib.Config;
-import org.junit.runner.RunWith;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.gerrit.extensions.annotations.PluginName;
@@ -41,6 +31,16 @@
import com.googlesource.gerrit.plugins.hooks.testutil.LoggingMockingTestCase;
+import org.eclipse.jgit.lib.Config;
+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;
+
@RunWith(PowerMockRunner.class)
@PrepareForTest({PatchSet.class,RevId.class})
public class IssueExtractorTest extends LoggingMockingTestCase {
diff --git a/src/test/java/com/googlesource/gerrit/plugins/hooks/util/PropertyAttributeExtractorTest.java b/src/test/java/com/googlesource/gerrit/plugins/hooks/util/PropertyAttributeExtractorTest.java
index ffc431b..3562116 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/hooks/util/PropertyAttributeExtractorTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/hooks/util/PropertyAttributeExtractorTest.java
@@ -15,8 +15,6 @@
import static org.easymock.EasyMock.expect;
-import java.util.Set;
-
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.gerrit.reviewdb.client.Change.Status;
@@ -28,9 +26,12 @@
import com.google.gerrit.server.data.RefUpdateAttribute;
import com.google.inject.Guice;
import com.google.inject.Injector;
+
import com.googlesource.gerrit.plugins.hooks.testutil.LoggingMockingTestCase;
import com.googlesource.gerrit.plugins.hooks.workflow.Property;
+import java.util.Set;
+
public class PropertyAttributeExtractorTest extends LoggingMockingTestCase {
private Injector injector;
@@ -426,6 +427,7 @@
assertEquals("Properties do not match", expected, actual);
}
+ @Override
public void setUp() throws Exception {
super.setUp();
injector = Guice.createInjector(new TestModule());
diff --git a/src/test/java/com/googlesource/gerrit/plugins/hooks/util/PropertyExtractorTest.java b/src/test/java/com/googlesource/gerrit/plugins/hooks/util/PropertyExtractorTest.java
index 7657f24..f61e9f1 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/hooks/util/PropertyExtractorTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/hooks/util/PropertyExtractorTest.java
@@ -442,6 +442,7 @@
assertEquals("Properties do not match", expected, actual);
}
+ @Override
public void setUp() throws Exception {
super.setUp();
injector = Guice.createInjector(new TestModule());
diff --git a/src/test/java/com/googlesource/gerrit/plugins/hooks/validation/ItsValidateCommentTest.java b/src/test/java/com/googlesource/gerrit/plugins/hooks/validation/ItsValidateCommentTest.java
index 7c65938..9fc9d79 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/hooks/validation/ItsValidateCommentTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/hooks/validation/ItsValidateCommentTest.java
@@ -15,19 +15,6 @@
import static org.easymock.EasyMock.expect;
-import java.io.IOException;
-import java.util.List;
-import java.util.regex.Pattern;
-
-import org.eclipse.jgit.lib.Config;
-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 com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.config.FactoryModule;
@@ -43,6 +30,17 @@
import com.googlesource.gerrit.plugins.hooks.testutil.LoggingMockingTestCase;
import com.googlesource.gerrit.plugins.hooks.util.IssueExtractor;
+import org.eclipse.jgit.lib.Config;
+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 {
@@ -97,7 +95,7 @@
"issue'",ret.get(0).getMessage().contains("Missing issue"));
}
- public void testMandatoryNonMatching() throws CommitValidationException {
+ public void testMandatoryNonMatching() {
ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
ReceiveCommand command = createMock(ReceiveCommand.class);
RevCommit commit = createMock(RevCommit.class);
@@ -205,7 +203,7 @@
}
public void testMandatoryMatchingSingleNonExisting()
- throws CommitValidationException, IOException {
+ throws IOException {
ItsValidateComment ivc = injector.getInstance(ItsValidateComment.class);
ReceiveCommand command = createMock(ReceiveCommand.class);
RevCommit commit = createMock(RevCommit.class);
diff --git a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionControllerTest.java b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionControllerTest.java
index 8819040..eea768c 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionControllerTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionControllerTest.java
@@ -15,10 +15,6 @@
import static org.easymock.EasyMock.expect;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Set;
-
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import com.google.gerrit.server.config.FactoryModule;
@@ -31,6 +27,10 @@
import com.googlesource.gerrit.plugins.hooks.testutil.LoggingMockingTestCase;
import com.googlesource.gerrit.plugins.hooks.util.PropertyExtractor;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Set;
+
public class ActionControllerTest extends LoggingMockingTestCase {
private Injector injector;
@@ -182,6 +182,7 @@
return injector.getInstance(ActionController.class);
}
+ @Override
public void setUp() throws Exception {
super.setUp();
injector = Guice.createInjector(new TestModule());
diff --git a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionExecutorTest.java b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionExecutorTest.java
index 63293e1..336722a 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionExecutorTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionExecutorTest.java
@@ -16,14 +16,11 @@
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.expectLastCall;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Set;
-
import com.google.common.collect.Sets;
import com.google.gerrit.server.config.FactoryModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
+
import com.googlesource.gerrit.plugins.hooks.its.ItsFacade;
import com.googlesource.gerrit.plugins.hooks.testutil.LoggingMockingTestCase;
import com.googlesource.gerrit.plugins.hooks.workflow.action.AddComment;
@@ -31,6 +28,10 @@
import com.googlesource.gerrit.plugins.hooks.workflow.action.AddVelocityComment;
import com.googlesource.gerrit.plugins.hooks.workflow.action.LogEvent;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Set;
+
public class ActionExecutorTest extends LoggingMockingTestCase {
private Injector injector;
@@ -199,6 +200,7 @@
return injector.getInstance(ActionExecutor.class);
}
+ @Override
public void setUp() throws Exception {
super.setUp();
injector = Guice.createInjector(new TestModule());
diff --git a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionRequestTest.java b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionRequestTest.java
index f7b160d..accb92b 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionRequestTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/ActionRequestTest.java
@@ -13,18 +13,18 @@
// limitations under the License.
package com.googlesource.gerrit.plugins.hooks.workflow;
-import java.io.IOException;
-import java.util.Arrays;
-
import com.google.gerrit.server.config.FactoryModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
+
import com.googlesource.gerrit.plugins.hooks.testutil.LoggingMockingTestCase;
+import java.util.Arrays;
+
public class ActionRequestTest extends LoggingMockingTestCase {
private Injector injector;
- public void testUnparsedParameterless() throws IOException {
+ public void testUnparsedParameterless() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action");
@@ -32,7 +32,7 @@
actionRequest.getUnparsed());
}
- public void testUnparsedNull() throws IOException {
+ public void testUnparsedNull() {
replayMocks();
ActionRequest actionRequest = createActionRequest(null);
@@ -40,7 +40,7 @@
actionRequest.getUnparsed());
}
- public void testUnparsedSingleParameter() throws IOException {
+ public void testUnparsedSingleParameter() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action param");
@@ -48,7 +48,7 @@
actionRequest.getUnparsed());
}
- public void testUnparsedMultipleParameters() throws IOException {
+ public void testUnparsedMultipleParameters() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action param1 param2");
@@ -56,7 +56,7 @@
actionRequest.getUnparsed());
}
- public void testNameParameterless() throws IOException {
+ public void testNameParameterless() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action");
@@ -64,7 +64,7 @@
actionRequest.getName());
}
- public void testNameSingleParameter() throws IOException {
+ public void testNameSingleParameter() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action param");
@@ -72,7 +72,7 @@
actionRequest.getName());
}
- public void testNameMultipleParameters() throws IOException {
+ public void testNameMultipleParameters() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action param1 param2");
@@ -80,7 +80,7 @@
actionRequest.getName());
}
- public void testNameNull() throws IOException {
+ public void testNameNull() {
replayMocks();
ActionRequest actionRequest = createActionRequest(null);
@@ -88,7 +88,7 @@
actionRequest.getName());
}
- public void testParameter1Parameterless() throws IOException {
+ public void testParameter1Parameterless() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action");
@@ -96,7 +96,7 @@
actionRequest.getParameter(1));
}
- public void testParameter1Null() throws IOException {
+ public void testParameter1Null() {
replayMocks();
ActionRequest actionRequest = createActionRequest(null);
@@ -104,7 +104,7 @@
actionRequest.getParameter(1));
}
- public void testParameter1SingleParameter() throws IOException {
+ public void testParameter1SingleParameter() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action param");
@@ -112,7 +112,7 @@
actionRequest.getParameter(1));
}
- public void testParemeter1MultipleParameters() throws IOException {
+ public void testParemeter1MultipleParameters() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action param1 param2");
@@ -120,7 +120,7 @@
actionRequest.getParameter(1));
}
- public void testParameter3Parameterless() throws IOException {
+ public void testParameter3Parameterless() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action");
@@ -128,7 +128,7 @@
actionRequest.getParameter(3));
}
- public void testParameter3Null() throws IOException {
+ public void testParameter3Null() {
replayMocks();
ActionRequest actionRequest = createActionRequest(null);
@@ -136,7 +136,7 @@
actionRequest.getParameter(3));
}
- public void testParameter3SingleParameter() throws IOException {
+ public void testParameter3SingleParameter() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action param");
@@ -144,7 +144,7 @@
actionRequest.getParameter(3));
}
- public void testParemeter3With2Parameters() throws IOException {
+ public void testParemeter3With2Parameters() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action param1 param2");
@@ -152,7 +152,7 @@
actionRequest.getParameter(3));
}
- public void testParemeter3With3Parameters() throws IOException {
+ public void testParemeter3With3Parameters() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action param1 param2 " +
@@ -161,7 +161,7 @@
actionRequest.getParameter(3));
}
- public void testParemeter3With4Parameters() throws IOException {
+ public void testParemeter3With4Parameters() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action param1 param2 " +
@@ -170,7 +170,7 @@
actionRequest.getParameter(3));
}
- public void testParametersParameterless() throws IOException {
+ public void testParametersParameterless() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action");
@@ -180,7 +180,7 @@
Arrays.asList(actionRequest.getParameters()));
}
- public void testParametersNull() throws IOException {
+ public void testParametersNull() {
replayMocks();
ActionRequest actionRequest = createActionRequest(null);
@@ -190,7 +190,7 @@
Arrays.asList(actionRequest.getParameters()));
}
- public void testParametersSingleParameter() throws IOException {
+ public void testParametersSingleParameter() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action param");
@@ -200,7 +200,7 @@
Arrays.asList(actionRequest.getParameters()));
}
- public void testParameters3Parameter() throws IOException {
+ public void testParameters3Parameter() {
replayMocks();
ActionRequest actionRequest = createActionRequest("action param1 param2 " +
@@ -217,6 +217,7 @@
return factory.create(specification);
}
+ @Override
public void setUp() throws Exception {
super.setUp();
injector = Guice.createInjector(new TestModule());
diff --git a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/ConditionTest.java b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/ConditionTest.java
index 886ab40..aadef6d 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/ConditionTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/ConditionTest.java
@@ -15,15 +15,16 @@
import static org.easymock.EasyMock.expect;
-import java.util.Collection;
-import java.util.Collections;
-
import com.google.common.collect.Lists;
import com.google.gerrit.server.config.FactoryModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
+
import com.googlesource.gerrit.plugins.hooks.testutil.LoggingMockingTestCase;
+import java.util.Collection;
+import java.util.Collections;
+
public class ConditionTest extends LoggingMockingTestCase {
private Injector injector;
@@ -317,6 +318,7 @@
return factory.create(key, value);
}
+ @Override
public void setUp() throws Exception {
super.setUp();
diff --git a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/PropertyTest.java b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/PropertyTest.java
index c977208..6944650 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/PropertyTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/PropertyTest.java
@@ -16,6 +16,7 @@
import com.google.gerrit.server.config.FactoryModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
+
import com.googlesource.gerrit.plugins.hooks.testutil.LoggingMockingTestCase;
public class PropertyTest extends LoggingMockingTestCase {
@@ -112,6 +113,7 @@
return factory.create(key, value);
}
+ @Override
public void setUp() throws Exception {
super.setUp();
diff --git a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/RuleBaseTest.java b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/RuleBaseTest.java
index ffadc1d..93776f0 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/RuleBaseTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/RuleBaseTest.java
@@ -15,17 +15,6 @@
import static org.easymock.EasyMock.expect;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.UUID;
-
-import org.eclipse.jgit.util.FileUtils;
-
import com.google.common.collect.Lists;
import com.google.gerrit.extensions.annotations.PluginName;
import com.google.gerrit.server.config.FactoryModule;
@@ -35,10 +24,24 @@
import com.googlesource.gerrit.plugins.hooks.testutil.LoggingMockingTestCase;
+import org.eclipse.jgit.util.FileUtils;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.UUID;
+
public class RuleBaseTest extends LoggingMockingTestCase {
private Injector injector;
- private File sitePath;
+ private Path sitePath;
private Rule.Factory ruleFactory;
private Condition.Factory conditionFactory;
private ActionRequest.Factory actionRequestFactory;
@@ -366,8 +369,9 @@
default:
fail("Unknown ruleBaseKind");
}
- File ruleBaseFile = new File(sitePath, "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()) {
@@ -381,24 +385,25 @@
unbufferedWriter.close();
}
+ @Override
public void setUp() throws Exception {
super.setUp();
cleanupSitePath = false;
injector = Guice.createInjector(new TestModule());
}
+ @Override
public void tearDown() throws Exception {
if (cleanupSitePath) {
- if (sitePath.exists()) {
- FileUtils.delete(sitePath, FileUtils.RECURSIVE);
+ if (Files.exists(sitePath)) {
+ FileUtils.delete(sitePath.toFile(), FileUtils.RECURSIVE);
}
}
super.tearDown();
}
- private File randomTargetFile() {
- final File t = new File("target");
- return new File(t, "random-name-" + UUID.randomUUID().toString());
+ private Path randomTargetPath() {
+ return Paths.get("target", "random-name-" + UUID.randomUUID().toString());
}
private class TestModule extends FactoryModule {
@@ -408,12 +413,12 @@
bind(String.class).annotatedWith(PluginName.class)
.toInstance("ItsTestName");
- sitePath = randomTargetFile();
+ sitePath = randomTargetPath();
assertFalse("sitePath already (" + sitePath + ") already exists",
- sitePath.exists());
+ Files.exists(sitePath));
cleanupSitePath = true;
- bind(File.class).annotatedWith(SitePath.class).toInstance(sitePath);
+ bind(Path.class).annotatedWith(SitePath.class).toInstance(sitePath);
ruleFactory = createMock(Rule.Factory.class);
bind(Rule.Factory.class).toInstance(ruleFactory);
diff --git a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/RuleTest.java b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/RuleTest.java
index d09a790..2eecbff 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/RuleTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/RuleTest.java
@@ -15,16 +15,17 @@
import static org.easymock.EasyMock.expect;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
import com.google.common.collect.Lists;
import com.google.gerrit.server.config.FactoryModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
+
import com.googlesource.gerrit.plugins.hooks.testutil.LoggingMockingTestCase;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
public class RuleTest extends LoggingMockingTestCase {
private Injector injector;
@@ -120,6 +121,7 @@
return factory.create(name);
}
+ @Override
public void setUp() throws Exception {
super.setUp();
injector = Guice.createInjector(new TestModule());
diff --git a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddCommentTest.java b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddCommentTest.java
index d833c55..53bc05c 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddCommentTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddCommentTest.java
@@ -15,17 +15,18 @@
import static org.easymock.EasyMock.expect;
-import java.io.IOException;
-import java.util.HashSet;
-
import com.google.gerrit.server.config.FactoryModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
+
import com.googlesource.gerrit.plugins.hooks.its.ItsFacade;
import com.googlesource.gerrit.plugins.hooks.testutil.LoggingMockingTestCase;
import com.googlesource.gerrit.plugins.hooks.workflow.ActionRequest;
import com.googlesource.gerrit.plugins.hooks.workflow.Property;
+import java.io.IOException;
+import java.util.HashSet;
+
public class AddCommentTest extends LoggingMockingTestCase {
private Injector injector;
@@ -59,6 +60,7 @@
return injector.getInstance(AddComment.class);
}
+ @Override
public void setUp() throws Exception {
super.setUp();
injector = Guice.createInjector(new TestModule());
diff --git a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddStandardCommentTest.java b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddStandardCommentTest.java
index 6b40093..8690ba4 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddStandardCommentTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddStandardCommentTest.java
@@ -15,19 +15,19 @@
import static org.easymock.EasyMock.expect;
-import java.io.IOException;
-import java.util.Set;
-
-
import com.google.common.collect.Sets;
import com.google.gerrit.server.config.FactoryModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
+
import com.googlesource.gerrit.plugins.hooks.its.ItsFacade;
import com.googlesource.gerrit.plugins.hooks.testutil.LoggingMockingTestCase;
import com.googlesource.gerrit.plugins.hooks.workflow.ActionRequest;
import com.googlesource.gerrit.plugins.hooks.workflow.Property;
+import java.io.IOException;
+import java.util.Set;
+
public class AddStandardCommentTest extends LoggingMockingTestCase {
private Injector injector;
@@ -302,6 +302,7 @@
action.execute("176", actionRequest, properties);
}
+ @Override
public void setUp() throws Exception {
super.setUp();
diff --git a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddVelocityCommentTest.java b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddVelocityCommentTest.java
index a7de371..940669f 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddVelocityCommentTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/action/AddVelocityCommentTest.java
@@ -18,15 +18,17 @@
import static org.easymock.EasyMock.eq;
import static org.easymock.EasyMock.expect;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Writer;
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.UUID;
+import com.google.common.collect.Sets;
+import com.google.gerrit.server.config.FactoryModule;
+import com.google.gerrit.server.config.SitePath;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+import com.googlesource.gerrit.plugins.hooks.its.ItsFacade;
+import com.googlesource.gerrit.plugins.hooks.testutil.LoggingMockingTestCase;
+import com.googlesource.gerrit.plugins.hooks.workflow.ActionRequest;
+import com.googlesource.gerrit.plugins.hooks.workflow.Property;
+import com.googlesource.gerrit.plugins.hooks.workflow.action.AddVelocityComment.VelocityAdapterItsFacade;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.runtime.RuntimeInstance;
@@ -35,21 +37,22 @@
import org.easymock.IAnswer;
import org.eclipse.jgit.util.FileUtils;
-import com.google.common.collect.Sets;
-import com.google.gerrit.server.config.FactoryModule;
-import com.google.gerrit.server.config.SitePath;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.googlesource.gerrit.plugins.hooks.its.ItsFacade;
-import com.googlesource.gerrit.plugins.hooks.testutil.LoggingMockingTestCase;
-import com.googlesource.gerrit.plugins.hooks.workflow.ActionRequest;
-import com.googlesource.gerrit.plugins.hooks.workflow.Property;
-import com.googlesource.gerrit.plugins.hooks.workflow.action.AddVelocityComment.VelocityAdapterItsFacade;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.UUID;
public class AddVelocityCommentTest extends LoggingMockingTestCase {
private Injector injector;
- private File sitePath;
+ private Path sitePath;
private ItsFacade its;
private RuntimeInstance velocityRuntime;
@@ -120,7 +123,7 @@
properties.add(propertySubject);
IAnswer<Boolean> answer = new VelocityWriterFiller("Rosebud");
- Capture<VelocityContext> contextCapture = new Capture<VelocityContext>();
+ Capture<VelocityContext> contextCapture = new Capture<>();
expect(velocityRuntime.evaluate(capture(contextCapture),
(Writer)anyObject(), (String)anyObject(), eq("${subject}")))
.andAnswer(answer);
@@ -182,7 +185,7 @@
properties.add(propertyReason);
IAnswer<Boolean> answer = new VelocityWriterFiller("Rosebud Life Rosebud");
- Capture<VelocityContext> contextCapture = new Capture<VelocityContext>();
+ Capture<VelocityContext> contextCapture = new Capture<>();
expect(velocityRuntime.evaluate(capture(contextCapture),
(Writer)anyObject(), (String)anyObject(),
eq("${subject} ${reason} ${subject}"))).andAnswer(answer);
@@ -202,15 +205,14 @@
}
public void testItsWrapperFormatLink1Parameter() throws IOException,
- SecurityException, NoSuchMethodException, IllegalArgumentException,
- IllegalAccessException, InvocationTargetException {
+ SecurityException, IllegalArgumentException {
ActionRequest actionRequest = createMock(ActionRequest.class);
expect(actionRequest.getParameter(1)).andReturn("inline");
expect(actionRequest.getParameters()).andReturn(
new String[] {"inline", "Simple-Text"});
IAnswer<Boolean> answer = new VelocityWriterFiller("Simple-Text");
- Capture<VelocityContext> contextCapture = new Capture<VelocityContext>();
+ Capture<VelocityContext> contextCapture = new Capture<>();
expect(velocityRuntime.evaluate(capture(contextCapture),
(Writer)anyObject(), (String)anyObject(), eq("Simple-Text")))
.andAnswer(answer);
@@ -238,15 +240,14 @@
}
public void testItsWrapperFormatLink2Parameters() throws IOException,
- SecurityException, NoSuchMethodException, IllegalArgumentException,
- IllegalAccessException, InvocationTargetException {
+ SecurityException, IllegalArgumentException {
ActionRequest actionRequest = createMock(ActionRequest.class);
expect(actionRequest.getParameter(1)).andReturn("inline");
expect(actionRequest.getParameters()).andReturn(
new String[] {"inline", "Simple-Text"});
IAnswer<Boolean> answer = new VelocityWriterFiller("Simple-Text");
- Capture<VelocityContext> contextCapture = new Capture<VelocityContext>();
+ Capture<VelocityContext> contextCapture = new Capture<>();
expect(velocityRuntime.evaluate(capture(contextCapture),
(Writer)anyObject(), (String)anyObject(), eq("Simple-Text")))
.andAnswer(answer);
@@ -327,7 +328,7 @@
IAnswer<Boolean> answer = new VelocityWriterFiller(
"Test Template with subject: Rosebud.\n" +
"Life is the reason for Rosebud.");
- Capture<VelocityContext> contextCapture = new Capture<VelocityContext>();
+ Capture<VelocityContext> contextCapture = new Capture<>();
expect(velocityRuntime.evaluate(capture(contextCapture),
(Writer)anyObject(), (String)anyObject(),
eq("Test Template with subject: ${subject}.\n" +
@@ -353,8 +354,8 @@
}
private void injectTestTemplate(String template) throws IOException {
- File templateParentFile = new File(sitePath, "etc" + File.separatorChar + "its" +
- File.separator + "templates");
+ 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");
@@ -366,35 +367,36 @@
unbufferedWriter.close();
}
+ @Override
public void setUp() throws Exception {
super.setUp();
cleanupSitePath = false;
injector = Guice.createInjector(new TestModule());
}
+ @Override
public void tearDown() throws Exception {
if (cleanupSitePath) {
- if (sitePath.exists()) {
- FileUtils.delete(sitePath, FileUtils.RECURSIVE);
+ if (Files.exists(sitePath)) {
+ FileUtils.delete(sitePath.toFile(), FileUtils.RECURSIVE);
}
}
super.tearDown();
}
- private File randomTargetFile() {
- final File t = new File("target");
- return new File(t, "random-name-" + UUID.randomUUID().toString());
+ private Path randomTargetPath() {
+ return Paths.get("target", "random-name-" + UUID.randomUUID().toString());
}
private class TestModule extends FactoryModule {
@Override
protected void configure() {
- sitePath = randomTargetFile();
+ sitePath = randomTargetPath();
assertFalse("sitePath already (" + sitePath + ") already exists",
- sitePath.exists());
+ Files.exists(sitePath));
cleanupSitePath = true;
- bind(File.class).annotatedWith(SitePath.class).toInstance(sitePath);
+ bind(Path.class).annotatedWith(SitePath.class).toInstance(sitePath);
its = createMock(ItsFacade.class);
bind(ItsFacade.class).toInstance(its);
diff --git a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/action/LogEventTest.java b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/action/LogEventTest.java
index 7d607b2..6a36736 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/action/LogEventTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/hooks/workflow/action/LogEventTest.java
@@ -15,20 +15,21 @@
import static org.easymock.EasyMock.expect;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.log4j.Level;
-
import com.google.common.collect.Sets;
import com.google.gerrit.server.config.FactoryModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
+
import com.googlesource.gerrit.plugins.hooks.testutil.LoggingMockingTestCase;
import com.googlesource.gerrit.plugins.hooks.workflow.ActionRequest;
import com.googlesource.gerrit.plugins.hooks.workflow.Property;
+import org.apache.log4j.Level;
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
public class LogEventTest extends LoggingMockingTestCase {
private Injector injector;
@@ -135,6 +136,7 @@
return injector.getInstance(LogEvent.class);
}
+ @Override
public void setUp() throws Exception {
super.setUp();
injector = Guice.createInjector(new TestModule());
@@ -154,6 +156,7 @@
this.toString = toString;
}
+ @Override
public String toString() {
return toString;
}