this.name = stepMeta.name; if ( stepMeta.stepMetaInterface != null ) { setStepMetaInterface( (StepMetaInterface) stepMeta.stepMetaInterface.clone() ); } else { this.stepMetaInterface = null;
private static StepMeta createTestMeta() throws Exception { StepMetaInterface stepMetaInterface = mock( AbstractStepMeta.class ); when( stepMetaInterface.clone() ).thenReturn( stepMetaInterface ); StepMeta meta = new StepMeta( STEP_ID, "stepname", stepMetaInterface ); meta.setSelected( true ); meta.setDistributes( false ); meta.setCopiesString( "2" ); meta.setLocation( 1, 2 ); meta.setDraw( true ); meta.setDescription( "description" ); meta.setTerminator( true ); meta.setClusterSchemaName( "clusterSchemaName" ); boolean shouldDistribute = rand.nextBoolean(); meta.setDistributes( shouldDistribute ); if ( shouldDistribute ) { meta.setRowDistribution( selectRowDistribution() ); } Map<String, Map<String, String>> attributes = new HashMap<String, Map<String, String>>(); Map<String, String> map1 = new HashMap<String, String>(); map1.put( "1", "1" ); Map<String, String> map2 = new HashMap<String, String>(); map2.put( "2", "2" ); attributes.put( "qwerty", map1 ); attributes.put( "asdfg", map2 ); meta.setAttributesMap( attributes ); meta.setStepPartitioningMeta( createStepPartitioningMeta( "stepMethod", "stepSchema" ) ); meta.setTargetStepPartitioningMeta( createStepPartitioningMeta( "targetMethod", "targetSchema" ) ); meta.setClusterSchema( new ClusterSchema( "cluster_schema", Collections.<SlaveServer>emptyList() ) ); return meta; }
@SuppressWarnings( { "deprecation", "unchecked" } ) protected void testClone() throws KettleException { T metaToSave = createMeta(); if ( initializer != null ) { initializer.modify( metaToSave ); } Map<String, FieldLoadSaveValidator<?>> validatorMap = createValidatorMapAndInvokeSetters( xmlAttributes, metaToSave ); T metaLoaded = (T) metaToSave.clone(); assertNotSame( metaToSave, metaLoaded ); validateLoadedMeta( xmlAttributes, validatorMap, metaToSave, metaLoaded ); validateLoadedMeta( repoAttributes, validatorMap, metaToSave, metaLoaded ); }