This is an automated email from the ASF dual-hosted git repository.

sjaranowski pushed a commit to branch MCHANGES-400
in repository https://gitbox.apache.org/repos/asf/maven-changes-plugin.git

commit ccd953e06c3a304b232cc6429bd93a198dd83f03
Author: Slawomir Jaranowski <s.jaranow...@gmail.com>
AuthorDate: Sun Dec 1 12:28:39 2024 +0100

    [MCHANGES-400] Authenticating to GitHub API by Authorization  Bearer
---
 src/it/report-github/pom.xml                       |  75 +++++++++++++++
 src/it/report-github/setup.groovy                  | 101 +++++++++++++++++++++
 .../{report-jira => report-github}/verify.groovy   |  18 +++-
 src/it/report-jira/setup.groovy                    |   2 -
 src/it/report-jira/verify.groovy                   |   2 +-
 src/it/settings.xml                                |   8 +-
 .../changes/announcement/AnnouncementMojo.java     |  25 +----
 .../plugins/changes/github/GitHubDownloader.java   |  24 ++---
 .../maven/plugins/changes/github/GitHubReport.java |  25 ++---
 .../apache/maven/plugins/changes/issues/Issue.java |  12 +--
 .../plugins/changes/jira/RestJiraDownloader.java   |   5 -
 .../apt/examples/configuring-github-report.apt.vm  |  39 ++++----
 ...aderTestCase.java => GitHubDownloaderTest.java} |  17 +++-
 13 files changed, 249 insertions(+), 104 deletions(-)

diff --git a/src/it/report-github/pom.xml b/src/it/report-github/pom.xml
new file mode 100644
index 0000000..2e48d23
--- /dev/null
+++ b/src/it/report-github/pom.xml
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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
+
+  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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.plugins</groupId>
+  <artifactId>maven-changes-plugin-test</artifactId>
+  <version>99.0</version>
+  <name>Maven</name>
+  <packaging>jar</packaging>
+
+  <properties>
+    <changesPluginVersion>@project.version@</changesPluginVersion>
+  </properties>
+
+  <issueManagement>
+    <system>GitHub</system>
+    <url>${mockServerUrl}/owner-name/repo-name/issues</url>
+  </issueManagement>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-changes-plugin</artifactId>
+          <version>${changesPluginVersion}</version>
+        </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-site-plugin</artifactId>
+          <version>@sitePluginVersion@</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+
+  <reporting>
+    <excludeDefaults>true</excludeDefaults>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-changes-plugin</artifactId>
+        <version>@project.version@</version>
+        <reportSets>
+          <reportSet>
+            <reports>
+              <report>github-report</report>
+            </reports>
+          </reportSet>
+        </reportSets>
+      </plugin>
+    </plugins>
+  </reporting>
+
+</project>
diff --git a/src/it/report-github/setup.groovy 
b/src/it/report-github/setup.groovy
new file mode 100644
index 0000000..00b6b0a
--- /dev/null
+++ b/src/it/report-github/setup.groovy
@@ -0,0 +1,101 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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
+ *
+ * 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.
+ */
+
+import com.github.tomakehurst.wiremock.WireMockServer
+import com.github.tomakehurst.wiremock.common.ConsoleNotifier
+import com.github.tomakehurst.wiremock.core.WireMockConfiguration
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse
+import static com.github.tomakehurst.wiremock.client.WireMock.configureFor
+import static com.github.tomakehurst.wiremock.client.WireMock.equalTo
+import static com.github.tomakehurst.wiremock.client.WireMock.get
+import static com.github.tomakehurst.wiremock.client.WireMock.stubFor
+
+WireMockServer wireMockServer = new 
WireMockServer(WireMockConfiguration.options()
+        .dynamicPort()
+        .notifier(new ConsoleNotifier(false)))
+wireMockServer.start()
+
+def userProperties = context.get('userProperties')
+userProperties.put('mockServerUrl', wireMockServer.baseUrl())
+
+configureFor(wireMockServer.port())
+
+stubFor(get('/repos/owner-name/repo-name')
+        .withHeader('accept', equalTo('application/vnd.github+json'))
+        .withHeader('authorization', equalTo('Bearer github-token'))
+        .willReturn(aResponse().withStatus(200).withBody('''
+{
+    "full_name": "owner-name/repo-name"
+}
+''')))
+
+stubFor(get('/repos/owner-name/repo-name/issues?state=open')
+        .withHeader('accept', equalTo('application/vnd.github+json'))
+        .withHeader('authorization', equalTo('Bearer github-token'))
+        .willReturn(aResponse().withStatus(200).withBody('''
+[
+    {
+        "number": 1234,
+        "title": "Authentication does not work after Upgrade",
+        "created_at": "2024-09-22T07:34:16Z",
+        "updated_at": "2024-11-04T06:12:17Z",
+        "closed_at": null,
+        "user": {
+            "login": "reporter-user1"        
+        },
+        "assignee": {
+            "login": "assigned-user1"
+        },
+        "milestone": {
+            "title": "2.12.1"
+        },
+        "state": "open"
+    }
+]
+''')))
+
+stubFor(get('/repos/owner-name/repo-name/issues?state=closed')
+        .withHeader('accept', equalTo('application/vnd.github+json'))
+        .withHeader('authorization', equalTo('Bearer github-token'))
+        .willReturn(aResponse().withStatus(200).withBody('''
+[
+    {
+        "number": 1235,
+        "title": "Next issue for testing",
+        "created_at": "2024-09-22T07:34:16Z",
+        "updated_at": "2023-11-04T06:12:17Z",
+        "closed_at": "2024-12-01T06:12:17Z",
+        "user": {
+            "login": "reporter-user2"        
+        },
+        "assignee": {
+            "login": "assigned-user2"
+        },
+        "milestone": {
+            "title": "2.12.2"
+        },
+        "state": "closed"
+    }
+]
+''')))
+
+context.put("wireMockServer", wireMockServer)
+true
+
diff --git a/src/it/report-jira/verify.groovy 
b/src/it/report-github/verify.groovy
similarity index 61%
copy from src/it/report-jira/verify.groovy
copy to src/it/report-github/verify.groovy
index 20f8f59..b316f81 100644
--- a/src/it/report-jira/verify.groovy
+++ b/src/it/report-github/verify.groovy
@@ -22,10 +22,18 @@ import com.github.tomakehurst.wiremock.WireMockServer
 WireMockServer wireMockServer = context.get("wireMockServer")
 wireMockServer.stop()
 
-content = new File( basedir, 'target/site/jira-report.html' ).text;
+content = new File(basedir, 'target/site/github-report.html').text;
 
-assert content.contains('/browse/TEST_PROJECT-1">TEST_PROJECT-1</a>');
+assert content.contains('/owner-name/repo-name/issues/1234">1234</a>');
 assert content.contains('<td>Authentication does not work after Upgrade</td>');
-assert content.contains('<td>Closed</td>');
-assert content.contains('<td>Fixed</td>');
-assert content.contains('<td>Assigned User</td>');
+assert content.contains('<td>OPEN</td>');
+assert content.contains('<td>assigned-user1</td>')
+assert content.contains('<td>reporter-user1</td>');
+assert content.contains('<td>2.12.1</td>');
+
+assert content.contains('/owner-name/repo-name/issues/1235">1235</a>');
+assert content.contains('<td>Next issue for testing</td>');
+assert content.contains('<td>CLOSED</td>');
+assert content.contains('<td>assigned-user2</td>')
+assert content.contains('<td>reporter-user2</td>');
+assert content.contains('<td>2.12.2</td>');
diff --git a/src/it/report-jira/setup.groovy b/src/it/report-jira/setup.groovy
index dee803d..5206031 100644
--- a/src/it/report-jira/setup.groovy
+++ b/src/it/report-jira/setup.groovy
@@ -17,9 +17,7 @@
  * under the License.
  */
 
-
 import com.github.tomakehurst.wiremock.WireMockServer
-import com.github.tomakehurst.wiremock.client.WireMock
 import com.github.tomakehurst.wiremock.common.ConsoleNotifier
 import com.github.tomakehurst.wiremock.core.WireMockConfiguration
 
diff --git a/src/it/report-jira/verify.groovy b/src/it/report-jira/verify.groovy
index 20f8f59..a80f3ce 100644
--- a/src/it/report-jira/verify.groovy
+++ b/src/it/report-jira/verify.groovy
@@ -22,7 +22,7 @@ import com.github.tomakehurst.wiremock.WireMockServer
 WireMockServer wireMockServer = context.get("wireMockServer")
 wireMockServer.stop()
 
-content = new File( basedir, 'target/site/jira-report.html' ).text;
+content = new File(basedir, 'target/site/jira-report.html').text;
 
 assert content.contains('/browse/TEST_PROJECT-1">TEST_PROJECT-1</a>');
 assert content.contains('<td>Authentication does not work after Upgrade</td>');
diff --git a/src/it/settings.xml b/src/it/settings.xml
index a57ccfa..f93d3f6 100644
--- a/src/it/settings.xml
+++ b/src/it/settings.xml
@@ -19,7 +19,8 @@ specific language governing permissions and limitations
 under the License.
 -->
 
-<settings>
+<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 
https://maven.apache.org/xsd/settings-1.2.0.xsd";>
   <profiles>
     <profile>
       <id>it-repo</id>
@@ -60,5 +61,10 @@ under the License.
       <!-- <password>jira-password</password> -->
       <password>{xZLx2669VMsHnW8pO9Ehd1FLMrPsCOQ3g2MiRNNA5vI=}</password>
     </server>
+    <server>
+      <id>github</id>
+      <!-- github-token -->
+      <password>{d0C24IDj+NEH8LOV7aQGx+yYDYR7nI4T9okO70geQuc=}</password>
+    </server>
   </servers>
 </settings>
diff --git 
a/src/main/java/org/apache/maven/plugins/changes/announcement/AnnouncementMojo.java
 
b/src/main/java/org/apache/maven/plugins/changes/announcement/AnnouncementMojo.java
index 3527d52..82d72bd 100644
--- 
a/src/main/java/org/apache/maven/plugins/changes/announcement/AnnouncementMojo.java
+++ 
b/src/main/java/org/apache/maven/plugins/changes/announcement/AnnouncementMojo.java
@@ -414,24 +414,10 @@ public class AnnouncementMojo extends 
AbstractAnnouncementMojo {
     // =======================================//
 
     /**
-     * The scheme of your github api domain. Only use if using github 
enterprise.
-     *
-     * @since 2.9
-     */
-    @Parameter(defaultValue = "http", property = "changes.githubAPIScheme")
-    private String githubAPIScheme;
-
-    /**
-     * The port of your github api domain. Only use if using github enterprise.
-     *
-     * @since 2.9
-     */
-    @Parameter(defaultValue = "80", property = "changes.githubAPIPort")
-    private int githubAPIPort;
-
-    /**
-     * The settings.xml server id to be used to authenticate into github api 
domain. Only use if using github
-     * enterprise.
+     * The settings.xml server id to be used to authenticate into GitHub Api.
+     * <br>
+     * Since 3.x - only password item is used as authentication token with 
{@code Authorization: Bearer YOUR-TOKEN}
+     * <a 
href="https://docs.github.com/en/rest/authentication/authenticating-to-the-rest-api";>Authenticating
 to the REST API</a>
      *
      * @since 2.12
      */
@@ -760,8 +746,7 @@ public class AnnouncementMojo extends 
AbstractAnnouncementMojo {
 
     protected List<Release> getGitHubReleases() throws MojoExecutionException {
         try {
-            GitHubDownloader issueDownloader =
-                    new GitHubDownloader(project, githubAPIScheme, 
githubAPIPort, includeOpenIssues, true);
+            GitHubDownloader issueDownloader = new GitHubDownloader(project, 
includeOpenIssues, true);
 
             issueDownloader.configureAuthentication(settingsDecrypter, 
githubAPIServerId, settings, getLog());
 
diff --git 
a/src/main/java/org/apache/maven/plugins/changes/github/GitHubDownloader.java 
b/src/main/java/org/apache/maven/plugins/changes/github/GitHubDownloader.java
index a18415b..943056e 100644
--- 
a/src/main/java/org/apache/maven/plugins/changes/github/GitHubDownloader.java
+++ 
b/src/main/java/org/apache/maven/plugins/changes/github/GitHubDownloader.java
@@ -74,12 +74,7 @@ public class GitHubDownloader {
      */
     private String githubIssueURL;
 
-    public GitHubDownloader(
-            MavenProject project,
-            String githubScheme,
-            int githubPort,
-            boolean includeOpenIssues,
-            boolean onlyMilestoneIssues)
+    public GitHubDownloader(MavenProject project, boolean includeOpenIssues, 
boolean onlyMilestoneIssues)
             throws IOException {
         this.includeOpenIssues = includeOpenIssues;
         this.onlyMilestoneIssues = onlyMilestoneIssues;
@@ -91,7 +86,9 @@ public class GitHubDownloader {
         if (githubURL.getHost().equalsIgnoreCase("github.com")) {
             this.client = new GitHubBuilder();
         } else {
-            this.client = new GitHubBuilder().withEndpoint(githubScheme + 
githubURL.getHost() + githubPort);
+            this.client = new GitHubBuilder()
+                    .withEndpoint(githubURL.getProtocol() + "://" + 
githubURL.getHost()
+                            + (githubURL.getPort() == -1 ? "" : ":" + 
githubURL.getPort()));
         }
 
         this.githubIssueURL = project.getIssueManagement().getUrl();
@@ -139,8 +136,6 @@ public class GitHubDownloader {
             }
         }
 
-        issue.setTitle(githubIssue.getTitle());
-
         issue.setSummary(githubIssue.getTitle());
 
         if (githubIssue.getMilestone() != null) {
@@ -149,11 +144,7 @@ public class GitHubDownloader {
 
         issue.setReporter(githubIssue.getUser().getLogin());
 
-        if (githubIssue.getClosedAt() != null) {
-            issue.setStatus("closed");
-        } else {
-            issue.setStatus("open");
-        }
+        issue.setStatus(githubIssue.getState().name());
 
         final Collection<GHLabel> labels = githubIssue.getLabels();
         if (labels != null && !labels.isEmpty()) {
@@ -201,9 +192,8 @@ public class GitHubDownloader {
                     log.error(problem.getMessage(), problem.getException());
                 }
                 server = result.getServer();
-                String user = server.getUsername();
                 String password = server.getPassword();
-                this.client.withPassword(user, password);
+                client.withJwtToken(password);
 
                 configured = true;
                 break;
@@ -211,7 +201,7 @@ public class GitHubDownloader {
         }
 
         if (!configured) {
-            log.warn("Can't find server id [" + githubAPIServerId + "] 
configured in githubAPIServerId.");
+            log.warn("Can't find server id [" + githubAPIServerId + "] 
configured in settings.xml");
         }
     }
 }
diff --git 
a/src/main/java/org/apache/maven/plugins/changes/github/GitHubReport.java 
b/src/main/java/org/apache/maven/plugins/changes/github/GitHubReport.java
index cf467c4..77ae516 100644
--- a/src/main/java/org/apache/maven/plugins/changes/github/GitHubReport.java
+++ b/src/main/java/org/apache/maven/plugins/changes/github/GitHubReport.java
@@ -77,20 +77,12 @@ public class GitHubReport extends AbstractChangesReport {
     private String columnNames;
 
     /**
-     * The scheme of your github api domain. Only use if using github 
enterprise.
-     */
-    @Parameter(defaultValue = "http")
-    private String githubAPIScheme;
-
-    /**
-     * The port of your github api domain. Only use if using github enterprise.
-     */
-    @Parameter(defaultValue = "80")
-    private int githubAPIPort;
-
-    /**
-     * The settings.xml server id to be used to authenticate into github api 
domain. Only use if using github
-     * enterprise.
+     * The settings.xml server id to be used to authenticate into GitHub Api.
+     * <br>
+     * Since 3.x - only password item is used as authentication token with 
{@code Authorization: Bearer YOUR-TOKEN}
+     * <a 
href="https://docs.github.com/en/rest/authentication/authenticating-to-the-rest-api";>Authenticating
 to the REST API</a>
+     *
+     * @since 2.12
      */
     @Parameter(defaultValue = "github")
     private String githubAPIServerId;
@@ -180,8 +172,7 @@ public class GitHubReport extends AbstractChangesReport {
 
         try {
             // Download issues
-            GitHubDownloader issueDownloader = new GitHubDownloader(
-                    project, githubAPIScheme, githubAPIPort, 
includeOpenIssues, onlyMilestoneIssues);
+            GitHubDownloader issueDownloader = new GitHubDownloader(project, 
includeOpenIssues, onlyMilestoneIssues);
 
             issueDownloader.configureAuthentication(settingsDecrypter, 
githubAPIServerId, settings, getLog());
 
@@ -203,7 +194,7 @@ public class GitHubReport extends AbstractChangesReport {
             }
         } catch (MalformedURLException e) {
             // Rethrow this error so that the build fails
-            throw new MavenReportException("The Github URL is incorrect.");
+            throw new MavenReportException("The Github URL is incorrect - " + 
e.getMessage());
         } catch (Exception e) {
             throw new MavenReportException(e.getMessage(), e);
         }
diff --git a/src/main/java/org/apache/maven/plugins/changes/issues/Issue.java 
b/src/main/java/org/apache/maven/plugins/changes/issues/Issue.java
index dcfa3c6..24b87ef 100644
--- a/src/main/java/org/apache/maven/plugins/changes/issues/Issue.java
+++ b/src/main/java/org/apache/maven/plugins/changes/issues/Issue.java
@@ -54,8 +54,6 @@ public class Issue {
 
     private String summary;
 
-    private String title;
-
     private String type;
 
     private Date updated;
@@ -166,14 +164,6 @@ public class Issue {
         this.summary = summary;
     }
 
-    public String getTitle() {
-        return title;
-    }
-
-    public void setTitle(String title) {
-        this.title = title;
-    }
-
     public String getType() {
         return type;
     }
@@ -199,7 +189,7 @@ public class Issue {
     }
 
     public String toString() {
-        return this.getClass().getSimpleName() + "[id='" + this.getId() + "'" 
+ ", title='" + this.getTitle() + "'"
+        return this.getClass().getSimpleName() + "[id='" + this.getId() + "'" 
+ ", summary='" + this.getSummary() + "'"
                 + ", fixVersions='" + this.getFixVersions() + "'" + "]";
     }
 }
diff --git 
a/src/main/java/org/apache/maven/plugins/changes/jira/RestJiraDownloader.java 
b/src/main/java/org/apache/maven/plugins/changes/jira/RestJiraDownloader.java
index 2ab4df5..a621a32 100644
--- 
a/src/main/java/org/apache/maven/plugins/changes/jira/RestJiraDownloader.java
+++ 
b/src/main/java/org/apache/maven/plugins/changes/jira/RestJiraDownloader.java
@@ -563,11 +563,6 @@ public class RestJiraDownloader {
                 issue.setSummary(val.asText());
             }
 
-            val = fieldsNode.get("title");
-            if (val != null) {
-                issue.setTitle(val.asText());
-            }
-
             val = fieldsNode.get("updated");
             processUpdated(issue, val);
 
diff --git a/src/site/apt/examples/configuring-github-report.apt.vm 
b/src/site/apt/examples/configuring-github-report.apt.vm
index 38c50a8..657172b 100644
--- a/src/site/apt/examples/configuring-github-report.apt.vm
+++ b/src/site/apt/examples/configuring-github-report.apt.vm
@@ -34,32 +34,31 @@ Configuring the GitHub Report
 
 * Using GitHub Enterprise
 
-  If you are using GitHub Enterprise you will want to make sure that the
-  githubAPIScheme and githubAPIPort are correct (they default to "http" and 80
-  by default). If either of these are incorrect make sure to include them in
-  your configuration.
+  Additional configurations are not needed. Address of your <<GitHub>> 
instance will be taken from <<<project -> issueManagement -> url>>>
+
+* Authenticating to the GitHub REST API
+
+  If you are using GitHub Enterprise or you want to authenticate to GitHub you 
will want to add server configuration in your settings.xml, like:
 
 +-----------------+
-<project>
+<settings>
   ...
-  <reporting>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-changes-plugin</artifactId>
-        <version>${project.version}</version>
-        <configuration>
-          <githubAPIScheme>https</githubAPIScheme>
-          <githubAPIPort>443</githubAPIPort>
-        </configuration>
-        ...
-      </plugin>
-    </plugins>
-  </reporting>
+  <servers>
+    <server>
+      <id>github</id>
+      <password>YOUR-TOKEN</password>
+    </server>
+  </servers>
   ...
-</project>
+</settings>
 +-----------------+
 
+  Only <<<password>>> item is used as your token for <<<Authorization: Bearer 
YOUR-TOKEN>>>
+
+  Default serverId is <<<github>>>, you can change it by 
<<<\<githubAPIServerId\>>>> configuration parameter.
+
+  
{{{https://docs.github.com/en/rest/authentication/authenticating-to-the-rest-api}Authenticating
 to the REST API}}
+
 * Filtering Issues
 
  We'll start off by creating a GitHub Report for one or more versions of your
diff --git 
a/src/test/java/org/apache/maven/plugins/changes/github/GitHubDownloaderTestCase.java
 
b/src/test/java/org/apache/maven/plugins/changes/github/GitHubDownloaderTest.java
similarity index 92%
rename from 
src/test/java/org/apache/maven/plugins/changes/github/GitHubDownloaderTestCase.java
rename to 
src/test/java/org/apache/maven/plugins/changes/github/GitHubDownloaderTest.java
index 216ebed..04ea946 100644
--- 
a/src/test/java/org/apache/maven/plugins/changes/github/GitHubDownloaderTestCase.java
+++ 
b/src/test/java/org/apache/maven/plugins/changes/github/GitHubDownloaderTest.java
@@ -22,7 +22,6 @@ import java.io.IOException;
 import java.util.Collections;
 import java.util.List;
 
-import junit.framework.TestCase;
 import org.apache.maven.model.IssueManagement;
 import org.apache.maven.plugin.logging.Log;
 import org.apache.maven.plugins.changes.issues.Issue;
@@ -36,17 +35,22 @@ import 
org.apache.maven.settings.crypto.DefaultSettingsDecryptionRequest;
 import org.apache.maven.settings.crypto.SettingsDecrypter;
 import org.apache.maven.settings.crypto.SettingsDecryptionRequest;
 import org.apache.maven.settings.crypto.SettingsDecryptionResult;
+import org.junit.Test;
 import org.kohsuke.github.GHIssue;
+import org.kohsuke.github.GHIssueState;
 import org.kohsuke.github.GHUser;
 import org.mockito.ArgumentCaptor;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
 import static org.mockito.Mockito.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-public class GitHubDownloaderTestCase extends TestCase {
+public class GitHubDownloaderTest {
 
+    @Test
     public void testCreateIssue() throws IOException {
         IssueManagement issueManagement = newGitHubIssueManagement();
         GitHubDownloader gitHubDownloader = 
newGitHubDownloader(issueManagement);
@@ -56,16 +60,18 @@ public class GitHubDownloaderTestCase extends TestCase {
         when(githubIssue.getTitle()).thenReturn("Title");
         when(githubIssue.getBody()).thenReturn("Body");
         when(githubIssue.getUser()).thenReturn(new GHUser());
+        when(githubIssue.getState()).thenReturn(GHIssueState.OPEN);
 
         Issue issue = gitHubDownloader.createIssue(githubIssue);
 
         assertEquals(Integer.toString(githubIssue.getNumber()), issue.getId());
         assertEquals(Integer.toString(githubIssue.getNumber()), 
issue.getKey());
-        assertEquals(githubIssue.getTitle(), issue.getTitle());
         assertEquals(githubIssue.getTitle(), issue.getSummary());
+        assertEquals(githubIssue.getState().name(), issue.getStatus());
         assertEquals(issueManagement.getUrl() + githubIssue.getNumber(), 
issue.getLink());
     }
 
+    @Test
     public void testConfigureAuthenticationWithProblems() throws Exception {
         IssueManagement issueManagement = newGitHubIssueManagement();
         GitHubDownloader gitHubDownloader = 
newGitHubDownloader(issueManagement);
@@ -91,6 +97,7 @@ public class GitHubDownloaderTestCase extends TestCase {
         assertSame(server, servers.get(0));
     }
 
+    @Test
     public void testConfigureAuthenticationWithNoServer() throws Exception {
         IssueManagement issueManagement = newGitHubIssueManagement();
         GitHubDownloader gitHubDownloader = 
newGitHubDownloader(issueManagement);
@@ -106,7 +113,7 @@ public class GitHubDownloaderTestCase extends TestCase {
 
         gitHubDownloader.configureAuthentication(decrypter, "github-server", 
settings, log);
 
-        verify(log).warn("Can't find server id [github-server] configured in 
githubAPIServerId.");
+        verify(log).warn("Can't find server id [github-server] configured in 
settings.xml");
     }
 
     private Server newServer(String id) {
@@ -120,7 +127,7 @@ public class GitHubDownloaderTestCase extends TestCase {
     private GitHubDownloader newGitHubDownloader(IssueManagement 
issueManagement) throws IOException {
         MavenProject mavenProject = new MavenProject();
         mavenProject.setIssueManagement(issueManagement);
-        return new GitHubDownloader(mavenProject, "https", 80, true, false);
+        return new GitHubDownloader(mavenProject, true, false);
     }
 
     private IssueManagement newGitHubIssueManagement() {

Reply via email to