@VisibleForTesting
  void writeInjectedKtr( String targetFilPath ) throws KettleException {
    if ( shouldWriteToFilesystem() ) {
      writeInjectedKtrToFs( targetFilPath );
    } else {
      writeInjectedKtrToRepo( targetFilPath );
    }
  }
@Test
  public void testWriteInjectedKtrToRepoDifferentDir() throws Exception {
    RepositoryDirectory adminDir = spy( new RepositoryDirectory( new RepositoryDirectory(
      new RepositoryDirectory( null, "/" ), "home" ), "admin" ) );
    TransMeta cloneMeta = spy( (TransMeta) data.transMeta.realClone( false ) );
    doReturn( cloneMeta ).when( data.transMeta ).realClone( false );

    doReturn( adminDir ).when( repository ).createRepositoryDirectory( any( RepositoryDirectory.class ),
      eq( "/home/admin" ) );
    doReturn( adminDir ).when( data.transMeta ).getRepositoryDirectory();
    ObjectId mockObjectId = mock( ObjectId.class );
    when( repository.getTransformationID( eq( "injected_trans" ), any( RepositoryDirectory.class ) ) ).thenReturn( mockObjectId );

    metaInject.setRepository( repository );
    metaInject.writeInjectedKtr( "injected_trans" );
    verify( repository, times( 0 ) ).findDirectory( anyString() );
    verify( repository, times( 0 ) ).createRepositoryDirectory( any(), any() );
    verify( cloneMeta, times( 1 ) ).setRepositoryDirectory( adminDir );
    verify( cloneMeta, times( 1 ) ).setObjectId( mockObjectId );
    verify( repository, times( 1 ) ).save( cloneMeta, null, null, true );
  }