@Override public SecurityFunction deleteSecurityFunction(SecurityFunctionKey securityFunctionKey) { // Perform validation and trim. validateAndTrimSecurityFunctionKey(securityFunctionKey); // Retrieve and ensure that a security function already exists with the specified name. SecurityFunctionEntity securityFunctionEntity = securityFunctionDaoHelper.getSecurityFunctionEntity(securityFunctionKey.getSecurityFunctionName()); // Delete the security function. securityFunctionDao.delete(securityFunctionEntity); // Create and return the security function object from the deleted entity. return createSecurityFunctionFromEntity(securityFunctionEntity); }
@Override public SecurityFunction deleteSecurityFunction(SecurityFunctionKey securityFunctionKey) { // Perform validation and trim. validateAndTrimSecurityFunctionKey(securityFunctionKey); // Retrieve and ensure that a security function already exists with the specified name. SecurityFunctionEntity securityFunctionEntity = securityFunctionDaoHelper.getSecurityFunctionEntity(securityFunctionKey.getSecurityFunctionName()); // Delete the security function. securityFunctionDao.delete(securityFunctionEntity); // Create and return the security function object from the deleted entity. return createSecurityFunctionFromEntity(securityFunctionEntity); }
@Test public void testDeleteSecurityFunction() { when(securityFunctionDaoHelper.getSecurityFunctionEntity(SECURITY_FUNCTION)).thenReturn(SECURITY_FUNCTION_ENTITY); when(alternateKeyHelper.validateStringParameter(anyString(), anyString())).thenReturn(SECURITY_FUNCTION); SecurityFunction securityFunction = securityFunctionService.deleteSecurityFunction(SECURITY_FUNCTION_KEY); assertEquals(SECURITY_FUNCTION, securityFunction.getSecurityFunctionName()); verify(alternateKeyHelper).validateStringParameter("security function name", SECURITY_FUNCTION); verify(securityFunctionDaoHelper).getSecurityFunctionEntity(SECURITY_FUNCTION); verify(securityFunctionDao).delete(SECURITY_FUNCTION_ENTITY); verifyNoMoreInteractionsHelper(); }