SecurityFunctionHelper { public void validateAndTrimSecurityFunctionKey(SecurityFunctionKey securityFunctionKey) { Assert.notNull(securityFunctionKey, "A security function key must be specified."); securityFunctionKey .setSecurityFunctionName(alternateKeyHelper.validateStringParameter("security function name", securityFunctionKey.getSecurityFunctionName())); }  void validateAndTrimSecurityFunctionKey(SecurityFunctionKey securityFunctionKey);  }
@Test public void testValidateAndTrimSecurityFunctionKey() { SecurityFunctionKey securityFunctionKey = new SecurityFunctionKey(SECURITY_FUNCTION); when(alternateKeyHelper.validateStringParameter("security function name", SECURITY_FUNCTION)).thenReturn(SECURITY_FUNCTION_2); securityFunctionHelper.validateAndTrimSecurityFunctionKey(securityFunctionKey); assertEquals(new SecurityFunctionKey(SECURITY_FUNCTION_2), securityFunctionKey); verify(alternateKeyHelper).validateStringParameter("security function name", SECURITY_FUNCTION); verifyNoMoreInteractions(alternateKeyHelper); }
@Test public void testValidateAndTrimSecurityFunctionKeyMissingSecurityFunctionKey() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("A security function key must be specified."); securityFunctionHelper.validateAndTrimSecurityFunctionKey(null); verifyNoMoreInteractions(alternateKeyHelper); }