Test sometimes fails: In an event of type [IngredientWeightChanged], the property [ingredientUUID] was not as expected

32 views
Skip to first unread message

Roland Kofler

unread,
Feb 27, 2012, 7:33:01 AM2/27/12
to Axon Framework Users
Looks really like a race condition:

org.axonframework.test.AxonAssertionError: One of the events contained
different values than expected

In an event of type [IngredientWeightChanged], the property
[ingredientUUID] was not as expected.
Expected <bc402926-8b59-4743-88fc-f795753d8209> but got
<a18268c8-2bac-4566-bb9b-ca1f0fff1bf6>

It happens approximately every second test-run. Because I expect two
events IngredientWeightChanged, I think the problem is now and then
the second Event comes first. Might be a bug with Fixture?

Appendix:

My Test

fixture.given(
new ArtisanCreated("",Guild.BAKER),
new RecipeCreated(recipeArId, recipeNameExpected, ownerUUID),
new IngredientInserted(ingredientUUID, name, nutsBefore ,
Allergen.False, 100),
new IngredientInserted(ingredientUUID2, "schnaps", nutsBefore ,
Allergen.False, 100),
new RecipeWeightChanged(nutsTot, 200))
when(new ChangeBakeLoss(recipeUUID, 100))
.expectEvents(
new BakeLossChanged(200, 100),
new IngredientWeightChanged(ingredientUUID, nutsAfter, 50),
new IngredientWeightChanged(ingredientUUID2, nutsAfter, 50),
new RecipeWeightChanged(nutsTot, 100)
);

Allard Buijze

unread,
Feb 27, 2012, 7:40:27 AM2/27/12
to axonfr...@googlegroups.com
Although I'm not ruling out any bugs in the fixture, are you sure that the events you generate are always in the same order?
If you use a HashMap or HashSet to store your ingredients, for example, that could explain the order difference.

Roland Kofler

unread,
Feb 27, 2012, 8:56:43 AM2/27/12
to Axon Framework Users
Indeed it is a HashMap, but does this mean I can't use a HashMap in
the Fixture? If I don't care about the order of events, how do I use
the fixture?

On Feb 27, 1:40 pm, Allard Buijze <bui...@gmail.com> wrote:
> Although I'm not ruling out any bugs in the fixture, are you sure that the
> events you generate are always in the same order?
> If you use a HashMap or HashSet to store your ingredients, for example,
> that could explain the order difference.
>

Roland Kofler

unread,
Feb 27, 2012, 9:55:04 AM2/27/12
to Axon Framework Users
I see it is a matter of matchers. Played with Hamcrest, didn't succeed
even to provide the right generics for a Matcherlist.
Will deffer this problem.
Reply all
Reply to author
Forward
0 new messages