use of org.pentaho.di.repository.RepositoryDirectory in project pentaho-kettle by pentaho.
the class PurRepositoryUnitTest method testTransRepoAfterSaveExtensionPoint.
@Test
public void testTransRepoAfterSaveExtensionPoint() throws KettleException {
PluginMockInterface pluginInterface = mock(PluginMockInterface.class);
when(pluginInterface.getName()).thenReturn(KettleExtensionPoint.TransImportAfterSaveToRepo.id);
when(pluginInterface.getMainType()).thenReturn((Class) ExtensionPointInterface.class);
when(pluginInterface.getIds()).thenReturn(new String[] { "extensionpointId" });
ExtensionPointInterface extensionPoint = mock(ExtensionPointInterface.class);
when(pluginInterface.loadClass(ExtensionPointInterface.class)).thenReturn(extensionPoint);
PluginRegistry.addPluginType(ExtensionPointPluginType.getInstance());
PluginRegistry.getInstance().registerPlugin(ExtensionPointPluginType.class, pluginInterface);
PurRepository rep = mock(PurRepository.class);
doCallRealMethod().when(rep).saveTransOrJob(any(ISharedObjectsTransformer.class), any(RepositoryElementInterface.class), anyString(), any(Calendar.class), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean());
IUnifiedRepository pur = mock(IUnifiedRepository.class);
doCallRealMethod().when(rep).setTest(same(pur));
PurRepositoryMeta mockMeta = mock(PurRepositoryMeta.class);
doCallRealMethod().when(rep).init(same(mockMeta));
rep.init(mockMeta);
rep.setTest(pur);
RepositoryFile file = mock(RepositoryFile.class);
when(file.getId()).thenReturn("id");
when(pur.createFile(any(Serializable.class), any(RepositoryFile.class), any(IRepositoryFileData.class), anyString())).thenReturn(file);
TransMeta trans = mock(TransMeta.class);
when(trans.getRepositoryElementType()).thenReturn(RepositoryObjectType.TRANSFORMATION);
when(trans.getName()).thenReturn("trans");
RepositoryDirectory dir = mock(RepositoryDirectory.class);
when(dir.getObjectId()).thenReturn(new StringObjectId("id"));
when(trans.getRepositoryDirectory()).thenReturn(dir);
TransMeta transFromRepo = mock(TransMeta.class);
when(rep.loadTransformation(any(ObjectId.class), isNull(String.class))).thenReturn(transFromRepo);
ISharedObjectsTransformer transformer = mock(ISharedObjectsTransformer.class);
rep.saveTransOrJob(transformer, trans, "", Calendar.getInstance(), false, false, false, false, false);
verify(extensionPoint, times(1)).callExtensionPoint(any(LogChannelInterface.class), same(transFromRepo));
}
use of org.pentaho.di.repository.RepositoryDirectory 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.RepositoryDirectory in project pentaho-kettle by pentaho.
the class UIRepositoryDirectoryTest method testRefresh.
@Test
public void testRefresh() throws Exception {
RepositoryDirectory root = new RepositoryDirectory();
LongObjectId rootObjectId = new LongObjectId(0L);
root.setObjectId(rootObjectId);
RepositoryDirectory dir = new RepositoryDirectory();
dir.setObjectId(new LongObjectId(1L));
root.addSubdirectory(dir);
RepositoryExtended repo = mock(RepositoryExtended.class);
UserInfo userInfo = new UserInfo();
userInfo.setAdmin(true);
Mockito.when(repo.getUserInfo()).thenReturn(userInfo);
RepositoryDirectory rd = Mockito.mock(RepositoryDirectory.class);
Mockito.when(rd.findDirectory(Mockito.eq(rootObjectId))).thenReturn(Mockito.mock(RepositoryDirectory.class));
Mockito.when(repo.loadRepositoryDirectoryTree("/", "*.ktr|*.kjb", -1, true, true, true)).thenReturn(rd);
UIRepositoryDirectory uiDir = new UIRepositoryDirectory(root, null, repo);
uiDir.refresh();
Mockito.verify(repo).loadRepositoryDirectoryTree("/", "*.ktr|*.kjb", -1, true, true, true);
}
use of org.pentaho.di.repository.RepositoryDirectory in project pentaho-kettle by pentaho.
the class SharedObjectSyncUtilTest method createTransMeta.
private TransMeta createTransMeta() throws KettleException {
TransMeta transMeta = new TransMeta();
transMeta.setName(UUID.randomUUID().toString());
transMeta.setFilename(UUID.randomUUID().toString());
RepositoryDirectory repositoryDirectory = mock(RepositoryDirectory.class);
doCallRealMethod().when(repositoryDirectory).setName(anyString());
doCallRealMethod().when(repositoryDirectory).getName();
transMeta.setRepositoryDirectory(repositoryDirectory);
initSharedObjects(transMeta, SHARED_OBJECTS_FILE);
when(spoon.getActiveMeta()).thenReturn(transMeta);
return transMeta;
}
use of org.pentaho.di.repository.RepositoryDirectory in project pentaho-kettle by pentaho.
the class StarModelerPerspective method generateSqlJobButton.
protected void generateSqlJobButton(StarDomain starDomain) {
final Spoon spoon = Spoon.getInstance();
List<DatabaseMeta> sharedDatabases = SharedDatabaseUtil.loadSharedDatabases();
// TODO: validate presence of repository, repository directory
//
JobGenerator jobGenerator = new JobGenerator(starDomain, spoon.rep, new RepositoryDirectory(), sharedDatabases, defaultLocale);
try {
JobMeta jobMeta = jobGenerator.generateSqlJob();
spoon.addJobGraph(jobMeta);
SpoonPerspectiveManager.getInstance().activatePerspective(MainSpoonPerspective.class);
} catch (Exception e) {
new ErrorDialog(spoon.getShell(), BaseMessages.getString(PKG, "StarModelerPerspective.ErrorGeneratingSqlJob.Title"), BaseMessages.getString(PKG, "StarModelerPerspective.ErrorGeneratingSqlJob.Message"), e);
}
}
Aggregations