### Question:
GenericHibernateDao { public List<E> findAll() throws HibernateException { logger.trace("Finding all instances of " + entityClass.getSimpleName()); return findByCriteria(); } @SuppressWarnings("unchecked")  GenericHibernateDao(); protected  GenericHibernateDao(Class<E> clazz); E findById(ID id); @SuppressWarnings("unchecked") List<E> findAllWhereFieldEquals(String fieldName, Object fieldEntity,
                                           Criterion... criterion); @SuppressWarnings("unchecked") List<E> findAllWithCollectionContaining(String fieldName, PersistentObject subElement,
                                                   Criterion... criterion); E loadById(ID id); List<E> findAll(); void saveOrUpdate(E e); void delete(E e); @SuppressWarnings("unchecked") E unproxy(E e); void evict(E e); @SuppressWarnings("unchecked") List<E> findByCriteria(Criterion... criterion); @SuppressWarnings("unchecked") List<E> findByCriteriaRestricted(List<String> restrictFieldNames, Criterion... criterion); @SuppressWarnings("unchecked") E findByUniqueCriteria(Criterion... criterion); @SuppressWarnings("unchecked") PagingResult<E> findByCriteriaWithSortingAndPaging(Integer firstResult,
                                                              Integer maxResults, List<Order> sorters, Criterion... criterion); @SuppressWarnings({"unchecked"}) Map<PersistentObject, PermissionCollection> findAllUserPermissionsOfUser(User user); @SuppressWarnings({"unchecked"}) Map<PersistentObject, PermissionCollection> findAllUserGroupPermissionsOfUserGroup(UserGroup userGroup); Number getTotalCount(Criterion... criterion); Class<E> getEntityClass();  }### Answer:
@Test public void findAll_shouldReturnEmptyListWhenNothingPersisted() { List<Application> all = this.appDao.findAll(); assertTrue("findAll() returns list with correct size", all.size() == 0); }
@Test public void findAll_shouldReturnCorrectResultWhenSthPersisted() { Application app1 = this.getRandomSavedMockApp(); Application app2 = this.getRandomSavedMockApp(); List<Application> all = this.appDao.findAll(); assertTrue("findAll() returns list with correct size", all.size() == 2); assertTrue("First app is contained when all requested", all.contains(app1)); assertTrue("Second app is contained when all requested", all.contains(app2)); }