@Test public void testEqualsHashCodeConsistency() throws Exception { StepMeta step = new StepMeta(); step.setName( "step" ); TestUtils.checkEqualsHashCodeConsistency( step, step ); StepMeta stepSame = new StepMeta(); stepSame.setName( "step" ); assertTrue( step.equals( stepSame ) ); TestUtils.checkEqualsHashCodeConsistency( step, stepSame ); StepMeta stepCaps = new StepMeta(); stepCaps.setName( "STEP" ); TestUtils.checkEqualsHashCodeConsistency( step, stepCaps ); StepMeta stepOther = new StepMeta(); stepOther.setName( "something else" ); TestUtils.checkEqualsHashCodeConsistency( step, stepOther ); }
@Before public void setUp() throws KettleException { // add variable to row generator step StepMetaInterface stepMetaInterface = spy( new RowGeneratorMeta() ); ( (RowGeneratorMeta) stepMetaInterface ).setRowLimit( "${ROW_LIMIT}" ); String[] strings = {}; when( ( (RowGeneratorMeta) stepMetaInterface ).getFieldName() ).thenReturn( strings ); StepMeta stepMeta = new StepMeta(); stepMeta.setStepMetaInterface( stepMetaInterface ); stepMeta.setName( "ROW_STEP_META" ); StepDataInterface stepDataInterface = stepMeta.getStepMetaInterface().getStepData(); // add variable to transformation variable space Map<String, String> map = new HashMap<String, String>(); map.put( "ROW_LIMIT", "1440" ); TransMeta transMeta = spy( new TransMeta() ); transMeta.injectVariables( map ); when( transMeta.findStep( anyString() ) ).thenReturn( stepMeta ); Trans trans = spy( new Trans( transMeta, null ) ); when( trans.getSocketRepository() ).thenReturn( null ); when( trans.getLogChannelId() ).thenReturn( "ROW_LIMIT" ); //prepare row generator, substitutes variable by value from transformation variable space rowGenerator = spy( new RowGenerator( stepMeta, stepDataInterface, 0, transMeta, trans ) ); rowGenerator.initializeVariablesFrom( trans ); rowGenerator.init( stepMetaInterface, stepDataInterface ); }
@Test public void testCreateMultivalueMap() { StepMeta stepMeta = new StepMeta(); stepMeta.setName( "TestRest" ); TransMeta transMeta = new TransMeta(); transMeta.setName( "TestRest" ); transMeta.addStep( stepMeta ); Rest rest = new Rest( stepMeta, mock( StepDataInterface.class ), 1, transMeta, mock( Trans.class ) ); MultivaluedMapImpl map = rest.createMultivalueMap( "param1", "{a:{[val1]}}" ); String val1 = map.getFirst( "param1" ); assertTrue( val1.contains( "%7D" ) ); }
public void renameStep( StepMeta stepMeta, String stepname ) { String newname = stepname; StepMeta smeta = transMeta.findStep( newname, stepMeta ); int nr = 2; while ( smeta != null ) { newname = stepname + " " + nr; smeta = transMeta.findStep( newname ); nr++; } if ( nr > 2 ) { stepname = newname; modalMessageDialog( getString( "Spoon.Dialog.StepnameExists.Title" ), getString( "Spoon.Dialog.StepnameExists.Message", stepname ), SWT.OK | SWT.ICON_INFORMATION ); } stepMeta.setName( stepname ); stepMeta.setChanged(); spoon.refreshTree(); // to reflect the new name spoon.refreshGraph(); }
/** * Initialize step info. Method is final against redefine in descendants. */ @Before public final void beforeCommon() throws Exception { KettleEnvironment.init(); PluginRegistry.addPluginType( CompressionPluginType.getInstance() ); PluginRegistry.init( false ); stepMeta = new StepMeta(); stepMeta.setName( "test" ); trans = new Trans(); trans.setLog( log ); trans.setRunning( true ); transMeta = new TransMeta() { @Override public StepMeta findStep( String name ) { return stepMeta; } }; fs = VFS.getManager(); inPrefix = '/' + this.getClass().getPackage().getName().replace( '.', '/' ) + "/files/"; }
@Test public void testInit() { StepMetaInterface stepMetaInterface = new AbstractStepMeta() { @Override public void setDefault() { } @Override public StepInterface getStep( StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta, Trans trans ) { return null; } }; StepMeta stepMeta = new StepMeta(); stepMeta.setName( "TestMetaStep" ); StepDataInterface stepDataInterface = mock( StepDataInterface.class ); Trans trans = new Trans(); LogChannel log = mock( LogChannel.class ); doAnswer( new Answer<Void>() { public Void answer( InvocationOnMock invocation ) { return null; } } ).when( log ).logError( anyString() ); trans.setLog( log ); TransMeta transMeta = new TransMeta(); transMeta.addStep( stepMeta ); MissingTransStep step = createAndInitStep( stepMetaInterface, stepDataInterface ); assertFalse( step.init( stepMetaInterface, stepDataInterface ) ); }
@Test public void testIsAnySelectedStepUsedInTransHopsAnySelectedCase() { StepMeta stepMeta = new StepMeta(); stepMeta.setName( STEP_NAME ); TransHopMeta transHopMeta = new TransHopMeta(); stepMeta.setSelected( true ); List<StepMeta> selectedSteps = asList( new StepMeta(), stepMeta, new StepMeta() ); transHopMeta.setToStep( stepMeta ); transHopMeta.setFromStep( stepMeta ); transMeta.getSteps().addAll( selectedSteps ); transMeta.addTransHop( transHopMeta ); assertTrue( transMeta.isAnySelectedStepUsedInTransHops() ); }
private JoinRows getJoinRows() throws Exception { StepMeta stepMeta = new StepMeta(); TransMeta transMeta = new TransMeta(); Trans trans = new Trans( transMeta ); transMeta.clear(); transMeta.addStep( stepMeta ); transMeta.setStep( 0, stepMeta ); stepMeta.setName( "test" ); trans.setLog( mock( LogChannelInterface.class ) ); trans.prepareExecution( null ); trans.startThreads(); return new JoinRows( stepMeta, null, 0, transMeta, trans ); }
public void dupeStep( TransMeta transMeta, StepMeta stepMeta ) { spoon.getLog().logDebug( toString(), BaseMessages.getString( PKG, "Spoon.Log.DuplicateStep" ) + stepMeta.getName() ); // Duplicate // step: StepMeta stMeta = (StepMeta) stepMeta.clone(); if ( stMeta != null ) { String newname = transMeta.getAlternativeStepname( stepMeta.getName() ); int nr = 2; while ( transMeta.findStep( newname ) != null ) { newname = stepMeta.getName() + " (copy " + nr + ")"; nr++; } stMeta.setName( newname ); // Don't select this new step! stMeta.setSelected( false ); Point loc = stMeta.getLocation(); stMeta.setLocation( loc.x + 20, loc.y + 20 ); transMeta.addStep( stMeta ); spoon.addUndoNew( transMeta, new StepMeta[] { (StepMeta) stMeta.clone() }, new int[] { transMeta .indexOfStep( stMeta ) } ); spoon.refreshTree(); spoon.refreshGraph(); } }
inf.setName( newName ); MessageBox mb = new MessageBox( shell, SWT.OK | SWT.ICON_INFORMATION );
@Test public void modifiedTarget() throws Exception { FilterRowsMeta filterRowsMeta = new FilterRowsMeta(); StepMeta trueOutput = new StepMeta( "true", new DummyTransMeta() ); StepMeta falseOutput = new StepMeta( "false", new DummyTransMeta() ); filterRowsMeta.setCondition( new Condition() ); filterRowsMeta.setTrueStepname( trueOutput.getName() ); filterRowsMeta.setFalseStepname( falseOutput.getName() ); filterRowsMeta.searchInfoAndTargetSteps( ImmutableList.of( trueOutput, falseOutput ) ); trueOutput.setName( "true renamed" ); falseOutput.setName( "false renamed" ); assertEquals( "true renamed", filterRowsMeta.getTrueStepname() ); assertEquals( "false renamed", filterRowsMeta.getFalseStepname() ); } }
steps[i].setName( transMeta.getAlternativeStepname( name ) ); transMeta.addStep( steps[i] ); position[i] = transMeta.indexOfStep( steps[i] );
stepMeta.setObjectId( stepId ); stepMeta.setName( r.getString( KettleDatabaseRepository.FIELD_STEP_NAME, null ) ); stepMeta.setDescription( r.getString( KettleDatabaseRepository.FIELD_STEP_DESCRIPTION, null ) );
stepMeta.setName( getString( stepNode, PROP_NAME ) ); if ( stepNode.hasProperty( PROP_DESCRIPTION ) ) { stepMeta.setDescription( getString( stepNode, PROP_DESCRIPTION ) );