@Test public void testExceptionNotHandle() throws Exception { RuntimeException runtimeException = new RuntimeException( "Exception handle" ); when( selectedTrashFileItemsMock.toArray() ) .thenReturn( new TrashBrowseController.UIDeletedObject[] { uiDirectoryObjectMock } ); when( selectedTrashFileItemsMock.size() ).thenReturn( 1 ); doReturn( uiDirectoryObjectMock ).when( selectedTrashFileItemsMock ).get( 0 ); doThrow( runtimeException ).when( trashServiceMock ).undelete( anyList() ); doReturn( true ).when( mainControllerMock ).handleLostRepository( any( Throwable.class ) ); trBrController.undelete(); verify( messageBoxMock, never() ).setTitle( "Error" ); verify( messageBoxMock, never() ).setAcceptLabel( "OK" ); verify( messageBoxMock, never() ).setMessage( contains( "Exception handle" ) ); verify( messageBoxMock, never() ).open(); verify( deckMock, never() ).setSelectedIndex( 1 ); }
public void undelete() { List<UIDeletedObject> selectedTrashFileItemsSnapshot = new ArrayList<UIDeletedObject>( selectedTrashFileItems ); if ( selectedTrashFileItemsSnapshot != null && selectedTrashFileItemsSnapshot.size() > 0 ) { List<ObjectId> ids = new ArrayList<ObjectId>(); for ( UIDeletedObject uiObj : selectedTrashFileItemsSnapshot ) { ids.add( uiObj.getId() ); } try { trashService.undelete( ids ); setTrash( trashService.getTrash() ); for ( UIDeletedObject uiObj : selectedTrashFileItemsSnapshot ) { RepositoryDirectoryInterface dir = repository.findDirectory( uiObj.getOriginalParentPath() ); while ( dir != null && dirMap.get( dir.getObjectId() ) == null ) { dir = dir.getParent(); } if ( dir != null ) { dirMap.get( dir.getObjectId() ).refresh(); } if ( RepositoryObjectType.TRANSFORMATION.name().equals( uiObj.getType() ) ) { TransMeta transMeta = repository.loadTransformation( uiObj.getId(), null ); ExtensionPointHandler .callExtensionPoint( LogChannel.GENERAL, KettleExtensionPoint.TransAfterOpen.id, transMeta ); transMeta.clearChanged(); } else if ( !RepositoryObjectType.JOB.name().equals( uiObj.getType() ) ) { RepositoryDirectoryInterface actualDir = repository.findDirectory( uiObj.getOriginalParentPath() + RepositoryDirectory.DIRECTORY_SEPARATOR + uiObj.getName() ); if ( actualDir != null ) { List<RepositoryElementMetaInterface> transformations = new ArrayList<>(); getAllTransformations( actualDir, transformations ); for ( RepositoryElementMetaInterface repositoryElementMetaInterface : transformations ) { TransMeta transMeta = repository.loadTransformation( repositoryElementMetaInterface.getObjectId(), null ); ExtensionPointHandler .callExtensionPoint( LogChannel.GENERAL, KettleExtensionPoint.TransAfterOpen.id, transMeta ); transMeta.clearChanged(); } } else { displayExceptionMessage( BaseMessages.getString( PKG, "TrashBrowseController.UnableToRestoreDirectory", uiObj.getOriginalParentPath() + RepositoryDirectory.DIRECTORY_SEPARATOR + uiObj .getName() ) ); } } } deck.setSelectedIndex( 1 ); } catch ( Throwable th ) { if ( mainController == null || !mainController.handleLostRepository( th ) ) { displayExceptionMessage( BaseMessages.getString( PKG, "TrashBrowseController.UnableToRestoreFile", th.getLocalizedMessage() ) ); } } } else { throw new RuntimeException(); } }
TrashBrowseController extends BrowseController implements java.io.Serializable { public void undelete() { List<UIDeletedObject> selectedTrashFileItemsSnapshot = new ArrayList<UIDeletedObject>( selectedTrashFileItems ); if ( selectedTrashFileItemsSnapshot != null && selectedTrashFileItemsSnapshot.size() > 0 ) { List<ObjectId> ids = new ArrayList<ObjectId>(); for ( UIDeletedObject uiObj : selectedTrashFileItemsSnapshot ) { ids.add( uiObj.getId() ); } try { trashService.undelete( ids ); setTrash( trashService.getTrash() ); for ( UIDeletedObject uiObj : selectedTrashFileItemsSnapshot ) { RepositoryDirectoryInterface dir = repository.findDirectory( uiObj.getOriginalParentPath() ); while ( dir != null && dirMap.get( dir.getObjectId() ) == null ) { dir = dir.getParent(); } if ( dir != null ) { dirMap.get( dir.getObjectId() ).refresh(); } if ( RepositoryObjectType.TRANSFORMATION.name().equals( uiObj.getType() ) ) { TransMeta transMeta = repository.loadTransformation( uiObj.getId(), null ); ExtensionPointHandler .callExtensionPoint( LogChannel.GENERAL, KettleExtensionPoint.TransAfterOpen.id, transMeta ); transMeta.clearChanged(); } else if ( !RepositoryObjectType.JOB.name().equals( uiObj.getType() ) ) { RepositoryDirectoryInterface actualDir = repository.findDirectory( uiObj.getOriginalParentPath() + RepositoryDirectory.DIRECTORY_SEPARATOR + uiObj.getName() ); if ( actualDir != null ) { List<RepositoryElementMetaInterface> transformations = new ArrayList<>(); getAllTransformations( actualDir, transformations ); for ( RepositoryElementMetaInterface repositoryElementMetaInterface : transformations ) { TransMeta transMeta = repository.loadTransformation( repositoryElementMetaInterface.getObjectId(), null ); ExtensionPointHandler .callExtensionPoint( LogChannel.GENERAL, KettleExtensionPoint.TransAfterOpen.id, transMeta ); transMeta.clearChanged(); } } else { displayExceptionMessage( BaseMessages.getString( PKG, "TrashBrowseController.UnableToRestoreDirectory", uiObj.getOriginalParentPath() + RepositoryDirectory.DIRECTORY_SEPARATOR + uiObj .getName() ) ); } } } deck.setSelectedIndex( 1 ); } catch ( Throwable th ) { if ( mainController == null || !mainController.handleLostRepository( th ) ) { displayExceptionMessage( BaseMessages.getString( PKG, "TrashBrowseController.UnableToRestoreFile", th.getLocalizedMessage() ) ); } } } else { throw new RuntimeException(); } } }
TrashBrowseController extends BrowseController implements java.io.Serializable { public void undelete() { List<UIDeletedObject> selectedTrashFileItemsSnapshot = new ArrayList<UIDeletedObject>( selectedTrashFileItems ); if ( selectedTrashFileItemsSnapshot != null && selectedTrashFileItemsSnapshot.size() > 0 ) { List<ObjectId> ids = new ArrayList<ObjectId>(); for ( UIDeletedObject uiObj : selectedTrashFileItemsSnapshot ) { ids.add( uiObj.getId() ); } try { trashService.undelete( ids ); setTrash( trashService.getTrash() ); for ( UIDeletedObject uiObj : selectedTrashFileItemsSnapshot ) { RepositoryDirectoryInterface dir = repository.findDirectory( uiObj.getOriginalParentPath() ); while ( dir != null && dirMap.get( dir.getObjectId() ) == null ) { dir = dir.getParent(); } if ( dir != null ) { dirMap.get( dir.getObjectId() ).refresh(); } if ( RepositoryObjectType.TRANSFORMATION.name().equals( uiObj.getType() ) ) { TransMeta transMeta = repository.loadTransformation( uiObj.getId(), null ); ExtensionPointHandler .callExtensionPoint( LogChannel.GENERAL, KettleExtensionPoint.TransAfterOpen.id, transMeta ); transMeta.clearChanged(); } else if ( !RepositoryObjectType.JOB.name().equals( uiObj.getType() ) ) { RepositoryDirectoryInterface actualDir = repository.findDirectory( uiObj.getOriginalParentPath() + RepositoryDirectory.DIRECTORY_SEPARATOR + uiObj.getName() ); if ( actualDir != null ) { List<RepositoryElementMetaInterface> transformations = new ArrayList<>(); getAllTransformations( actualDir, transformations ); for ( RepositoryElementMetaInterface repositoryElementMetaInterface : transformations ) { TransMeta transMeta = repository.loadTransformation( repositoryElementMetaInterface.getObjectId(), null ); ExtensionPointHandler .callExtensionPoint( LogChannel.GENERAL, KettleExtensionPoint.TransAfterOpen.id, transMeta ); transMeta.clearChanged(); } } else { displayExceptionMessage( BaseMessages.getString( PKG, "TrashBrowseController.UnableToRestoreDirectory", uiObj.getOriginalParentPath() + RepositoryDirectory.DIRECTORY_SEPARATOR + uiObj .getName() ) ); } } } deck.setSelectedIndex( 1 ); } catch ( Throwable th ) { if ( mainController == null || !mainController.handleLostRepository( th ) ) { displayExceptionMessage( BaseMessages.getString( PKG, "TrashBrowseController.UnableToRestoreFile", th.getLocalizedMessage() ) ); } } } else { throw new RuntimeException(); } } TrashBrowseController(); }
TrashBrowseController extends BrowseController implements java.io.Serializable { public void undelete() { List<UIDeletedObject> selectedTrashFileItemsSnapshot = new ArrayList<UIDeletedObject>( selectedTrashFileItems ); if ( selectedTrashFileItemsSnapshot != null && selectedTrashFileItemsSnapshot.size() > 0 ) { List<ObjectId> ids = new ArrayList<ObjectId>(); for ( UIDeletedObject uiObj : selectedTrashFileItemsSnapshot ) { ids.add( uiObj.getId() ); } try { trashService.undelete( ids ); setTrash( trashService.getTrash() ); for ( UIDeletedObject uiObj : selectedTrashFileItemsSnapshot ) { RepositoryDirectoryInterface dir = repository.findDirectory( uiObj.getOriginalParentPath() ); while ( dir != null && dirMap.get( dir.getObjectId() ) == null ) { dir = dir.getParent(); } if ( dir != null ) { dirMap.get( dir.getObjectId() ).refresh(); } if ( RepositoryObjectType.TRANSFORMATION.name().equals( uiObj.getType() ) ) { TransMeta transMeta = repository.loadTransformation( uiObj.getId(), null ); ExtensionPointHandler .callExtensionPoint( LogChannel.GENERAL, KettleExtensionPoint.TransAfterOpen.id, transMeta ); transMeta.clearChanged(); } else if ( !RepositoryObjectType.JOB.name().equals( uiObj.getType() ) ) { RepositoryDirectoryInterface actualDir = repository.findDirectory( uiObj.getOriginalParentPath() + RepositoryDirectory.DIRECTORY_SEPARATOR + uiObj.getName() ); if ( actualDir != null ) { List<RepositoryElementMetaInterface> transformations = new ArrayList<>(); getAllTransformations( actualDir, transformations ); for ( RepositoryElementMetaInterface repositoryElementMetaInterface : transformations ) { TransMeta transMeta = repository.loadTransformation( repositoryElementMetaInterface.getObjectId(), null ); ExtensionPointHandler .callExtensionPoint( LogChannel.GENERAL, KettleExtensionPoint.TransAfterOpen.id, transMeta ); transMeta.clearChanged(); } } else { displayExceptionMessage( BaseMessages.getString( PKG, "TrashBrowseController.UnableToRestoreDirectory", uiObj.getOriginalParentPath() + RepositoryDirectory.DIRECTORY_SEPARATOR + uiObj .getName() ) ); } } } deck.setSelectedIndex( 1 ); } catch ( Throwable th ) { if ( mainController == null || !mainController.handleLostRepository( th ) ) { displayExceptionMessage( BaseMessages.getString( PKG, "TrashBrowseController.UnableToRestoreFile", th.getLocalizedMessage() ) ); } } } else { throw new RuntimeException(); } } TrashBrowseController(); @Override void init( Repository repository ); @Override void setSelectedFolderItems( List<UIRepositoryDirectory> selectedFolderItems ); void setTrash( List<IDeletedObject> trash ); List<IDeletedObject> getTrash(); void delete(); void undelete(); void setSelectedTrashFileItems( List<UIDeletedObject> selectedTrashFileItems ); }
TrashBrowseController extends BrowseController implements java.io.Serializable { public void undelete() { List<UIDeletedObject> selectedTrashFileItemsSnapshot = new ArrayList<UIDeletedObject>( selectedTrashFileItems ); if ( selectedTrashFileItemsSnapshot != null && selectedTrashFileItemsSnapshot.size() > 0 ) { List<ObjectId> ids = new ArrayList<ObjectId>(); for ( UIDeletedObject uiObj : selectedTrashFileItemsSnapshot ) { ids.add( uiObj.getId() ); } try { trashService.undelete( ids ); setTrash( trashService.getTrash() ); for ( UIDeletedObject uiObj : selectedTrashFileItemsSnapshot ) { RepositoryDirectoryInterface dir = repository.findDirectory( uiObj.getOriginalParentPath() ); while ( dir != null && dirMap.get( dir.getObjectId() ) == null ) { dir = dir.getParent(); } if ( dir != null ) { dirMap.get( dir.getObjectId() ).refresh(); } if ( RepositoryObjectType.TRANSFORMATION.name().equals( uiObj.getType() ) ) { TransMeta transMeta = repository.loadTransformation( uiObj.getId(), null ); ExtensionPointHandler .callExtensionPoint( LogChannel.GENERAL, KettleExtensionPoint.TransAfterOpen.id, transMeta ); transMeta.clearChanged(); } else if ( !RepositoryObjectType.JOB.name().equals( uiObj.getType() ) ) { RepositoryDirectoryInterface actualDir = repository.findDirectory( uiObj.getOriginalParentPath() + RepositoryDirectory.DIRECTORY_SEPARATOR + uiObj.getName() ); if ( actualDir != null ) { List<RepositoryElementMetaInterface> transformations = new ArrayList<>(); getAllTransformations( actualDir, transformations ); for ( RepositoryElementMetaInterface repositoryElementMetaInterface : transformations ) { TransMeta transMeta = repository.loadTransformation( repositoryElementMetaInterface.getObjectId(), null ); ExtensionPointHandler .callExtensionPoint( LogChannel.GENERAL, KettleExtensionPoint.TransAfterOpen.id, transMeta ); transMeta.clearChanged(); } } else { displayExceptionMessage( BaseMessages.getString( PKG, "TrashBrowseController.UnableToRestoreDirectory", uiObj.getOriginalParentPath() + RepositoryDirectory.DIRECTORY_SEPARATOR + uiObj .getName() ) ); } } } deck.setSelectedIndex( 1 ); } catch ( Throwable th ) { if ( mainController == null || !mainController.handleLostRepository( th ) ) { displayExceptionMessage( BaseMessages.getString( PKG, "TrashBrowseController.UnableToRestoreFile", th.getLocalizedMessage() ) ); } } } else { throw new RuntimeException(); } } TrashBrowseController(); @Override void init( Repository repository ); @Override void setSelectedFolderItems( List<UIRepositoryDirectory> selectedFolderItems ); void setTrash( List<IDeletedObject> trash ); List<IDeletedObject> getTrash(); void delete(); void undelete(); void setSelectedTrashFileItems( List<UIDeletedObject> selectedTrashFileItems );  }