### Question:
Order extends AggregateRoot<OrderId> { public void place(OrderId orderId, CustomerInformation customerInformation, List<OrderLine> orderLines, long totalAmount) { assertHasNotBeenPlaced(); assertMoreThanZeroOrderLines(orderLines); applyChange(new OrderPlacedEvent(orderId, nextVersion(), now(), toCustomerInformation(customerInformation), toOrderLines(orderLines), totalAmount)); }  void place(OrderId orderId, CustomerInformation customerInformation, List<OrderLine> orderLines, long totalAmount); void activate();  }### Answer:
@Test public void placingAnOrder() { Order order = new Order(); OrderLine orderLine = new OrderLine(ProductId.<BookId>randomId(), "title", 10, 200L); order.place(OrderId.<OrderId>randomId(), JOHN_DOE, asList(orderLine), 2000L); List<DomainEvent> uncommittedEvents = order.getUncommittedEvents(); assertThat(uncommittedEvents.size(), is(1)); assertThat(order.version(), is(1)); assertThat(getOnlyElement(uncommittedEvents), instanceOf(OrderPlacedEvent.class)); }
@Test(expected = IllegalArgumentException.class) public void requireOrderLinesWhenPlacingAnOrder() { Order order = new Order(); order.place(OrderId.<OrderId>randomId(), JOHN_DOE, Collections.<OrderLine>emptyList(), 2000L); }
@Test(expected = IllegalStateException.class) public void cannotPlaceAnOrderTwice() { OrderLine orderLine = new OrderLine(ProductId.<BookId>randomId(), "title", 10, 200L); Order order = new Order(); order.place(randomId(), JOHN_DOE, asList(orderLine), 2000L); order.place(randomId(), JOHN_DOE, asList(orderLine), 2000L); }