MessengerDataService { public Envelope getEnvelope( UUID messageId ) { MessageEntity messageEntity = messageDao.find( messageId.toString() ); if ( messageEntity == null ) { return null; } return new Envelope( messageEntity ); } MessengerDataService( EntityManagerFactory entityManagerFactory ); void purgeExpiredMessages(); Set<Envelope> getEnvelopes(); void markAsSent( Envelope envelope ); void incrementDeliveryAttempts( Envelope envelope ); void saveEnvelope( Envelope envelope ); Envelope getEnvelope( UUID messageId );  }
@Test public void testGetEnvelope() throws Exception { when( messageDao.find( message.getId().toString() ) ).thenReturn( messageEntity ); Envelope envelope1 = messengerDataService.getEnvelope( message.getId() ); verify( messageDao ).find( message.getId().toString() ); }