diff --git a/src/main/kotlin/application/business/events.kt b/src/main/kotlin/application/business/events.kt index 49de224..035886a 100644 --- a/src/main/kotlin/application/business/events.kt +++ b/src/main/kotlin/application/business/events.kt @@ -11,20 +11,13 @@ interface Event { } interface OrderEvent : Event { - val order: OrderData + val order: Order } -data class OrderData( - val orderId: UUID, - val customerId: UUID, - val status: OrderStatus, - // etc .. -) - data class OrderPlaced( override val id: UUID, override val timestamp: Instant, - override val order: OrderData, + override val order: Order, ) : OrderEvent { override fun eventName() = "Order Placed" override fun eventType() = "order.placed" @@ -33,7 +26,7 @@ data class OrderPlaced( data class OrderCanceled( override val id: UUID, override val timestamp: Instant, - override val order: OrderData, + override val order: Order, ) : OrderEvent { override fun eventName() = "Order Canceled" override fun eventType() = "order.canceled" diff --git a/src/main/kotlin/application/business/model.kt b/src/main/kotlin/application/business/model.kt new file mode 100644 index 0000000..e2bc47d --- /dev/null +++ b/src/main/kotlin/application/business/model.kt @@ -0,0 +1,10 @@ +package application.business + +import java.util.UUID + +data class Order( + val orderId: UUID, + val customerId: UUID, + val status: OrderStatus, + // etc .. +) diff --git a/src/test/kotlin/application/business/OrderEventTests.kt b/src/test/kotlin/application/business/OrderEventTests.kt index 0fc5709..1272ee4 100644 --- a/src/test/kotlin/application/business/OrderEventTests.kt +++ b/src/test/kotlin/application/business/OrderEventTests.kt @@ -21,7 +21,7 @@ class OrderEventTests { example = OrderPlaced( id = fromString("3d6fd447-a311-4028-8248-356e3621d450"), timestamp = parse("2024-07-22T12:34:56.789Z"), - order = OrderData( + order = Order( orderId = fromString("a64914f7-7404-4e85-8e1a-778068fae307"), customerId = fromString("ed2a43d7-e49b-408d-8b5f-e2e2305954c2"), status = PLACED @@ -41,7 +41,7 @@ class OrderEventTests { example = OrderCanceled( id = fromString("4c97c099-0c00-4e56-841d-fbfe81770936"), timestamp = parse("2024-07-22T12:34:56.789Z"), - order = OrderData( + order = Order( orderId = fromString("a64914f7-7404-4e85-8e1a-778068fae307"), customerId = fromString("ed2a43d7-e49b-408d-8b5f-e2e2305954c2"), status = PROCESSING