SecurityFunctionServiceImpl implements SecurityFunctionService { void validateAndTrimSecurityFunctionKey(SecurityFunctionKey securityFunctionKey) throws IllegalArgumentException { Assert.notNull(securityFunctionKey, "A security function key must be specified."); securityFunctionKey .setSecurityFunctionName(alternateKeyHelper.validateStringParameter("security function name", securityFunctionKey.getSecurityFunctionName())); }  @Override SecurityFunction createSecurityFunction(SecurityFunctionCreateRequest request); @Override SecurityFunction getSecurityFunction(SecurityFunctionKey securityFunctionKey); @Override SecurityFunction deleteSecurityFunction(SecurityFunctionKey securityFunctionKey); @Override SecurityFunctionKeys getSecurityFunctions();  }
@Test public void testValidateAndTrimSecurityFunctionKeyExtraSpaces() { when(alternateKeyHelper.validateStringParameter(anyString(), anyString())).thenReturn(SECURITY_FUNCTION); assertEquals(SECURITY_FUNCTION_NAME_WITH_EXTRA_SPACES, SECURITY_FUNCTION_KEY_WITH_EXTRA_SPACES_IN_NAME.getSecurityFunctionName()); securityFunctionService.validateAndTrimSecurityFunctionKey(SECURITY_FUNCTION_KEY_WITH_EXTRA_SPACES_IN_NAME); assertEquals(SECURITY_FUNCTION, SECURITY_FUNCTION_KEY_WITH_EXTRA_SPACES_IN_NAME.getSecurityFunctionName()); }