Search in sources :

Example 1 with MondrianCatalogHelper

use of org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalogHelper in project pentaho-platform by pentaho.

the class UserRoleMapperIT method testReadRolesInSchema.

@Test
public void testReadRolesInSchema() throws Exception {
    final MondrianCatalogHelper helper = (MondrianCatalogHelper) PentahoSystem.get(IMondrianCatalogService.class);
    Assert.assertNotNull(helper);
    MondrianCatalog mc = SecurityHelper.getInstance().runAsUser("admin", new Callable<MondrianCatalog>() {

        @Override
        public MondrianCatalog call() throws Exception {
            return helper.getCatalog("SteelWheelsRoles", PentahoSessionHolder.getSession());
        }
    });
    Assert.assertNotNull(mc);
    MondrianSchema ms = mc.getSchema();
    Assert.assertNotNull(ms);
    String[] roleNames = ms.getRoleNames();
    Assert.assertNotNull(roleNames);
    Assert.assertEquals(2, roleNames.length);
    Assert.assertEquals("Role1", roleNames[0]);
    Assert.assertEquals("Role2", roleNames[1]);
}
Also used : MondrianCatalogHelper(org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalogHelper) MondrianCatalog(org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalog) MondrianSchema(org.pentaho.platform.plugin.action.mondrian.catalog.MondrianSchema) IMondrianCatalogService(org.pentaho.platform.plugin.action.mondrian.catalog.IMondrianCatalogService) UsernameNotFoundException(org.springframework.security.core.userdetails.UsernameNotFoundException) PentahoAccessControlException(org.pentaho.platform.api.engine.PentahoAccessControlException) PlatformInitializationException(org.pentaho.platform.engine.core.system.boot.PlatformInitializationException) DataAccessException(org.springframework.dao.DataAccessException) Test(org.junit.Test)

Example 2 with MondrianCatalogHelper

use of org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalogHelper in project pentaho-platform by pentaho.

the class UserRoleMapperIT method init0.

@Before
public void init0() {
    IAclNodeHelper aclHelper = mock(IAclNodeHelper.class);
    when(aclHelper.canAccess(any(RepositoryFile.class), any(EnumSet.class))).thenReturn(true);
    MondrianCatalogHelper catalogService = new MondrianCatalogHelper(aclHelper);
    microPlatform = new MicroPlatform(TestResourceLocation.TEST_RESOURCES + "/solution");
    microPlatform.define(ISolutionEngine.class, SolutionEngine.class);
    microPlatform.define(IUnifiedRepository.class, FileSystemBackedUnifiedRepository.class, Scope.GLOBAL);
    microPlatform.defineInstance(IMondrianCatalogService.class, catalogService);
    microPlatform.define("connection-SQL", SQLConnection.class);
    microPlatform.define("connection-MDX", MDXConnection.class);
    microPlatform.define(IDBDatasourceService.class, JndiDatasourceService.class, Scope.GLOBAL);
    microPlatform.define(IUserRoleListService.class, TestUserRoleListService.class, Scope.GLOBAL);
    microPlatform.define(UserDetailsService.class, TestUserDetailsService.class, Scope.GLOBAL);
    FileSystemBackedUnifiedRepository repo = (FileSystemBackedUnifiedRepository) PentahoSystem.get(IUnifiedRepository.class);
    repo.setRootDir(new File(TestResourceLocation.TEST_RESOURCES + "/solution"));
    try {
        microPlatform.start();
    } catch (PlatformInitializationException ex) {
        Assert.fail();
    }
    catalogService.setDataSourcesConfig("file:" + PentahoSystem.getApplicationContext().getSolutionPath("test/analysis/test-datasources.xml"));
    // JNDI
    System.setProperty("java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory");
    System.setProperty("org.osjava.sj.root", TestResourceLocation.TEST_RESOURCES + "/solution/system/simple-jndi");
    System.setProperty("org.osjava.sj.delimiter", "/");
}
Also used : MondrianCatalogHelper(org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalogHelper) IAclNodeHelper(org.pentaho.platform.api.repository2.unified.IAclNodeHelper) PlatformInitializationException(org.pentaho.platform.engine.core.system.boot.PlatformInitializationException) EnumSet(java.util.EnumSet) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) RepositoryFile(org.pentaho.platform.api.repository2.unified.RepositoryFile) File(java.io.File) FileSystemBackedUnifiedRepository(org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) Before(org.junit.Before)

Aggregations

PlatformInitializationException (org.pentaho.platform.engine.core.system.boot.PlatformInitializationException)2 MondrianCatalogHelper (org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalogHelper)2 File (java.io.File)1 EnumSet (java.util.EnumSet)1 Before (org.junit.Before)1 Test (org.junit.Test)1 PentahoAccessControlException (org.pentaho.platform.api.engine.PentahoAccessControlException)1 IAclNodeHelper (org.pentaho.platform.api.repository2.unified.IAclNodeHelper)1 IUnifiedRepository (org.pentaho.platform.api.repository2.unified.IUnifiedRepository)1 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)1 IMondrianCatalogService (org.pentaho.platform.plugin.action.mondrian.catalog.IMondrianCatalogService)1 MondrianCatalog (org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalog)1 MondrianSchema (org.pentaho.platform.plugin.action.mondrian.catalog.MondrianSchema)1 FileSystemBackedUnifiedRepository (org.pentaho.platform.repository2.unified.fs.FileSystemBackedUnifiedRepository)1 MicroPlatform (org.pentaho.test.platform.engine.core.MicroPlatform)1 DataAccessException (org.springframework.dao.DataAccessException)1 UsernameNotFoundException (org.springframework.security.core.userdetails.UsernameNotFoundException)1