@Override public OrderBookRow apply(final MontageRow input) { final OrderBookRow orderRow = new OrderBookRow(); orderRow.side = OrderSide.Sell; orderRow.broker = input.sellBroker; orderRow.price = input.sellPrice; orderRow.quantity = input.sellQuantity; return orderRow; }
@Then("^the book is empty$") public void the_book_is_empty() throws Throwable { 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(new ArrayList<OrderBookRow>(), actualBuy); assertEquals(new ArrayList<OrderBookRow>(), actualSell); }
@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); }