feat(wcs): add shared domain contracts
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package com.ruoyi.wcs.domain.shared;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
class SharedContractsTest {
|
||||
|
||||
@Test
|
||||
void rejectsBlankEventIdentity() {
|
||||
assertThrows(IllegalArgumentException.class, () ->
|
||||
new DomainEvent("", "ORDER-1", 1L, Instant.EPOCH, "OrderAccepted"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsInvalidEventSequence() {
|
||||
assertThrows(IllegalArgumentException.class, () ->
|
||||
new DomainEvent("E-1", "ORDER-1", 0L, Instant.EPOCH, "OrderAccepted"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void exposesDeterministicEventFields() {
|
||||
Instant occurredAt = Instant.parse("2026-08-04T00:00:00Z");
|
||||
DomainEvent event = new DomainEvent("E-1", "ORDER-1", 2L,
|
||||
occurredAt, "OrderPlanned");
|
||||
|
||||
assertEquals("E-1", event.getEventId());
|
||||
assertEquals("ORDER-1", event.getAggregateId());
|
||||
assertEquals(2L, event.getSequence());
|
||||
assertEquals(occurredAt, event.getOccurredAt());
|
||||
assertEquals("OrderPlanned", event.getType());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user