Adapt to the latest changes in master

Gerrit master has a specific ProjectConfig.Factory for
loading the project.config of a repository.

Amends also the method signatures to the latest
multi-jira server extensions merged on stable-2.16.

Change-Id: I16e311e80b12258049f7e8be41e489bae3223ac5
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/jira/JiraClient.java b/src/main/java/com/googlesource/gerrit/plugins/its/jira/JiraClient.java
index ab6cba2..2c8128c 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/jira/JiraClient.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/jira/JiraClient.java
@@ -102,10 +102,11 @@
     }
   }
 
-  public void createVersion(String projectKey, String version) throws IOException {
+  public void createVersion(JiraItsServerInfo server, String projectKey, String version)
+      throws IOException {
     log.debug("Trying to create version {} on project {}", version, projectKey);
     JiraVersion jiraVersion = JiraVersion.builder().project(projectKey).name(version).build();
-    apiBuilder.getVersions().doPost("", gson.toJson(jiraVersion), HTTP_CREATED);
+    apiBuilder.getVersions(server).doPost("", gson.toJson(jiraVersion), HTTP_CREATED);
     log.debug("Version {} created on project {}", version, projectKey);
   }
 
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 5b4e197..f4cf11d 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
@@ -60,6 +60,7 @@
   private final JiraItsServerInfo defaultJiraServerInfo;
   private final GitRepositoryManager repoManager;
   private final ProjectCache projectCache;
+  private final ProjectConfig.Factory projectConfigFactory;
   private final PersonIdent serverUser;
 
   @Inject
@@ -69,13 +70,15 @@
       PluginConfigFactory cfgFactory,
       @GerritPersonIdent PersonIdent serverUser,
       ProjectCache projectCache,
-      GitRepositoryManager repoManager) {
+      GitRepositoryManager repoManager,
+      ProjectConfig.Factory projectConfigFactory) {
     this.gerritConfig = config;
     this.pluginName = pluginName;
     this.cfgFactory = cfgFactory;
     this.serverUser = serverUser;
     this.projectCache = projectCache;
     this.repoManager = repoManager;
+    this.projectConfigFactory = projectConfigFactory;
     this.defaultJiraServerInfo = buildDefaultServerInfo(gerritConfig, pluginName);
   }
 
@@ -107,7 +110,7 @@
   void addCommentLinksSection(Project.NameKey projectName, JiraItsServerInfo jiraItsServerInfo) {
     try (Repository git = repoManager.openRepository(projectName);
         MetaDataUpdate md = new MetaDataUpdate(GitReferenceUpdated.DISABLED, projectName, git)) {
-      ProjectConfig config = ProjectConfig.read(md);
+      ProjectConfig config = projectConfigFactory.read(md);
       String link =
           CharMatcher.is('/').trimFrom(jiraItsServerInfo.getUrl().toString()) + JiraURL.URL_SUFFIX;
       if (!commentLinksExist(config, link)) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/jira/JiraItsFacade.java b/src/main/java/com/googlesource/gerrit/plugins/its/jira/JiraItsFacade.java
index 4480c08..1827a28 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/jira/JiraItsFacade.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/jira/JiraItsFacade.java
@@ -94,7 +94,7 @@
     execute(
         () -> {
           log.debug("Creating version {} on project {}", version, projectKey);
-          jiraClient.createVersion(projectKey, version);
+          jiraClient.createVersion(itsServerInfo, projectKey, version);
           return projectKey;
         });
   }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/its/jira/restapi/JiraRestApiProvider.java b/src/main/java/com/googlesource/gerrit/plugins/its/jira/restapi/JiraRestApiProvider.java
index 17809ab..7c59e09 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/its/jira/restapi/JiraRestApiProvider.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/its/jira/restapi/JiraRestApiProvider.java
@@ -40,7 +40,7 @@
     return get(serverInfo, JiraProject[].class, "/project");
   }
 
-  public JiraRestApi<JiraVersion[]> getVersions() {
-    return get(JiraVersion[].class, "/version");
+  public JiraRestApi<JiraVersion[]> getVersions(JiraItsServerInfo serverInfo) {
+    return get(serverInfo, JiraVersion[].class, "/version");
   }
 }
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 66e151e..5348e8f 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
@@ -23,6 +23,7 @@
 import com.google.gerrit.server.git.GitRepositoryManager;
 import com.google.gerrit.server.project.NoSuchProjectException;
 import com.google.gerrit.server.project.ProjectCache;
+import com.google.gerrit.server.project.ProjectConfig;
 import org.eclipse.jgit.lib.Config;
 import org.eclipse.jgit.lib.PersonIdent;
 import org.junit.Before;
@@ -44,13 +45,21 @@
   @Mock private PersonIdent serverUser;
   @Mock private ProjectCache projectCache;
   @Mock private GitRepositoryManager repoManager;
+  @Mock private ProjectConfig.Factory projectConfigFactory;
 
   private JiraConfig jiraConfig;
 
   @Before
   public void createJiraConfig() {
     jiraConfig =
-        new JiraConfig(cfg, PLUGIN_NAME, cfgFactory, serverUser, projectCache, repoManager);
+        new JiraConfig(
+            cfg,
+            PLUGIN_NAME,
+            cfgFactory,
+            serverUser,
+            projectCache,
+            repoManager,
+            projectConfigFactory);
   }
 
   @Test
diff --git a/src/test/java/com/googlesource/gerrit/plugins/its/jira/JiraItsFacadeTest.java b/src/test/java/com/googlesource/gerrit/plugins/its/jira/JiraItsFacadeTest.java
index 56dfb09..a7e9768 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/its/jira/JiraItsFacadeTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/its/jira/JiraItsFacadeTest.java
@@ -76,7 +76,7 @@
   public void createVersion() throws IOException {
     jiraFacade = new JiraItsFacade(jiraClient);
     jiraFacade.createVersion(PROJECT_KEY, "1.0");
-    verify(jiraClient).createVersion(PROJECT_KEY, "1.0");
+    verify(jiraClient).createVersion(server, PROJECT_KEY, "1.0");
   }
 
   @Test