@Test(expected = IllegalStateException.class) public void throwsIllegalStateExceptionWhenUpdatesAnInventoryWithParamWithLessThanTwoKeyValueMappings() { Map<String, Object> param = new HashMap<String, Object>(); persistence.updateInventoryQuantity(param); }
@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()); Query query = createNamedQuery("Item.updateInventoryQuantity"); query.setParameter(ITEM_ID.toString(), itemId); query.setParameter(INCREMENT.toString(), increment); int count = query.executeUpdate(); logger.info("Query[Item.updateInventoryQuantity] with parameters[itemId[{}], " + "quantity[{}]] updated with count[{}]", itemId, increment, count); }
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()); Query query = createNamedQuery("Item.updateInventoryQuantity"); query.setParameter(ITEM_ID.toString(), itemId); query.setParameter(INCREMENT.toString(), increment); int count = query.executeUpdate(); logger.info("Query[Item.updateInventoryQuantity] with parameters[itemId[{}], " + "quantity[{}]] updated with count[{}]", itemId, increment, count); } }
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()); Query query = createNamedQuery("Item.updateInventoryQuantity"); query.setParameter(ITEM_ID.toString(), itemId); query.setParameter(INCREMENT.toString(), increment); int count = query.executeUpdate(); logger.info("Query[Item.updateInventoryQuantity] with parameters[itemId[{}], " + "quantity[{}]] updated with count[{}]", itemId, increment, count); }  }
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()); Query query = createNamedQuery("Item.updateInventoryQuantity"); query.setParameter(ITEM_ID.toString(), itemId); query.setParameter(INCREMENT.toString(), increment); int count = query.executeUpdate(); logger.info("Query[Item.updateInventoryQuantity] with parameters[itemId[{}], " + "quantity[{}]] updated with count[{}]", itemId, increment, count); }  @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()); Query query = createNamedQuery("Item.updateInventoryQuantity"); query.setParameter(ITEM_ID.toString(), itemId); query.setParameter(INCREMENT.toString(), increment); int count = query.executeUpdate(); logger.info("Query[Item.updateInventoryQuantity] with parameters[itemId[{}], " + "quantity[{}]] updated with count[{}]", itemId, increment, count); }  @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);  }