Search in sources :

Example 46 with RepositoryObject

use of org.pentaho.di.repository.RepositoryObject in project pdi-dataservice-server-plugin by pentaho.

the class ServiceTransTest method testRepoIdStorageMethod.

@Test
public void testRepoIdStorageMethod() throws KettleException {
    ObjectId transId = new StringObjectId("transId");
    when(repository.loadTransformation(eq(transId), isNull(String.class))).thenReturn(transMeta);
    ServiceTrans.StorageMethod method = ServiceTrans.StorageMethod.REPO_ID;
    when(repository.getObjectInformation(any(ObjectId.class), eq(RepositoryObjectType.TRANSFORMATION))).thenReturn(mock(RepositoryObject.class)).thenThrow(new KettleException());
    assertThat(method.exists(repository, transId.getId()), is(true));
    assertThat(method.exists(repository, "/nonExistingTrans"), is(false));
    RepositoryObject transInfo = mock(RepositoryObject.class);
    when(transInfo.isDeleted()).thenReturn(false, true);
    when(repository.getObjectInformation(eq(transId), eq(RepositoryObjectType.TRANSFORMATION))).thenReturn(transInfo);
    assertThat(method.load(repository, transId.getId()), is(transMeta));
    assertThat(method.load(repository, transId.getId()), is(nullValue()));
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryObject(org.pentaho.di.repository.RepositoryObject) ObjectId(org.pentaho.di.repository.ObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId) StringObjectId(org.pentaho.di.repository.StringObjectId) Test(org.junit.Test)

Aggregations

RepositoryObject (org.pentaho.di.repository.RepositoryObject)46 KettleException (org.pentaho.di.core.exception.KettleException)31 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)15 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)11 StringObjectId (org.pentaho.di.repository.StringObjectId)9 ObjectId (org.pentaho.di.repository.ObjectId)7 ArrayList (java.util.ArrayList)6 Date (java.util.Date)6 Test (org.junit.Test)6 KettleFileException (org.pentaho.di.core.exception.KettleFileException)5 RepositoryElementMetaInterface (org.pentaho.di.repository.RepositoryElementMetaInterface)5 IOException (java.io.IOException)4 FileSystemException (org.apache.commons.vfs2.FileSystemException)4 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)4 FileDialogOperation (org.pentaho.di.ui.core.FileDialogOperation)4 FileObject (org.apache.commons.vfs2.FileObject)3 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)3 RepositoryObjectInterface (org.pentaho.di.repository.RepositoryObjectInterface)3 Serializable (java.io.Serializable)2 List (java.util.List)2