Fixes failing testing and adding missing cases.

This commit is contained in:
yueh 2016-10-27 19:29:23 +02:00
parent bbf77dc65f
commit 0bbf898709
2 changed files with 7 additions and 10 deletions

View file

@ -42,16 +42,10 @@ public final class DefaultVersion extends BaseVersion
@Override @Override
public boolean isNewerAs( final Version maybeOlder ) public boolean isNewerAs( final Version maybeOlder )
{ {
if( this.revision() < maybeOlder.revision() ) final boolean isNewerRevision = this.revision() > maybeOlder.revision();
{ final boolean isNewerChannel = this.channel().compareTo( maybeOlder.channel() ) > 0;
return false; final boolean isNewerBuild = this.build() > maybeOlder.build();
}
if( this.channel().compareTo( maybeOlder.channel() ) < 0 ) return isNewerRevision || isNewerChannel || isNewerBuild;
{
return false;
}
return this.build() > maybeOlder.build();
} }
} }

View file

@ -36,6 +36,7 @@ public final class VersionTest
private static final Version DEFAULT_VERSION_RV2_BETA_9 = new DefaultVersion( 2, Channel.Beta, 9 ); private static final Version DEFAULT_VERSION_RV2_BETA_9 = new DefaultVersion( 2, Channel.Beta, 9 );
private static final Version DEFAULT_VERSION_RV3_BETA_8 = new DefaultVersion( 3, Channel.Beta, 8 ); private static final Version DEFAULT_VERSION_RV3_BETA_8 = new DefaultVersion( 3, Channel.Beta, 8 );
private static final Version DEFAULT_VERSION_RV2_ALPHA_8 = new DefaultVersion( 2, Channel.Alpha, 8 ); private static final Version DEFAULT_VERSION_RV2_ALPHA_8 = new DefaultVersion( 2, Channel.Alpha, 8 );
private static final Version DEFAULT_VERSION_RV4_ALPHA_1 = new DefaultVersion( 4, Channel.Alpha, 1 );
private static final Version DO_NOT_CHECK_VERSION = new DoNotCheckVersion(); private static final Version DO_NOT_CHECK_VERSION = new DoNotCheckVersion();
private static final Version MISSING_VERSION = new MissingVersion(); private static final Version MISSING_VERSION = new MissingVersion();
@ -69,6 +70,8 @@ public final class VersionTest
public void compareTwoDefaultVersions() public void compareTwoDefaultVersions()
{ {
Assert.assertTrue( DEFAULT_VERSION_RV2_BETA_8.isNewerAs( DEFAULT_VERSION_RV2_ALPHA_8 ) ); Assert.assertTrue( DEFAULT_VERSION_RV2_BETA_8.isNewerAs( DEFAULT_VERSION_RV2_ALPHA_8 ) );
Assert.assertTrue( DEFAULT_VERSION_RV4_ALPHA_1.isNewerAs( DEFAULT_VERSION_RV3_BETA_8 ) );
Assert.assertTrue( DEFAULT_VERSION_RV2_BETA_9.isNewerAs( DEFAULT_VERSION_RV2_BETA_8 ) );
} }
@Test @Test