### Question:
TransFileListener implements FileListener { protected TransMeta processLinkedTrans( TransMeta transMeta ) { for ( StepMeta stepMeta : transMeta.getSteps() ) { if ( stepMeta.getStepID().equalsIgnoreCase( "TransExecutor" ) ) { TransExecutorMeta tem = (TransExecutorMeta) stepMeta.getStepMetaInterface(); ObjectLocationSpecificationMethod specMethod = tem.getSpecificationMethod(); if ( specMethod == ObjectLocationSpecificationMethod.FILENAME ) { tem.setSpecificationMethod( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME ); String filename = tem.getFileName(); String jobname = filename.substring( filename.lastIndexOf( "/" ) + 1, filename.lastIndexOf( '.' ) ); String directory = filename.substring( 0, filename.lastIndexOf( "/" ) ); tem.setTransName( jobname ); tem.setDirectoryPath( directory ); } } } return transMeta; }  boolean open( Node transNode, String fname, boolean importfile ); boolean save( EngineMetaInterface meta, String fname, boolean export ); void syncMetaName( EngineMetaInterface meta, String name ); boolean accepts( String fileName ); boolean acceptsXml( String nodeName ); String[] getFileTypeDisplayNames( Locale locale ); String getRootNodeName(); String[] getSupportedExtensions();  }### Answer:
@Test public void testProcessLinkedTransWithFilename() { TransExecutorMeta transExecutorMeta = spy( new TransExecutorMeta() ); transExecutorMeta.setFileName( "/path/to/Transformation2.ktr" ); transExecutorMeta.setSpecificationMethod( ObjectLocationSpecificationMethod.FILENAME ); StepMeta transExecutorStep = mock( StepMeta.class ); when( transExecutorStep.getStepID() ).thenReturn( "TransExecutor" ); when( transExecutorStep.getStepMetaInterface() ).thenReturn( transExecutorMeta ); TransMeta parent = mock( TransMeta.class ); when( parent.getSteps() ).thenReturn( Arrays.asList( transExecutorStep ) ); TransMeta result = transFileListener.processLinkedTrans( parent ); boolean found = false; for ( StepMeta stepMeta : result.getSteps() ) { if ( stepMeta.getStepID().equalsIgnoreCase( "TransExecutor" ) ) { found = true; TransExecutorMeta resultExecMeta = (TransExecutorMeta) stepMeta.getStepMetaInterface(); assertEquals( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME, resultExecMeta.getSpecificationMethod() ); assertEquals( resultExecMeta.getDirectoryPath(), "/path/to" ); assertEquals( resultExecMeta.getTransName(), "Transformation2" ); } } assertTrue( found ); }
@Test public void testProcessLinkedTransWithNoFilename() { TransExecutorMeta transExecutorMeta = spy( new TransExecutorMeta() ); transExecutorMeta.setFileName( null ); transExecutorMeta.setDirectoryPath( "/path/to" ); transExecutorMeta.setTransName( "Transformation2" ); transExecutorMeta.setSpecificationMethod( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME ); StepMeta transExecutorStep = mock( StepMeta.class ); when( transExecutorStep.getStepID() ).thenReturn( "TransExecutor" ); when( transExecutorStep.getStepMetaInterface() ).thenReturn( transExecutorMeta ); TransMeta parent = mock( TransMeta.class ); when( parent.getSteps() ).thenReturn( Arrays.asList( transExecutorStep ) ); TransMeta result = transFileListener.processLinkedTrans( parent ); boolean found = false; for ( StepMeta stepMeta : result.getSteps() ) { if ( stepMeta.getStepID().equalsIgnoreCase( "TransExecutor" ) ) { found = true; TransExecutorMeta resultExecMeta = (TransExecutorMeta) stepMeta.getStepMetaInterface(); assertEquals( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME, resultExecMeta.getSpecificationMethod() ); assertEquals( resultExecMeta.getDirectoryPath(), "/path/to" ); assertEquals( resultExecMeta.getTransName(), "Transformation2" ); } } assertTrue( found ); }