Search in sources :

Example 6 with RoleListWrapper

use of org.pentaho.platform.web.http.api.resources.RoleListWrapper in project pentaho-platform by pentaho.

the class UserRoleListServiceTest method testDoGetAllRoles.

@Test
public void testDoGetAllRoles() {
    List<String> roles = new ArrayList<String>();
    roles.add("ROLE1");
    roles.add("ROLE2");
    List<String> extraRoles = new ArrayList<String>();
    extraRoles.add("ROLE3");
    extraRoles.add("ROLE4");
    IUserRoleListService userRoleListService1 = mock(IUserRoleListService.class);
    doReturn(userRoleListService1).when(userRoleListService).getUserRoleListService();
    doReturn(roles).when(userRoleListService1).getAllRoles();
    doReturn(extraRoles).when(userRoleListService).getExtraRoles();
    RoleListWrapper roleListWrapper = userRoleListService.getAllRoles();
    verify(userRoleListService).getUserRoleListService();
    verify(userRoleListService1).getAllRoles();
    verify(userRoleListService).getExtraRoles();
    assertEquals(4, roleListWrapper.getRoles().size());
}
Also used : RoleListWrapper(org.pentaho.platform.web.http.api.resources.RoleListWrapper) ArrayList(java.util.ArrayList) IUserRoleListService(org.pentaho.platform.api.engine.IUserRoleListService) Test(org.junit.Test)

Example 7 with RoleListWrapper

use of org.pentaho.platform.web.http.api.resources.RoleListWrapper in project pentaho-platform by pentaho.

the class UserRoleListServiceTest method testDoGetExtraRolesList.

@Test
public void testDoGetExtraRolesList() {
    List<String> extraRoles = new ArrayList<String>();
    extraRoles.add("ROLE1");
    extraRoles.add("ROLE2");
    extraRoles.add("ROLE3");
    extraRoles.add("ROLE4");
    doReturn(extraRoles).when(userRoleListService).getExtraRoles();
    RoleListWrapper roleListWrapper = userRoleListService.getExtraRolesList();
    verify(userRoleListService).getExtraRoles();
    assertEquals(4, roleListWrapper.getRoles().size());
    assertEquals(extraRoles, roleListWrapper.getRoles());
}
Also used : RoleListWrapper(org.pentaho.platform.web.http.api.resources.RoleListWrapper) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

RoleListWrapper (org.pentaho.platform.web.http.api.resources.RoleListWrapper)7 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)6 IUserRoleListService (org.pentaho.platform.api.engine.IUserRoleListService)4 IPentahoRole (org.pentaho.platform.api.engine.security.userroledao.IPentahoRole)2 IUserRoleDao (org.pentaho.platform.api.engine.security.userroledao.IUserRoleDao)2 Matchers.anyString (org.mockito.Matchers.anyString)1 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)1 ITenant (org.pentaho.platform.api.mt.ITenant)1