@Test public void testDelStepsExtensionPointCancelDelete() throws Exception { PluginMockInterface pluginInterface = mock( PluginMockInterface.class ); when( pluginInterface.getName() ).thenReturn( KettleExtensionPoint.TransBeforeDeleteSteps.id ); when( pluginInterface.getMainType() ).thenReturn( (Class) ExtensionPointInterface.class ); when( pluginInterface.getIds() ).thenReturn( new String[] { KettleExtensionPoint.TransBeforeDeleteSteps.id } ); ExtensionPointInterface extensionPoint = mock( ExtensionPointInterface.class ); when( pluginInterface.loadClass( ExtensionPointInterface.class ) ).thenReturn( extensionPoint ); doThrow( KettleException.class ).when( extensionPoint ) .callExtensionPoint( any( LogChannelInterface.class ), any( StepMeta[].class ) ); PluginRegistry.addPluginType( ExtensionPointPluginType.getInstance() ); PluginRegistry.getInstance().registerPlugin( ExtensionPointPluginType.class, pluginInterface ); SpoonStepsDelegate delegate = mock( SpoonStepsDelegate.class ); doCallRealMethod().when( delegate ).delSteps( any( TransMeta.class ), any( StepMeta[].class ) ); TransMeta trans = mock( TransMeta.class ); StepMeta[] steps = new StepMeta[] { mock( StepMeta.class ) }; delegate.delSteps( trans, steps ); verify( extensionPoint, times( 1 ) ).callExtensionPoint( any(), eq( steps ) ); }
public void delSteps( TransMeta transformation, StepMeta[] steps ) { try { ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.TransBeforeDeleteSteps.id, steps ); } catch ( KettleException e ) { return; } List<TransHopMeta> transHops = new ArrayList<TransHopMeta>(); int[] hopIndexes = new int[transformation.nrTransHops()]; int hopIndex = 0; for ( int i = transformation.nrTransHops() - 1; i >= 0; i-- ) { TransHopMeta hi = transformation.getTransHop( i ); for ( int j = 0; j < steps.length && hopIndex < hopIndexes.length; j++ ) { if ( hi.getFromStep().equals( steps[j] ) || hi.getToStep().equals( steps[j] ) ) { int idx = transformation.indexOfTransHop( hi ); transHops.add( (TransHopMeta) hi.clone() ); hopIndexes[hopIndex] = idx; transformation.removeTransHop( idx ); spoon.refreshTree(); hopIndex++; break; } } } if ( !transHops.isEmpty() ) { TransHopMeta[] hops = transHops.toArray( new TransHopMeta[transHops.size()] ); spoon.addUndoDelete( transformation, hops, hopIndexes ); } int[] positions = new int[steps.length]; for ( int i = 0; i < steps.length; i++ ) { int pos = transformation.indexOfStep( steps[i] ); transformation.removeStep( pos ); positions[i] = pos; } spoon.addUndoDelete( transformation, steps, positions ); spoon.refreshTree(); spoon.refreshGraph(); }
SpoonStepsDelegate extends SpoonDelegate { public void delSteps( TransMeta transformation, StepMeta[] steps ) { try { ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.TransBeforeDeleteSteps.id, steps ); } catch ( KettleException e ) { return; } List<TransHopMeta> transHops = new ArrayList<TransHopMeta>(); int[] hopIndexes = new int[transformation.nrTransHops()]; int hopIndex = 0; for ( int i = transformation.nrTransHops() - 1; i >= 0; i-- ) { TransHopMeta hi = transformation.getTransHop( i ); for ( int j = 0; j < steps.length && hopIndex < hopIndexes.length; j++ ) { if ( hi.getFromStep().equals( steps[j] ) || hi.getToStep().equals( steps[j] ) ) { int idx = transformation.indexOfTransHop( hi ); transHops.add( (TransHopMeta) hi.clone() ); hopIndexes[hopIndex] = idx; transformation.removeTransHop( idx ); spoon.refreshTree(); hopIndex++; break; } } } if ( !transHops.isEmpty() ) { TransHopMeta[] hops = transHops.toArray( new TransHopMeta[transHops.size()] ); spoon.addUndoDelete( transformation, hops, hopIndexes ); } int[] positions = new int[steps.length]; for ( int i = 0; i < steps.length; i++ ) { int pos = transformation.indexOfStep( steps[i] ); transformation.removeStep( pos ); positions[i] = pos; } spoon.addUndoDelete( transformation, steps, positions ); spoon.refreshTree(); spoon.refreshGraph(); } }
SpoonStepsDelegate extends SpoonDelegate { public void delSteps( TransMeta transformation, StepMeta[] steps ) { try { ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.TransBeforeDeleteSteps.id, steps ); } catch ( KettleException e ) { return; } List<TransHopMeta> transHops = new ArrayList<TransHopMeta>(); int[] hopIndexes = new int[transformation.nrTransHops()]; int hopIndex = 0; for ( int i = transformation.nrTransHops() - 1; i >= 0; i-- ) { TransHopMeta hi = transformation.getTransHop( i ); for ( int j = 0; j < steps.length && hopIndex < hopIndexes.length; j++ ) { if ( hi.getFromStep().equals( steps[j] ) || hi.getToStep().equals( steps[j] ) ) { int idx = transformation.indexOfTransHop( hi ); transHops.add( (TransHopMeta) hi.clone() ); hopIndexes[hopIndex] = idx; transformation.removeTransHop( idx ); spoon.refreshTree(); hopIndex++; break; } } } if ( !transHops.isEmpty() ) { TransHopMeta[] hops = transHops.toArray( new TransHopMeta[transHops.size()] ); spoon.addUndoDelete( transformation, hops, hopIndexes ); } int[] positions = new int[steps.length]; for ( int i = 0; i < steps.length; i++ ) { int pos = transformation.indexOfStep( steps[i] ); transformation.removeStep( pos ); positions[i] = pos; } spoon.addUndoDelete( transformation, steps, positions ); spoon.refreshTree(); spoon.refreshGraph(); } SpoonStepsDelegate( Spoon spoon ); }
SpoonStepsDelegate extends SpoonDelegate { public void delSteps( TransMeta transformation, StepMeta[] steps ) { try { ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.TransBeforeDeleteSteps.id, steps ); } catch ( KettleException e ) { return; } List<TransHopMeta> transHops = new ArrayList<TransHopMeta>(); int[] hopIndexes = new int[transformation.nrTransHops()]; int hopIndex = 0; for ( int i = transformation.nrTransHops() - 1; i >= 0; i-- ) { TransHopMeta hi = transformation.getTransHop( i ); for ( int j = 0; j < steps.length && hopIndex < hopIndexes.length; j++ ) { if ( hi.getFromStep().equals( steps[j] ) || hi.getToStep().equals( steps[j] ) ) { int idx = transformation.indexOfTransHop( hi ); transHops.add( (TransHopMeta) hi.clone() ); hopIndexes[hopIndex] = idx; transformation.removeTransHop( idx ); spoon.refreshTree(); hopIndex++; break; } } } if ( !transHops.isEmpty() ) { TransHopMeta[] hops = transHops.toArray( new TransHopMeta[transHops.size()] ); spoon.addUndoDelete( transformation, hops, hopIndexes ); } int[] positions = new int[steps.length]; for ( int i = 0; i < steps.length; i++ ) { int pos = transformation.indexOfStep( steps[i] ); transformation.removeStep( pos ); positions[i] = pos; } spoon.addUndoDelete( transformation, steps, positions ); spoon.refreshTree(); spoon.refreshGraph(); } SpoonStepsDelegate( Spoon spoon ); void editStepErrorHandling( TransMeta transMeta, StepMeta stepMeta ); void dupeStep( TransMeta transMeta, StepMeta stepMeta ); void clipStep( StepMeta stepMeta ); String editStep( TransMeta transMeta, StepMeta stepMeta ); void delSteps( TransMeta transformation, StepMeta[] steps ); void delStep( TransMeta transMeta, StepMeta stepMeta ); StepDialogInterface getStepDialog( StepMetaInterface stepMeta, TransMeta transMeta, String stepName ); StepDialogInterface getPartitionerDialog( StepMeta stepMeta, StepPartitioningMeta partitioningMeta,
    TransMeta transMeta ); }
SpoonStepsDelegate extends SpoonDelegate { public void delSteps( TransMeta transformation, StepMeta[] steps ) { try { ExtensionPointHandler.callExtensionPoint( log, KettleExtensionPoint.TransBeforeDeleteSteps.id, steps ); } catch ( KettleException e ) { return; } List<TransHopMeta> transHops = new ArrayList<TransHopMeta>(); int[] hopIndexes = new int[transformation.nrTransHops()]; int hopIndex = 0; for ( int i = transformation.nrTransHops() - 1; i >= 0; i-- ) { TransHopMeta hi = transformation.getTransHop( i ); for ( int j = 0; j < steps.length && hopIndex < hopIndexes.length; j++ ) { if ( hi.getFromStep().equals( steps[j] ) || hi.getToStep().equals( steps[j] ) ) { int idx = transformation.indexOfTransHop( hi ); transHops.add( (TransHopMeta) hi.clone() ); hopIndexes[hopIndex] = idx; transformation.removeTransHop( idx ); spoon.refreshTree(); hopIndex++; break; } } } if ( !transHops.isEmpty() ) { TransHopMeta[] hops = transHops.toArray( new TransHopMeta[transHops.size()] ); spoon.addUndoDelete( transformation, hops, hopIndexes ); } int[] positions = new int[steps.length]; for ( int i = 0; i < steps.length; i++ ) { int pos = transformation.indexOfStep( steps[i] ); transformation.removeStep( pos ); positions[i] = pos; } spoon.addUndoDelete( transformation, steps, positions ); spoon.refreshTree(); spoon.refreshGraph(); } SpoonStepsDelegate( Spoon spoon ); void editStepErrorHandling( TransMeta transMeta, StepMeta stepMeta ); void dupeStep( TransMeta transMeta, StepMeta stepMeta ); void clipStep( StepMeta stepMeta ); String editStep( TransMeta transMeta, StepMeta stepMeta ); void delSteps( TransMeta transformation, StepMeta[] steps ); void delStep( TransMeta transMeta, StepMeta stepMeta ); StepDialogInterface getStepDialog( StepMetaInterface stepMeta, TransMeta transMeta, String stepName ); StepDialogInterface getPartitionerDialog( StepMeta stepMeta, StepPartitioningMeta partitioningMeta,
    TransMeta transMeta );  }