title: How to inject PersistenceContext during unit testing?
body: <p>This is my java class:</p>
  
  <pre><code>public class Finder {
    @PersistenceContext(unitName = "abc")
    EntityManager em;
    public boolean exists(int i) {
      return (this.em.find(Employee.class, i) != null);
    }
  }
  </code></pre>
  
  <p>This is the unit test:</p>
  
  <pre><code>public class FinderTest {
    @Test public void testSimple() {
      Finder f = new Finder();
      assert(f.exists(1) == true);
    }
  }
  </code></pre>
  
  <p>Testing fails with <code>NullPointerException</code> since <code>Finder.em</code> is not injected by anyone. How should I handle this situation properly? Does there any best practice exist?</p>