@Test public void getCategoryList_shouldFindListWithExistingCategories() { Category existingCategory = createCategoryBuilderWithAllFields().build(); insertCategory(existingCategory); List<Category> categories = categoryDao.getCategoryList(); assertThat(categories.size(), is(1)); assertReflectionEquals(existingCategory, categories.get(0)); }
public List<Category> getCategoryList() { List<Category> categories = new ArrayList<>(); try (DBCursor cursor = collection.find().sort(new BasicDBObject("category_id", 1))) { while (cursor.hasNext()) { DBObject categoryObj = cursor.next(); categories.add(Category.fromDBObject(categoryObj)); } } logger.info("Found [{}] categories", categories.size()); return categories; }
CategoryDao extends AbstractBaseDao<Category, String> implements CategoryMapper { public List<Category> getCategoryList() { List<Category> categories = new ArrayList<>(); try (DBCursor cursor = collection.find().sort(new BasicDBObject("category_id", 1))) { while (cursor.hasNext()) { DBObject categoryObj = cursor.next(); categories.add(Category.fromDBObject(categoryObj)); } } logger.info("Found [{}] categories", categories.size()); return categories; } }
CategoryDao extends AbstractBaseDao<Category, String> implements CategoryMapper { public List<Category> getCategoryList() { List<Category> categories = new ArrayList<>(); try (DBCursor cursor = collection.find().sort(new BasicDBObject("category_id", 1))) { while (cursor.hasNext()) { DBObject categoryObj = cursor.next(); categories.add(Category.fromDBObject(categoryObj)); } } logger.info("Found [{}] categories", categories.size()); return categories; } CategoryDao(final String collectionName); }
CategoryDao extends AbstractBaseDao<Category, String> implements CategoryMapper { public List<Category> getCategoryList() { List<Category> categories = new ArrayList<>(); try (DBCursor cursor = collection.find().sort(new BasicDBObject("category_id", 1))) { while (cursor.hasNext()) { DBObject categoryObj = cursor.next(); categories.add(Category.fromDBObject(categoryObj)); } } logger.info("Found [{}] categories", categories.size()); return categories; } CategoryDao(final String collectionName); List<Category> getCategoryList(); Category getCategory(final String categoryId); }
CategoryDao extends AbstractBaseDao<Category, String> implements CategoryMapper { public List<Category> getCategoryList() { List<Category> categories = new ArrayList<>(); try (DBCursor cursor = collection.find().sort(new BasicDBObject("category_id", 1))) { while (cursor.hasNext()) { DBObject categoryObj = cursor.next(); categories.add(Category.fromDBObject(categoryObj)); } } logger.info("Found [{}] categories", categories.size()); return categories; } CategoryDao(final String collectionName); List<Category> getCategoryList(); Category getCategory(final String categoryId);  }