@Test public void testCreateRunConfigurationName() throws Exception { assertEquals( "pentaho_auto_carte_config", runConfigurationImportExtensionPoint.createRunConfigurationName( Collections.emptyList(), "carte" ) ); assertEquals( "pentaho_auto_carte_config_3", runConfigurationImportExtensionPoint.createRunConfigurationName( Arrays.asList( "pentaho_auto_carte_config_2", "pentaho_auto_carte_config_manuallyUpdated" ), "carte" ) ); }
@VisibleForTesting String createRunConfigurationName( List<String> runConfigurations, String slaveServerName ) { String defaultName = String.format( "pentaho_auto_%s_config", slaveServerName ); long count = runConfigurations.stream().filter( s -> s.matches( defaultName + "(_\\d)*" ) ).count(); if ( count == 0 ) { return defaultName; } Optional<Integer> index = runConfigurations.stream() .filter( s -> s.matches( defaultName + "_\\d+" ) ) .map( s -> s.substring( defaultName.length() + 1 ) ) .filter( s -> s.matches( "\\d+" ) ) .map( Integer::valueOf ) .sorted( Comparator.reverseOrder() ) .findFirst(); return String.format( "%s_%d", defaultName, index.orElse( 0 ) + 1 ); }
RunConfigurationImportExtensionPoint implements ExtensionPointInterface { @VisibleForTesting String createRunConfigurationName( List<String> runConfigurations, String slaveServerName ) { String defaultName = String.format( "pentaho_auto_%s_config", slaveServerName ); long count = runConfigurations.stream().filter( s -> s.matches( defaultName + "(_\\d)*" ) ).count(); if ( count == 0 ) { return defaultName; } Optional<Integer> index = runConfigurations.stream() .filter( s -> s.matches( defaultName + "_\\d+" ) ) .map( s -> s.substring( defaultName.length() + 1 ) ) .filter( s -> s.matches( "\\d+" ) ) .map( Integer::valueOf ) .sorted( Comparator.reverseOrder() ) .findFirst(); return String.format( "%s_%d", defaultName, index.orElse( 0 ) + 1 ); } }
RunConfigurationImportExtensionPoint implements ExtensionPointInterface { @VisibleForTesting String createRunConfigurationName( List<String> runConfigurations, String slaveServerName ) { String defaultName = String.format( "pentaho_auto_%s_config", slaveServerName ); long count = runConfigurations.stream().filter( s -> s.matches( defaultName + "(_\\d)*" ) ).count(); if ( count == 0 ) { return defaultName; } Optional<Integer> index = runConfigurations.stream() .filter( s -> s.matches( defaultName + "_\\d+" ) ) .map( s -> s.substring( defaultName.length() + 1 ) ) .filter( s -> s.matches( "\\d+" ) ) .map( Integer::valueOf ) .sorted( Comparator.reverseOrder() ) .findFirst(); return String.format( "%s_%d", defaultName, index.orElse( 0 ) + 1 ); } RunConfigurationImportExtensionPoint( RunConfigurationManager runConfigurationManager ); }
RunConfigurationImportExtensionPoint implements ExtensionPointInterface { @VisibleForTesting String createRunConfigurationName( List<String> runConfigurations, String slaveServerName ) { String defaultName = String.format( "pentaho_auto_%s_config", slaveServerName ); long count = runConfigurations.stream().filter( s -> s.matches( defaultName + "(_\\d)*" ) ).count(); if ( count == 0 ) { return defaultName; } Optional<Integer> index = runConfigurations.stream() .filter( s -> s.matches( defaultName + "_\\d+" ) ) .map( s -> s.substring( defaultName.length() + 1 ) ) .filter( s -> s.matches( "\\d+" ) ) .map( Integer::valueOf ) .sorted( Comparator.reverseOrder() ) .findFirst(); return String.format( "%s_%d", defaultName, index.orElse( 0 ) + 1 ); } RunConfigurationImportExtensionPoint( RunConfigurationManager runConfigurationManager ); @Override void callExtensionPoint( LogChannelInterface logChannelInterface, Object o ); }
RunConfigurationImportExtensionPoint implements ExtensionPointInterface { @VisibleForTesting String createRunConfigurationName( List<String> runConfigurations, String slaveServerName ) { String defaultName = String.format( "pentaho_auto_%s_config", slaveServerName ); long count = runConfigurations.stream().filter( s -> s.matches( defaultName + "(_\\d)*" ) ).count(); if ( count == 0 ) { return defaultName; } Optional<Integer> index = runConfigurations.stream() .filter( s -> s.matches( defaultName + "_\\d+" ) ) .map( s -> s.substring( defaultName.length() + 1 ) ) .filter( s -> s.matches( "\\d+" ) ) .map( Integer::valueOf ) .sorted( Comparator.reverseOrder() ) .findFirst(); return String.format( "%s_%d", defaultName, index.orElse( 0 ) + 1 ); } RunConfigurationImportExtensionPoint( RunConfigurationManager runConfigurationManager ); @Override void callExtensionPoint( LogChannelInterface logChannelInterface, Object o );  }