### Question:
CategoryDAO extends DefaultDAOBase<Integer, Category> { public Category findDefault() { return getSingleResult(createCriteria(isDefault())); } CategoryDAO();  CategoryDAO(final EntityManager entityManager); Category findDefault(); ArrayList<Category> findGlobalCategories(); ArrayList<Category> findLocalCategories(final Integer idEnterprise); Category findByNameAndEnterprise(final String categoryName, final Enterprise enterprise); boolean existsAnyWithName(final String name); boolean existsAnyOtherWithName(final Category category, final String name); static final String BY_NAME_AND_ENTERPRISE; static final String BY_NAME_AND_NO_ENTERPRISE; static final String BY_GLOBAL; static final String BY_LOCAL; }### Answer:
@Test public void testFindDefault() { Category category = eg().createDefaultInstance(); ds().persistAll(category); CategoryDAO dao = createDaoForRollbackTransaction(); Category defaultCategory = dao.findDefault(); assertNotNull(defaultCategory); assertTrue(defaultCategory.isDefaultCategory()); assertEquals(defaultCategory.getName(), category.getName()); }
@Test(expectedExceptions = NoResultException.class) public void testGetUnexistingDefault() { Category category = eg().createUniqueInstance(); ds().persistAll(category); CategoryDAO dao = createDaoForRollbackTransaction(); dao.findDefault(); }