/** * Create an instance of {@link SecurityRoleKey } * */ public SecurityRoleKey createSecurityRoleKey() { return new SecurityRoleKey(); }
/** * Create an instance of {@link SecurityRoleKey } * */ public SecurityRoleKey createSecurityRoleKey() { return new SecurityRoleKey(); }
/** * Create an instance of {@link SecurityRoleKey } * */ public SecurityRoleKey createSecurityRoleKey() { return new SecurityRoleKey(); }
public Object createNewInstance() { return new SecurityRoleKey(); }
/** * Retrieves an existing security role. * * @param securityRoleName the security role name * * @return the retrieved security role */ @RequestMapping(value = SECURITY_ROLES_URI_PREFIX + "/{securityRoleName}", method = RequestMethod.GET) @Secured(SecurityFunctions.FN_SECURITY_ROLES_GET) public SecurityRole getSecurityRole(@PathVariable("securityRoleName") String securityRoleName) { return securityRoleService.getSecurityRole(new SecurityRoleKey(securityRoleName)); }
/** * Deletes an existing security role. * * @param securityRoleName the security role name * * @return the deleted security role */ @RequestMapping(value = SECURITY_ROLES_URI_PREFIX + "/{securityRoleName}", method = RequestMethod.DELETE) @Secured(SecurityFunctions.FN_SECURITY_ROLES_DELETE) public SecurityRole deleteSecurityRole(@PathVariable("securityRoleName") String securityRoleName) { return securityRoleService.deleteSecurityRole(new SecurityRoleKey(securityRoleName)); }
/** * Retrieves an existing security role. * * @param securityRoleName the security role name * * @return the retrieved security role */ @RequestMapping(value = SECURITY_ROLES_URI_PREFIX + "/{securityRoleName}", method = RequestMethod.GET) @Secured(SecurityFunctions.FN_SECURITY_ROLES_GET) public SecurityRole getSecurityRole(@PathVariable("securityRoleName") String securityRoleName) { return securityRoleService.getSecurityRole(new SecurityRoleKey(securityRoleName)); }
/** * Deletes an existing security role. * * @param securityRoleName the security role name * * @return the deleted security role */ @RequestMapping(value = SECURITY_ROLES_URI_PREFIX + "/{securityRoleName}", method = RequestMethod.DELETE) @Secured(SecurityFunctions.FN_SECURITY_ROLES_DELETE) public SecurityRole deleteSecurityRole(@PathVariable("securityRoleName") String securityRoleName) { return securityRoleService.deleteSecurityRole(new SecurityRoleKey(securityRoleName)); }
@Override public SecurityRole getSecurityRole(SecurityRoleKey securityRoleKey) { // validate and trim security role key. String securityRole = validateSecurityRoleKey(securityRoleKey); // get the security role entity. SecurityRoleEntity securityRoleEntity = getSecurityRoleEntityByName(new SecurityRoleKey(securityRole)); // create and return the security role from the security role entity. return createSecurityRoleFromEntity(securityRoleEntity); }
@Override public SecurityRole getSecurityRole(SecurityRoleKey securityRoleKey) { // validate and trim security role key. String securityRole = validateSecurityRoleKey(securityRoleKey); // get the security role entity. SecurityRoleEntity securityRoleEntity = getSecurityRoleEntityByName(new SecurityRoleKey(securityRole)); // create and return the security role from the security role entity. return createSecurityRoleFromEntity(securityRoleEntity); }
@Override public SecurityRole deleteSecurityRole(SecurityRoleKey securityRoleKey) { // validate and trim security role key. String securityRole = validateSecurityRoleKey(securityRoleKey); // get the security role entity. SecurityRoleEntity securityRoleEntity = getSecurityRoleEntityByName(new SecurityRoleKey(securityRole)); // Delete the security role. securityRoleDao.delete(securityRoleEntity); // Create and return the security role object from the deleted entity. return createSecurityRoleFromEntity(securityRoleEntity); }
@Override public SecurityRole deleteSecurityRole(SecurityRoleKey securityRoleKey) { // validate and trim security role key. String securityRole = validateSecurityRoleKey(securityRoleKey); // get the security role entity. SecurityRoleEntity securityRoleEntity = getSecurityRoleEntityByName(new SecurityRoleKey(securityRole)); // Delete the security role. securityRoleDao.delete(securityRoleEntity); // Create and return the security role object from the deleted entity. return createSecurityRoleFromEntity(securityRoleEntity); }
@Test public void testDeleteNonExistingSecurityRole() { // Try to delete a non-existing security role. try { securityRoleService.deleteSecurityRole(new SecurityRoleKey(SECURITY_ROLE)); fail("Should throw an ObjectNotFoundException when security role doesn't exist."); } catch (ObjectNotFoundException e) { assertEquals(String.format("Security role with name \"%s\" doesn't exist.", SECURITY_ROLE), e.getMessage()); } }
@Test public void testUpdateSecurityRoleThatDoesNotExists() { try { securityRoleService.updateSecurityRole(new SecurityRoleKey(SECURITY_ROLE), new SecurityRoleUpdateRequest(DESCRIPTION)); fail("Should throw ObjectNotFoundException when security role does not exist."); } catch (ObjectNotFoundException e) { assertEquals(String.format("Security role with name \"%s\" doesn't exist.", SECURITY_ROLE), e.getMessage()); } }
@Test public void testDeleteSecurityRole() throws Exception { // Create and persist a security role entity. securityRoleDaoTestHelper.createSecurityRoleEntity(SECURITY_ROLE, DESCRIPTION); // Delete the security role. SecurityRole securityRole = securityRoleService.deleteSecurityRole(new SecurityRoleKey(SECURITY_ROLE)); // Validate the response. assertEquals(new SecurityRole(SECURITY_ROLE, DESCRIPTION), securityRole); }
@Test public void testGetSecurityRole() throws Exception { // Create and persist a security role entity. securityRoleDaoTestHelper.createSecurityRoleEntity(SECURITY_ROLE, DESCRIPTION); // Retrieve the security role. SecurityRole securityRole = securityRoleService.getSecurityRole(new SecurityRoleKey(SECURITY_ROLE)); // Validate the returned object. assertEquals(new SecurityRole(SECURITY_ROLE, DESCRIPTION), securityRole); }
@Test public void testDeleteSecurityRoleTrimParameters() { // Create and persist a security role entity. securityRoleDaoTestHelper.createSecurityRoleEntity(SECURITY_ROLE, DESCRIPTION); // Get a security role using input parameters with leading and trailing empty spaces. SecurityRole securityRole = securityRoleService.deleteSecurityRole(new SecurityRoleKey(addWhitespace(SECURITY_ROLE))); assertEquals(new SecurityRole(SECURITY_ROLE, DESCRIPTION), securityRole); }
@Test public void testUpdateSecurityRole() throws Exception { // Create and persist a security role entity. securityRoleDaoTestHelper.createSecurityRoleEntity(SECURITY_ROLE, DESCRIPTION); // Update the security role. SecurityRole updatedSecurityRole = securityRoleService.updateSecurityRole(new SecurityRoleKey(SECURITY_ROLE), new SecurityRoleUpdateRequest(DESCRIPTION_2)); // Validate the returned object assertEquals(new SecurityRole(SECURITY_ROLE, DESCRIPTION_2), updatedSecurityRole); }
@Test public void testGetSecurityRoleTrimParameters() { // Create and persist a security role entity. securityRoleDaoTestHelper.createSecurityRoleEntity(SECURITY_ROLE, DESCRIPTION); // Get a security role using input parameters with leading and trailing empty spaces. SecurityRole securityRole = securityRoleService.getSecurityRole(new SecurityRoleKey(addWhitespace(SECURITY_ROLE))); assertEquals(new SecurityRole(SECURITY_ROLE, DESCRIPTION), securityRole); }
@Test public void testUpdateSecurityRoleTrimParameters() { // Create and persist a security role entity. securityRoleDaoTestHelper.createSecurityRoleEntity(SECURITY_ROLE, DESCRIPTION); // Get a security role using input parameters with leading and trailing empty spaces. SecurityRole securityRole = securityRoleService .updateSecurityRole(new SecurityRoleKey(addWhitespace(SECURITY_ROLE)), new SecurityRoleUpdateRequest(addWhitespace(DESCRIPTION))); assertEquals(new SecurityRole(SECURITY_ROLE, addWhitespace(DESCRIPTION)), securityRole); }