Search in sources :

Example 36 with IUserRoleListService

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();
}
Also used : IUserRoleListService(org.pentaho.platform.api.engine.IUserRoleListService) Test(org.junit.Test)

Example 37 with IUserRoleListService

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");
}
Also used : IUserRoleListService(org.pentaho.platform.api.engine.IUserRoleListService) Test(org.junit.Test)

Aggregations

IUserRoleListService (org.pentaho.platform.api.engine.IUserRoleListService)37 Test (org.junit.Test)20 ArrayList (java.util.ArrayList)8 IAuthorizationPolicy (org.pentaho.platform.api.engine.IAuthorizationPolicy)7 ITenant (org.pentaho.platform.api.mt.ITenant)6 List (java.util.List)4 Document (org.dom4j.Document)4 Element (org.dom4j.Element)4 DefaultElement (org.dom4j.tree.DefaultElement)4 Before (org.junit.Before)4 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)4 RoleListWrapper (org.pentaho.platform.web.http.api.resources.RoleListWrapper)4 MicroPlatform (org.pentaho.test.platform.engine.core.MicroPlatform)4 File (java.io.File)3 IPentahoObjectFactory (org.pentaho.platform.api.engine.IPentahoObjectFactory)3 IPluginResourceLoader (org.pentaho.platform.api.engine.IPluginResourceLoader)3 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)3 SystemSettings (org.pentaho.platform.engine.core.system.SystemSettings)3 PluginClassLoader (org.pentaho.platform.plugin.services.pluginmgr.PluginClassLoader)3 PluginResourceLoader (org.pentaho.platform.plugin.services.pluginmgr.PluginResourceLoader)3