Skip to content

Commit

Permalink
extract model class
Browse files Browse the repository at this point in the history
  • Loading branch information
slu-it committed Sep 25, 2024
1 parent 504cd86 commit 7f9221a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
13 changes: 3 additions & 10 deletions src/main/kotlin/application/business/events.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
10 changes: 10 additions & 0 deletions src/main/kotlin/application/business/model.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package application.business

import java.util.UUID

data class Order(
val orderId: UUID,
val customerId: UUID,
val status: OrderStatus,
// etc ..
)
4 changes: 2 additions & 2 deletions src/test/kotlin/application/business/OrderEventTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 7f9221a

Please sign in to comment.