ExternalInterfaceServiceImpl implements ExternalInterfaceService { void validateAndTrimExternalInterfaceKey(ExternalInterfaceKey externalInterfaceKey) throws IllegalArgumentException { Assert.notNull(externalInterfaceKey, "An external interface key must be specified."); externalInterfaceKey.setExternalInterfaceName( alternateKeyHelper.validateStringParameter("An", "external interface name", externalInterfaceKey.getExternalInterfaceName())); }  @Override ExternalInterface createExternalInterface(ExternalInterfaceCreateRequest request); @Override ExternalInterface getExternalInterface(ExternalInterfaceKey externalInterfaceKey); @Override ExternalInterface deleteExternalInterface(ExternalInterfaceKey externalInterfaceKey); @Override ExternalInterfaceKeys getExternalInterfaces(); @Override ExternalInterface updateExternalInterface(ExternalInterfaceKey externalInterfaceKey, ExternalInterfaceUpdateRequest request);  }
@Test public void testValidateAndTrimExternalInterfaceKeyExtraSpaces() { when(alternateKeyHelper.validateStringParameter(anyString(), anyString(), anyString())).thenReturn(EXTERNAL_INTERFACE); ExternalInterfaceKey externalInterfaceKeyWithExtraSpacesInName = new ExternalInterfaceKey(EXTERNAL_INTERFACE_NAME_WITH_EXTRA_SPACES); assertEquals(EXTERNAL_INTERFACE_NAME_WITH_EXTRA_SPACES, externalInterfaceKeyWithExtraSpacesInName.getExternalInterfaceName()); externalInterfaceService.validateAndTrimExternalInterfaceKey(externalInterfaceKeyWithExtraSpacesInName); assertEquals(EXTERNAL_INTERFACE, externalInterfaceKeyWithExtraSpacesInName.getExternalInterfaceName()); }