@Before public void setUp() { fixture = Fixtures.newGivenWhenThenFixture(ExchangeAggregateRoot.class); exchangeId = new ExchangeId("test-exchange:" + UUID.randomUUID().toString()); ticker = TickerFaker.createValid(); currency = CurrencyFaker.createValid(); tradeableItem = TradeableItemFaker.createValid(); }
@Test public void GET_orderbook() { // Arrange final String exchangeId = "test-exchange"; final String orderId = UUID.randomUUID().toString(); final String orderType = "BID"; final Ticker ticker = TickerFaker.createValid(); TradeableItem tradeableItem = TradeableItemFaker.createValid(); final BigDecimal orderAmount = new BigDecimal("86.75309"); Currency currency = CurrencyFaker.createValid(); final Date orderTimestamp = DateUtils.nowUtc().toDate(); final List<OrderReadModel> expectedOrders = Lists.newArrayList(); expectedOrders.add( new OrderReadModel( ObjectId.get().toString(), orderId, orderType, ticker.getSymbol(), tradeableItem.getSymbol(), orderAmount, currency.getSymbol(), orderTimestamp)); when(readService.fetchOpenOrders(ticker.getSymbol())).thenReturn(expectedOrders); // Act OrderListReadModel actual = client() .resource( "/exchanges/" + exchangeId + "/securities/" + ticker.getSymbol() + "/orderbook") .get(OrderListReadModel.class); // Assert assertThat(actual.getOrders()).isEqualTo(expectedOrders); assertThat(actual.getTicker()).isEqualTo(ticker.getSymbol()); verify(readService, times(1)).fetchOpenOrders(ticker.getSymbol()); }