### Question:
EntityRepositoryHandler implements EntityRepository<E, PK>, DelegateQueryHandler { @Override public Long count() { return (Long) context.applyRestrictions(entityManager().createQuery(countQuery(), Long.class)) .getSingleResult(); }  @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_count_all() { testData.createSimple("testCountAll"); Long result = repo.count(); assertEquals(Long.valueOf(1), result); }
@Test @SuppressWarnings("unchecked") public void should_count_with_attributes() { Simple simple = testData.createSimple("testFindAll1", Integer.valueOf(55)); testData.createSimple("testFindAll2", Integer.valueOf(55)); Long result = repo.count(simple, Simple_.name, Simple_.counter); assertEquals(Long.valueOf(1), result); }
@Test @SuppressWarnings("unchecked") public void should_count_with_no_attributes() { Simple simple = testData.createSimple("testFindAll1"); testData.createSimple("testFindAll2"); SingularAttribute<Simple, Object>[] attributes = new SingularAttribute[] {}; Long result = repo.count(simple, attributes); assertEquals(Long.valueOf(2), result); }