use of org.pentaho.platform.security.userroledao.ws.ProxyPentahoRole in project pentaho-platform by pentaho.
the class UserRoleWebServiceBase method testCreateRole.
@Test
public void testCreateRole() throws Exception {
UserRoleDaoMock userRoleDao = PentahoSystem.get(UserRoleDaoMock.class, USER_ROLE_DAO_TXN, null);
IUserRoleWebService service = getUserRoleWebService();
mockUserAsAdmin(false);
ProxyPentahoRole role = new ProxyPentahoRole("role");
role.setDescription("testing");
try {
service.createRole(role);
Assert.fail();
} catch (UserRoleException e) {
Assert.assertTrue("ERROR_0001 not found in " + e.getMessage(), e.getMessage().indexOf("ERROR_0001") >= 0);
}
mockUserAsAdmin(true);
service.createRole(role);
// the last role should have the same name and description
IPentahoRole roleVerified = userRoleDao.getRole(null, "role");
Assert.assertNotNull(roleVerified);
Assert.assertEquals("role", roleVerified.getName());
Assert.assertEquals("testing", roleVerified.getDescription());
}
Aggregations