/** {@inheritDoc} */
  @Override
  public Response createStock(Stock stock) {

    // assigns the stock id
    stock.setId(counter.incrementAndGet());
    // saves the stock
    stockMap.put(stock.getId(), stock);
    // creates response
    return Response.created(URI.create("/stocks/" + stock.getId())).build();
  }
  @Override
  public void updateStock(@PathParam("id") long id, Stock stock) {

    Stock current = stockMap.get(id);
    if (current == null) {
      throw new WebApplicationException(Response.Status.NOT_FOUND);
    }

    // updates the stock
    current.setName(stock.getName());
    current.setCode(stock.getCode());
    current.setDate(stock.getDate());
    current.setValue(stock.getValue());
  }
  /** Creates new instance of {@link StockServiceResource} class. */
  public StockServiceResource() {

    // creates test stock
    Stock stock = new Stock();
    stock.setId(1L);
    stock.setName("Acme");
    stock.setCode("ACM");
    stock.setValue(new BigDecimal(37.5D));
    stock.setDate(new Date());

    stockMap.put(stock.getId(), stock);
  }