### Question:
OrderBook { public void cancel(long orderId, long size) { Order order = orders.get(orderId); if (order == null) return; long remainingQuantity = order.getRemainingQuantity(); if (size >= remainingQuantity) return; if (size > 0) { order.resize(size); } else { TreeSet<Order> queue = order.getSide() == Side.BUY ? bids : asks; queue.remove(order); orders.remove(orderId); } listener.cancel(orderId, remainingQuantity - size, size); } OrderBook(OrderBookListener listener); void enter(long orderId, Side side, long price, long size); void cancel(long orderId, long size);  }### Answer:
@Test public void cancel() { book.enter(1, Side.BUY, 1000, 100); book.cancel(1, 0); book.enter(2, Side.SELL, 1000, 100); Event bid = new Add(1, Side.BUY, 1000, 100); Event cancel = new Cancel(1, 100, 0); Event ask = new Add(2, Side.SELL, 1000, 100); assertEquals(asList(bid, cancel, ask), events.collect()); }