@Test public void getsAnInventoryQuantity() { int quantity = persistence.getInventoryQuantity(item.getItemId()); assertThat(quantity, equalTo(item.getQuantity())); }
@Override public int getInventoryQuantity(@Nonnull final String itemId) { int result = -1; Query query = createNamedQuery("Item.getInventoryQuantity"); query.setParameter("itemId", itemId); @SuppressWarnings("unchecked") List<Integer> quantities = (List<Integer>) query.getResultList(); checkState(quantities.size() <= 1, String.format("Query[Item.getInventoryQuantity]" + "with parameter[%s] returned [%d] results", itemId, quantities.size())); if (quantities.size() == 1) { result = quantities.get(0); } logger.info("Read quantity[{}] for item[{}]", result, itemId); return result; }
ItemBasePersistence extends AbstractBasePersistence<Item, String> implements ItemMapper { @Override public int getInventoryQuantity(@Nonnull final String itemId) { int result = -1; Query query = createNamedQuery("Item.getInventoryQuantity"); query.setParameter("itemId", itemId); @SuppressWarnings("unchecked") List<Integer> quantities = (List<Integer>) query.getResultList(); checkState(quantities.size() <= 1, String.format("Query[Item.getInventoryQuantity]" + "with parameter[%s] returned [%d] results", itemId, quantities.size())); if (quantities.size() == 1) { result = quantities.get(0); } logger.info("Read quantity[{}] for item[{}]", result, itemId); return result; } }
ItemBasePersistence extends AbstractBasePersistence<Item, String> implements ItemMapper { @Override public int getInventoryQuantity(@Nonnull final String itemId) { int result = -1; Query query = createNamedQuery("Item.getInventoryQuantity"); query.setParameter("itemId", itemId); @SuppressWarnings("unchecked") List<Integer> quantities = (List<Integer>) query.getResultList(); checkState(quantities.size() <= 1, String.format("Query[Item.getInventoryQuantity]" + "with parameter[%s] returned [%d] results", itemId, quantities.size())); if (quantities.size() == 1) { result = quantities.get(0); } logger.info("Read quantity[{}] for item[{}]", result, itemId); return result; }  }
ItemBasePersistence extends AbstractBasePersistence<Item, String> implements ItemMapper { @Override public int getInventoryQuantity(@Nonnull final String itemId) { int result = -1; Query query = createNamedQuery("Item.getInventoryQuantity"); query.setParameter("itemId", itemId); @SuppressWarnings("unchecked") List<Integer> quantities = (List<Integer>) query.getResultList(); checkState(quantities.size() <= 1, String.format("Query[Item.getInventoryQuantity]" + "with parameter[%s] returned [%d] results", itemId, quantities.size())); if (quantities.size() == 1) { result = quantities.get(0); } logger.info("Read quantity[{}] for item[{}]", result, itemId); return result; }  @Override void updateInventoryQuantity(@Nonnull final Map<String, Object> param); @Override int getInventoryQuantity(@Nonnull final String itemId); @Override List<Item> getItemListByProduct(@Nonnull final String productId); @Override Item getItem(@Nonnull final String itemId); }
ItemBasePersistence extends AbstractBasePersistence<Item, String> implements ItemMapper { @Override public int getInventoryQuantity(@Nonnull final String itemId) { int result = -1; Query query = createNamedQuery("Item.getInventoryQuantity"); query.setParameter("itemId", itemId); @SuppressWarnings("unchecked") List<Integer> quantities = (List<Integer>) query.getResultList(); checkState(quantities.size() <= 1, String.format("Query[Item.getInventoryQuantity]" + "with parameter[%s] returned [%d] results", itemId, quantities.size())); if (quantities.size() == 1) { result = quantities.get(0); } logger.info("Read quantity[{}] for item[{}]", result, itemId); return result; }  @Override void updateInventoryQuantity(@Nonnull final Map<String, Object> param); @Override int getInventoryQuantity(@Nonnull final String itemId); @Override List<Item> getItemListByProduct(@Nonnull final String productId); @Override Item getItem(@Nonnull final String itemId);  }