use of org.pentaho.platform.api.engine.IUserRoleListService in project pentaho-platform by pentaho.
the class CachingUserRoleListServiceDecoratorTest method testGetAllRoles.
@Test
public void testGetAllRoles() throws Exception {
IUserRoleListService mockService = mock(IUserRoleListService.class);
when(mockService.getAllRoles()).thenReturn(Arrays.asList("foo", "bar"));
CachingUserRoleListServiceDecorator decorator = new CachingUserRoleListServiceDecorator(mockService);
List<String> allRoles = decorator.getAllRoles();
assertArrayEquals("does not match", new String[] { "foo", "bar" }, allRoles.toArray());
// second call should be from cache
allRoles = decorator.getAllRoles();
assertArrayEquals("does not match", new String[] { "foo", "bar" }, allRoles.toArray());
verify(mockService, times(1)).getAllRoles();
}
use of org.pentaho.platform.api.engine.IUserRoleListService in project pentaho-platform by pentaho.
the class CachingUserRoleListServiceDecoratorTest method testGetUsersInRole.
@Test
public void testGetUsersInRole() throws Exception {
IUserRoleListService mockService = mock(IUserRoleListService.class);
when(mockService.getUsersInRole(tenant, "ceo")).thenReturn(Arrays.asList("foo", "bar"));
CachingUserRoleListServiceDecorator decorator = new CachingUserRoleListServiceDecorator(mockService);
List<String> allRoles = decorator.getUsersInRole(tenant, "ceo");
assertArrayEquals("does not match", new String[] { "foo", "bar" }, allRoles.toArray());
// second call should be from cache
allRoles = decorator.getUsersInRole(tenant, "ceo");
assertArrayEquals("does not match", new String[] { "foo", "bar" }, allRoles.toArray());
verify(mockService, times(1)).getUsersInRole(tenant, "ceo");
}
Aggregations