Final project: a composed shipping system
Builder, State/FSM, Command/undo, Observer, and Strategy working together in one shipment dispatch center.
The final project composes the patterns the book taught into one working shipping
dispatch center: a ShipmentBuilder (Builder) resolves a RateStrategy per carrier,
a Shipment is both the State-machine context and the Observer subject, undoable
ShipmentCommands drive it through its lifecycle with a CommandHistory, and status
listeners react to events. Each pattern answers one named force.
The JUnit 5 + AssertJ (+ Mockito) tests prove the composed behavior end to end:
building, the lifecycle (illegal transitions refused), command undo restoring state,
a strategy swap, and observers seeing events, with an InOrder integration test.
Build, run, observe
cd examples/33-final-project
mvn -q test
./demo.sh
The module also runs from the aggregator root with
mvn -q -f examples/pom.xml test.