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);
}
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);
}
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());
}
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");
}
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);
}
}
Aggregations