Search in sources :

Example 1 with Role

use of mondrian.olap.Role 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());
}
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 2 with Role

use of mondrian.olap.Role 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 3 with Role

use of mondrian.olap.Role 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 4 with Role

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

the class RestrictedMemberReaderTest method testDefaultMember_noDefaultMember_roleAccess.

public void testDefaultMember_noDefaultMember_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);
    RolapMember member0 = mockMember();
    List<RolapMember> rootMembers = Arrays.asList(new RolapMember[] { member0 });
    RolapMember hierDefaultMember = null;
    Mockito.doReturn(roleAccess).when(role).getAccessDetails(Mockito.any(Hierarchy.class));
    Mockito.doReturn(hierarchy).when(delegateMemberReader).getHierarchy();
    Mockito.doReturn(hierDefaultMember).when(hierarchy).getDefaultMember();
    rmr = Mockito.spy(new RestrictedMemberReader(delegateMemberReader, role));
    Mockito.doReturn(rootMembers).when(rmr).getRootMembers();
    Mockito.doReturn(null).when(roleAccess).getAccess(anyRolapMember());
    Assert.assertSame("on Access is null", member0, rmr.getDefaultMember());
    Mockito.doReturn(Access.ALL).when(roleAccess).getAccess(anyRolapMember());
    Assert.assertSame("on Access.ALL", member0, rmr.getDefaultMember());
    Mockito.doReturn(Access.CUSTOM).when(roleAccess).getAccess(anyRolapMember());
    Assert.assertSame("on Access.CUSTOM", member0, rmr.getDefaultMember());
    Mockito.doReturn(Access.NONE).when(roleAccess).getAccess(anyRolapMember());
    Assert.assertNotSame("on Access.NONE", member0, rmr.getDefaultMember());
    Assert.assertTrue(rmr.getDefaultMember() instanceof MultiCardinalityDefaultMember);
}
Also used : Role(mondrian.olap.Role) Hierarchy(mondrian.olap.Hierarchy) MultiCardinalityDefaultMember(mondrian.rolap.RestrictedMemberReader.MultiCardinalityDefaultMember) HierarchyAccess(mondrian.olap.Role.HierarchyAccess)

Example 5 with Role

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

the class RestrictedMemberReaderTest method testDefaultMember_roleAccess.

public void testDefaultMember_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);
    RolapMember member0 = mockMember();
    List<RolapMember> rootMembers = Arrays.asList(new RolapMember[] { member0 });
    RolapMember hierDefaultMember = member0;
    Mockito.doReturn(roleAccess).when(role).getAccessDetails(Mockito.any(Hierarchy.class));
    Mockito.doReturn(hierarchy).when(delegateMemberReader).getHierarchy();
    Mockito.doReturn(hierDefaultMember).when(hierarchy).getDefaultMember();
    rmr = Mockito.spy(new RestrictedMemberReader(delegateMemberReader, role));
    Mockito.doReturn(rootMembers).when(rmr).getRootMembers();
    Mockito.doReturn(null).when(roleAccess).getAccess(anyRolapMember());
    Assert.assertSame("on Access is null", hierDefaultMember, rmr.getDefaultMember());
    Mockito.doReturn(Access.ALL).when(roleAccess).getAccess(anyRolapMember());
    Assert.assertSame("on Access.ALL", hierDefaultMember, rmr.getDefaultMember());
    Mockito.doReturn(Access.CUSTOM).when(roleAccess).getAccess(anyRolapMember());
    Assert.assertSame("on Access.CUSTOM", hierDefaultMember, rmr.getDefaultMember());
    Mockito.doReturn(Access.NONE).when(roleAccess).getAccess(anyRolapMember());
    Assert.assertNotSame("on Access.NONE", hierDefaultMember, rmr.getDefaultMember());
    Assert.assertTrue(rmr.getDefaultMember() instanceof MultiCardinalityDefaultMember);
}
Also used : Role(mondrian.olap.Role) Hierarchy(mondrian.olap.Hierarchy) MultiCardinalityDefaultMember(mondrian.rolap.RestrictedMemberReader.MultiCardinalityDefaultMember) HierarchyAccess(mondrian.olap.Role.HierarchyAccess)

Aggregations

Role (mondrian.olap.Role)9 Hierarchy (mondrian.olap.Hierarchy)8 HierarchyAccess (mondrian.olap.Role.HierarchyAccess)7 MultiCardinalityDefaultMember (mondrian.rolap.RestrictedMemberReader.MultiCardinalityDefaultMember)5 Level (mondrian.olap.Level)3 Dimension (mondrian.olap.Dimension)2 Schema (mondrian.olap.Schema)2 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 TupleList (mondrian.calc.TupleList)1 Member (mondrian.olap.Member)1 LimitedRollupMember (mondrian.rolap.RolapHierarchy.LimitedRollupMember)1 FilteredIterableList (mondrian.util.FilteredIterableList)1