@Then("^the following trades are generated:$")
  public void the_following_trades_are_generated(DataTable expectedTradesTable) throws Throwable {
    final List<TradeRow> expectedTrades = expectedTradesTable.asList(TradeRow.class);
    final List<TradeRow> actualTrades =
        FluentIterable.from(generatedTrades).transform(TradeRow.FROM_TRADE).toImmutableList();
    assertEquals(expectedTrades, actualTrades);

    generatedTrades.clear();
  }
  @Given("^the following orders are submitted in this order:$")
  public void the_following_orders_are_submitted_in_this_order(DataTable orderTable)
      throws Throwable {

    final List<OrderEntryRow> orderRows = orderTable.asList(OrderEntryRow.class);
    for (OrderEntryRow orderRow : orderRows) {
      matchingUnit.addOrder(
          new OrderEntry(
              orderRow.side, orderRow.broker, orderRow.quantity, orderRow.getOrderType()));
    }
  }
  @Then("^the book looks like:$")
  public void the_book_looks_like(DataTable expectedBooks) throws Throwable {

    final List<String> headerColumns = new ArrayList<String>(expectedBooks.raw().get(0));
    final int columns = headerColumns.size();
    final int sideSize = columns / 2;
    for (int i = 0; i < columns; i++) {
      headerColumns.set(i, (i < sideSize ? "Buy " : "Sell ") + headerColumns.get(i));
    }

    final List<List<String>> raw = new ArrayList<List<String>>();
    raw.add(headerColumns);
    final List<List<String>> body = expectedBooks.raw().subList(1, expectedBooks.raw().size());
    raw.addAll(body);

    final DataTable montageTable = expectedBooks.toTable(raw);
    final List<MontageRow> rows = montageTable.asList(MontageRow.class);
    final List<OrderBookRow> expectedBids =
        FluentIterable.from(rows)
            .filter(MontageRow.NON_EMPTY_BID)
            .transform(MontageRow.TO_TEST_BID)
            .toImmutableList();
    final List<OrderBookRow> expectedAsks =
        FluentIterable.from(rows)
            .filter(MontageRow.NON_EMPTY_ASK)
            .transform(MontageRow.TO_TEST_ASK)
            .toImmutableList();

    final List<OrderBookRow> actualBuy =
        FluentIterable.from(matchingUnit.getOrders(OrderSide.Buy))
            .transform(OrderBookRow.FROM_Order(matchingUnit))
            .toImmutableList();
    final List<OrderBookRow> actualSell =
        FluentIterable.from(matchingUnit.getOrders(OrderSide.Sell))
            .transform(OrderBookRow.FROM_Order(matchingUnit))
            .toImmutableList();

    assertEquals(expectedBids, actualBuy);
    assertEquals(expectedAsks, actualSell);
  }