SecurityFunctionServiceImpl implements SecurityFunctionService { @Override public SecurityFunction deleteSecurityFunction(SecurityFunctionKey securityFunctionKey) { validateAndTrimSecurityFunctionKey(securityFunctionKey); SecurityFunctionEntity securityFunctionEntity = securityFunctionDaoHelper.getSecurityFunctionEntity(securityFunctionKey.getSecurityFunctionName()); securityFunctionDao.delete(securityFunctionEntity); return createSecurityFunctionFromEntity(securityFunctionEntity); }  @Override SecurityFunction createSecurityFunction(SecurityFunctionCreateRequest request); @Override SecurityFunction getSecurityFunction(SecurityFunctionKey securityFunctionKey); @Override SecurityFunction deleteSecurityFunction(SecurityFunctionKey securityFunctionKey); @Override SecurityFunctionKeys getSecurityFunctions();  }
@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(); }
@Test public void testDeleteSecurityFunctionNullKey() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("A security function key must be specified"); securityFunctionService.deleteSecurityFunction(null); }