// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
// 
//   public final T aggregateId;
//   public final int version;
//   public final long timestamp;
// 
//   protected DomainEvent(T aggregateId, int version, long timestamp) {
//     this.aggregateId = aggregateId;
//     this.version = version;
//     this.timestamp = timestamp;
//   }
// 
//   @Override
//   public boolean equals(Object o) {
//     return EqualsBuilder.reflectionEquals(this, o);
//   }
// 
//   @Override
//   public int hashCode() {
//     return HashCodeBuilder.reflectionHashCode(this);
//   }
// 
//   @Override
//   public String toString() {
//     return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
//   }
// 
// }
// 
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/BookId.java
// public class BookId extends GenericId {
// 
//   public BookId(@JsonProperty("id") String id) {
//     super(id);
//   }
// 
//   public static BookId randomId() {
//     return new BookId(UUID.randomUUID().toString());
//   }
// 
// }
// 
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
// 
//   public OrderId(@JsonProperty("id") String id) {
//     super(id);
//   }
// 
//   public static OrderId randomId() {
//     return new OrderId(UUID.randomUUID().toString());
//   }
// 
// }
// 
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
// 
//   public ProductId(@JsonProperty("id") String id) {
//     super(id);
//   }
// 
//   public static ProductId randomId() {
//     return new ProductId(UUID.randomUUID().toString());
//   }
// 
// }
// 
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
// 
//   public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
//                              @JsonProperty("version") int version,
//                              @JsonProperty("timestamp") long timestamp) {
//     super(aggregateId, version, timestamp);
//   }
// 
// }
// 
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
// 
//   public final CustomerInformation customerInformation;
//   public final List<OrderLine> orderLines;
//   public final long orderAmount;
// 
//   public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
//                           @JsonProperty("version") int version,
//                           @JsonProperty("timestamp") long timestamp,
//                           @JsonProperty("customerInformation") CustomerInformation customerInformation,
//                           @JsonProperty("orderLines") List<OrderLine> orderLines,
//                           @JsonProperty("orderAmount") long orderAmount) {
//     super(id, version, timestamp);
//     this.customerInformation = customerInformation;
//     this.orderLines = Collections.unmodifiableList(orderLines);
//     this.orderAmount = orderAmount;
//   }
// 
// }
// 
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public static OrderId randomId() {
//   return new OrderId(UUID.randomUUID().toString());
// }


import org.junit.Test;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.BookId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.List;
import static com.google.common.collect.Iterables.getLast;
import static com.google.common.collect.Iterables.getOnlyElement;
import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderId.randomId;
package se.citerus.cqrs.bookstore.ordercontext.order.domain;




public class OrderTest {

  private static final CustomerInformation JOHN_DOE = new CustomerInformation("John Doe", "john@acme.com", "Highway street 1");

  @Test
  public void placingAnOrder() {
    Order order = new Order();
    OrderLine orderLine = new OrderLine(ProductId.<BookId>randomId(), "title", 10, 200L);
// Path: cqrs-lib/src/main/java/se/citerus/cqrs/bookstore/event/DomainEvent.java
// public abstract class DomainEvent<T extends GenericId> implements Serializable {
// 
//   public final T aggregateId;
//   public final int version;
//   public final long timestamp;
// 
//   protected DomainEvent(T aggregateId, int version, long timestamp) {
//     this.aggregateId = aggregateId;
//     this.version = version;
//     this.timestamp = timestamp;
//   }
// 
//   @Override
//   public boolean equals(Object o) {
//     return EqualsBuilder.reflectionEquals(this, o);
//   }
// 
//   @Override
//   public int hashCode() {
//     return HashCodeBuilder.reflectionHashCode(this);
//   }
// 
//   @Override
//   public String toString() {
//     return ToStringBuilder.reflectionToString(this, SHORT_PREFIX_STYLE);
//   }
// 
// }
// 
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/BookId.java
// public class BookId extends GenericId {
// 
//   public BookId(@JsonProperty("id") String id) {
//     super(id);
//   }
// 
//   public static BookId randomId() {
//     return new BookId(UUID.randomUUID().toString());
//   }
// 
// }
// 
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public class OrderId extends GenericId {
// 
//   public OrderId(@JsonProperty("id") String id) {
//     super(id);
//   }
// 
//   public static OrderId randomId() {
//     return new OrderId(UUID.randomUUID().toString());
//   }
// 
// }
// 
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/ProductId.java
// public class ProductId extends GenericId {
// 
//   public ProductId(@JsonProperty("id") String id) {
//     super(id);
//   }
// 
//   public static ProductId randomId() {
//     return new ProductId(UUID.randomUUID().toString());
//   }
// 
// }
// 
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderActivatedEvent.java
// public class OrderActivatedEvent extends DomainEvent<OrderId> {
// 
//   public OrderActivatedEvent(@JsonProperty("aggregateId") OrderId aggregateId,
//                              @JsonProperty("version") int version,
//                              @JsonProperty("timestamp") long timestamp) {
//     super(aggregateId, version, timestamp);
//   }
// 
// }
// 
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/event/OrderPlacedEvent.java
// public class OrderPlacedEvent extends DomainEvent<OrderId> {
// 
//   public final CustomerInformation customerInformation;
//   public final List<OrderLine> orderLines;
//   public final long orderAmount;
// 
//   public OrderPlacedEvent(@JsonProperty("aggregateId") OrderId id,
//                           @JsonProperty("version") int version,
//                           @JsonProperty("timestamp") long timestamp,
//                           @JsonProperty("customerInformation") CustomerInformation customerInformation,
//                           @JsonProperty("orderLines") List<OrderLine> orderLines,
//                           @JsonProperty("orderAmount") long orderAmount) {
//     super(id, version, timestamp);
//     this.customerInformation = customerInformation;
//     this.orderLines = Collections.unmodifiableList(orderLines);
//     this.orderAmount = orderAmount;
//   }
// 
// }
// 
// Path: order-context-parent/eventbus-contract/src/main/java/se/citerus/cqrs/bookstore/ordercontext/order/OrderId.java
// public static OrderId randomId() {
//   return new OrderId(UUID.randomUUID().toString());
// }


// Path: order-context-parent/order-command/src/test/java/se/citerus/cqrs/bookstore/ordercontext/order/domain/OrderTest.java
import org.junit.Test;
import se.citerus.cqrs.bookstore.event.DomainEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.BookId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.ProductId;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderActivatedEvent;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import java.util.List;
import static com.google.common.collect.Iterables.getLast;
import static com.google.common.collect.Iterables.getOnlyElement;
import static java.util.Arrays.asList;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static se.citerus.cqrs.bookstore.ordercontext.order.OrderId.randomId;

package se.citerus.cqrs.bookstore.ordercontext.order.domain;




public class OrderTest {

  private static final CustomerInformation JOHN_DOE = new CustomerInformation("John Doe", "john@acme.com", "Highway street 1");

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