use of org.pentaho.platform.api.mt.ITenant in project pentaho-platform by pentaho.
the class DefaultUnifiedRepositoryContentIT method testGetReferrers.
@Test
public void testGetReferrers() throws Exception {
loginAsSysTenantAdmin();
ITenant tenantAcme = tenantManager.createTenant(systemTenant, TENANT_ID_ACME, tenantAdminRoleName, tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME);
userRoleDao.createUser(tenantAcme, USERNAME_ADMIN, PASSWORD, "", new String[] { tenantAdminRoleName });
login(USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName });
userRoleDao.createUser(tenantAcme, USERNAME_SUZY, PASSWORD, "", null);
login(USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName });
final String refereeFileName = "referee.sample";
final String referrerFileName = "referrer.sample";
final String parentFolderPath = ClientRepositoryPaths.getUserHomeFolderPath(USERNAME_SUZY);
RepositoryFile parentFolder = repo.getFile(parentFolderPath);
RepositoryFile refereeFile = createSampleFile(parentFolderPath, refereeFileName, "dfdd", true, 83);
DataNode node = new DataNode("kdjd");
node.setProperty("ddf", "ljsdfkjsdkf");
DataNode newChild1 = node.addNode("herfkmdx");
newChild1.setProperty("urei2", new DataNodeRef(refereeFile.getId()));
NodeRepositoryFileData data = new NodeRepositoryFileData(node);
repo.createFile(parentFolder.getId(), new RepositoryFile.Builder(referrerFileName).build(), data, null);
List<RepositoryFile> referrers = repo.getReferrers(refereeFile.getId());
assertNotNull(referrers);
assertEquals(1, referrers.size());
assertEquals(referrers.get(0).getName(), referrerFileName);
}
use of org.pentaho.platform.api.mt.ITenant in project pentaho-platform by pentaho.
the class DefaultUnifiedRepositoryContentIT method testTransactionRollback.
/**
* Create a versioned file then update it with invalid data and the checkout that we did before setting the data
* should be rolled back.
*/
@Test
public void testTransactionRollback() throws Exception {
loginAsSysTenantAdmin();
ITenant tenantAcme = tenantManager.createTenant(systemTenant, TENANT_ID_ACME, tenantAdminRoleName, tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME);
userRoleDao.createUser(tenantAcme, USERNAME_ADMIN, PASSWORD, "", new String[] { tenantAdminRoleName });
login(USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName });
userRoleDao.createUser(tenantAcme, USERNAME_SUZY, PASSWORD, "", null);
login(USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName });
final String expectedName = "helloworld.sample";
final String sampleString = "Ciao World!";
final boolean sampleBoolean = true;
final int sampleInteger = 99;
final String parentFolderPath = ClientRepositoryPaths.getUserHomeFolderPath(USERNAME_SUZY);
final String expectedAbsolutePath = ServerRepositoryPaths.getTenantRootFolderPath() + parentFolderPath + RepositoryFile.SEPARATOR + expectedName;
RepositoryFile newFile = createSampleFile(parentFolderPath, expectedName, sampleString, sampleBoolean, sampleInteger, true);
assertNotNull(SimpleJcrTestUtils.getItem(testJcrTemplate, expectedAbsolutePath));
try {
repo.updateFile(newFile, new IRepositoryFileData() {
@Override
public long getDataSize() {
return 0;
}
}, null);
fail("expected UnifiedRepositoryException");
} catch (UnifiedRepositoryException e) {
// ignore
}
assertFalse(SimpleJcrTestUtils.isCheckedOut(testJcrTemplate, expectedAbsolutePath));
}
use of org.pentaho.platform.api.mt.ITenant in project pentaho-platform by pentaho.
the class DefaultUnifiedRepositoryContentIT method testWeird1.
/**
* This test exists to prove that the server wasn't the source of a problem. I'm leaving it in.
*/
@Test
public void testWeird1() throws Exception {
loginAsSysTenantAdmin();
ITenant tenantAcme = tenantManager.createTenant(systemTenant, TENANT_ID_ACME, tenantAdminRoleName, tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME);
userRoleDao.createUser(tenantAcme, USERNAME_ADMIN, PASSWORD, "", new String[] { tenantAdminRoleName });
login(USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName });
userRoleDao.createUser(tenantAcme, USERNAME_SUZY, PASSWORD, "", null);
login(USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName });
RepositoryFile parentFolder = repo.getFile(ClientRepositoryPaths.getUserHomeFolderPath(USERNAME_SUZY));
RepositoryFile newFolder = new RepositoryFile.Builder("test").folder(true).build();
RepositoryFile testFolder = repo.createFolder(parentFolder.getId(), newFolder, null);
final String fileName = "helloworld.sample";
RepositoryFile newFile = createSampleFile(testFolder.getPath(), fileName, "dfdfd", true, 3);
assertNotNull(repo.getFile(testFolder.getPath()));
assertNotNull(repo.getFile(newFile.getPath()));
repo.deleteFile(testFolder.getId(), null);
// make sure it's gone
assertNull(repo.getFile(testFolder.getPath()));
RepositoryFile testFolder2 = repo.createFolder(parentFolder.getId(), newFolder, null);
// make sure ID is different for new folder
assertFalse(testFolder.getId().equals(testFolder2.getId()));
assertNotNull(repo.getFile(testFolder2.getPath()));
assertNull(repo.getFile(newFile.getPath()));
}
use of org.pentaho.platform.api.mt.ITenant in project pentaho-platform by pentaho.
the class DefaultUnifiedRepositoryContentIT method testUpdateFile.
@Test
public void testUpdateFile() throws Exception {
loginAsSysTenantAdmin();
ITenant tenantAcme = tenantManager.createTenant(systemTenant, TENANT_ID_ACME, tenantAdminRoleName, tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME);
userRoleDao.createUser(tenantAcme, USERNAME_ADMIN, PASSWORD, "", new String[] { tenantAdminRoleName });
login(USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName });
userRoleDao.createUser(tenantAcme, USERNAME_SUZY, PASSWORD, "", null);
login(USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName });
final String parentFolderPath = ClientRepositoryPaths.getUserHomeFolderPath(USERNAME_SUZY);
final String fileName = "helloworld.sample";
RepositoryFile newFile = createSampleFile(parentFolderPath, fileName, "Hello World!", false, 222);
final String modSampleString = "Ciao World!";
final boolean modSampleBoolean = true;
final int modSampleInteger = 99;
final SampleRepositoryFileData modContent = new SampleRepositoryFileData(modSampleString, modSampleBoolean, modSampleInteger);
repo.updateFile(newFile, modContent, null);
SampleRepositoryFileData modData = repo.getDataForRead(repo.getFile(ClientRepositoryPaths.getUserHomeFolderPath(USERNAME_SUZY) + RepositoryFile.SEPARATOR + fileName).getId(), SampleRepositoryFileData.class);
assertEquals(modSampleString, modData.getSampleString());
assertEquals(modSampleBoolean, modData.getSampleBoolean());
assertEquals(modSampleInteger, modData.getSampleInteger());
}
use of org.pentaho.platform.api.mt.ITenant in project pentaho-platform by pentaho.
the class DefaultUnifiedRepositoryContentIT method testCreateShadowFolder.
@Test
public void testCreateShadowFolder() throws Exception {
loginAsSysTenantAdmin();
ITenant tenantAcme = tenantManager.createTenant(systemTenant, TENANT_ID_ACME, tenantAdminRoleName, tenantAuthenticatedRoleName, ANONYMOUS_ROLE_NAME);
userRoleDao.createUser(tenantAcme, USERNAME_ADMIN, PASSWORD, "", new String[] { tenantAdminRoleName });
login(USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName });
userRoleDao.createUser(tenantAcme, USERNAME_SUZY, PASSWORD, "", null);
login(USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName });
RepositoryFile parentFolder = repo.getFile(ClientRepositoryPaths.getUserHomeFolderPath(USERNAME_SUZY));
RepositoryFile newFolder = new RepositoryFile.Builder("test").folder(true).aclNode(true).build();
Date beginTime = Calendar.getInstance().getTime();
// Sleep for 1 second for time comparison
Thread.sleep(1000);
newFolder = repo.createFolder(parentFolder.getId(), newFolder, null);
Thread.sleep(1000);
Date endTime = Calendar.getInstance().getTime();
assertTrue(beginTime.before(newFolder.getCreatedDate()));
assertTrue(endTime.after(newFolder.getCreatedDate()));
assertNotNull(newFolder);
assertNotNull(newFolder.getId());
assertTrue(newFolder.isAclNode());
assertNotNull(SimpleJcrTestUtils.getItem(testJcrTemplate, ServerRepositoryPaths.getUserHomeFolderPath(tenantAcme, USERNAME_SUZY) + "/test"));
}
Aggregations