@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); }
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)); }
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)); } }
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)); }  }
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(); }
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();  }