@Test public void testBuildOldValueSetWithTemporaryAndMultipleAlternatives() { Properties user = new Properties(); user.setProperty( VersioningState.INCREMENT_SERIAL_SUFFIX_SYSPROP, "temporary-redhat" ); user.setProperty( VersioningState.VERSION_SUFFIX_ALT, "foobar,redhat" ); final VersioningState vs = new VersioningState( user ); Set<String> found = PropertiesUtils.buildOldValueSet( vs, "1.0.0.Final-foobar-10" ); assertEquals( Stream.of( "1.0.0.Final-foobar-10", "1.0.0.Final-temporary-redhat-0" ).collect( toSet() ), found ); }
static Set<String> buildOldValueSet( VersioningState versioningState, String oldValue ) { final Set<String> result = new HashSet<>(); result.add( oldValue ); if ( versioningState.getAllSuffixes().size() > 1 ) { versioningState.getSuffixAlternatives().forEach( s -> { final String suffixStripRegExp = "(.*)([.|-])(" + s + "-\\d+)"; final Pattern suffixStripPattern = Pattern.compile( suffixStripRegExp ); final Matcher suffixMatcher = suffixStripPattern.matcher( oldValue ); if ( suffixMatcher.matches() && !oldValue.contains( versioningState.getRebuildSuffix() ) ) { result.add( suffixMatcher.group( 1 ) + suffixMatcher.group( 2 ) + versioningState.getRebuildSuffix() + "-0" ); } } ); } logger.debug( "Generated original value set for matching {}", result ); return result; }
PropertiesUtils { static Set<String> buildOldValueSet( VersioningState versioningState, String oldValue ) { final Set<String> result = new HashSet<>(); result.add( oldValue ); if ( versioningState.getAllSuffixes().size() > 1 ) { versioningState.getSuffixAlternatives().forEach( s -> { final String suffixStripRegExp = "(.*)([.|-])(" + s + "-\\d+)"; final Pattern suffixStripPattern = Pattern.compile( suffixStripRegExp ); final Matcher suffixMatcher = suffixStripPattern.matcher( oldValue ); if ( suffixMatcher.matches() && !oldValue.contains( versioningState.getRebuildSuffix() ) ) { result.add( suffixMatcher.group( 1 ) + suffixMatcher.group( 2 ) + versioningState.getRebuildSuffix() + "-0" ); } } ); } logger.debug( "Generated original value set for matching {}", result ); return result; } }
PropertiesUtils { static Set<String> buildOldValueSet( VersioningState versioningState, String oldValue ) { final Set<String> result = new HashSet<>(); result.add( oldValue ); if ( versioningState.getAllSuffixes().size() > 1 ) { versioningState.getSuffixAlternatives().forEach( s -> { final String suffixStripRegExp = "(.*)([.|-])(" + s + "-\\d+)"; final Pattern suffixStripPattern = Pattern.compile( suffixStripRegExp ); final Matcher suffixMatcher = suffixStripPattern.matcher( oldValue ); if ( suffixMatcher.matches() && !oldValue.contains( versioningState.getRebuildSuffix() ) ) { result.add( suffixMatcher.group( 1 ) + suffixMatcher.group( 2 ) + versioningState.getRebuildSuffix() + "-0" ); } } ); } logger.debug( "Generated original value set for matching {}", result ); return result; } private  PropertiesUtils(); }
PropertiesUtils { static Set<String> buildOldValueSet( VersioningState versioningState, String oldValue ) { final Set<String> result = new HashSet<>(); result.add( oldValue ); if ( versioningState.getAllSuffixes().size() > 1 ) { versioningState.getSuffixAlternatives().forEach( s -> { final String suffixStripRegExp = "(.*)([.|-])(" + s + "-\\d+)"; final Pattern suffixStripPattern = Pattern.compile( suffixStripRegExp ); final Matcher suffixMatcher = suffixStripPattern.matcher( oldValue ); if ( suffixMatcher.matches() && !oldValue.contains( versioningState.getRebuildSuffix() ) ) { result.add( suffixMatcher.group( 1 ) + suffixMatcher.group( 2 ) + versioningState.getRebuildSuffix() + "-0" ); } } ); } logger.debug( "Generated original value set for matching {}", result ); return result; } private  PropertiesUtils(); static Map<String, String> getPropertiesByPrefix( final Properties properties, final String prefix ); static PropertyUpdate updateProperties( ManipulationSession session, Project project, boolean ignoreStrict,
                                                   String key, String newValue ); static String getSuffix( ManipulationSession session ); static boolean checkStrictValue( ManipulationSession session, String oldValue, String newValue ); static boolean cacheProperty( Project project, CommonState state, Map<Project, Map<String, PropertyMapper>> versionPropertyUpdateMap,
                                         String oldVersion, String newVersion, Object originalType, boolean force ); static String extractPropertyName( String version ); static void verifyPropertyMapping( CommonState cState, Project project, Map<Project, Map<String, PropertyMapper>> versionPropertyMap,
                                              ProjectVersionRef pvr, String version ); static void handleConfigPrecedence( Properties userProperties, Properties config ); }
PropertiesUtils { static Set<String> buildOldValueSet( VersioningState versioningState, String oldValue ) { final Set<String> result = new HashSet<>(); result.add( oldValue ); if ( versioningState.getAllSuffixes().size() > 1 ) { versioningState.getSuffixAlternatives().forEach( s -> { final String suffixStripRegExp = "(.*)([.|-])(" + s + "-\\d+)"; final Pattern suffixStripPattern = Pattern.compile( suffixStripRegExp ); final Matcher suffixMatcher = suffixStripPattern.matcher( oldValue ); if ( suffixMatcher.matches() && !oldValue.contains( versioningState.getRebuildSuffix() ) ) { result.add( suffixMatcher.group( 1 ) + suffixMatcher.group( 2 ) + versioningState.getRebuildSuffix() + "-0" ); } } ); } logger.debug( "Generated original value set for matching {}", result ); return result; } private  PropertiesUtils(); static Map<String, String> getPropertiesByPrefix( final Properties properties, final String prefix ); static PropertyUpdate updateProperties( ManipulationSession session, Project project, boolean ignoreStrict,
                                                   String key, String newValue ); static String getSuffix( ManipulationSession session ); static boolean checkStrictValue( ManipulationSession session, String oldValue, String newValue ); static boolean cacheProperty( Project project, CommonState state, Map<Project, Map<String, PropertyMapper>> versionPropertyUpdateMap,
                                         String oldVersion, String newVersion, Object originalType, boolean force ); static String extractPropertyName( String version ); static void verifyPropertyMapping( CommonState cState, Project project, Map<Project, Map<String, PropertyMapper>> versionPropertyMap,
                                              ProjectVersionRef pvr, String version ); static void handleConfigPrecedence( Properties userProperties, Properties config );  }