public void testCreateRepeated() { Role repeated = Role.Builder.fromRole(env.role).build(); try { repeated.save(); fail("Should not be able to create roles with the same name"); } catch (AbiquoException ex) { assertHasError(ex, Status.CONFLICT, "ROLE-7"); } }
public void testCreateEnterpriseRole() { final Role entRole = Role.Builder.fromRole(env.role).build(); entRole.setName(entRole.getName() + "enterprise"); entRole.setEnterprise(env.enterprise); entRole.save(); find( env.enterprise.listRoles(), new Predicate<Role>() { @Override public boolean apply(Role input) { return input.getName().equals(entRole.getName()); } }); }
public void testUpdate() { Role role = Role.builder(env.context.getApiContext()) .name("dummyRoleUpdateRole") .blocked(false) .build(); role.save(); role.setName("UPDATED_ROLE"); role.update(); // Recover the updated role RoleDto updated = env.adminApi.getRole(role.getId()); assertEquals(updated.getName(), "UPDATED_ROLE"); role.delete(); }