### Question:
JobFileListener implements FileListener { protected JobMeta processLinkedTrans( JobMeta jobMeta ) { for ( int i = 0; i < jobMeta.nrJobEntries(); i++ ) { JobEntryCopy jec = jobMeta.getJobEntry( i ); if ( jec.getEntry() instanceof JobEntryTrans ) { JobEntryTrans jet = (JobEntryTrans) jec.getEntry(); ObjectLocationSpecificationMethod specMethod = jet.getSpecificationMethod(); if ( specMethod == ObjectLocationSpecificationMethod.FILENAME ) { jet.setSpecificationMethod( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME ); String filename = jet.getFilename(); String jobname = filename.substring( filename.lastIndexOf( "/" ) + 1, filename.lastIndexOf( '.' ) ); String directory = filename.substring( 0, filename.lastIndexOf( "/" ) ); jet.setTransname( jobname ); jet.setDirectory( directory ); jobMeta.setJobEntry( i, jec ); } } } return jobMeta; }  boolean open( Node jobNode, 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[] getSupportedExtensions(); String getRootNodeName();  }### Answer:
@Test public void testProcessLinkedTransWithFilename() { JobEntryTrans jobTransExecutor = spy( new JobEntryTrans() ); jobTransExecutor.setFileName( "/path/to/Transformation2.ktr" ); jobTransExecutor.setSpecificationMethod( ObjectLocationSpecificationMethod.FILENAME ); JobEntryCopy jobEntry = mock( JobEntryCopy.class ); when( jobEntry.getEntry() ).thenReturn( jobTransExecutor ); JobMeta parent = mock( JobMeta.class ); when( parent.nrJobEntries() ).thenReturn( 1 ); when( parent.getJobEntry( 0 ) ).thenReturn( jobEntry ); JobMeta result = jobFileListener.processLinkedTrans( parent ); JobEntryCopy meta = result.getJobEntry( 0 ); assertNotNull( meta ); JobEntryTrans resultExecMeta = (JobEntryTrans) meta.getEntry(); assertEquals( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME, resultExecMeta.getSpecificationMethod() ); assertEquals( "/path/to", resultExecMeta.getDirectory() ); assertEquals( "Transformation2", resultExecMeta.getTransname() ); }
@Test public void testProcessLinkedTransWithNoFilename() { JobEntryTrans jobTransExecutor = spy( new JobEntryTrans() ); jobTransExecutor.setFileName( null ); jobTransExecutor.setDirectory( "/path/to" ); jobTransExecutor.setTransname( "Transformation2" ); jobTransExecutor.setSpecificationMethod( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME ); JobEntryCopy jobEntry = mock( JobEntryCopy.class ); when( jobEntry.getEntry() ).thenReturn( jobTransExecutor ); JobMeta parent = mock( JobMeta.class ); when( parent.nrJobEntries() ).thenReturn( 1 ); when( parent.getJobEntry( 0 ) ).thenReturn( jobEntry ); JobMeta result = jobFileListener.processLinkedTrans( parent ); JobEntryCopy meta = result.getJobEntry( 0 ); assertNotNull( meta ); JobEntryTrans resultExecMeta = (JobEntryTrans) meta.getEntry(); assertEquals( ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME, resultExecMeta.getSpecificationMethod() ); assertEquals( "/path/to", resultExecMeta.getDirectory() ); assertEquals( "Transformation2", resultExecMeta.getTransname() ); }