Search in sources :

Example 41 with RepositoryDirectory

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));
}
Also used : IRepositoryFileData(org.pentaho.platform.api.repository2.unified.IRepositoryFileData) Serializable(java.io.Serializable) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) StringObjectId(org.pentaho.di.repository.StringObjectId) ObjectId(org.pentaho.di.repository.ObjectId) Calendar(java.util.Calendar) TransMeta(org.pentaho.di.trans.TransMeta) Matchers.anyString(org.mockito.Matchers.anyString) StringObjectId(org.pentaho.di.repository.StringObjectId) RepositoryElementInterface(org.pentaho.di.repository.RepositoryElementInterface) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) LogChannelInterface(org.pentaho.di.core.logging.LogChannelInterface) ExtensionPointInterface(org.pentaho.di.core.extension.ExtensionPointInterface) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) Test(org.junit.Test)

Example 42 with RepositoryDirectory

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);
}
Also used : Repository(org.pentaho.di.repository.Repository) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) LongObjectId(org.pentaho.di.repository.LongObjectId) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface) Test(org.junit.Test)

Example 43 with RepositoryDirectory

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);
}
Also used : RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) RepositoryExtended(org.pentaho.di.repository.RepositoryExtended) UserInfo(org.pentaho.di.repository.UserInfo) LongObjectId(org.pentaho.di.repository.LongObjectId) Test(org.junit.Test)

Example 44 with RepositoryDirectory

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;
}
Also used : RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) TransMeta(org.pentaho.di.trans.TransMeta)

Example 45 with RepositoryDirectory

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);
    }
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) Spoon(org.pentaho.di.ui.spoon.Spoon) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) JobGenerator(org.pentaho.di.starmodeler.generator.JobGenerator) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) XulException(org.pentaho.ui.xul.XulException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) KettleException(org.pentaho.di.core.exception.KettleException) MetaStoreElementExistException(org.pentaho.metastore.api.exceptions.MetaStoreElementExistException)

Aggregations

RepositoryDirectory (org.pentaho.di.repository.RepositoryDirectory)57 KettleException (org.pentaho.di.core.exception.KettleException)23 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)15 Test (org.junit.Test)14 TransMeta (org.pentaho.di.trans.TransMeta)11 LongObjectId (org.pentaho.di.repository.LongObjectId)10 ObjectId (org.pentaho.di.repository.ObjectId)9 KettleFileException (org.pentaho.di.core.exception.KettleFileException)8 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)8 Repository (org.pentaho.di.repository.Repository)8 RepositoryElementMetaInterface (org.pentaho.di.repository.RepositoryElementMetaInterface)8 ArrayList (java.util.ArrayList)7 StringObjectId (org.pentaho.di.repository.StringObjectId)7 FileSystemException (org.apache.commons.vfs2.FileSystemException)6 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)6 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)6 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)6 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)5 JobMeta (org.pentaho.di.job.JobMeta)5 TreeItem (org.eclipse.swt.widgets.TreeItem)4