### Question:
Trade implements Serializable { public Order operate(int index) { return operate(index, NaN, NaN); } Trade();  Trade(OrderType startingType);  Trade(OrderType startingType, CostModel transactionCostModel, CostModel holdingCostModel);  Trade(Order entry, Order exit);  Trade(Order entry, Order exit, CostModel transactionCostModel, CostModel holdingCostModel); Order getEntry(); Order getExit(); @Override boolean equals(Object obj); @Override int hashCode(); Order operate(int index); Order operate(int index, Num price, Num amount); boolean isClosed(); boolean isOpened(); boolean isNew(); @Override String toString(); Num getProfit(); Num getProfit(int finalIndex, Num finalPrice); Num getTradeCost(int finalIndex); Num getTradeCost(); Num getHoldingCost(); Num getHoldingCost(int finalIndex);  }### Answer:
@Test(expected = IllegalStateException.class) public void whenExitIndexIsLessThanEntryIndexShouldThrowException() { newTrade.operate(3); newTrade.operate(1); }
@Test public void testEqualsForEntryOrders() { Trade trLeft = newTrade; Trade trRightEquals = new Trade(); Trade trRightNotEquals = new Trade(); assertEquals(OrderType.BUY, trRightNotEquals.operate(2).getType()); assertNotEquals(trLeft, trRightNotEquals); assertEquals(OrderType.BUY, trLeft.operate(1).getType()); assertEquals(OrderType.BUY, trRightEquals.operate(1).getType()); assertEquals(trLeft, trRightEquals); assertNotEquals(trLeft, trRightNotEquals); }
@Test public void testEqualsForExitOrders() { Trade trLeft = newTrade; Trade trRightEquals = new Trade(); Trade trRightNotEquals = new Trade(); assertEquals(OrderType.BUY, trLeft.operate(1).getType()); assertEquals(OrderType.BUY, trRightEquals.operate(1).getType()); assertEquals(OrderType.BUY, trRightNotEquals.operate(1).getType()); assertEquals(OrderType.SELL, trRightNotEquals.operate(3).getType()); assertNotEquals(trLeft, trRightNotEquals); assertEquals(OrderType.SELL, trLeft.operate(2).getType()); assertEquals(OrderType.SELL, trRightEquals.operate(2).getType()); assertEquals(trLeft, trRightEquals); assertNotEquals(trLeft, trRightNotEquals); }