File tree Expand file tree Collapse file tree
axon/src/main/java/com/baeldung/axon Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313import com .baeldung .axon .coreapi .events .OrderConfirmedEvent ;
1414import com .baeldung .axon .coreapi .events .OrderPlacedEvent ;
1515import com .baeldung .axon .coreapi .events .OrderShippedEvent ;
16+ import com .baeldung .axon .coreapi .exceptions .UnconfirmedOrderException ;
1617
1718@ Aggregate
1819public class OrderAggregate {
@@ -34,7 +35,7 @@ public void handle(ConfirmOrderCommand command) {
3435 @ CommandHandler
3536 public void handle (ShipOrderCommand command ) {
3637 if (!orderConfirmed ) {
37- throw new IllegalStateException ( "Cannot ship an order which has not been confirmed yet." );
38+ throw new UnconfirmedOrderException ( );
3839 }
3940
4041 apply (new OrderShippedEvent (orderId ));
@@ -43,12 +44,12 @@ public void handle(ShipOrderCommand command) {
4344 @ EventSourcingHandler
4445 public void on (OrderPlacedEvent event ) {
4546 this .orderId = event .getOrderId ();
46- orderConfirmed = false ;
47+ this . orderConfirmed = false ;
4748 }
4849
4950 @ EventSourcingHandler
5051 public void on (OrderConfirmedEvent event ) {
51- orderConfirmed = true ;
52+ this . orderConfirmed = true ;
5253 }
5354
5455 protected OrderAggregate () {
Original file line number Diff line number Diff line change 1+ package com .baeldung .axon .coreapi .exceptions ;
2+
3+ public class UnconfirmedOrderException extends IllegalStateException {
4+
5+ public UnconfirmedOrderException () {
6+ super ("Cannot ship an order which has not been confirmed yet." );
7+ }
8+ }
You can’t perform that action at this time.
0 commit comments