ExternalInterfaceServiceImpl implements ExternalInterfaceService { @Override public ExternalInterface updateExternalInterface(ExternalInterfaceKey externalInterfaceKey, ExternalInterfaceUpdateRequest request) { validateAndTrimExternalInterfaceKey(externalInterfaceKey); validateExternalInterfaceUpdateRequest(request); ExternalInterfaceEntity externalInterfaceEntity = externalInterfaceDaoHelper.getExternalInterfaceEntity(externalInterfaceKey.getExternalInterfaceName()); updateExternalInterfaceEntity(externalInterfaceEntity, request); 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 testUpdateExternalInterface() { when(alternateKeyHelper.validateStringParameter(anyString(), anyString(), anyString())).thenReturn(EXTERNAL_INTERFACE); when(alternateKeyHelper.validateStringParameter(anyString(), anyString())).thenReturn(DISPLAY_NAME_FIELD); when(externalInterfaceDaoHelper.getExternalInterfaceEntity(EXTERNAL_INTERFACE)).thenReturn(EXTERNAL_INTERFACE_ENTITY); when(externalInterfaceDao.saveAndRefresh(any(ExternalInterfaceEntity.class))).thenReturn(EXTERNAL_INTERFACE_ENTITY); ExternalInterface externalInterface = externalInterfaceService.updateExternalInterface(EXTERNAL_INTERFACE_KEY, EXTERNAL_INTERFACE_UPDATE_REQUEST); assertEquals(DISPLAY_NAME_FIELD, externalInterface.getDisplayName()); verify(alternateKeyHelper).validateStringParameter("An", "external interface name", EXTERNAL_INTERFACE_KEY.getExternalInterfaceName()); verify(alternateKeyHelper).validateStringParameter("display name", DISPLAY_NAME_FIELD); verify(externalInterfaceDaoHelper).getExternalInterfaceEntity(EXTERNAL_INTERFACE); verify(externalInterfaceDao).saveAndRefresh(any(ExternalInterfaceEntity.class)); verifyNoMoreInteractionsHelper(); }