@Test public void shouldCreateRunConfigurationsForSlaveServer() throws Exception { JobMeta jobMeta = mock( JobMeta.class ); JobEntryCopy jobEntryCopy1 = mock( JobEntryCopy.class ); JobEntryCopy jobEntryCopy2 = mock( JobEntryCopy.class ); JobEntryCopy jobEntryCopy3 = mock( JobEntryCopy.class ); JobEntryTrans trans1 = mock( JobEntryTrans.class ); JobEntryTrans trans2 = mock( JobEntryTrans.class ); JobEntryTrans trans3 = mock( JobEntryTrans.class ); ArgumentCaptor<DefaultRunConfiguration> rcCaptor = ArgumentCaptor.forClass( DefaultRunConfiguration.class ); when( jobMeta.getEmbeddedMetaStore() ).thenReturn( embeddedMetaStore ); when( jobMeta.getSlaveServers() ).thenReturn( Arrays.asList( new SlaveServer( "carte1", "host1", "1234", "user", "passw" ), new SlaveServer( "carte2", "host2", "1234", "user", "passw" ) ) ); when( jobMeta.getJobCopies() ).thenReturn( Arrays.asList( jobEntryCopy1, jobEntryCopy2, jobEntryCopy3 ) ); when( jobEntryCopy1.getEntry() ).thenReturn( trans1 ); when( jobEntryCopy2.getEntry() ).thenReturn( trans2 ); when( jobEntryCopy3.getEntry() ).thenReturn( trans3 ); when( trans1.getRemoteSlaveServerName() ).thenReturn( "carte1" ); when( trans2.getRemoteSlaveServerName() ).thenReturn( "carte1" ); when( trans3.getRemoteSlaveServerName() ).thenReturn( "carte2" ); when( trans1.getRunConfiguration() ).thenReturn( null ); when( trans2.getRunConfiguration() ).thenReturn( null ); when( trans3.getRunConfiguration() ).thenReturn( null ); when( runConfigurationManager.getNames() ).thenReturn( Collections.singletonList( "pentaho_auto_carte1_config" ) ); runConfigurationImportExtensionPoint.callExtensionPoint( log, jobMeta ); verify( runConfigurationManager, times( 2 ) ).save( rcCaptor.capture() ); verify( trans1 ).setRunConfiguration( "pentaho_auto_carte1_config_1" ); verify( trans2 ).setRunConfiguration( "pentaho_auto_carte1_config_1" ); verify( trans3 ).setRunConfiguration( "pentaho_auto_carte2_config" ); List<DefaultRunConfiguration> allValues = rcCaptor.getAllValues(); DefaultRunConfiguration runConfiguration1 = allValues.get( 0 ); assertEquals( "pentaho_auto_carte1_config_1", runConfiguration1.getName() ); assertEquals( "carte1", runConfiguration1.getServer() ); DefaultRunConfiguration runConfiguration2 = allValues.get( 1 ); assertEquals( "pentaho_auto_carte2_config", runConfiguration2.getName() ); assertEquals( "carte2", runConfiguration2.getServer() ); }
@Override public void callExtensionPoint( LogChannelInterface logChannelInterface, Object o ) throws KettleException { AbstractMeta abstractMeta = (AbstractMeta) o; final EmbeddedMetaStore embeddedMetaStore = abstractMeta.getEmbeddedMetaStore(); RunConfigurationManager embeddedRunConfigurationManager = EmbeddedRunConfigurationManager.build( embeddedMetaStore ); List<RunConfiguration> runConfigurationList = embeddedRunConfigurationManager.load(); List<String> runConfigurationNames = runConfigurationList.stream().map( RunConfiguration::getName ).collect( Collectors.toList() ); runConfigurationNames.addAll( runConfigurationManager.getNames() ); runConfigurationList.addAll( createSlaveServerRunConfigurations( runConfigurationNames, abstractMeta ) ); for ( RunConfiguration runConfiguration : runConfigurationList ) { if ( !runConfiguration.getName().equals( DefaultRunConfigurationProvider.DEFAULT_CONFIG_NAME ) ) { runConfigurationManager.save( runConfiguration ); } } }
RunConfigurationImportExtensionPoint implements ExtensionPointInterface { @Override public void callExtensionPoint( LogChannelInterface logChannelInterface, Object o ) throws KettleException { AbstractMeta abstractMeta = (AbstractMeta) o; final EmbeddedMetaStore embeddedMetaStore = abstractMeta.getEmbeddedMetaStore(); RunConfigurationManager embeddedRunConfigurationManager = EmbeddedRunConfigurationManager.build( embeddedMetaStore ); List<RunConfiguration> runConfigurationList = embeddedRunConfigurationManager.load(); List<String> runConfigurationNames = runConfigurationList.stream().map( RunConfiguration::getName ).collect( Collectors.toList() ); runConfigurationNames.addAll( runConfigurationManager.getNames() ); runConfigurationList.addAll( createSlaveServerRunConfigurations( runConfigurationNames, abstractMeta ) ); for ( RunConfiguration runConfiguration : runConfigurationList ) { if ( !runConfiguration.getName().equals( DefaultRunConfigurationProvider.DEFAULT_CONFIG_NAME ) ) { runConfigurationManager.save( runConfiguration ); } } } }
RunConfigurationImportExtensionPoint implements ExtensionPointInterface { @Override public void callExtensionPoint( LogChannelInterface logChannelInterface, Object o ) throws KettleException { AbstractMeta abstractMeta = (AbstractMeta) o; final EmbeddedMetaStore embeddedMetaStore = abstractMeta.getEmbeddedMetaStore(); RunConfigurationManager embeddedRunConfigurationManager = EmbeddedRunConfigurationManager.build( embeddedMetaStore ); List<RunConfiguration> runConfigurationList = embeddedRunConfigurationManager.load(); List<String> runConfigurationNames = runConfigurationList.stream().map( RunConfiguration::getName ).collect( Collectors.toList() ); runConfigurationNames.addAll( runConfigurationManager.getNames() ); runConfigurationList.addAll( createSlaveServerRunConfigurations( runConfigurationNames, abstractMeta ) ); for ( RunConfiguration runConfiguration : runConfigurationList ) { if ( !runConfiguration.getName().equals( DefaultRunConfigurationProvider.DEFAULT_CONFIG_NAME ) ) { runConfigurationManager.save( runConfiguration ); } } } RunConfigurationImportExtensionPoint( RunConfigurationManager runConfigurationManager ); }
RunConfigurationImportExtensionPoint implements ExtensionPointInterface { @Override public void callExtensionPoint( LogChannelInterface logChannelInterface, Object o ) throws KettleException { AbstractMeta abstractMeta = (AbstractMeta) o; final EmbeddedMetaStore embeddedMetaStore = abstractMeta.getEmbeddedMetaStore(); RunConfigurationManager embeddedRunConfigurationManager = EmbeddedRunConfigurationManager.build( embeddedMetaStore ); List<RunConfiguration> runConfigurationList = embeddedRunConfigurationManager.load(); List<String> runConfigurationNames = runConfigurationList.stream().map( RunConfiguration::getName ).collect( Collectors.toList() ); runConfigurationNames.addAll( runConfigurationManager.getNames() ); runConfigurationList.addAll( createSlaveServerRunConfigurations( runConfigurationNames, abstractMeta ) ); for ( RunConfiguration runConfiguration : runConfigurationList ) { if ( !runConfiguration.getName().equals( DefaultRunConfigurationProvider.DEFAULT_CONFIG_NAME ) ) { runConfigurationManager.save( runConfiguration ); } } } RunConfigurationImportExtensionPoint( RunConfigurationManager runConfigurationManager ); @Override void callExtensionPoint( LogChannelInterface logChannelInterface, Object o ); }
RunConfigurationImportExtensionPoint implements ExtensionPointInterface { @Override public void callExtensionPoint( LogChannelInterface logChannelInterface, Object o ) throws KettleException { AbstractMeta abstractMeta = (AbstractMeta) o; final EmbeddedMetaStore embeddedMetaStore = abstractMeta.getEmbeddedMetaStore(); RunConfigurationManager embeddedRunConfigurationManager = EmbeddedRunConfigurationManager.build( embeddedMetaStore ); List<RunConfiguration> runConfigurationList = embeddedRunConfigurationManager.load(); List<String> runConfigurationNames = runConfigurationList.stream().map( RunConfiguration::getName ).collect( Collectors.toList() ); runConfigurationNames.addAll( runConfigurationManager.getNames() ); runConfigurationList.addAll( createSlaveServerRunConfigurations( runConfigurationNames, abstractMeta ) ); for ( RunConfiguration runConfiguration : runConfigurationList ) { if ( !runConfiguration.getName().equals( DefaultRunConfigurationProvider.DEFAULT_CONFIG_NAME ) ) { runConfigurationManager.save( runConfiguration ); } } } RunConfigurationImportExtensionPoint( RunConfigurationManager runConfigurationManager ); @Override void callExtensionPoint( LogChannelInterface logChannelInterface, Object o );  }