SecurityRoleHelper { public void validateAndTrimSecurityRoleKey(SecurityRoleKey securityRoleKey) { Assert.notNull(securityRoleKey, "A security role key must be specified."); securityRoleKey.setSecurityRoleName(alternateKeyHelper.validateStringParameter("security role name", securityRoleKey.getSecurityRoleName())); }  void validateAndTrimSecurityRoleKey(SecurityRoleKey securityRoleKey);  }
@Test public void testValidateAndTrimSecurityRoleKey() { SecurityRoleKey securityRoleKey = new SecurityRoleKey(SECURITY_ROLE); when(alternateKeyHelper.validateStringParameter("security role name", SECURITY_ROLE)).thenReturn(SECURITY_ROLE_2); securityRoleHelper.validateAndTrimSecurityRoleKey(securityRoleKey); assertEquals(new SecurityRoleKey(SECURITY_ROLE_2), securityRoleKey); verify(alternateKeyHelper).validateStringParameter("security role name", SECURITY_ROLE); verifyNoMoreInteractions(alternateKeyHelper); }
@Test public void testValidateAndTrimSecurityRoleKeyMissingSecurityRoleKey() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("A security role key must be specified."); securityRoleHelper.validateAndTrimSecurityRoleKey(null); verifyNoMoreInteractions(alternateKeyHelper); }