use of mondrian.olap.Dimension in project mondrian by pentaho.
the class RestrictedMemberReaderTest method testGetHierarchy_allAccess.
public void testGetHierarchy_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();
rmr = new RestrictedMemberReader(delegateMemberReader, role);
Assert.assertSame(hierarchy, rmr.getHierarchy());
}
use of mondrian.olap.Dimension 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.Dimension in project pentaho-platform by pentaho.
the class MDXMetaDataTest method mockMember.
private Member mockMember(String caption, String name) {
Level level = mockLevel(name);
Dimension dimension = mockDimension(name);
Hierarchy hierarchy = mockHierarchy(name, caption);
Member member = mock(Member.class);
when(member.getCaption()).thenReturn(caption);
when(member.getHierarchy()).thenReturn(hierarchy);
when(member.getDimension()).thenReturn(dimension);
when(member.getLevel()).thenReturn(level);
return member;
}
use of mondrian.olap.Dimension in project mondrian by pentaho.
the class SqlMemberSourceTest method getStoreHierarchyMock.
// Mock for the Store hierarchy
private RolapHierarchy getStoreHierarchyMock() {
MondrianDef.Relation relationMock = mock(MondrianDef.Relation.class);
when(relationMock.getAlias()).thenReturn(STORE_TABLE);
Dimension dimMock = mock(Dimension.class);
when(dimMock.getDimensionType()).thenReturn(null);
SchemaKey sKeyMock = mock(SchemaKey.class);
RolapConnection rlConnectionMock = mock(RolapConnection.class);
RolapSchema rlSchema = new RolapSchema(sKeyMock, MD5_BYTE_STRING, rlConnectionMock);
RolapHierarchy rlHierarchyStoreMock = mock(RolapHierarchy.class);
when(rlConnectionMock.getDataSource()).thenReturn(dataSourceMock);
when(rlHierarchyStoreMock.getRolapSchema()).thenReturn(rlSchema);
when(rlHierarchyStoreMock.getUniqueName()).thenReturn("[Store]");
when(rlHierarchyStoreMock.getUniqueTable()).thenReturn(relationMock);
when(rlHierarchyStoreMock.getDimension()).thenReturn(dimMock);
when(rlHierarchyStoreMock.tableExists(STORE_TABLE)).thenReturn(true);
return rlHierarchyStoreMock;
}
use of mondrian.olap.Dimension in project mondrian by pentaho.
the class SqlConstraintUtils method hasMultipleLevelSlicer.
public static boolean hasMultipleLevelSlicer(Evaluator evaluator) {
Map<Dimension, Level> levels = new HashMap<Dimension, Level>();
List<Member> slicerMembers = expandSupportedCalculatedMembers(((RolapEvaluator) evaluator).getSlicerMembers(), evaluator).getMembers();
for (Member member : slicerMembers) {
if (member.isAll()) {
continue;
}
Level before = levels.put(member.getDimension(), member.getLevel());
if (before != null && !before.equals(member.getLevel())) {
return true;
}
}
return false;
}
Aggregations