title: How to mock persisting and Entity with Mockito and jUnit
body: <p>I'm trying to find a way to test my entity using Mockito;</p>
  
  <p>This is the simple test method:</p>
  
  <pre><code>@Mock
  private EntityManager em;
  
  @Test
  public void persistArticleWithValidArticleSetsArticleId() {
      Article article = new Article();
      em.persist(article);
      assertThat(article.getId(), is(not(0L)));
  }
  </code></pre>
  
  <p>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.</p>
  
  <p>Edit:
  Some extra information; Outside test-scope the EntityManager is produced by an application-container </p>