Search in sources :

Example 6 with Hierarchy

use of mondrian.olap.Hierarchy in project mondrian by pentaho.

the class RestrictedMemberReaderTest method testDefaultMember_allAccess.

public void testDefaultMember_allAccess() {
    Schema schema = Mockito.mock(Schema.class);
    Dimension dimension = Mockito.mock(Dimension.class);
    RolapHierarchy hierarchy = Mockito.mock(RolapHierarchy.class);
    Level[] hierarchyAccessLevels = new Level[] { null };
    MemberReader delegateMemberReader = Mockito.mock(MemberReader.class);
    HierarchyAccess roleAccess = null;
    Role role = Mockito.mock(Role.class);
    Mockito.doReturn(schema).when(dimension).getSchema();
    Mockito.doReturn(dimension).when(hierarchy).getDimension();
    Mockito.doReturn(hierarchyAccessLevels).when(hierarchy).getLevels();
    Mockito.doReturn(true).when(hierarchy).isRagged();
    Mockito.doReturn(roleAccess).when(role).getAccessDetails(Mockito.any(Hierarchy.class));
    Mockito.doReturn(hierarchy).when(delegateMemberReader).getHierarchy();
    RolapMember hDefaultMember = mockMember();
    Mockito.doReturn(hDefaultMember).when(hierarchy).getDefaultMember();
    rmr = new RestrictedMemberReader(delegateMemberReader, role);
    Assert.assertSame(hDefaultMember, rmr.getDefaultMember());
}
Also used : Role(mondrian.olap.Role) Hierarchy(mondrian.olap.Hierarchy) Schema(mondrian.olap.Schema) Level(mondrian.olap.Level) Dimension(mondrian.olap.Dimension) HierarchyAccess(mondrian.olap.Role.HierarchyAccess)

Example 7 with Hierarchy

use of mondrian.olap.Hierarchy in project mondrian by pentaho.

the class RestrictedMemberReaderTest method testGetHierarchy_roleAccess.

public void testGetHierarchy_roleAccess() {
    RolapHierarchy hierarchy = Mockito.mock(RolapHierarchy.class);
    MemberReader delegateMemberReader = Mockito.mock(MemberReader.class);
    HierarchyAccess roleAccess = Mockito.mock(HierarchyAccess.class);
    Role role = Mockito.mock(Role.class);
    Mockito.doReturn(roleAccess).when(role).getAccessDetails(Mockito.any(Hierarchy.class));
    Mockito.doReturn(hierarchy).when(delegateMemberReader).getHierarchy();
    rmr = new RestrictedMemberReader(delegateMemberReader, role);
    Assert.assertSame(hierarchy, rmr.getHierarchy());
}
Also used : Role(mondrian.olap.Role) Hierarchy(mondrian.olap.Hierarchy) HierarchyAccess(mondrian.olap.Role.HierarchyAccess)

Example 8 with Hierarchy

use of mondrian.olap.Hierarchy in project mondrian by pentaho.

the class RolapCubeDimensionTest method stubRolapCubeDimension.

private RolapCubeDimension stubRolapCubeDimension(boolean virtualCube) {
    RolapCube cube = mock(RolapCube.class);
    doReturn(virtualCube).when(cube).isVirtual();
    RolapDimension rolapDim = mock(RolapDimension.class);
    Hierarchy[] rolapDim_hierarchies = new Hierarchy[] {};
    doReturn(rolapDim_hierarchies).when(rolapDim).getHierarchies();
    MondrianDef.CubeDimension cubeDim = new MondrianDef.Dimension();
    cubeDim.caption = "StubCubeDimCaption";
    cubeDim.description = "StubCubeDimDescription";
    cubeDim.visible = true;
    String name = "StubCubeName";
    int cubeOrdinal = 0;
    List<RolapHierarchy> hierarchyList = null;
    final boolean highCardinality = false;
    return new RolapCubeDimension(cube, rolapDim, cubeDim, name, cubeOrdinal, hierarchyList, highCardinality);
}
Also used : Mockito.anyString(org.mockito.Mockito.anyString) Hierarchy(mondrian.olap.Hierarchy) MondrianDef(mondrian.olap.MondrianDef)

Example 9 with Hierarchy

use of mondrian.olap.Hierarchy in project mondrian by pentaho.

the class RolapCubeHierarchyTest method testInit_FactCube_FactTableEquals.

public void testInit_FactCube_FactTableEquals() {
    RolapCubeDimension cubeDimension = mock(RolapCubeDimension.class);
    RolapCube cubeDimension_cube = mock(RolapCube.class);
    boolean cubeDimension_cube_isVirtual = true;
    String cubeDimension_uniqueName = "TheDimUniqueName";
    RolapSchema cubeDimension_schema = mock(RolapSchema.class);
    RolapConnection cubeDimension_schema_connection = mock(RolapConnection.class);
    DataSource cubeDimension_schema_connection_DS = mock(DataSource.class);
    MondrianDef.CubeDimension cubeDim = null;
    RolapHierarchy rolapHierarchy = mock(RolapHierarchy.class);
    Hierarchy rolapHierarchy_hierarchy = null;
    String rolapHierarchy_uniqueName = "TheDimUniqueName";
    Level[] rolapHierarchy_levels = new Level[] {};
    RelationOrJoin rolapHierarchy_relation = mock(Relation.class);
    String subName = null;
    int ordinal = 0;
    RolapCube factCube = mock(RolapCube.class);
    RelationOrJoin factCube_Fact = rolapHierarchy_relation;
    boolean factCube_Fact_equals = true;
    // check
    assertEquals(factCube_Fact_equals, factCube_Fact.equals(rolapHierarchy_relation));
    assertEquals(factCube_Fact_equals, rolapHierarchy_relation.equals(factCube_Fact));
    doReturn(cubeDimension_cube).when(cubeDimension).getCube();
    doReturn(cubeDimension_cube_isVirtual).when(cubeDimension_cube).isVirtual();
    doReturn(cubeDimension_schema).when(cubeDimension).getSchema();
    doReturn(cubeDimension_schema_connection).when(cubeDimension_schema).getInternalConnection();
    doReturn(cubeDimension_schema_connection_DS).when(cubeDimension_schema_connection).getDataSource();
    doReturn(cubeDimension_uniqueName).when(cubeDimension).getUniqueName();
    doReturn(rolapHierarchy_hierarchy).when(rolapHierarchy).getHierarchy();
    doReturn(rolapHierarchy_levels).when(rolapHierarchy).getLevels();
    doReturn(rolapHierarchy_uniqueName).when(rolapHierarchy).getUniqueName();
    doReturn(rolapHierarchy_relation).when(rolapHierarchy).getRelation();
    doReturn(factCube_Fact).when(factCube).getFact();
    RolapCubeHierarchy rch = new RolapCubeHierarchy(cubeDimension, cubeDim, rolapHierarchy, subName, ordinal, factCube);
    assertEquals(true, rch.isUsingCubeFact());
}
Also used : DataSource(javax.sql.DataSource) Hierarchy(mondrian.olap.Hierarchy) MondrianDef(mondrian.olap.MondrianDef) Level(mondrian.olap.Level) RelationOrJoin(mondrian.olap.MondrianDef.RelationOrJoin)

Example 10 with Hierarchy

use of mondrian.olap.Hierarchy in project pentaho-platform by pentaho.

the class MDXMetaDataTest method mockHierarchy.

private Hierarchy mockHierarchy(String name, String caption) {
    String hierarchyCaption = HIERARCHY_NAME + caption;
    String hierarchyName = HIERARCHY_NAME + name;
    Hierarchy hierarchy = mock(Hierarchy.class);
    when(hierarchy.getCaption()).thenReturn(hierarchyCaption);
    when(hierarchy.getName()).thenReturn(hierarchyName);
    return hierarchy;
}
Also used : Hierarchy(mondrian.olap.Hierarchy)

Aggregations

Hierarchy (mondrian.olap.Hierarchy)27 Level (mondrian.olap.Level)9 Member (mondrian.olap.Member)8 Role (mondrian.olap.Role)8 HierarchyAccess (mondrian.olap.Role.HierarchyAccess)7 MultiCardinalityDefaultMember (mondrian.rolap.RestrictedMemberReader.MultiCardinalityDefaultMember)6 MondrianDef (mondrian.olap.MondrianDef)5 DataSource (javax.sql.DataSource)4 Dimension (mondrian.olap.Dimension)4 mondrian.olap (mondrian.olap)3 Schema (mondrian.olap.Schema)3 RolapCube (mondrian.rolap.RolapCube)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 LinkedHashMap (java.util.LinkedHashMap)2 Axis (mondrian.olap.Axis)2 RelationOrJoin (mondrian.olap.MondrianDef.RelationOrJoin)2 LimitedRollupMember (mondrian.rolap.RolapHierarchy.LimitedRollupMember)2 Level (org.apache.log4j.Level)2