Hopefully a quick question – I have a command (enroll) which creates a new Enrollment aggregate and fires an EnrollmentEvent. It seems to me that the caller of the command shouldn’t need to worry about the enrollmentId as that can be created by the commandHandler or aggregate constructor.
However, in testing, I am required to “know” the enrollmentId to create an event to compare to.
@Test
public void testFirstEnroll() {
DateTime startDate = new DateTime(2015, 1, 1, 0, 0);
DateTime endDate = new DateTime(2016, 1, 1, 0, 0);
DateTime eventDate = DateTime.now();
fixture.given()
.when(new EnrollCommand("ClientId1", "Fred", "medical", "insurance-1", startDate, endDate, eventDate))
.expectVoidReturnType()
.expectEvents(new EnrollEvent("ClientId1", "965201A1-2738-42CC-832A-54E896150095", "Fred", "medical", "insurance-1", startDate, endDate, eventDate));
}
I feel there’s something reasonably obvious that I’m missing, either in terms of crafting a matcher or that the command caller will have to provide an ID for a new aggregate.
Thanks, Tim