use of org.pentaho.test.mock.MockPentahoUser in project pentaho-platform by pentaho.
the class UserRoleDaoResource_RolesUpdatedTest method rolesUpdated_WhenAssignAllUsersToRole_WithSessionUser.
@Test
public void rolesUpdated_WhenAssignAllUsersToRole_WithSessionUser() {
ITenant tenant = mock(ITenant.class);
doReturn(tenant).when(resource).getTenant(DEFAULT_STRING);
IPentahoUser sessionUser = new MockPentahoUser(tenant, SESSION_USER_NAME, DEFAULT_STRING, DEFAULT_STRING, true);
doReturn(Collections.singletonList(sessionUser)).when(userRoleDao).getUsers(tenant);
resource.assignAllUsersToRole(DEFAULT_STRING, ROLE_NAME_DEVELOPER);
verify(resource).updateRolesForCurrentSession();
}
use of org.pentaho.test.mock.MockPentahoUser in project pentaho-platform by pentaho.
the class UserRoleDaoResource_RolesUpdatedTest method rolesNotUpdated_WhenAssignAllUsersToRole_WithNoSessionUser.
@Test
public void rolesNotUpdated_WhenAssignAllUsersToRole_WithNoSessionUser() {
ITenant tenant = mock(ITenant.class);
doReturn(tenant).when(resource).getTenant(DEFAULT_STRING);
IPentahoUser nonSessionUser = new MockPentahoUser(tenant, NON_SESSION_USER_NAME, DEFAULT_STRING, DEFAULT_STRING, true);
doReturn(Collections.singletonList(nonSessionUser)).when(userRoleDao).getUsers(tenant);
resource.assignAllUsersToRole(DEFAULT_STRING, ROLE_NAME_DEVELOPER);
verify(resource, never()).updateRolesForCurrentSession();
}
use of org.pentaho.test.mock.MockPentahoUser in project pentaho-platform by pentaho.
the class UserRoleDaoResource_RolesUpdatedTest method rolesUpdated_WhenAssignAllUsersToRole_WithSessionAndNonSessionUser.
@Test
public void rolesUpdated_WhenAssignAllUsersToRole_WithSessionAndNonSessionUser() {
ITenant tenant = mock(ITenant.class);
doReturn(tenant).when(resource).getTenant(DEFAULT_STRING);
final IPentahoUser sessionUser = new MockPentahoUser(tenant, SESSION_USER_NAME, DEFAULT_STRING, DEFAULT_STRING, true);
final IPentahoUser nonSessionUser = new MockPentahoUser(tenant, NON_SESSION_USER_NAME, DEFAULT_STRING, DEFAULT_STRING, true);
List<IPentahoUser> users = Arrays.asList(sessionUser, nonSessionUser);
doReturn(users).when(userRoleDao).getUsers(tenant);
resource.assignAllUsersToRole(DEFAULT_STRING, ROLE_NAME_DEVELOPER);
verify(resource).updateRolesForCurrentSession();
}
Aggregations