Merge branch 'stable-3.2'

Change-Id: I1ed519b543e478736a459df3a2e5950f04e4fc83
diff --git a/external_plugin_deps.bzl b/external_plugin_deps.bzl
index f04d8fb..2d26664 100644
--- a/external_plugin_deps.bzl
+++ b/external_plugin_deps.bzl
@@ -25,6 +25,6 @@
 
   maven_jar(
     name = "wiremock",
-    artifact = "com.github.tomakehurst:wiremock-standalone:2.12.0",
-    sha1 = "25f45d45091627a3bae5510495c99a561b2633c4",
+    artifact = "com.github.tomakehurst:wiremock-standalone:2.27.2",
+    sha1 = "327647a19b2319af2526b9c33a5733a2241723e0",
   )
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/jira/JiraConfig.java b/src/main/java/com/googlesource/gerrit/plugins/its/jira/JiraConfig.java
index b44d60e..339d16c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/jira/JiraConfig.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/jira/JiraConfig.java
@@ -18,6 +18,7 @@
 import com.google.common.base.CharMatcher;
 import com.google.common.base.Strings;
 import com.google.gerrit.entities.Project;
+import com.google.gerrit.entities.StoredCommentLinkInfo;
 import com.google.gerrit.extensions.annotations.PluginName;
 import com.google.gerrit.server.GerritPersonIdent;
 import com.google.gerrit.server.config.GerritServerConfig;
@@ -26,7 +27,6 @@
 import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
 import com.google.gerrit.server.git.GitRepositoryManager;
 import com.google.gerrit.server.git.meta.MetaDataUpdate;
-import com.google.gerrit.server.project.CommentLinkInfoImpl;
 import com.google.gerrit.server.project.NoSuchProjectException;
 import com.google.gerrit.server.project.ProjectCache;
 import com.google.gerrit.server.project.ProjectConfig;
@@ -130,8 +130,12 @@
           CharMatcher.is('/').trimFrom(jiraItsServerInfo.getUrl().toString()) + JiraURL.URL_SUFFIX;
       if (!commentLinksExist(config, link)) {
         String match = getCommentLinkFromGerritConfig("match");
-        CommentLinkInfoImpl commentlinkSection =
-            new CommentLinkInfoImpl(pluginName, match, link, null, true);
+        StoredCommentLinkInfo commentlinkSection =
+            StoredCommentLinkInfo.builder(pluginName)
+                .setMatch(match)
+                .setLink(link)
+                .setEnabled(true)
+                .build();
         config.addCommentLinkSection(commentlinkSection);
         md.getCommitBuilder().setAuthor(serverUser);
         md.getCommitBuilder().setCommitter(serverUser);
@@ -144,7 +148,7 @@
   }
 
   private boolean commentLinksExist(ProjectConfig config, String link) {
-    return config.getCommentLinkSections().stream().map(c -> c.link).anyMatch(link::equals);
+    return config.getCommentLinkSections().stream().map(c -> c.getLink()).anyMatch(link::equals);
   }
 
   @VisibleForTesting
@@ -161,6 +165,6 @@
             e);
       }
     }
-    return new PluginConfig(pluginName, new Config());
+    return PluginConfig.create(pluginName, new Config(), null);
   }
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/jira/workflow/MarkPropertyAsReleasedVersionParametersExtractor.java b/src/main/java/com/googlesource/gerrit/plugins/its/jira/workflow/MarkPropertyAsReleasedVersionParametersExtractor.java
index d55e550..65d3aa6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/jira/workflow/MarkPropertyAsReleasedVersionParametersExtractor.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/jira/workflow/MarkPropertyAsReleasedVersionParametersExtractor.java
@@ -36,7 +36,8 @@
     String[] parameters = actionRequest.getParameters();
     if (parameters.length != 1) {
       log.error(
-          "Wrong number of received parameters. Received parameters are {}. Only one parameter is expected, the property id.",
+          "Wrong number of received parameters. Received parameters are {}. Only one parameter is"
+              + " expected, the property id.",
           Arrays.toString(parameters));
       return Optional.empty();
     }
diff --git a/src/main/resources/Documentation/config.md b/src/main/resources/Documentation/config.md
index 9e35208..a86b80c 100644
--- a/src/main/resources/Documentation/config.md
+++ b/src/main/resources/Documentation/config.md
@@ -8,7 +8,7 @@
 project must have the following entry in its `project.config` file in
 the `refs/meta/config` branch:
 
-```
+```ini
   [plugin "its-jira"]
     enabled = true
 ```
@@ -43,7 +43,7 @@
 E.g. to limit the Jira integration to the `master` branch and all
 stable branches the following could be configured:
 
-```
+```ini
   [plugin "its-jira"]
     enabled = true
     branch = refs/heads/master
@@ -54,10 +54,10 @@
 -------------
 
 Git commits are associated to Jira issues reusing the existing Gerrit
-[commitLink configuration][1] to extract the issue-id from the commit
+[commentLink configuration][1] to extract the issue-id from the commit
 messages.
 
-[1]: ../../../Documentation/config-gerrit.html#__a_id_commentlink_a_section_commentlink
+[1]: ../../../Documentation/config-gerrit.html#commentlink
 
 Additionally you need to specify the enforcement policy for git commits
 with regards to issue-tracker associations; the following values are supported:
@@ -76,10 +76,12 @@
 
 Example:
 
+```ini
     [commentLink "its-jira"]
     match = ([A-Z]+-[0-9]+)
     html = "<a href=\"http://jira.example.com/browse/$1\">$1</a>"
     association = SUGGESTED
+```
 
 Jira connectivity
 -----------------
@@ -90,10 +92,12 @@
 
 Example:
 
+```ini
     [its-jira]
     url=http://jira.example.com
     username=admin
     password=jirapass
+```
 
 Jira credentials and connectivity details are asked and verified during the Gerrit init.
 
@@ -106,6 +110,7 @@
 
 Gerrit init example:
 
+```text
     *** Jira Integration
     ***
 
@@ -133,6 +138,7 @@
            suggested
            optional
     Issue-id enforced in commit message [MANDATORY/?]: suggested
+```
 
 The connectivity of its-jira plugin with Jira server happens on-request. When an
 action is requested, a connection is established based on any of the two
@@ -145,8 +151,9 @@
 `review_site/etc/its/actions.config`. Rules specific to @PLUGIN@ are defined in
 the file `review_site/etc/its/actions-@PLUGIN@.config`.
 
-**Sample actions-@Plugin@.config:**
+**Sample actions-@PLUGIN@.config:**
 
+```ini
     [rule "open"]
         event-type = patchset-created
         action = add-standard-comment
@@ -164,6 +171,7 @@
         event-type = change-abandoned
         action = add-standard-comment
         action = To Do
+```
 
 The first rule triggers an action which adds a comment and a hyperlink to the change created
 in gerrit. The comment will appear in an Jira issue's `Comment` section whenever a patchset-created
@@ -171,14 +179,22 @@
 in Jira to `In Progress`. The title of the action `In Progress` should match the workflow actions
 used by the JIRA server as different versions of JIRA can have different workflow actions.
 
+**Note:** Velocity comments were deprecated in Gerrit 2.14 and will be removed in Gerrit 2.16/3.0;
+the `actions-@PLUGIN@.config` needs to be changed accordingly. For example, to use Soy comments
+instead of velocity comments:
+
+```ini
+    [rule "open"]
+        event-type = patchset-created
+        action = add-soy-comment Change ${its.formatLink($changeUrl)} is created.
+        action = In Progress
+```
 
 Multiple Jira servers integration
 ---------------------------------
 
-```
-Please note that this feature is considered EXPERIMENTAL and should be used with
-caution, as it could expose sensitive information.
-```
+> Please note that this feature is considered EXPERIMENTAL and should be used with
+> caution, as it could expose sensitive information.
 
 In corporate environments, it is not unusual to have multiple Jira servers
 and it is a common requirement to integrate Gerrit projects with those.
@@ -194,6 +210,7 @@
 
 A typical Jira server configuration in the *project.config* file will look like:
 
+```ini
     [plugin "its-jira"]
          enabled = true
          instanceUrl = http://jiraserver:8075/
@@ -203,10 +220,12 @@
     [commentlink "its-jira"]
          match = ([A-Z]+-[0-9]+)
          link = http://jiraserver:8075/browse/$1
+```
 
 A different project could define its own Jira server in its *project.config*
 file:
 
+```ini
     [plugin "its-jira"]
          enabled = true
          instanceUrl = http://other_jiraserver:7171/
@@ -216,6 +235,7 @@
     [commentlink "its-jira"]
          match = (JIRA-ISSUE:[0-9]+)
          link = http://other_jiraserver:7171/browse/$1
+```
 
 In case its-jira plugin is enabled for a project but no Jira server is configured
 for the project, i.e., it is not specified in the *project.config* file, the
@@ -247,7 +267,7 @@
 
 Example with the event property `ref`:
 
-```
+```ini
   action = mark-property-as-released-version ref
 ```
 
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/jira/JiraConfigTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/jira/JiraConfigTest.java
index 7f5d0be..782b459 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/jira/JiraConfigTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/jira/JiraConfigTest.java
@@ -65,7 +65,7 @@
   @Test
   public void testGetPluginConfigFor() throws NoSuchProjectException {
     Project.NameKey project = Project.nameKey("$project");
-    PluginConfig pluginCfg = new PluginConfig(PLUGIN_NAME, new Config());
+    PluginConfig pluginCfg = PluginConfig.create(PLUGIN_NAME, new Config(), null);
     when(cfgFactory.getFromProjectConfigWithInheritance(project, PLUGIN_NAME))
         .thenReturn(pluginCfg);
     jiraConfig.getPluginConfigFor(project.get());
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/jira/JiraITTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/jira/JiraITTest.java
index e304b28..a656a06 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/jira/JiraITTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/jira/JiraITTest.java
@@ -24,7 +24,6 @@
 import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
 import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
-import static com.google.gerrit.server.project.ProjectCache.illegalState;
 import static java.lang.String.format;
 import static java.net.HttpURLConnection.HTTP_CREATED;
 import static java.net.HttpURLConnection.HTTP_FORBIDDEN;
@@ -37,7 +36,9 @@
 import com.google.gerrit.acceptance.TestPlugin;
 import com.google.gerrit.acceptance.UseLocalDisk;
 import com.google.gerrit.acceptance.config.GerritConfig;
+import com.google.gerrit.acceptance.testsuite.project.ProjectOperations;
 import com.google.gerrit.testing.ConfigSuite;
+import com.google.inject.Inject;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -73,6 +74,7 @@
   private Path its_dir;
 
   @Rule public WireMockRule wireMockRule = new WireMockRule(options().port(PORT));
+  @Inject private ProjectOperations projectOperations;
 
   @Override
   public void beforeTest(Description description) throws Exception {
@@ -82,12 +84,11 @@
 
   @Before
   public void enablePluginInProjectConfig() throws Exception {
-    projectCache
-        .get(project)
-        .orElseThrow(illegalState(project))
-        .getConfig()
-        .getPluginConfig(PLUGIN_NAME)
-        .setString("enabled", "true");
+    projectOperations
+        .project(project)
+        .forInvalidation()
+        .addProjectConfigUpdater(cfg -> cfg.setBoolean("plugin", PLUGIN_NAME, "enabled", true))
+        .invalidate();
   }
 
   @Test