Skip to content

Commit

Permalink
Fix Reports Success/Warning icons, counts
Browse files Browse the repository at this point in the history
  • Loading branch information
sultan committed Oct 15, 2022
1 parent 954a853 commit bdebc6d
Show file tree
Hide file tree
Showing 15 changed files with 185 additions and 245 deletions.
6 changes: 3 additions & 3 deletions src/it/it-dependency-updates-report-001/verify.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ try
System.out.println( "Result = \"" + result +"\"" );
return false;
}
if ( result.indexOf( "1.1.1 Next Incremental" ) < 0)
if ( result.indexOf( "1.1.1" ) < 0)
{
System.out.println( "Did not identify next incremental" );
System.out.println( "Result = \"" + result +"\"" );
Expand All @@ -35,7 +35,7 @@ try
System.out.println( "Result = \"" + result +"\"" );
return false;
}
if ( result.indexOf( "1.2 Next Minor" ) < 0)
if ( result.indexOf( "1.2" ) < 0)
{
System.out.println( "Did not identify next minor version" );
System.out.println( "Result = \"" + result +"\"" );
Expand All @@ -47,7 +47,7 @@ try
System.out.println( "Result = \"" + result +"\"" );
return false;
}
if ( result.indexOf( "2.0 Next Major" ) < 0)
if ( result.indexOf( "2.0" ) < 0)
{
System.out.println( "Did not identify next major version" );
System.out.println( "Result = \"" + result +"\"" );
Expand Down
8 changes: 4 additions & 4 deletions src/it/it-dependency-updates-report-002/verify.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ try
// System.out.println( "Result = \"" + result +"\"" );
// return false;
// }
// if ( result.indexOf( "1.1.0-2 Next Version" ) < 0)
// if ( result.indexOf( "1.1.0-2" ) < 0)
// {
// System.out.println( "Did not identify next version" );
// System.out.println( "Result = \"" + result +"\"" );
// return false;
// }
// if ( result.indexOf( "1.1.1 Next Incremental" ) < 0)
// if ( result.indexOf( "1.1.1" ) < 0)
// {
// System.out.println( "Did not identify next incremental" );
// System.out.println( "Result = \"" + result +"\"" );
Expand All @@ -35,7 +35,7 @@ try
// System.out.println( "Result = \"" + result +"\"" );
// return false;
// }
// if ( result.indexOf( "1.2 Next Minor" ) < 0)
// if ( result.indexOf( "1.2" ) < 0)
// {
// System.out.println( "Did not identify next minor version" );
// System.out.println( "Result = \"" + result +"\"" );
Expand All @@ -47,7 +47,7 @@ try
// System.out.println( "Result = \"" + result +"\"" );
// return false;
// }
// if ( result.indexOf( "2.0 Next Major" ) < 0)
// if ( result.indexOf( "2.0" ) < 0)
// {
// System.out.println( "Did not identify next major version" );
// System.out.println( "Result = \"" + result +"\"" );
Expand Down
6 changes: 3 additions & 3 deletions src/it/it-plugin-updates-report-001/verify.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ try
return false;
}
if ( result.indexOf( "Group Id localhost Artifact Id dummy-maven-plugin Current Version 1.0 Newer versions 2.0 "
+ "Next Major 2.1 3.0 3.1 Latest Major" ) < 0)
+ "2.1 3.0 3.1 Latest Major" ) < 0)
{
System.out.println( "Did not identify plugin next versions" );
System.out.println( "Result = \"" + result +"\"" );
return false;
}
if ( result.indexOf( "Group Id localhost Artifact Id dummy-api Current Version 1.1 Classifier Type jar Newer "
+ "versions 1.1.0-2 Latest Subincremental 1.1.1 Next Incremental 1.1.1-2 1.1.2 1.1.3 Latest Incremental 1.2 Next "
+ "Minor 1.2.1 1.2.2 1.3 Latest Minor 2.0 Next Major 2.1 3.0 Latest Major" ) < 0)
+ "versions 1.1.0-2 Latest Subincremental 1.1.1 1.1.1-2 1.1.2 1.1.3 Latest Incremental 1.2 "
+ "1.2.1 1.2.2 1.3 Latest Minor 2.0 2.1 3.0 Latest Major" ) < 0)
{
System.out.println( "Did not identify dependency next versions" );
System.out.println( "Result = \"" + result +"\"" );
Expand Down
2 changes: 1 addition & 1 deletion src/it/it-plugin-updates-report-002/verify.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ try
return false;
}
if ( result.indexOf( "Group Id localhost Artifact Id dummy-maven-plugin Current Version 1.0 Newer versions 2.0 "
+ "Next Major 2.1 3.0 3.1 Latest Major" ) < 0)
+ "2.1 3.0 3.1 Latest Major" ) < 0)
{
System.out.println( "Did not identify plugin next versions" );
System.out.println( "Result = \"" + result +"\"" );
Expand Down
2 changes: 1 addition & 1 deletion src/it/it-plugin-updates-report-003/verify.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ try
return false;
}
if ( result.indexOf( "Group Id localhost Artifact Id dummy-maven-plugin Current Version 1.0 Newer versions 2.0 "
+ "Next Major 2.1 3.0 3.1 Latest Major" ) < 0)
+ "2.1 3.0 3.1 Latest Major" ) < 0)
{
System.out.println( "Did not identify plugin next versions" );
System.out.println( "Result = \"" + result +"\"" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.apache.commons.lang3.tuple.Pair;

/**
* Utility providing a cached {@link ArtifactVersions#getOldestUpdate(Optional)} API
* Utility providing a cached {@link ArtifactVersions#getNewestUpdate(Optional)} API
*/
public class ArtifactVersionsCache
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public abstract class AbstractVersionsReportRenderer<T> extends VersionsReportRe
*/
protected T model;

protected ArtifactVersionsCache oldestUpdateCache
= new ArtifactVersionsCache( AbstractVersionDetails::getOldestUpdate );
protected ArtifactVersionsCache newestUpdateCache
= new ArtifactVersionsCache( AbstractVersionDetails::getNewestUpdate );

protected ArtifactVersionsCache allUpdatesCache
= new ArtifactVersionsCache( AbstractVersionDetails::getAllUpdates );
Expand Down Expand Up @@ -136,59 +136,11 @@ protected void renderOverview()
*/
protected <Q extends OverviewStats> void renderOverviewTableRow( Q stats )
{
sink.tableCell();
renderSuccessIcon();
sink.tableCell_();
sink.tableCell();
sink.text( getText( "report.overview.numUpToDate" ) );
sink.tableCell_();
sink.tableCell();
sink.text( Integer.toString( stats.getUpToDate() ) );
sink.tableCell_();
sink.tableRow_();
sink.tableRow();
sink.tableCell();
renderWarningIcon();
sink.tableCell_();
sink.tableCell();
sink.text( getText( "report.overview.numNewerVersionAvailable" ) );
sink.tableCell_();
sink.tableCell();
sink.text( Integer.toString( stats.getAny() ) );
sink.tableCell_();
sink.tableRow_();
sink.tableRow();
sink.tableCell();
renderWarningIcon();
sink.tableCell_();
sink.tableCell();
sink.text( getText( "report.overview.numNewerIncrementalAvailable" ) );
sink.tableCell_();
sink.tableCell();
sink.text( Integer.toString( stats.getIncremental() ) );
sink.tableCell_();
sink.tableRow_();
sink.tableRow();
sink.tableCell();
renderWarningIcon();
sink.tableCell_();
sink.tableCell();
sink.text( getText( "report.overview.numNewerMinorAvailable" ) );
sink.tableCell_();
sink.tableCell();
sink.text( Integer.toString( stats.getMinor() ) );
sink.tableCell_();
sink.tableRow_();
sink.tableRow();
sink.tableCell();
renderWarningIcon();
sink.tableCell_();
sink.tableCell();
sink.text( getText( "report.overview.numNewerMajorAvailable" ) );
sink.tableCell_();
sink.tableCell();
sink.text( Integer.toString( stats.getMajor() ) );
sink.tableCell_();
renderStatRow( "report.overview.numUpToDate", stats.getUpToDate() );
renderStatRow( "report.overview.numNewerVersionAvailable", stats.getAny() );
renderStatRow( "report.overview.numNewerIncrementalAvailable", stats.getIncremental() );
renderStatRow( "report.overview.numNewerMinorAvailable", stats.getMinor() );
renderStatRow( "report.overview.numNewerMajorAvailable", stats.getMajor() );
}

/**
Expand Down Expand Up @@ -237,13 +189,15 @@ protected void renderSummaryTableHeader( boolean hasScope, boolean hasType )
"report.latestIncremental", "report.latestMinor", "report.latestMajor" );
}

protected void renderSummaryTableRow( Dependency artifact, ArtifactVersions artifactVersions,
boolean includeScope )
protected void renderSummaryTableRow( Dependency artifact, ArtifactVersions details,
boolean includeScope )
{
ArtifactVersion[] allUpdates = allUpdatesCache.get( details, empty() );
boolean upToDate = allUpdates == null || allUpdates.length == 0;

sink.tableRow();
sink.tableCell();
ArtifactVersion[] allUpdates = artifactVersions.getAllUpdates( empty() );
if ( allUpdates == null || allUpdates.length == 0 )
if ( upToDate )
{
renderSuccessIcon();
}
Expand Down Expand Up @@ -275,37 +229,37 @@ protected void renderSummaryTableRow( Dependency artifact, ArtifactVersions arti
sink.tableCell_();

sink.tableCell();
if ( artifactVersions.getNewestUpdate( of( SUBINCREMENTAL ) ) != null )
if ( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null )
{
safeBold();
sink.text( artifactVersions.getNewestUpdate( of( SUBINCREMENTAL ) ).toString() );
sink.text( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ).toString() );
safeBold_();
}
sink.tableCell_();

sink.tableCell();
if ( artifactVersions.getNewestUpdate( of( INCREMENTAL ) ) != null )
if ( newestUpdateCache.get( details, of( INCREMENTAL ) ) != null )
{
safeBold();
sink.text( artifactVersions.getNewestUpdate( of( INCREMENTAL ) ).toString() );
sink.text( newestUpdateCache.get( details, of( INCREMENTAL ) ).toString() );
safeBold_();
}
sink.tableCell_();

sink.tableCell();
if ( artifactVersions.getNewestUpdate( of( MINOR ) ) != null )
if ( newestUpdateCache.get( details, of( MINOR ) ) != null )
{
safeBold();
sink.text( artifactVersions.getNewestUpdate( of( MINOR ) ).toString() );
sink.text( newestUpdateCache.get( details, of( MINOR ) ).toString() );
safeBold_();
}
sink.tableCell_();

sink.tableCell();
if ( artifactVersions.getNewestUpdate( of( MAJOR ) ) != null )
if ( newestUpdateCache.get( details, of( MAJOR ) ) != null )
{
safeBold();
sink.text( artifactVersions.getNewestUpdate( of( MAJOR ) ).toString() );
sink.text( newestUpdateCache.get( details, of( MAJOR ) ).toString() );
safeBold_();
}
sink.tableCell_();
Expand All @@ -316,37 +270,39 @@ protected void renderSummaryTableRow( Dependency artifact, ArtifactVersions arti
@SuppressWarnings( "checkstyle:MethodLength" )
protected void renderDependencyDetailTable( Dependency artifact, ArtifactVersions details, boolean includeScope )
{
ArtifactVersion[] allUpdates = allUpdatesCache.get( details, empty() );
boolean upToDate = allUpdates == null || allUpdates.length == 0;

final SinkEventAttributes headerAttributes = new SinkEventAttributeSet();
headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "20%" );
headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "70%" );
final SinkEventAttributes cellAttributes = new SinkEventAttributeSet();
headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "80%" );
headerAttributes.addAttribute( SinkEventAttributes.WIDTH, "30%" );
sink.table();
sink.tableRows( new int[] { Sink.JUSTIFY_RIGHT, Sink.JUSTIFY_LEFT }, false );
sink.tableRow();
sink.tableHeaderCell( headerAttributes );
sink.text( getText( "report.status" ) );
sink.tableHeaderCell_();
sink.tableCell( cellAttributes );
ArtifactVersion[] versions = allUpdatesCache.get( details, empty() );
if ( oldestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null )
if ( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null )
{
renderWarningIcon();
sink.nonBreakingSpace();
sink.text( getText( "report.otherUpdatesAvailable" ) );
}
else if ( oldestUpdateCache.get( details, of( INCREMENTAL ) ) != null )
else if ( newestUpdateCache.get( details, of( INCREMENTAL ) ) != null )
{
renderWarningIcon();
sink.nonBreakingSpace();
sink.text( getText( "report.incrementalUpdatesAvailable" ) );
}
else if ( oldestUpdateCache.get( details, of( MINOR ) ) != null )
else if ( newestUpdateCache.get( details, of( MINOR ) ) != null )
{
renderWarningIcon();
sink.nonBreakingSpace();
sink.text( getText( "report.minorUpdatesAvailable" ) );
}
else if ( oldestUpdateCache.get( details, of( MAJOR ) ) != null )
else if ( newestUpdateCache.get( details, of( MAJOR ) ) != null )
{
renderWarningIcon();
sink.nonBreakingSpace();
Expand Down Expand Up @@ -411,25 +367,25 @@ else if ( oldestUpdateCache.get( details, of( MAJOR ) ) != null )
sink.text( artifact.getType() );
sink.tableCell_();
sink.tableRow_();
if ( versions != null && versions.length > 0 )
if ( !upToDate )
{
sink.tableRow();
sink.tableHeaderCell( headerAttributes );
sink.text( getText( "report.updateVersions" ) );
sink.tableHeaderCell_();
sink.tableCell( cellAttributes );
for ( int i = 0; i < versions.length; i++ )
for ( int i = 0; i < allUpdates.length; i++ )
{
if ( i > 0 )
{
sink.lineBreak();
}
String label = getLabel( versions[i], details );
String label = getLabel( allUpdates[i], details );
if ( label != null )
{
safeBold();
}
sink.text( versions[i].toString() );
sink.text( allUpdates[i].toString() );
if ( label != null )
{
safeBold_();
Expand Down Expand Up @@ -462,4 +418,29 @@ protected void renderTableHeaderCells( String... keys )
sink.tableHeaderCell_();
} );
}

protected String getLabel( ArtifactVersion version, AbstractVersionDetails details )
{
if ( equals( version, newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) ) )
{
return getText( "report.latestSubIncremental" );
}

if ( equals( version, newestUpdateCache.get( details, of( INCREMENTAL ) ) ) )
{
return getText( "report.latestIncremental" );
}

if ( equals( version, newestUpdateCache.get( details, of( MINOR ) ) ) )
{
return getText( "report.latestMinor" );
}

if ( equals( version, newestUpdateCache.get( details, of( MAJOR ) ) ) )
{
return getText( "report.latestMajor" );
}

return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,19 @@ protected OverviewStats computeOverviewStats()
OverviewStats stats = new OverviewStats();
model.getAllUpdates().values().forEach( details ->
{
if ( oldestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null )
if ( newestUpdateCache.get( details, of( SUBINCREMENTAL ) ) != null )
{
stats.incrementAny();
}
else if ( oldestUpdateCache.get( details, of( INCREMENTAL ) ) != null )
else if ( newestUpdateCache.get( details, of( INCREMENTAL ) ) != null )
{
stats.incrementIncremental();
}
else if ( oldestUpdateCache.get( details, of( MINOR ) ) != null )
else if ( newestUpdateCache.get( details, of( MINOR ) ) != null )
{
stats.incrementMinor();
}
else if ( oldestUpdateCache.get( details, of( MAJOR ) ) != null )
else if ( newestUpdateCache.get( details, of( MAJOR ) ) != null )
{
stats.incrementMajor();
}
Expand Down
Loading

0 comments on commit bdebc6d

Please sign in to comment.