@Test(expected = NullPointerException.class) public void updateInventoryQuantity_shouldThrowNPEOnNullParamMap() { persistence.updateInventoryQuantity(null); }
@Override public void updateInventoryQuantity(@Nonnull final Map<String, Object> param) { checkNotNull(param, "Argument[param] must not be null"); checkState(param.size() == 2, String.format("Argument[param] has illegal state: size[%d]", param.size())); String itemId = (String) param.get(ITEM_ID.toString()); Integer increment = (Integer) param.get(INCREMENT.toString()); Item item = getItem(itemId); Integer itemQuantity = item.getQuantity(); item.setQuantity(itemQuantity - increment); update(item); logger.info("Updated inventory quantity from [{}] to [{}] for item with id[{}]", itemQuantity, item.getQuantity(), itemId); }
ItemBasePersistence extends AbstractBasePersistence<Item, String> implements ItemMapper { @Override public void updateInventoryQuantity(@Nonnull final Map<String, Object> param) { checkNotNull(param, "Argument[param] must not be null"); checkState(param.size() == 2, String.format("Argument[param] has illegal state: size[%d]", param.size())); String itemId = (String) param.get(ITEM_ID.toString()); Integer increment = (Integer) param.get(INCREMENT.toString()); Item item = getItem(itemId); Integer itemQuantity = item.getQuantity(); item.setQuantity(itemQuantity - increment); update(item); logger.info("Updated inventory quantity from [{}] to [{}] for item with id[{}]", itemQuantity, item.getQuantity(), itemId); } }
ItemBasePersistence extends AbstractBasePersistence<Item, String> implements ItemMapper { @Override public void updateInventoryQuantity(@Nonnull final Map<String, Object> param) { checkNotNull(param, "Argument[param] must not be null"); checkState(param.size() == 2, String.format("Argument[param] has illegal state: size[%d]", param.size())); String itemId = (String) param.get(ITEM_ID.toString()); Integer increment = (Integer) param.get(INCREMENT.toString()); Item item = getItem(itemId); Integer itemQuantity = item.getQuantity(); item.setQuantity(itemQuantity - increment); update(item); logger.info("Updated inventory quantity from [{}] to [{}] for item with id[{}]", itemQuantity, item.getQuantity(), itemId); }  }
ItemBasePersistence extends AbstractBasePersistence<Item, String> implements ItemMapper { @Override public void updateInventoryQuantity(@Nonnull final Map<String, Object> param) { checkNotNull(param, "Argument[param] must not be null"); checkState(param.size() == 2, String.format("Argument[param] has illegal state: size[%d]", param.size())); String itemId = (String) param.get(ITEM_ID.toString()); Integer increment = (Integer) param.get(INCREMENT.toString()); Item item = getItem(itemId); Integer itemQuantity = item.getQuantity(); item.setQuantity(itemQuantity - increment); update(item); logger.info("Updated inventory quantity from [{}] to [{}] for item with id[{}]", itemQuantity, item.getQuantity(), itemId); }  @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 void updateInventoryQuantity(@Nonnull final Map<String, Object> param) { checkNotNull(param, "Argument[param] must not be null"); checkState(param.size() == 2, String.format("Argument[param] has illegal state: size[%d]", param.size())); String itemId = (String) param.get(ITEM_ID.toString()); Integer increment = (Integer) param.get(INCREMENT.toString()); Item item = getItem(itemId); Integer itemQuantity = item.getQuantity(); item.setQuantity(itemQuantity - increment); update(item); logger.info("Updated inventory quantity from [{}] to [{}] for item with id[{}]", itemQuantity, item.getQuantity(), itemId); }  @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);  }