### Question:
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @SuppressWarnings("unchecked") @Override public PK getPrimaryKey(E entity) { return (PK) persistenceUnitUtil().getIdentifier(entity); }  @Override @RequiresTransaction E save(E entity); @Override @RequiresTransaction E saveAndFlush(E entity); @Override @RequiresTransaction E saveAndFlushAndRefresh(E entity); @Override @RequiresTransaction void refresh(E entity); @Override E findBy(PK primaryKey); @Override Optional<E> findOptionalBy(PK primaryKey); @Override List<E> findBy(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findBy(E example, int start, int max, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, SingularAttribute<E, ?>... attributes); @Override List<E> findByLike(E example, int start, int max, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override List<E> findAll(); @SuppressWarnings("unchecked") @Override List<E> findAll(int start, int max); @Override Long count(); @Override Long count(E example, SingularAttribute<E, ?>... attributes); @Override Long countLike(E example, SingularAttribute<E, ?>... attributes); @SuppressWarnings("unchecked") @Override PK getPrimaryKey(E entity); @Override @RequiresTransaction void remove(E entity); @Override @RequiresTransaction void removeAndFlush(E entity); @Override @RequiresTransaction void attachAndRemove(E entity); @Override @RequiresTransaction void flush(); EntityManager entityManager(); CriteriaQuery<E> criteriaQuery(); TypedQuery<E> typedQuery(String qlString); @SuppressWarnings("unchecked") Class<E> entityClass(); String tableName(); String entityName();  }### Answer:
@Test public void should_return_entity_primary_key() { Simple simple = testData.createSimple("should_return_entity_primary_key"); Long id = simple.getId(); Long primaryKey = repo.getPrimaryKey(simple); assertNotNull(primaryKey); assertEquals(id, primaryKey); }
@Test public void should_return_null_primary_key() { Simple simple = new Simple("should_return_null_primary_key"); Long primaryKey = repo.getPrimaryKey(simple); assertNull(primaryKey); }
@Test public void should_return_entity_primary_key_detached_entity() { Simple simple = testData.createSimple("should_return_entity_primary_key"); Long id = simple.getId(); getEntityManager().detach(simple); Long primaryKey = repo.getPrimaryKey(simple); assertNotNull(primaryKey); assertEquals(id, primaryKey); }