New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added an option to create a fixture for a state stored aggregate #1772
Conversation
Hey @sascha-eisenmann, happy to see your first contribution! fixture.givenState(() -> new SampleAggregate())
.andGivenCommands(...) I understand your solution allows direct usage of the Well, let me know what you think, and whether you've used the |
…ure a fixture for a state stored aggregate
Hi @smcvb, I already tried the combination of
I could probably use the command handling constructor in the It would be possible, but it would not be as nice as it is for event sourced aggregates. :) I really like the idea of using an additional method like Let me know what you think! |
test/src/main/java/org/axonframework/test/aggregate/AggregateTestFixture.java
Outdated
Show resolved
Hide resolved
Thanks for this reply @sascha-eisenmann. I've left a comment on your changes by the way. And, thanks for providing this pull request by the way! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of comments to go over still. But, looking good so far!
test/src/main/java/org/axonframework/test/aggregate/AggregateTestFixture.java
Outdated
Show resolved
Hide resolved
test/src/main/java/org/axonframework/test/aggregate/AggregateTestFixture.java
Outdated
Show resolved
Hide resolved
test/src/main/java/org/axonframework/test/aggregate/AggregateTestFixture.java
Outdated
Show resolved
Hide resolved
test/src/main/java/org/axonframework/test/aggregate/AggregateTestFixture.java
Outdated
Show resolved
Hide resolved
test/src/main/java/org/axonframework/test/aggregate/AggregateTestFixture.java
Outdated
Show resolved
Hide resolved
test/src/main/java/org/axonframework/test/aggregate/AggregateTestFixture.java
Show resolved
Hide resolved
test/src/main/java/org/axonframework/test/aggregate/FixtureConfiguration.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change you did on the givenNoPriorActivity
method actually let me validate the JavaDoc more thoroughly.
As you can read on the givenNoPriorActivity
method, it is intended to define a start point where no events have been provided yet.
This makes it an event-sourcing specific operation, not something to be used in conjunction with a state-stored aggregate.
Hence, I would like to ask you to keep the givenNoPriorActivity
as is, thus event-sourcing specific.
Sadly enough, my eye didn't immediately fall on the givenCommands
/andGivenCommands
early enough, but they state a similar point as on the givenNoPriorActivity
.
Granted, that is what you're adjusting, which thus warrants an adjustment in the JavaDoc of those methods too.
Furthermore, we'd need to check whether the current implementation of the andGivenCommands(List<?>)
method actually does what you want.
Right now all it does is dispatch the given commands, check if command handling was successful and store the events as the "given events"-set.
This makes it seem like it doesn't do what we need it to do, which is constructing the initial state.
I am pretty confident it does do the trick right now, but it does warrant a little extra investigation in that area if you ask me.
In all, I thus still have some adjustments to ask of you.
So, let me know what you think!
test/src/main/java/org/axonframework/test/aggregate/AggregateTestFixture.java
Show resolved
Hide resolved
I removed the call to Do you think it would be reasonable to update the JavaDoc for |
Hmm, wouldn't hurt indeed actually. It does clarify the process when using the |
I don't think that any more changes to the code will be necessary. Calling In my opinion the only thing to do is updating the JavaDoc of |
I shouldn't be free-wheeling on my mental picture of the implementation and should've instead looked at the changes you made... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small nit, and then we should be done.
test/src/main/java/org/axonframework/test/aggregate/FixtureConfiguration.java
Outdated
Show resolved
Hide resolved
…figuration.java Co-authored-by: Steven van Beelen <steven.vanbeelen@axoniq.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concerns have been addressed, hence approving.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
test/src/test/java/org/axonframework/test/aggregate/FixtureTest_StateStorage.java
Outdated
Show resolved
Hide resolved
I'm not entirely sure, but I think the build is failing at the Sonar scan. java.lang.IllegalStateException: You're not authorized to run analysis. Please contact the project administrator. Any ideas what is causing this problem? |
That's the current set up of the GitHub Actions I'm afraid. For now, though, I'll base myself on the fact that the JDK 8 build succeeds, as that's the Java version used by Axon for releases still. |
Thanks for the contribution on this @sascha-eisenmann! |
Hi @smcvb, I can't see this feature in the v4.5.1 release but it is the master branch. Is this PR reverted somehow in the release? |
That's correct and intended @ahmetavc. The milestone for this issue is targeted towards 4.6.0. The intent for placing this under 4.6.0 and not under 4.5.x., is because this is a feature and not a bug. Another way to test a State-Stored Aggregate is by using the |
Hello Steven @smcvb, Sorry that I have some difficulties to understand the approach you suggested about using Since So the sample you shared in earlier would result in complaint goes After checking the implementation of Could you share some insight or sample on how to setup the fixture properly please? Any advice will be greatly appreciated. Thanks a lot. |
Firstly @sallowdish, I'd like to point to our forum as the place to open threads for questions. Nonetheless, pointing you "to go away" without an answer is bonkers. The testing use case you have is exactly what's not implemented yet. I can tell you, though, that the At any point, I hope this gives some guidance @sallowdish! |
Adds an option to explicitly create an AggregateTestFixture for a state stored aggregate.
This enables the usage of givenCommands() in connection with a constructor handling the command for state stored aggregates.
P.S. Since this is my first PR to this repository, I would be grateful for any feedback or comments.