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