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