SecurityRoleFunctionHelper { public void validateAndTrimSecurityRoleFunctionKey(SecurityRoleFunctionKey securityRoleFunctionKey) { Assert.notNull(securityRoleFunctionKey, "A security role to function mapping key must be specified."); securityRoleFunctionKey .setSecurityRoleName(alternateKeyHelper.validateStringParameter("security role name", securityRoleFunctionKey.getSecurityRoleName())); securityRoleFunctionKey .setSecurityFunctionName(alternateKeyHelper.validateStringParameter("security function name", securityRoleFunctionKey.getSecurityFunctionName())); }  void validateAndTrimSecurityRoleFunctionCreateRequest(SecurityRoleFunctionCreateRequest securityRoleFunctionCreateRequest); void validateAndTrimSecurityRoleFunctionKey(SecurityRoleFunctionKey securityRoleFunctionKey);  }
@Test public void testValidateAndTrimSecurityRoleFunctionKey() { SecurityRoleFunctionKey securityRoleFunctionKey = new SecurityRoleFunctionKey(SECURITY_ROLE, SECURITY_FUNCTION); when(alternateKeyHelper.validateStringParameter("security role name", SECURITY_ROLE)).thenReturn(SECURITY_ROLE_2); when(alternateKeyHelper.validateStringParameter("security function name", SECURITY_FUNCTION)).thenReturn(SECURITY_FUNCTION_2); securityRoleFunctionHelper.validateAndTrimSecurityRoleFunctionKey(securityRoleFunctionKey); assertEquals(new SecurityRoleFunctionKey(SECURITY_ROLE_2, SECURITY_FUNCTION_2), securityRoleFunctionKey); verify(alternateKeyHelper).validateStringParameter("security role name", SECURITY_ROLE); verify(alternateKeyHelper).validateStringParameter("security function name", SECURITY_FUNCTION); verifyNoMoreInteractions(alternateKeyHelper); }
@Test public void testValidateAndTrimSecurityRoleFunctionKeyMissingSecurityRoleFunctionKey() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("A security role to function mapping key must be specified."); securityRoleFunctionHelper.validateAndTrimSecurityRoleFunctionKey(null); verifyNoMoreInteractions(alternateKeyHelper); }