samedi 15 novembre 2014

How to mock persisting and Entity with Mockito and jUnit


Vote count:

0




I'm trying to find a way to test my entity using Mockito;


This is the simple test method:



@Mock
private EntityManager em;

@Test
public void persistArticleWithValidArticleSetsArticleId() {
Article article = new Article();
em.persist(article);
assertThat(article.getId(), is(not(0L)));
}


How do I best mock the behaviour that the EntityManager changes the Id from 0L to i.e. 1L? Possibly with the least obstructions in readability.



asked 1 min ago







How to mock persisting and Entity with Mockito and jUnit

Aucun commentaire:

Enregistrer un commentaire