@Test
public void testSetRoles() throws UserRoleException {
UserRoleDaoMock userRoleDao = PentahoSystem.get( UserRoleDaoMock.class, USER_ROLE_DAO_TXN, null );
IUserRoleWebService service = getUserRoleWebService();
ProxyPentahoUser userObj = new ProxyPentahoUser();
userObj.setName( "test1" );
ProxyPentahoRole[] rolesObj = new ProxyPentahoRole[1];
rolesObj[0] = new ProxyPentahoRole( "testRole2" );
try {
service.setRoles( userObj, rolesObj );
Assert.fail();
} catch ( UserRoleException e ) {
Assert.assertTrue( "ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf( "ERROR_0001" ) >= 0 );
}
isAdmin = true;
userRoleDao.getUserRoles( null, "test1" );
Assert.assertEquals( "testRole1", userRoleDao.getUserRoles( null, "test1" ).get( 0 ).getName() );
service.setRoles( userObj, rolesObj );
Assert.assertEquals( "testRole2", userRoleDao.getUserRoles( null, "test1" ).get( 0 ).getName() );
}