### Question:
Version { public static String setBuildNumber( String version, String buildNumber ) { if ( !isNumeric( buildNumber ) ) { logger.warn("Failed attempt to set non-numeric build number '{}' for version '{}'", buildNumber, version); return version; } if ( isEmpty( buildNumber ) ) { buildNumber = EMPTY_STRING; } if ( isEmpty( getQualifier( version ) ) ) { return version + DEFAULT_DELIMITER + buildNumber; } Matcher qualifierMatcher = qualifierPattern.matcher( version ); if ( qualifierMatcher.matches() ) { if ( isEmpty( qualifierMatcher.group( 2 ) ) ) { buildNumber = prependDelimiter( buildNumber, DEFAULT_QUALIFIER_DELIMITER ); } return qualifierMatcher.replaceFirst( "$1$3" + buildNumber + "$5" ); } return version; } private  Version(); static String getBuildNumber(String version); static int getBuildNumberPadding( int incrementalSerialSuffixPadding, Set<String> versions ); static String getMMM(String version); static String getOsgiVersion(String version); static String getQualifier(String version); static String getQualifierBase(String version); static String getQualifierWithDelim(String version); static String getSnapshot( String version ); static String getSnapshotWithDelim( String version ); static boolean hasBuildNumber( String version ); static boolean hasQualifier( String version ); static boolean isEmpty( String string ); static boolean isSnapshot( String version ); static boolean isValidOSGi(String version); static String removeBuildNumber( String version ); static String removeSnapshot( String version ); static String appendQualifierSuffix( final String version, final String suffix ); static String setBuildNumber( String version, String buildNumber ); static String setSnapshot( String version, boolean snapshot ); static int findHighestMatchingBuildNumber(String version, Set<String> versionSet ); static int getIntegerBuildNumber( String version ); static final String PROJECT_VERSION; }### Answer:
@Test public void testSetBuildNumber() { assertThat( Version.setBuildNumber( "1.0.beta1", "2" ), equalTo( "1.0.beta2") ); assertThat( Version.setBuildNumber( "1.0_2-Beta1-SNAPSHOT", "41" ), equalTo( "1.0_2-Beta41-SNAPSHOT") ); assertThat( Version.setBuildNumber( "1.0.2.1", "3" ), equalTo( "1.0.2.3") ); assertThat( Version.setBuildNumber( "1.0.2", "3" ), equalTo( "1.0.2.3") ); assertThat( Version.setBuildNumber( "1.0", "2" ), equalTo( "1.0.2") ); assertThat( Version.setBuildNumber( "1.0-alpha", "001" ), equalTo( "1.0-alpha-001") ); }