[maven-project-info-reports-plugin] branch MPIR-385 created (now a15271a)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[maven-project-info-reports-plugin] branch MPIR-385 created (now a15271a)

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

slachiewicz pushed a change to branch MPIR-385
in repository https://gitbox.apache.org/repos/asf/maven-project-info-reports-plugin.git.


      at a15271a  [MPIR-385] - Emails in mailing list section of pom are improperly handled

This branch includes the following new commits:

     new a15271a  [MPIR-385] - Emails in mailing list section of pom are improperly handled

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Reply | Threaded
Open this post in threaded view
|

[maven-project-info-reports-plugin] 01/01: [MPIR-385] - Emails in mailing list section of pom are improperly handled

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

slachiewicz pushed a commit to branch MPIR-385
in repository https://gitbox.apache.org/repos/asf/maven-project-info-reports-plugin.git

commit a15271a904bc768b50ea751e0b363cfa042289f3
Author: Sylwester Lachiewicz <[hidden email]>
AuthorDate: Mon Dec 16 00:55:02 2019 +0100

    [MPIR-385] - Emails in mailing list section of pom are improperly handled
   
   
   
    - Corrected the generated link for emails in the mailing-list report.
    - Added asserts in the testReport() UT to avoid future regressions.
    Corrected as it was not showing exactly the same output than before when the emails were null.
   
    Factored out method createEmailLinkPatternedText() to render email links with a default value.
---
 .../report/projectinfo/MailingListsReport.java     | 32 +++++++++++++++-------
 .../report/projectinfo/MailingListsReportTest.java |  8 ++++++
 2 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java b/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java
index 1b6411b..39b415f 100644
--- a/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java
+++ b/src/main/java/org/apache/maven/report/projectinfo/MailingListsReport.java
@@ -161,18 +161,11 @@ public class MailingListsReport
                 // Validate here subsribe/unsubsribe lists and archives?
                 textRow.add( mailingList.getName() );
 
-                textRow.add( createLinkPatternedText( subscribe, mailingList.getSubscribe() ) );
+                textRow.add( createEmailLinkPatternedText( subscribe, mailingList.getSubscribe(), null ) );
 
-                textRow.add( createLinkPatternedText( unsubscribe, mailingList.getUnsubscribe() ) );
+                textRow.add( createEmailLinkPatternedText( unsubscribe, mailingList.getUnsubscribe(), null ) );
 
-                if ( mailingList.getPost() != null && mailingList.getPost().length() > 0 )
-                {
-                    textRow.add( createLinkPatternedText( post, mailingList.getPost() ) );
-                }
-                else
-                {
-                    textRow.add( "-" );
-                }
+                textRow.add( createEmailLinkPatternedText( post, mailingList.getPost(), "-" ) );
 
                 if ( mailingList.getArchive() != null && mailingList.getArchive().length() > 0 )
                 {
@@ -239,6 +232,25 @@ public class MailingListsReport
         }
 
         /**
+         * Create a link pattern text for email addresses defined by <code>{text, mailto:href}</code>. If href is null,
+         * then <code>defaultHref</code> is used instead.
+         *
+         * @param text a text.
+         * @param href the email address to use.
+         * @param defaultHref the String to use in case href is null.
+         * @return an email link pattern.
+         * @see #createLinkPatternedText(String,String)
+         */
+        private String createEmailLinkPatternedText( String text, String href, String defaultHref )
+        {
+            if ( href == null || href.isEmpty() )
+            {
+                return createLinkPatternedText( text, defaultHref );
+            }
+            return createLinkPatternedText( text, "mailto:" + href );
+        }
+
+        /**
          * Convenience method to return the name of a web-based mailing list archive server. <br>
          * For instance, if the archive uri is <code>http://www.mail-archive.com/dev@...</code>, this
          * method return <code>www.mail-archive.com</code>
diff --git a/src/test/java/org/apache/maven/report/projectinfo/MailingListsReportTest.java b/src/test/java/org/apache/maven/report/projectinfo/MailingListsReportTest.java
index 27dd5c5..112eb06 100644
--- a/src/test/java/org/apache/maven/report/projectinfo/MailingListsReportTest.java
+++ b/src/test/java/org/apache/maven/report/projectinfo/MailingListsReportTest.java
@@ -76,6 +76,14 @@ public class MailingListsReportTest
         TextBlock[] textBlocks = response.getTextBlocks();
         assertEquals( getString( "report.mailing-lists.title" ), textBlocks[0].getText() );
         assertEquals( getString( "report.mailing-lists.intro" ), textBlocks[1].getText() );
+
+        // MPIR-385: Test emails starts with 'mailto:'
+        String post = getString("report.mailing-lists.column.post");
+        assertEquals( "mailto:[hidden email]", response.getLinkWith( post ).getAttribute( "href" ) );
+        String subscribe = getString("report.mailing-lists.column.subscribe");
+        assertEquals( "mailto:[hidden email]", response.getLinkWith( subscribe ).getAttribute( "href" ) );
+        String unsubscribe = getString("report.mailing-lists.column.unsubscribe");
+        assertNull( response.getLinkWith( unsubscribe ) );
     }
 
     /**