title: What unit test to write for a class using generics in Java?
body: <p>Taking the very specific example of the <code>JpaDao</code> class defined in this <a href="http://java.dzone.com/articles/jpa-implementation-patterns" rel="noreferrer" title="JPA Implementation Patterns">article</a>:</p>
  
  <pre><code>public abstract class JpaDao&lt;K, E&gt; implements Dao&lt;K, E&gt; {
      protected Class&lt;E&gt; entityClass;
  
      @PersistenceContext
      protected EntityManager entityManager;
  
      public JpaDao() {
          ParameterizedType genericSuperclass = (ParameterizedType) getClass().getGenericSuperclass();
          this.entityClass = (Class&lt;E&gt;) genericSuperclass.getActualTypeArguments()[1];
      }
  
      public void persist(E entity) { entityManager.persist(entity); }
  
      public void remove(E entity) { entityManager.remove(entity); }
  
      public E findById(K id) { return entityManager.find(entityClass, id); }
  }
  </code></pre>
  
  <p>would it be best to write unit tests for all the existing entities in the application (<code>Order</code>, <code>Customer</code>, Book, etc.), or would it be acceptable to write unit tests for just one entity, as hinted by this <a href="https://stackoverflow.com/questions/1566539/writing-unittest-for-generic-classes-best-approach">other question</a>?  Are there any best practice regarding unit testing java classes using generics?</p>