use of org.pentaho.di.repository.RepositoryElementMetaInterface in project pentaho-kettle by pentaho.
the class RepositoryDirectoryUITest method testLoadRepositoryObjectsFilled.
@Test
public void testLoadRepositoryObjectsFilled() throws Exception {
RepositoryDirectory root = new RepositoryDirectory();
root.setObjectId(new LongObjectId(0L));
RepositoryDirectory dir = new RepositoryDirectory();
dir.setObjectId(new LongObjectId(1L));
root.addSubdirectory(dir);
RepositoryElementMetaInterface meta = mock(RepositoryElementMetaInterface.class);
when(meta.getObjectType()).thenReturn(RepositoryObjectType.TRANSFORMATION);
root.setRepositoryObjects(Collections.emptyList());
dir.setRepositoryObjects(Collections.singletonList(meta));
Repository repo = mock(Repository.class);
assertTrue(RepositoryDirectoryUI.loadRepositoryObjects(root, true, true, repo).isEmpty());
assertEquals(1, RepositoryDirectoryUI.loadRepositoryObjects(dir, true, true, repo).size());
verifyZeroInteractions(repo);
}
use of org.pentaho.di.repository.RepositoryElementMetaInterface in project pentaho-kettle by pentaho.
the class UIDatabaseConnectionTest method testModifiedDate.
@Test
public void testModifiedDate() {
final Long timestamp = 100000L;
SimpleDateFormat sdf = new SimpleDateFormat("d MMM yyyy HH:mm:ss z");
UIDatabaseConnection uiconn = new UIDatabaseConnection();
RepositoryElementMetaInterface repoMeta = mock(RepositoryElementMetaInterface.class);
when(repoMeta.getModifiedDate()).thenReturn(new Date(timestamp));
uiconn.setRepositoryElementMetaInterface(repoMeta);
assertEquals(sdf.format(new Date(timestamp)), uiconn.getDateModified());
}
use of org.pentaho.di.repository.RepositoryElementMetaInterface in project pentaho-kettle by pentaho.
the class DialogUtilsTest method nullDirectory.
@Test
public void nullDirectory() {
RepositoryElementMetaInterface object = mock(RepositoryElementMetaInterface.class);
when(object.getRepositoryDirectory()).thenReturn(null);
assertNull(getPathOf(object));
}
use of org.pentaho.di.repository.RepositoryElementMetaInterface in project pentaho-kettle by pentaho.
the class DialogUtilsTest method deletedObject.
@Test
public void deletedObject() {
RepositoryElementMetaInterface object = mock(RepositoryElementMetaInterface.class);
when(object.isDeleted()).thenReturn(true);
assertNull(getPathOf(object));
}
use of org.pentaho.di.repository.RepositoryElementMetaInterface in project pentaho-kettle by pentaho.
the class PurRepository method getPdiObjects.
protected List<RepositoryElementMetaInterface> getPdiObjects(ObjectId dirId, List<RepositoryObjectType> objectTypes, boolean includeDeleted) throws KettleException {
try {
// RepositoryDirectoryInterface repDir = getRootDir().findDirectory( dirId );
RepositoryFile dirFile = pur.getFileById(dirId.getId());
RepositoryDirectory repDir = new RepositoryDirectory();
repDir.setObjectId(dirId);
repDir.setName(dirFile.getName());
List<RepositoryElementMetaInterface> list = new ArrayList<RepositoryElementMetaInterface>();
List<RepositoryFile> nonDeletedChildren = getAllFilesOfType(dirId, objectTypes);
for (RepositoryFile file : nonDeletedChildren) {
RepositoryLock lock = unifiedRepositoryLockService.getLock(file);
RepositoryObjectType objectType = getObjectType(file.getName());
list.add(new EERepositoryObject(file, repDir, null, objectType, null, lock, false));
}
if (includeDeleted) {
String dirPath = null;
if (dirId != null) {
// derive path using id
dirPath = pur.getFileById(dirId.getId()).getPath();
}
List<RepositoryFile> deletedChildren = getAllDeletedFilesOfType(dirPath, objectTypes);
for (RepositoryFile file : deletedChildren) {
RepositoryLock lock = unifiedRepositoryLockService.getLock(file);
RepositoryObjectType objectType = getObjectType(file.getName());
list.add(new EERepositoryObject(file, repDir, null, objectType, null, lock, true));
}
}
return list;
} catch (Exception e) {
throw new KettleException("Unable to get list of objects from directory [" + dirId + "]", e);
}
}
Aggregations