VersionInfo { @SuppressWarnings( { "fallthrough" } ) void setVersion( final String version ) { if ( version != null ) { String[] pieces = version.replace( '-', '.' ).split( "\\." ); switch ( pieces.length ) { case 9: case 8: case 7: case 6: case 5: setVersionBuild( pieces[4] ); case 4: setVersionMilestone( pieces[3] ); case 3: setVersionRelease( pieces[2] ); case 2: setVersionMinor( pieces[1] ); case 1: setVersionMajor( pieces[0] ); default: } } }  boolean isFromManifest(); String getProductID(); String getTitle(); String getVersionMajor(); String getVersionMinor(); String getVersionRelease(); String getVersionMilestone(); String getVersionBuild(); String getVersionNumber(); @Override String toString();  }
@Test public void testSetVersion() { VersionInfo info; String version, versionClean; info = new VersionInfo(); version = "10.3a.123.007.87590"; versionClean = "10.3a.123.007.87590"; info.setVersion( version ); doTest( info, false, null, null, "10", "3a", "123", "007", "87590", versionClean ); info = new VersionInfo(); version = "10.3a.123.007"; versionClean = "10.3a.123.007"; info.setVersion( version ); doTest( info, false, null, null, "10", "3a", "123", "007", null, versionClean ); info = new VersionInfo(); version = "10-3a-123"; versionClean = "10.3a.123"; info.setVersion( version ); doTest( info, false, null, null, "10", "3a", "123", null, null, versionClean ); info = new VersionInfo(); version = "10-3a"; versionClean = "10.3a"; info.setVersion( version ); doTest( info, false, null, null, "10", "3a", null, null, null, versionClean ); info = new VersionInfo(); version = "10"; versionClean = "10"; info.setVersion( version ); doTest( info, false, null, null, "10", null, null, null, null, versionClean ); }
@Test public void testSetVersionEmpty() { VersionInfo info = new VersionInfo(); info.setVersion( "" ); doTest( info, false, null, null, "", null, null, null, null, "" ); final String[] emptyVersions = new String[] { null, "-", "." }; for ( final String emptyVersion : emptyVersions ) { info = new VersionInfo(); info.setVersion( emptyVersion ); doTest( info, false, null, null, null, null, null, null, null, "" ); } }
@Test public void testSetVersionAdditionalFields() { VersionInfo info; String version, versionClean; info = new VersionInfo(); version = "10.3a.123.007.87590.foe"; versionClean = "10.3a.123.007.87590"; info.setVersion( version ); doTest( info, false, null, null, "10", "3a", "123", "007", "87590", versionClean ); info = new VersionInfo(); version = "10.3a.123.007.87590.foe.foo-abc.xyz"; versionClean = "10.3a.123.007.87590"; info.setVersion( version ); doTest( info, false, null, null, "10", "3a", "123", "007", "87590", versionClean ); }
@Test public void testSetVersionMissingFields() { VersionInfo info; String version, versionClean; info = new VersionInfo(); version = ".3a.123.007."; versionClean = ".3a.123.007"; info.setVersion( version ); doTest( info, false, null, null, "", "3a", "123", "007", null, versionClean ); info = new VersionInfo(); version = "-3a.123.007-"; versionClean = ".3a.123.007"; info.setVersion( version ); doTest( info, false, null, null, "", "3a", "123", "007", null, versionClean ); info = new VersionInfo(); version = "10..123..87590"; versionClean = "10..123..87590"; info.setVersion( version ); doTest( info, false, null, null, "10", "", "123", "", "87590", versionClean ); info = new VersionInfo(); version = "10.3a.-.87590"; versionClean = "10.3a...87590"; info.setVersion( version ); doTest( info, false, null, null, "10", "3a", "", "", "87590", versionClean ); }