SnapshotPart extends VersionPart implements Serializable { @Override public int compareTo( final VersionPart o ) { if ( o instanceof SnapshotPart ) { final SnapshotPart oSnap = (SnapshotPart) o; if ( !isLocalSnapshot() && !oSnap.isLocalSnapshot() ) { final int comp = getTimestamp().compareTo( oSnap.getTimestamp() ); if ( comp == 0 ) { return getBuildNumber() - oSnap.getBuildNumber(); } return comp; } else if ( isLocalSnapshot() && !oSnap.isLocalSnapshot() ) { return 1; } else if ( !isLocalSnapshot() && oSnap.isLocalSnapshot() ) { return -1; } return 0; } else if ( o instanceof StringPart ) { return -1 * o.compareTo( this ); } else { return -1; } } SnapshotPart( final Date timestamp, final int buildNumber, final String literal );  SnapshotPart( final String literal ); String getLiteral(); Date getTimestamp(); int getBuildNumber(); boolean isLocalSnapshot(); boolean isRemoteSnapshot(); @Override String toString(); @Override String renderStandard(); String getValue(); @Override int compareTo( final VersionPart o ); boolean isPaddingPrepended(); @Override int hashCode(); @Override boolean equals( final Object obj );  }
@Test public void compareTwoRemoteSnapshotsWithDifferentTimestamps_ParsedFromLiterals() throws Exception { final SnapshotPart first = new SnapshotPart( "20140604.124355-1" ); final SnapshotPart second = new SnapshotPart( "20140604.124350-1" ); final int result = first.compareTo( second ); assertThat( result, equalTo( 1 ) ); }
@Test public void compareLocalVsRemoteSnapshot_LocalSortsLastAsMostRecent() throws Exception { final SnapshotPart first = new SnapshotPart( SnapshotUtils.LOCAL_SNAPSHOT_VERSION_PART ); final SnapshotPart second = new SnapshotPart( "20140604.124350-1" ); final int result = first.compareTo( second ); assertThat( result, equalTo( 1 ) ); }