MessengerDataService { public void saveEnvelope( Envelope envelope ) { MessageEntity messageEntity = new MessageEntity( envelope ); messageDao.persist( 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 testSaveEnvelope() throws Exception { messengerDataService.saveEnvelope( envelope ); verify( messageDao ).persist( isA( MessageEntity.class ) ); }