@Test public void getItemListByProduct_shouldFindListWithExistingItems() { Item existingItem = createItemBuilderWithBaseFields().build(); insertItem(existingItem); List<Item> items = itemDao.getItemListByProduct(existingItem.getProduct().getProductId()); assertThat(items.size(), is(1)); assertReflectionEquals(existingItem, items.get(0)); }
public List<Item> getItemListByProduct(final String productId) { checkNotNull(emptyToNull(productId), "Argument[productId] must not be empty or null"); List<Item> items = new ArrayList<>(); DBObject query = new BasicDBObject("product.product_id", productId); try (DBCursor cursor = collection.find(query).sort(new BasicDBObject("item_id", 1))) { while (cursor.hasNext()) { DBObject itemObj = cursor.next(); items.add(Item.fromDBObject(itemObj)); } } logger.info("Found for product id [{}] [{}] item(s)", productId, items.size()); return items; }
ItemDao extends AbstractBaseDao<Item, String> implements ItemMapper { public List<Item> getItemListByProduct(final String productId) { checkNotNull(emptyToNull(productId), "Argument[productId] must not be empty or null"); List<Item> items = new ArrayList<>(); DBObject query = new BasicDBObject("product.product_id", productId); try (DBCursor cursor = collection.find(query).sort(new BasicDBObject("item_id", 1))) { while (cursor.hasNext()) { DBObject itemObj = cursor.next(); items.add(Item.fromDBObject(itemObj)); } } logger.info("Found for product id [{}] [{}] item(s)", productId, items.size()); return items; } }
ItemDao extends AbstractBaseDao<Item, String> implements ItemMapper { public List<Item> getItemListByProduct(final String productId) { checkNotNull(emptyToNull(productId), "Argument[productId] must not be empty or null"); List<Item> items = new ArrayList<>(); DBObject query = new BasicDBObject("product.product_id", productId); try (DBCursor cursor = collection.find(query).sort(new BasicDBObject("item_id", 1))) { while (cursor.hasNext()) { DBObject itemObj = cursor.next(); items.add(Item.fromDBObject(itemObj)); } } logger.info("Found for product id [{}] [{}] item(s)", productId, items.size()); return items; } ItemDao(final String collectionName); }
ItemDao extends AbstractBaseDao<Item, String> implements ItemMapper { public List<Item> getItemListByProduct(final String productId) { checkNotNull(emptyToNull(productId), "Argument[productId] must not be empty or null"); List<Item> items = new ArrayList<>(); DBObject query = new BasicDBObject("product.product_id", productId); try (DBCursor cursor = collection.find(query).sort(new BasicDBObject("item_id", 1))) { while (cursor.hasNext()) { DBObject itemObj = cursor.next(); items.add(Item.fromDBObject(itemObj)); } } logger.info("Found for product id [{}] [{}] item(s)", productId, items.size()); return items; } ItemDao(final String collectionName); void updateInventoryQuantity(final Map<NumericValueUpdateParam, Object> params); int getInventoryQuantity(final String itemId); List<Item> getItemListByProduct(final String productId); Item getItem(final String itemId); }
ItemDao extends AbstractBaseDao<Item, String> implements ItemMapper { public List<Item> getItemListByProduct(final String productId) { checkNotNull(emptyToNull(productId), "Argument[productId] must not be empty or null"); List<Item> items = new ArrayList<>(); DBObject query = new BasicDBObject("product.product_id", productId); try (DBCursor cursor = collection.find(query).sort(new BasicDBObject("item_id", 1))) { while (cursor.hasNext()) { DBObject itemObj = cursor.next(); items.add(Item.fromDBObject(itemObj)); } } logger.info("Found for product id [{}] [{}] item(s)", productId, items.size()); return items; } ItemDao(final String collectionName); void updateInventoryQuantity(final Map<NumericValueUpdateParam, Object> params); int getInventoryQuantity(final String itemId); List<Item> getItemListByProduct(final String productId); Item getItem(final String itemId);  }