I’m having some trouble testing a saga and thought that I might get some hints…
It looks like this:
AggregateA -> AEvent
-> Saga starts, associationProperty = EventA.id
-> Saga sends a list of CreateB commands, for each command it stores CreateB.id (which is generated in the saga, a random string) in a list so that it can later know if all new B’s are created.
AggregateB -> BCreatedEvent
-> Saga handles the event and removes BCreatedEvent.id from the list of ids it is waiting for.
-> Saga publishes AllBCreatedEvent if there are no more ids in the list
-> Saga ends if there are no more ids in the list
Now to my problem. The test does not know which ids are generated in the saga when it dispatches CreateB commands, so I can’t check that the right commands are dispatched and I can’t generate the events that the saga should react to to end itself.