Search in sources :

Example 1 with PurRepositoryMeta

use of org.pentaho.di.repository.pur.PurRepositoryMeta in project pentaho-kettle by pentaho.

the class PurRepositoryMetaStoreTest method setUp.

@Before
public void setUp() throws Exception {
    purRepository = mock(PurRepository.class);
    pur = mock(IUnifiedRepository.class);
    namespacesFolder = mock(RepositoryFile.class);
    when(purRepository.getUnderlyingRepository()).thenReturn(pur);
    when(pur.getFile(PurRepositoryMetaStore.METASTORE_FOLDER_PATH)).thenReturn(namespacesFolder);
    PurRepositoryMeta mockPurRepositoryMeta = mock(PurRepositoryMeta.class);
    when(purRepository.getRepositoryMeta()).thenReturn(mockPurRepositoryMeta);
    when(purRepository.getRepositoryMeta().getName()).thenReturn("MockPurRepository");
    metaStore = new PurRepositoryMetaStore(purRepository);
}
Also used : PurRepository(org.pentaho.di.repository.pur.PurRepository) PurRepositoryMeta(org.pentaho.di.repository.pur.PurRepositoryMeta) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) Before(org.junit.Before)

Example 2 with PurRepositoryMeta

use of org.pentaho.di.repository.pur.PurRepositoryMeta in project pentaho-kettle by pentaho.

the class RepositoryLockControllerTest method testBlockLock.

@Test
public void testBlockLock() throws Exception {
    RepositoryLockController repositoryLockController = new RepositoryLockController();
    List<UIRepositoryObject> selectedRepoObjects = new ArrayList<>();
    UIEETransformation lockObject = Mockito.mock(UIEETransformation.class);
    selectedRepoObjects.add(lockObject);
    Mockito.when(lockObject.isLocked()).thenReturn(true);
    ObjectId objectId = Mockito.mock(ObjectId.class);
    Mockito.when(lockObject.getObjectId()).thenReturn(objectId);
    XulMenuitem lockFileMenuItem = Mockito.mock(XulMenuitem.class);
    Field lockFileMenuItemField = repositoryLockController.getClass().getDeclaredField("lockFileMenuItem");
    lockFileMenuItemField.setAccessible(true);
    lockFileMenuItemField.set(repositoryLockController, lockFileMenuItem);
    XulMenuitem deleteFileMenuItem = Mockito.mock(XulMenuitem.class);
    Field deleteFileMenuItemField = repositoryLockController.getClass().getDeclaredField("deleteFileMenuItem");
    deleteFileMenuItemField.setAccessible(true);
    deleteFileMenuItemField.set(repositoryLockController, deleteFileMenuItem);
    XulMenuitem renameFileMenuItem = Mockito.mock(XulMenuitem.class);
    Field renameFileMenuItemField = repositoryLockController.getClass().getDeclaredField("renameFileMenuItem");
    renameFileMenuItemField.setAccessible(true);
    renameFileMenuItemField.set(repositoryLockController, renameFileMenuItem);
    Repository repository = Mockito.mock(Repository.class);
    PurRepositoryMeta repositoryMeta = Mockito.mock(PurRepositoryMeta.class);
    Mockito.when(repository.getRepositoryMeta()).thenReturn(repositoryMeta);
    Field repositoryField = repositoryLockController.getClass().getDeclaredField("repository");
    repositoryField.setAccessible(true);
    repositoryField.set(repositoryLockController, repository);
    ILockService service = Mockito.mock(ILockService.class);
    Mockito.when(service.canUnlockFileById(objectId)).thenReturn(true);
    Field serviceField = repositoryLockController.getClass().getDeclaredField("service");
    serviceField.setAccessible(true);
    serviceField.set(repositoryLockController, service);
    repositoryLockController.setMenuItemEnabledState(selectedRepoObjects);
    Assert.assertFalse(lockFileMenuItem.isDisabled());
    Mockito.verify(lockFileMenuItem).setDisabled(false);
}
Also used : UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) Field(java.lang.reflect.Field) Repository(org.pentaho.di.repository.Repository) ObjectId(org.pentaho.di.repository.ObjectId) XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) ILockService(org.pentaho.di.ui.repository.pur.services.ILockService) ArrayList(java.util.ArrayList) PurRepositoryMeta(org.pentaho.di.repository.pur.PurRepositoryMeta) UIEETransformation(org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIEETransformation) Test(org.junit.Test)

Example 3 with PurRepositoryMeta

use of org.pentaho.di.repository.pur.PurRepositoryMeta in project pentaho-kettle by pentaho.

the class UIEERepositoryDirectoryIT method setUp.

@Before
public void setUp() throws Exception {
    this.testContextManager = new TestContextManager(getClass());
    this.testContextManager.prepareTestInstance(this);
    loginAsRepositoryAdmin();
    SimpleJcrTestUtils.deleteItem(testJcrTemplate, ServerRepositoryPaths.getPentahoRootFolderPath());
    mp = new MicroPlatform();
    // used by DefaultPentahoJackrabbitAccessControlHelper
    mp.defineInstance("tenantedUserNameUtils", userNameUtils);
    mp.defineInstance("tenantedRoleNameUtils", roleNameUtils);
    mp.defineInstance(IAuthorizationPolicy.class, authorizationPolicy);
    mp.defineInstance(ITenantManager.class, tenantManager);
    mp.defineInstance("roleAuthorizationPolicyRoleBindingDaoTarget", roleBindingDaoTarget);
    mp.defineInstance("repositoryAdminUsername", repositoryAdminUsername);
    mp.defineInstance("RepositoryFileProxyFactory", new RepositoryFileProxyFactory(testJcrTemplate, repositoryFileDao));
    mp.defineInstance("useMultiByteEncoding", new Boolean(false));
    mp.defineInstance(IAclService.class, new Boolean(false));
    // Start the micro-platform
    mp.start();
    loginAsRepositoryAdmin();
    setAclManagement();
    systemTenant = tenantManager.createTenant(null, ServerRepositoryPaths.getPentahoRootFolderName(), singleTenantAdminRoleName, tenantAuthenticatedRoleName, "Anonymous");
    userRoleDao.createUser(systemTenant, sysAdminUserName, "password", "", new String[] { singleTenantAdminRoleName });
    logout();
    super.setUp();
    KettleEnvironment.init();
    // programmatically register plugins, annotation based plugins do not get loaded unless
    // they are in kettle's plugins folder.
    JobEntryPluginType.getInstance().registerCustom(JobEntryAttributeTesterJobEntry.class, "test", "JobEntryAttributeTester", "JobEntryAttributeTester", "JobEntryAttributeTester", "");
    StepPluginType.getInstance().registerCustom(TransStepAttributeTesterTransStep.class, "test", "StepAttributeTester", "StepAttributeTester", "StepAttributeTester", "");
    repositoryMeta = new PurRepositoryMeta();
    repositoryMeta.setName("JackRabbit");
    repositoryMeta.setDescription("JackRabbit test repository");
    userInfo = new UserInfo(EXP_LOGIN, "password", EXP_USERNAME, "Apache Tomcat user", true);
    repository = new PurRepository();
    repository.init(repositoryMeta);
    login(sysAdminUserName, systemTenant, new String[] { singleTenantAdminRoleName, tenantAuthenticatedRoleName });
    ITenant tenantAcme = tenantManager.createTenant(systemTenant, EXP_TENANT, singleTenantAdminRoleName, tenantAuthenticatedRoleName, "Anonymous");
    userRoleDao.createUser(tenantAcme, EXP_LOGIN, "password", "", new String[] { singleTenantAdminRoleName });
    logout();
    setUpUser();
    PurRepository purRep = (PurRepository) repository;
    final PurRepositoryConnector purRepositoryConnector = new PurRepositoryConnector(purRep, (PurRepositoryMeta) repositoryMeta, purRep.getRootRef());
    purRep.setPurRepositoryConnector(purRepositoryConnector);
    purRep.setTest(repo);
    repository.connect(EXP_LOGIN, "password");
    login(EXP_LOGIN, tenantAcme, new String[] { singleTenantAdminRoleName, tenantAuthenticatedRoleName });
    System.out.println("PUR NAME!!!: " + repo.getClass().getCanonicalName());
    RepositoryFile repositoryFile = repo.getFile(ClientRepositoryPaths.getPublicFolderPath());
    Serializable repositoryFileId = repositoryFile.getId();
    List<RepositoryFile> files = repo.getChildren(repositoryFileId);
    StringBuilder buf = new StringBuilder();
    for (RepositoryFile file : files) {
        buf.append("\n").append(file);
    }
    assertTrue("files not deleted: " + buf, files.isEmpty());
}
Also used : Serializable(java.io.Serializable) PurRepository(org.pentaho.di.repository.pur.PurRepository) PurRepositoryMeta(org.pentaho.di.repository.pur.PurRepositoryMeta) PurRepositoryConnector(org.pentaho.di.repository.pur.PurRepositoryConnector) UserInfo(org.pentaho.di.repository.UserInfo) TestContextManager(org.springframework.test.context.TestContextManager) ITenant(org.pentaho.platform.api.mt.ITenant) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) RepositoryFileProxyFactory(org.pentaho.platform.repository2.unified.jcr.RepositoryFileProxyFactory) Before(org.junit.Before)

Example 4 with PurRepositoryMeta

use of org.pentaho.di.repository.pur.PurRepositoryMeta in project pentaho-kettle by pentaho.

the class RepositoryPerformanceApp method startupRepository.

protected void startupRepository() throws Exception {
    // PentahoLicenseVerifier.setStreamOpener(new TestLicenseStream("pdi-ee=true")); //$NON-NLS-1$
    KettleEnvironment.init();
    repositoryMeta = new PurRepositoryMeta();
    repositoryMeta.setName("JackRabbit");
    repositoryMeta.setDescription("JackRabbit test repository");
    ((PurRepositoryMeta) repositoryMeta).setRepositoryLocation(new PurRepositoryLocation(repositoryLocation));
    userInfo = new UserInfo(EXP_LOGIN, "password", EXP_USERNAME, "Apache Tomcat user", true);
    repository = new PurRepository();
    repository.init(repositoryMeta);
    repository.connect(EXP_LOGIN, "password");
}
Also used : PurRepository(org.pentaho.di.repository.pur.PurRepository) PurRepositoryMeta(org.pentaho.di.repository.pur.PurRepositoryMeta) PurRepositoryLocation(org.pentaho.di.repository.pur.PurRepositoryLocation)

Example 5 with PurRepositoryMeta

use of org.pentaho.di.repository.pur.PurRepositoryMeta in project pentaho-kettle by pentaho.

the class RepositoryConfigController method initializeModel.

private void initializeModel() {
    PurRepositoryMeta purRepositoryMeta = null;
    if (repositoryMeta != null && repositoryMeta instanceof PurRepositoryMeta) {
        purRepositoryMeta = (PurRepositoryMeta) repositoryMeta;
        model.setName(purRepositoryMeta.getName());
        model.setId(purRepositoryMeta.getDescription());
        PurRepositoryLocation location = purRepositoryMeta.getRepositoryLocation();
        if (location != null) {
            model.setUrl(location.getUrl());
        } else {
            model.setUrl(getDefaultUrl());
        }
    } else {
        model.setModificationComments(true);
    }
}
Also used : PurRepositoryMeta(org.pentaho.di.repository.pur.PurRepositoryMeta) PurRepositoryLocation(org.pentaho.di.repository.pur.PurRepositoryLocation)

Aggregations

PurRepositoryMeta (org.pentaho.di.repository.pur.PurRepositoryMeta)7 PurRepository (org.pentaho.di.repository.pur.PurRepository)3 PurRepositoryLocation (org.pentaho.di.repository.pur.PurRepositoryLocation)3 Before (org.junit.Before)2 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)2 Serializable (java.io.Serializable)1 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 Test (org.junit.Test)1 ObjectId (org.pentaho.di.repository.ObjectId)1 Repository (org.pentaho.di.repository.Repository)1 UserInfo (org.pentaho.di.repository.UserInfo)1 PurRepositoryConnector (org.pentaho.di.repository.pur.PurRepositoryConnector)1 UIEETransformation (org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIEETransformation)1 ILockService (org.pentaho.di.ui.repository.pur.services.ILockService)1 UIRepositoryObject (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject)1 ITenant (org.pentaho.platform.api.mt.ITenant)1 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)1