### Question:
TradingRecord implements Serializable { public final void operate(int index) { operate(index, Decimal.NaN, Decimal.NaN); } TradingRecord();  TradingRecord(OrderType entryOrderType);  TradingRecord(Order... orders); Trade getCurrentTrade(); final void operate(int index); final void operate(int index, Decimal price, Decimal amount); final boolean enter(int index); final boolean enter(int index, Decimal price, Decimal amount); final boolean exit(int index); final boolean exit(int index, Decimal price, Decimal amount); boolean isClosed(); List<Trade> getTrades(); int getTradeCount(); Trade getLastTrade(); Order getLastOrder(); Order getLastOrder(OrderType orderType); Order getLastEntry(); Order getLastExit();  }### Answer:
@Test public void operate() { TradingRecord record = new TradingRecord(); record.operate(1); assertTrue(record.getCurrentTrade().isOpened()); assertEquals(0, record.getTradeCount()); assertNull(record.getLastTrade()); assertEquals(Order.buyAt(1), record.getLastOrder()); assertEquals(Order.buyAt(1), record.getLastOrder(Order.OrderType.BUY)); assertNull(record.getLastOrder(Order.OrderType.SELL)); assertEquals(Order.buyAt(1), record.getLastEntry()); assertNull(record.getLastExit()); record.operate(3); assertTrue(record.getCurrentTrade().isNew()); assertEquals(1, record.getTradeCount()); assertEquals(new Trade(Order.buyAt(1), Order.sellAt(3)), record.getLastTrade()); assertEquals(Order.sellAt(3), record.getLastOrder()); assertEquals(Order.buyAt(1), record.getLastOrder(Order.OrderType.BUY)); assertEquals(Order.sellAt(3), record.getLastOrder(Order.OrderType.SELL)); assertEquals(Order.buyAt(1), record.getLastEntry()); assertEquals(Order.sellAt(3), record.getLastExit()); record.operate(5); assertTrue(record.getCurrentTrade().isOpened()); assertEquals(1, record.getTradeCount()); assertEquals(new Trade(Order.buyAt(1), Order.sellAt(3)), record.getLastTrade()); assertEquals(Order.buyAt(5), record.getLastOrder()); assertEquals(Order.buyAt(5), record.getLastOrder(Order.OrderType.BUY)); assertEquals(Order.sellAt(3), record.getLastOrder(Order.OrderType.SELL)); assertEquals(Order.buyAt(5), record.getLastEntry()); assertEquals(Order.sellAt(3), record.getLastExit()); }