ExternalInterfaceServiceImpl implements ExternalInterfaceService { @Override public ExternalInterface getExternalInterface(ExternalInterfaceKey externalInterfaceKey) { validateAndTrimExternalInterfaceKey(externalInterfaceKey); ExternalInterfaceEntity externalInterfaceEntity = externalInterfaceDaoHelper.getExternalInterfaceEntity(externalInterfaceKey.getExternalInterfaceName()); return createExternalInterfaceFromEntity(externalInterfaceEntity); }  @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 testGetExternalInterface() { when(externalInterfaceDaoHelper.getExternalInterfaceEntity(EXTERNAL_INTERFACE)).thenReturn(EXTERNAL_INTERFACE_ENTITY); when(alternateKeyHelper.validateStringParameter(anyString(), anyString(), anyString())).thenReturn(EXTERNAL_INTERFACE); ExternalInterface externalInterface = externalInterfaceService.getExternalInterface(EXTERNAL_INTERFACE_KEY); assertEquals(EXTERNAL_INTERFACE, externalInterface.getExternalInterfaceKey().getExternalInterfaceName()); verify(alternateKeyHelper).validateStringParameter("An", "external interface name", EXTERNAL_INTERFACE_KEY.getExternalInterfaceName()); verify(externalInterfaceDaoHelper).getExternalInterfaceEntity(EXTERNAL_INTERFACE); verifyNoMoreInteractionsHelper(); }
@Test public void testGetExternalInterfaceNullKey() { expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("An external interface key must be specified"); externalInterfaceService.getExternalInterface(null); }