I have a problem running a test in my test app when using the Axon Server.
The project is at:
https://github.com/antoniosignore/creditcard-ddd
The test is very simple : create a credit card and make purchases.
**CreditCardAggregateTest.java**
Other simpler tests without prior activity are green.
For instance:
@Test
public void test_create_credit_card_with_100_limit() {
testFixture.givenNoPriorActivity()
.when(new IssueCmd("123", "me", 100))
.expectEvents(new IssuedEvt("123", "me", 100));
}
The failing tests are the tests with the given non null:
@Test
public void test_purchase_with_credit_card_with_100_limit() {
final PurchaseCmd purchase = new PurchaseCmd("123", 10);
testFixture
.given(new IssueCmd("123", "me", 100))
.when(purchase)
.expectEvents(new PurchasedEvt("123", 10));
}
And then I get the (sadly) usual error :
org.axonframework.test.AxonAssertionError: The published events do not match the expected events
Expected | Actual |
---|---|
com.sapient.demo.creditcard.api.PurchasedEvt < | > |
A probable cause for the wrong chain of events is an exception that occurred while handling the command.
org.axonframework.eventsourcing.IncompatibleAggregateException: Aggregate identifier must be non-null after applying an event. Make sure the aggregate identifier is initialized at the latest when handling the creation event.
The starting point for the demo is your giftcard demo taken off your github account.
That project does not present any unit test so I could not get any working example.
thanks