ExternalInterfaceDaoHelper { public ExternalInterfaceEntity getExternalInterfaceEntity(String externalInterfaceName) { ExternalInterfaceEntity externalInterfaceEntity = externalInterfaceDao.getExternalInterfaceByName(externalInterfaceName); if (externalInterfaceEntity == null) { throw new ObjectNotFoundException(String.format("External interface with name \"%s\" doesn't exist.", externalInterfaceName)); } return externalInterfaceEntity; }  ExternalInterfaceEntity getExternalInterfaceEntity(String externalInterfaceName);  }
@Test public void testGetExternalInterfaceEntity() { ExternalInterfaceEntity externalInterfaceEntity = new ExternalInterfaceEntity(); when(externalInterfaceDao.getExternalInterfaceByName(EXTERNAL_INTERFACE)).thenReturn(externalInterfaceEntity); ExternalInterfaceEntity result = externalInterfaceDaoHelper.getExternalInterfaceEntity(EXTERNAL_INTERFACE); assertEquals(externalInterfaceEntity, result); verify(externalInterfaceDao).getExternalInterfaceByName(EXTERNAL_INTERFACE); verifyNoMoreInteractionsHelper(); }
@Test public void testGetExternalInterfaceEntityExternalInterfaceNoExists() { when(externalInterfaceDao.getExternalInterfaceByName(EXTERNAL_INTERFACE)).thenReturn(null); expectedException.expect(ObjectNotFoundException.class); expectedException.expectMessage(String.format("External interface with name \"%s\" doesn't exist.", EXTERNAL_INTERFACE)); externalInterfaceDaoHelper.getExternalInterfaceEntity(EXTERNAL_INTERFACE); verify(externalInterfaceDao).getExternalInterfaceByName(EXTERNAL_INTERFACE); verifyNoMoreInteractionsHelper(); }