// 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/OrderLine.java
// public class OrderLine extends TransportObject {
// 
//   public final ProductId productId;
//   public final String title;
//   public final int quantity;
//   public final long unitPrice;
// 
//   public OrderLine(@JsonProperty("productId") ProductId productId,
//                    @JsonProperty("title") String title,
//                    @JsonProperty("quantity") int quantity,
//                    @JsonProperty("unitPrice") long unitPrice) {
//     this.productId = productId;
//     this.title = title;
//     this.quantity = quantity;
//     this.unitPrice = unitPrice;
//   }
// 
// }
// 
// 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;
//   }
// 
// }


import org.joda.time.LocalDate;
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
package se.citerus.cqrs.bookstore.ordercontext.query.sales;




public class OrdersPerDayAggregatorTest {

  private final OrdersPerDayAggregator ordersPerDayAggregator = new OrdersPerDayAggregator();

  @Test
  public void testHandleEvent() {
    OrderPlacedEvent book1 = createOrder(2013, 1, 1);
    OrderPlacedEvent book2 = createOrder(2013, 1, 2);
    OrderPlacedEvent book3 = createOrder(2013, 1, 2);

    ordersPerDayAggregator.handleEvent(book1);
    ordersPerDayAggregator.handleEvent(book2);
    ordersPerDayAggregator.handleEvent(book3);

    assertThat(ordersPerDayAggregator.getOrdersPerDay().toString(), is("{2013-01-01=1, 2013-01-02=2}"));
  }

  private OrderPlacedEvent createOrder(int year, int month, int day) {
    long timestamp = new LocalDate(year, month, day).toDate().getTime();
// 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/OrderLine.java
// public class OrderLine extends TransportObject {
// 
//   public final ProductId productId;
//   public final String title;
//   public final int quantity;
//   public final long unitPrice;
// 
//   public OrderLine(@JsonProperty("productId") ProductId productId,
//                    @JsonProperty("title") String title,
//                    @JsonProperty("quantity") int quantity,
//                    @JsonProperty("unitPrice") long unitPrice) {
//     this.productId = productId;
//     this.title = title;
//     this.quantity = quantity;
//     this.unitPrice = unitPrice;
//   }
// 
// }
// 
// 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/order-query/src/test/java/se/citerus/cqrs/bookstore/ordercontext/query/sales/OrdersPerDayAggregatorTest.java
import org.joda.time.LocalDate;
import org.junit.Test;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderId;
import se.citerus.cqrs.bookstore.ordercontext.order.OrderLine;
import se.citerus.cqrs.bookstore.ordercontext.order.event.OrderPlacedEvent;
import java.util.Collections;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;

package se.citerus.cqrs.bookstore.ordercontext.query.sales;




public class OrdersPerDayAggregatorTest {

  private final OrdersPerDayAggregator ordersPerDayAggregator = new OrdersPerDayAggregator();

  @Test
  public void testHandleEvent() {
    OrderPlacedEvent book1 = createOrder(2013, 1, 1);
    OrderPlacedEvent book2 = createOrder(2013, 1, 2);
    OrderPlacedEvent book3 = createOrder(2013, 1, 2);

    ordersPerDayAggregator.handleEvent(book1);
    ordersPerDayAggregator.handleEvent(book2);
    ordersPerDayAggregator.handleEvent(book3);

    assertThat(ordersPerDayAggregator.getOrdersPerDay().toString(), is("{2013-01-01=1, 2013-01-02=2}"));
  }

  private OrderPlacedEvent createOrder(int year, int month, int day) {
    long timestamp = new LocalDate(year, month, day).toDate().getTime();
    return new OrderPlacedEvent(OrderId.<OrderId>randomId(), 1, timestamp, null, Collections.<OrderLine>emptyList(), 0);