@Test public void testGetJobEntryDialogClass() throws KettlePluginException { PluginRegistry registry = PluginRegistry.getInstance(); PluginMockInterface plugin = mock( PluginMockInterface.class ); when( plugin.getIds() ).thenReturn( new String[] { "mockJobPlugin" } ); when( plugin.matches( "mockJobPlugin" ) ).thenReturn( true ); when( plugin.getName() ).thenReturn( "mockJobPlugin" ); JobEntryInterface jobEntryInterface = mock( JobEntryInterface.class ); when( jobEntryInterface.getDialogClassName() ).thenReturn( String.class.getName() ); when( plugin.getClassMap() ).thenReturn( new HashMap<Class<?>, String>() {{ put( JobEntryInterface.class, jobEntryInterface.getClass().getName() ); put( JobEntryDialogInterface.class, JobEntryDialogInterface.class.getName() ); }} ); registry.registerPlugin( JobEntryPluginType.class, plugin ); SpoonJobDelegate delegate = mock( SpoonJobDelegate.class ); Spoon spoon = mock( Spoon.class ); delegate.spoon = spoon; delegate.log = mock( LogChannelInterface.class ); when( spoon.getShell() ).thenReturn( mock( Shell.class ) ); doCallRealMethod().when( delegate ).getJobEntryDialog( any( JobEntryInterface.class ), any( JobMeta.class ) ); JobMeta meta = mock( JobMeta.class ); try { delegate.getJobEntryDialog( jobEntryInterface, meta ); } catch ( Throwable ignore ) { verify( jobEntryInterface, never() ).getDialogClassName(); } when( plugin.getClassMap() ).thenReturn( new HashMap<Class<?>, String>() {{ put( JobEntryInterface.class, jobEntryInterface.getClass().getName() ); }} ); try { delegate.getJobEntryDialog( jobEntryInterface, meta ); } catch ( Throwable ignore ) { verify( jobEntryInterface, times( 1 ) ).getDialogClassName(); } registry.removePlugin( JobEntryPluginType.class, plugin ); }
public JobEntryDialogInterface getJobEntryDialog( JobEntryInterface jobEntryInterface, JobMeta jobMeta ) { Class<?>[] paramClasses = new Class<?>[] { Shell.class, JobEntryInterface.class, Repository.class, JobMeta.class }; Object[] paramArgs = new Object[] { spoon.getShell(), jobEntryInterface, spoon.getRepository(), jobMeta }; PluginRegistry registry = PluginRegistry.getInstance(); PluginInterface plugin = registry.getPlugin( JobEntryPluginType.class, jobEntryInterface ); String dialogClassName = plugin.getClassMap().get( JobEntryDialogInterface.class ); if ( dialogClassName == null ) { log.logDebug( "Use of JobEntryInterface#getDialogClassName is deprecated, use PluginDialog annotation instead." ); dialogClassName = jobEntryInterface.getDialogClassName(); } try { Class<JobEntryDialogInterface> dialogClass = registry.getClass( plugin, dialogClassName ); Constructor<JobEntryDialogInterface> dialogConstructor = dialogClass.getConstructor( paramClasses ); JobEntryDialogInterface entryDialogInterface = dialogConstructor.newInstance( paramArgs ); entryDialogInterface.setMetaStore( spoon.getMetaStore() ); return entryDialogInterface; } catch ( Throwable t ) { t.printStackTrace(); String errorTitle = BaseMessages.getString( PKG, "Spoon.Dialog.ErrorCreatingJobDialog.Title" ); String errorMsg = BaseMessages.getString( PKG, "Spoon.Dialog.ErrorCreatingJobEntryDialog.Message", dialogClassName ); spoon.getLog().logError( spoon.toString(), errorMsg ); new ErrorDialog( spoon.getShell(), errorTitle, errorMsg, t ); return null; } }
SpoonJobDelegate extends SpoonDelegate { public JobEntryDialogInterface getJobEntryDialog( JobEntryInterface jobEntryInterface, JobMeta jobMeta ) { Class<?>[] paramClasses = new Class<?>[] { Shell.class, JobEntryInterface.class, Repository.class, JobMeta.class }; Object[] paramArgs = new Object[] { spoon.getShell(), jobEntryInterface, spoon.getRepository(), jobMeta }; PluginRegistry registry = PluginRegistry.getInstance(); PluginInterface plugin = registry.getPlugin( JobEntryPluginType.class, jobEntryInterface ); String dialogClassName = plugin.getClassMap().get( JobEntryDialogInterface.class ); if ( dialogClassName == null ) { log.logDebug( "Use of JobEntryInterface#getDialogClassName is deprecated, use PluginDialog annotation instead." ); dialogClassName = jobEntryInterface.getDialogClassName(); } try { Class<JobEntryDialogInterface> dialogClass = registry.getClass( plugin, dialogClassName ); Constructor<JobEntryDialogInterface> dialogConstructor = dialogClass.getConstructor( paramClasses ); JobEntryDialogInterface entryDialogInterface = dialogConstructor.newInstance( paramArgs ); entryDialogInterface.setMetaStore( spoon.getMetaStore() ); return entryDialogInterface; } catch ( Throwable t ) { t.printStackTrace(); String errorTitle = BaseMessages.getString( PKG, "Spoon.Dialog.ErrorCreatingJobDialog.Title" ); String errorMsg = BaseMessages.getString( PKG, "Spoon.Dialog.ErrorCreatingJobEntryDialog.Message", dialogClassName ); spoon.getLog().logError( spoon.toString(), errorMsg ); new ErrorDialog( spoon.getShell(), errorTitle, errorMsg, t ); return null; } } }
SpoonJobDelegate extends SpoonDelegate { public JobEntryDialogInterface getJobEntryDialog( JobEntryInterface jobEntryInterface, JobMeta jobMeta ) { Class<?>[] paramClasses = new Class<?>[] { Shell.class, JobEntryInterface.class, Repository.class, JobMeta.class }; Object[] paramArgs = new Object[] { spoon.getShell(), jobEntryInterface, spoon.getRepository(), jobMeta }; PluginRegistry registry = PluginRegistry.getInstance(); PluginInterface plugin = registry.getPlugin( JobEntryPluginType.class, jobEntryInterface ); String dialogClassName = plugin.getClassMap().get( JobEntryDialogInterface.class ); if ( dialogClassName == null ) { log.logDebug( "Use of JobEntryInterface#getDialogClassName is deprecated, use PluginDialog annotation instead." ); dialogClassName = jobEntryInterface.getDialogClassName(); } try { Class<JobEntryDialogInterface> dialogClass = registry.getClass( plugin, dialogClassName ); Constructor<JobEntryDialogInterface> dialogConstructor = dialogClass.getConstructor( paramClasses ); JobEntryDialogInterface entryDialogInterface = dialogConstructor.newInstance( paramArgs ); entryDialogInterface.setMetaStore( spoon.getMetaStore() ); return entryDialogInterface; } catch ( Throwable t ) { t.printStackTrace(); String errorTitle = BaseMessages.getString( PKG, "Spoon.Dialog.ErrorCreatingJobDialog.Title" ); String errorMsg = BaseMessages.getString( PKG, "Spoon.Dialog.ErrorCreatingJobEntryDialog.Message", dialogClassName ); spoon.getLog().logError( spoon.toString(), errorMsg ); new ErrorDialog( spoon.getShell(), errorTitle, errorMsg, t ); return null; } } SpoonJobDelegate( Spoon spoon ); }
SpoonJobDelegate extends SpoonDelegate { public JobEntryDialogInterface getJobEntryDialog( JobEntryInterface jobEntryInterface, JobMeta jobMeta ) { Class<?>[] paramClasses = new Class<?>[] { Shell.class, JobEntryInterface.class, Repository.class, JobMeta.class }; Object[] paramArgs = new Object[] { spoon.getShell(), jobEntryInterface, spoon.getRepository(), jobMeta }; PluginRegistry registry = PluginRegistry.getInstance(); PluginInterface plugin = registry.getPlugin( JobEntryPluginType.class, jobEntryInterface ); String dialogClassName = plugin.getClassMap().get( JobEntryDialogInterface.class ); if ( dialogClassName == null ) { log.logDebug( "Use of JobEntryInterface#getDialogClassName is deprecated, use PluginDialog annotation instead." ); dialogClassName = jobEntryInterface.getDialogClassName(); } try { Class<JobEntryDialogInterface> dialogClass = registry.getClass( plugin, dialogClassName ); Constructor<JobEntryDialogInterface> dialogConstructor = dialogClass.getConstructor( paramClasses ); JobEntryDialogInterface entryDialogInterface = dialogConstructor.newInstance( paramArgs ); entryDialogInterface.setMetaStore( spoon.getMetaStore() ); return entryDialogInterface; } catch ( Throwable t ) { t.printStackTrace(); String errorTitle = BaseMessages.getString( PKG, "Spoon.Dialog.ErrorCreatingJobDialog.Title" ); String errorMsg = BaseMessages.getString( PKG, "Spoon.Dialog.ErrorCreatingJobEntryDialog.Message", dialogClassName ); spoon.getLog().logError( spoon.toString(), errorMsg ); new ErrorDialog( spoon.getShell(), errorTitle, errorMsg, t ); return null; } } SpoonJobDelegate( Spoon spoon ); JobEntryCopy newJobEntry( JobMeta jobMeta, String type_desc, boolean openit ); JobEntryDialogInterface getJobEntryDialog( JobEntryInterface jobEntryInterface, JobMeta jobMeta ); void editJobEntry( JobMeta jobMeta, JobEntryCopy je ); void deleteJobEntryCopies( JobMeta job, JobEntryCopy[] jobEntries ); void deleteJobEntryCopies( JobMeta jobMeta, JobEntryCopy jobEntry ); void dupeJobEntry( JobMeta jobMeta, JobEntryCopy jobEntry ); void copyJobEntries( List<JobEntryCopy> jec ); void pasteXML( JobMeta jobMeta, String clipcontent, Point loc ); void newJobHop( JobMeta jobMeta, JobEntryCopy fr, JobEntryCopy to ); void ripDBWizard(); JobMeta ripDB( final List<DatabaseMeta> databases, final String jobname,
    final RepositoryDirectoryInterface repdir, final String directory, final DatabaseMeta sourceDbInfo,
    final DatabaseMeta targetDbInfo, final String[] tables ); boolean isDefaultJobName( String name ); JobGraph findJobGraphOfJob( JobMeta jobMeta ); boolean addJob( JobMeta jobMeta ); void closeJob( JobMeta jobMeta ); void addJobGraph( JobMeta jobMeta ); List<JobMeta> getJobList(); JobMeta getJob( String name ); JobMeta[] getLoadedJobs(); void redoJobAction( JobMeta jobMeta, TransAction transAction ); void undoJobAction( JobMeta jobMeta, TransAction transAction ); void executeJob( JobMeta jobMeta, boolean local, boolean remote, Date replayDate, boolean safe,
    String startCopyName, int startCopyNr ); }
SpoonJobDelegate extends SpoonDelegate { public JobEntryDialogInterface getJobEntryDialog( JobEntryInterface jobEntryInterface, JobMeta jobMeta ) { Class<?>[] paramClasses = new Class<?>[] { Shell.class, JobEntryInterface.class, Repository.class, JobMeta.class }; Object[] paramArgs = new Object[] { spoon.getShell(), jobEntryInterface, spoon.getRepository(), jobMeta }; PluginRegistry registry = PluginRegistry.getInstance(); PluginInterface plugin = registry.getPlugin( JobEntryPluginType.class, jobEntryInterface ); String dialogClassName = plugin.getClassMap().get( JobEntryDialogInterface.class ); if ( dialogClassName == null ) { log.logDebug( "Use of JobEntryInterface#getDialogClassName is deprecated, use PluginDialog annotation instead." ); dialogClassName = jobEntryInterface.getDialogClassName(); } try { Class<JobEntryDialogInterface> dialogClass = registry.getClass( plugin, dialogClassName ); Constructor<JobEntryDialogInterface> dialogConstructor = dialogClass.getConstructor( paramClasses ); JobEntryDialogInterface entryDialogInterface = dialogConstructor.newInstance( paramArgs ); entryDialogInterface.setMetaStore( spoon.getMetaStore() ); return entryDialogInterface; } catch ( Throwable t ) { t.printStackTrace(); String errorTitle = BaseMessages.getString( PKG, "Spoon.Dialog.ErrorCreatingJobDialog.Title" ); String errorMsg = BaseMessages.getString( PKG, "Spoon.Dialog.ErrorCreatingJobEntryDialog.Message", dialogClassName ); spoon.getLog().logError( spoon.toString(), errorMsg ); new ErrorDialog( spoon.getShell(), errorTitle, errorMsg, t ); return null; } } SpoonJobDelegate( Spoon spoon ); JobEntryCopy newJobEntry( JobMeta jobMeta, String type_desc, boolean openit ); JobEntryDialogInterface getJobEntryDialog( JobEntryInterface jobEntryInterface, JobMeta jobMeta ); void editJobEntry( JobMeta jobMeta, JobEntryCopy je ); void deleteJobEntryCopies( JobMeta job, JobEntryCopy[] jobEntries ); void deleteJobEntryCopies( JobMeta jobMeta, JobEntryCopy jobEntry ); void dupeJobEntry( JobMeta jobMeta, JobEntryCopy jobEntry ); void copyJobEntries( List<JobEntryCopy> jec ); void pasteXML( JobMeta jobMeta, String clipcontent, Point loc ); void newJobHop( JobMeta jobMeta, JobEntryCopy fr, JobEntryCopy to ); void ripDBWizard(); JobMeta ripDB( final List<DatabaseMeta> databases, final String jobname,
    final RepositoryDirectoryInterface repdir, final String directory, final DatabaseMeta sourceDbInfo,
    final DatabaseMeta targetDbInfo, final String[] tables ); boolean isDefaultJobName( String name ); JobGraph findJobGraphOfJob( JobMeta jobMeta ); boolean addJob( JobMeta jobMeta ); void closeJob( JobMeta jobMeta ); void addJobGraph( JobMeta jobMeta ); List<JobMeta> getJobList(); JobMeta getJob( String name ); JobMeta[] getLoadedJobs(); void redoJobAction( JobMeta jobMeta, TransAction transAction ); void undoJobAction( JobMeta jobMeta, TransAction transAction ); void executeJob( JobMeta jobMeta, boolean local, boolean remote, Date replayDate, boolean safe,
    String startCopyName, int startCopyNr );  }