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:
-
A Repository must be able to provide the next available identity, or
Reffor an Aggregate. -
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
-
KitchenOrderhas an associatedKitchenOrderReftype. Complete its implementation. Look for hints in theReftypes found in the Ordering and Payments contexts. -
Pizzahas an associatedPizzaReftype. Complete its implementation. Look for hints in theReftypes found in the Ordering and Payments contexts. -
KitchenOrderhas an internal static class calledOrderStatethat captures the initial state snapshot for theKitchenOrder. It is returned by thestate()method. Complete these implementations. Look for hints in theAggregatetypes found in the Ordering and Payments contexts. -
Pizzahas an internal static class calledPizzaStatethat captures the initial state snapshot for thePizza. It is returned by thestate()method. Complete these implementations. Look for hints in theAggregatetypes found in the Ordering and Payments contexts.