public boolean saveToRepository( EngineMetaInterface meta ) throws KettleException {
    return saveToRepository( meta, meta.getObjectId() == null );
  }
@Test
  public void saveToRepository() throws Exception {
    JobMeta mockJobMeta = mock( JobMeta.class );

    prepareSetSaveTests( spoon, log, mockSpoonPerspective, mockJobMeta, false, false, "NotMainSpoonPerspective", true,
      true, "filename", null, true, false );

    RepositoryDirectoryInterface dirMock = mock( RepositoryDirectoryInterface.class );
    doReturn( "my/path" ).when( dirMock ).getPath();
    doReturn( dirMock ).when( mockJobMeta ).getRepositoryDirectory();
    doReturn( "trans" ).when( mockJobMeta ).getName();

    RepositoryDirectoryInterface newDirMock = mock( RepositoryDirectoryInterface.class );
    doReturn( "my/new/path" ).when( newDirMock ).getPath();
    RepositoryObject repositoryObject = mock( RepositoryObject.class );
    doReturn( newDirMock ).when( repositoryObject ).getRepositoryDirectory();

    FileDialogOperation fileDlgOp = mock( FileDialogOperation.class );
    doReturn( repositoryObject ).when( fileDlgOp ).getRepositoryObject();
    doReturn( fileDlgOp ).when( spoon ).getFileDialogOperation( FileDialogOperation.SAVE,
      FileDialogOperation.ORIGIN_SPOON );
    doReturn( "newTrans" ).when( repositoryObject ).getName();
    doCallRealMethod().when( spoon ).saveToRepository( mockJobMeta, true );

    // mock a successful save
    doReturn( true ).when( spoon ).saveToRepositoryConfirmed( mockJobMeta );
    spoon.saveToRepository( mockJobMeta, true );
    // verify that the meta name and directory have been updated and renameTabs is called
    verify( spoon.delegates.tabs, times( 1 ) ).renameTabs();
    verify( mockJobMeta, times( 1 ) ).setRepositoryDirectory( newDirMock );
    verify( mockJobMeta, never() ).setRepositoryDirectory( dirMock ); // verify that the dir is never set back
    verify( mockJobMeta, times( 1 ) ).setName( "newTrans" );
    verify( mockJobMeta, never()  ).setName( "trans" ); // verify that the name is never set back

    // mock a failed save
    doReturn( false ).when( spoon ).saveToRepositoryConfirmed( mockJobMeta );
    spoon.saveToRepository( mockJobMeta, true );
    // verify that the meta name and directory have not changed and renameTabs is not called (only once form the
    // previous test)
    verify( spoon.delegates.tabs, times( 1 ) ).renameTabs();
    verify( mockJobMeta, times( 2 ) ).setRepositoryDirectory( newDirMock );
    verify( mockJobMeta, times( 1 ) ).setRepositoryDirectory( dirMock ); // verify that the dir is set back
    verify( mockJobMeta, times( 2 ) ).setName( "newTrans" );
    verify( mockJobMeta, times( 1 ) ).setName( "trans" ); // verify that the name is set back
  }