Author: dennisl Date: Tue Aug 5 15:09:44 2008 New Revision: 682988 URL: http://svn.apache.org/viewvc?rev=682988&view=rev Log: o Produce proper output for all combinations of attributes and elements, regarding fixes and dueTo for issues.
Modified: maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-generation/src/changes/changes.xml maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-generation/verify.bsh maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesReportGenerator.java Modified: maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-generation/src/changes/changes.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-generation/src/changes/changes.xml?rev=682988&r1=682987&r2=682988&view=diff ============================================================================== --- maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-generation/src/changes/changes.xml (original) +++ maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-generation/src/changes/changes.xml Tue Aug 5 15:09:44 2008 @@ -37,7 +37,17 @@ <fixes issue="MCHANGES-1"/> <fixes issue="JIRA-12"/> <dueto name="John Doe" email="[EMAIL PROTECTED]"/> - <dueto name="Jane Doe"/> + <dueto name="Jane Doe"/> + </action> + <action dev="you" type="update" system="bugzilla"> + Handle different issue systems. + <fixes issue="bug-12345"/> + <dueto name="John Doe" email="[EMAIL PROTECTED]"/> + </action> + <action dev="him" type="update"> + Updated dependencies. + <dueto name="John Doe" email="[EMAIL PROTECTED]"/> + <dueto name="Jane Doe"/> </action> </release> Modified: maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-generation/verify.bsh URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-generation/verify.bsh?rev=682988&r1=682987&r2=682988&view=diff ============================================================================== --- maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-generation/verify.bsh (original) +++ maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-generation/verify.bsh Tue Aug 5 15:09:44 2008 @@ -34,22 +34,44 @@ return false; } FileInputStream fis = new FileInputStream ( report ); - String reportContent = IOUtil.toString ( fis ); - + String reportContent = IOUtil.toString ( fis ); + int indexOf = reportContent.indexOf( "Changes Report" ); if ( indexOf < 0) { System.err.println( "changes-report.html doesn't contains Changes Report title" ); return false; - } - + } + indexOf = reportContent.indexOf( "href=\"http://myjira/browse/MCHANGES-88\"" ); if ( indexOf < 0) { System.err.println( "changes-report.html doesn't contains jira issue link" ); return false; } - + + // Test for output problem caused by only using <dueTo> elements + indexOf = reportContent.indexOf( "Thanks to , " ); + if ( indexOf != -1) + { + System.err.println( "changes-report.html has too many dueTos in the Map" ); + return false; + } + + // Tests output problems caused by only using <fixes> element + indexOf = reportContent.indexOf( "bug-12345" ); + if ( indexOf < 0) + { + System.err.println( "changes-report.html doesn't contains issue text for issue specified with <fixes> element" ); + return false; + } + indexOf = reportContent.indexOf( "Fixes ." ); + if ( indexOf != -1) + { + System.err.println( "changes-report.html doesn't handle empty fixes attribute properly" ); + return false; + } + } catch( Throwable e ) { Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesReportGenerator.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesReportGenerator.java?rev=682988&r1=682987&r2=682988&view=diff ============================================================================== --- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesReportGenerator.java (original) +++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesReportGenerator.java Tue Aug 5 15:09:44 2008 @@ -53,15 +53,15 @@ * The token in [EMAIL PROTECTED] #issueLink} denoting the issue ID. */ private static final String ISSUE_TOKEN = "%ISSUE%"; - + private static final String DEFAULT_ISSUE_SYSTEM_KEY = "default"; private ChangesXML report; private String url; - + private Map issueLinksPerSystem; - + private boolean addActionDate; public ChangesReportGenerator() @@ -89,7 +89,7 @@ /** * @deprecated - */ + */ public String getIssueLink() { return (String) issueLinksPerSystem.get( DEFAULT_ISSUE_SYSTEM_KEY ); @@ -104,7 +104,7 @@ { return url; } - + public Map getIssueLinksPerSystem() { return issueLinksPerSystem; @@ -131,7 +131,7 @@ /** * Checks whether links to the issues can be generated. - * + * * @return <code>true</code> if issue links can be generated, <code>false</code> otherwise. */ public boolean canGenerateIssueLinks( String system ) @@ -152,8 +152,8 @@ return false; } return this.issueLinksPerSystem.containsKey( DEFAULT_ISSUE_SYSTEM_KEY ); - } - + } + public void doGenerateEmptyReport( ResourceBundle bundle, Sink sink, String message ) { sinkBeginReport( sink, bundle ); @@ -185,7 +185,7 @@ sinkHeader( sink, bundle.getString( "report.changes.label.changes" ) ); sinkHeader( sink, bundle.getString( "report.changes.label.by" ) ); - + if ( this.isAddActionDate() ) { sinkHeader( sink, bundle.getString( "report.changes.label.date" ) ); @@ -195,7 +195,7 @@ for ( int idx = 0; idx < actionList.size(); idx++ ) { Action action = (Action) actionList.get( idx ); - + sink.tableRow(); sinkShowTypeIcon( sink, action.getType() ); @@ -213,7 +213,7 @@ system = StringUtils.isEmpty( system ) ? DEFAULT_ISSUE_SYSTEM_KEY : system; if ( !canGenerateIssueLinks( system ) ) { - sink.text( action.getIssue() ); + constructIssueText( action.getIssue(), sink, action.getFixedIssues() ); } else { @@ -230,12 +230,12 @@ sink.tableCell_(); sinkCellLink( sink, action.getDev(), "team-list.html#" + action.getDev() ); - + if ( this.isAddActionDate() ) { sinkCell( sink, action.getDate() ); } - + sink.tableRow_(); } @@ -468,13 +468,13 @@ sink.tableCell_(); } - + /** - * @param issue the current String + * @param issue The issue specified by attributes + * @param fixes The List of issues specified as fixes elements */ private void constructIssueLink( String issue, String system, Sink sink, List fixes ) { - if ( StringUtils.isNotEmpty( issue ) ) { sink.link( parseIssueLink( issue, system ) ); @@ -482,16 +482,19 @@ sink.text( issue ); sink.link_(); + + if ( !fixes.isEmpty() ) + { + sink.text( ", " ); + } } for ( Iterator iterator = fixes.iterator(); iterator.hasNext(); ) { - FixedIssue fixedIssue = (FixedIssue) iterator.next(); String currentIssueId = fixedIssue.getIssue(); if ( StringUtils.isNotEmpty( currentIssueId ) ) { - sink.link( parseIssueLink( currentIssueId, system ) ); sink.text( currentIssueId ); @@ -499,33 +502,75 @@ sink.link_(); } + if ( iterator.hasNext() ) + { + sink.text( ", " ); + } + } + } + + /** + * @param issue The issue specified by attributes + * @param fixes The List of issues specified as fixes elements + */ + private void constructIssueText( String issue, Sink sink, List fixes ) + { + if ( StringUtils.isNotEmpty( issue ) ) + { + sink.text( issue ); + + if ( !fixes.isEmpty() ) + { + sink.text( ", " ); + } + } + + for ( Iterator iterator = fixes.iterator(); iterator.hasNext(); ) + { + FixedIssue fixedIssue = (FixedIssue) iterator.next(); + + String currentIssueId = fixedIssue.getIssue(); + if ( StringUtils.isNotEmpty( currentIssueId ) ) + { + sink.text( currentIssueId ); + } + + if ( iterator.hasNext() ) + { + sink.text( ", " ); + } } } - + /** - * + * * @param sink * @param action * @param bundle */ private void constructDueTo( Sink sink, Action action, ResourceBundle bundle, List dueTos ) { - - // creat a Map which key : dueTo name, value : dueTo email + + // Create a Map with key : dueTo name, value : dueTo email Map namesEmailMap = new LinkedHashMap(); - namesEmailMap.put( action.getDueTo(), action.getDueToEmail() ); - + + // Only add the dueTo specified as attributes, if it has either a dueTo or a dueToEmail + if ( StringUtils.isNotEmpty( action.getDueTo() ) || StringUtils.isNotEmpty( action.getDueToEmail() ) ) + { + namesEmailMap.put( action.getDueTo(), action.getDueToEmail() ); + } + for (Iterator iterator = dueTos.iterator();iterator.hasNext();) { DueTo dueTo = (DueTo) iterator.next(); namesEmailMap.put( dueTo.getName(), dueTo.getEmail() ); } - + if (namesEmailMap.isEmpty()) { return; } - + sink.text( " " + bundle.getString( "report.changes.text.thanx" ) + " " ); int i = 0; for (Iterator iterator = namesEmailMap.keySet().iterator(); iterator.hasNext();) @@ -548,8 +593,8 @@ sink.text( ", " ); } } - - sink.text( " ." ); + + sink.text( "." ); } }