### Question:
EntityCollection extends BaseObject { public long count(Filter filter) { filter.condition("id", parent.getId()); CriteriaBuilder builder = getEntityManager().getCriteriaBuilder(); CriteriaQuery<Long> cQuery = builder.createQuery(Long.class); Root<? extends Model> root = cQuery.from(parent.getClass()); Join<?,?> join = root.join(name); cQuery.select(builder.count(join)); filter.constructQuery(builder, cQuery, root); TypedQuery<Long> query = createQuery(cQuery, filter); return query.getSingleResult(); }  T add(T item); T remove(T item); T findById(Serializable id); List<T> all(); T first(Object... paramValues); T one(Object... paramValues); List<T> where(Filter filter); List<T> where(Object... paramValues); long count(Filter filter); void persist();  }### Answer:
@Test public void shouldGetCount() { assertEquals(model.collection("children").count(new Filter()), 3); }