Lab 3 - TDD Aggregate Repository - Create Kitchen Repositories and Add Domain Events

When persisting Aggregate instances using Event Sourcing, we persist an "Add Event" rather than the instance itself. This event will contain the initial state snapshot on which we will apply all subsequent events to "rehydrate" the current state of the object.

In this lab, we’ll begin filling in the details necessary for a Repository to "add" an Aggregate instance.

We will complete two stories:

  1. A Repository must be able to provide the next available identity, or Ref for an Aggregate.

  2. A Repository must properly construct and publish a RepositoryAddEvent.

You can run com.mattstine.dddworkshop.pizzashop.suites.Lab3Suite to check your progress in this lab.

1. Instructions

  1. KitchenOrder has an associated KitchenOrderRef type. Complete its implementation. Look for hints in the Ref types found in the Ordering and Payments contexts.

  2. Pizza has an associated PizzaRef type. Complete its implementation. Look for hints in the Ref types found in the Ordering and Payments contexts.

  3. KitchenOrder has an internal static class called OrderState that captures the initial state snapshot for the KitchenOrder. It is returned by the state() method. Complete these implementations. Look for hints in the Aggregate types found in the Ordering and Payments contexts.

  4. Pizza has an internal static class called PizzaState that captures the initial state snapshot for the Pizza. It is returned by the state() method. Complete these implementations. Look for hints in the Aggregate types found in the Ordering and Payments contexts.