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