SecurityRoleFunctionHelper { public void validateAndTrimSecurityRoleFunctionCreateRequest(SecurityRoleFunctionCreateRequest securityRoleFunctionCreateRequest) { Assert.notNull(securityRoleFunctionCreateRequest, "A security role to function mapping create request must be specified."); validateAndTrimSecurityRoleFunctionKey(securityRoleFunctionCreateRequest.getSecurityRoleFunctionKey()); }  void validateAndTrimSecurityRoleFunctionCreateRequest(SecurityRoleFunctionCreateRequest securityRoleFunctionCreateRequest); void validateAndTrimSecurityRoleFunctionKey(SecurityRoleFunctionKey securityRoleFunctionKey);  }
@Test public void testValidateAndTrimSecurityRoleFunctionCreateRequest() { SecurityRoleFunctionKey securityRoleFunctionKey = new SecurityRoleFunctionKey(SECURITY_ROLE, SECURITY_FUNCTION); SecurityRoleFunctionCreateRequest securityRoleFunctionCreateRequest = new SecurityRoleFunctionCreateRequest(securityRoleFunctionKey); 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.validateAndTrimSecurityRoleFunctionCreateRequest(securityRoleFunctionCreateRequest); assertEquals(new SecurityRoleFunctionCreateRequest(new SecurityRoleFunctionKey(SECURITY_ROLE_2, SECURITY_FUNCTION_2)), securityRoleFunctionCreateRequest); verify(alternateKeyHelper).validateStringParameter("security role name", SECURITY_ROLE); verify(alternateKeyHelper).validateStringParameter("security function name", SECURITY_FUNCTION); verifyNoMoreInteractions(alternateKeyHelper); }
@Test public void testValidateAndTrimSecurityRoleFunctionCreateRequestMissingSecurityRoleFunctionCreateRequest() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("A security role to function mapping create request must be specified."); securityRoleFunctionHelper.validateAndTrimSecurityRoleFunctionCreateRequest(null); verifyNoMoreInteractions(alternateKeyHelper); }
@Test public void testValidateAndTrimSecurityRoleFunctionCreateRequestMissingSecurityRoleFunctionKey() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("A security role to function mapping key must be specified."); securityRoleFunctionHelper.validateAndTrimSecurityRoleFunctionCreateRequest(new SecurityRoleFunctionCreateRequest()); verifyNoMoreInteractions(alternateKeyHelper); }