Skip to content
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

Clear givenWhen state after setting the repository for State-Stored Aggregate testing #1896

Merged
merged 1 commit into from
Jul 21, 2021

Conversation

smcvb
Copy link
Member

@smcvb smcvb commented Jul 21, 2021

When using the AggregateTestFixture#givenState method, any events published by invocation of the provided state object are kept.
This might occur for example if the constructor of a state-stored aggregate publishes an event and when the constructor is invoked in the givenState method.
This setup wrongfully adds events published in the given phase to the expect phase.

This pull request fixes that issue by invoking (the private) AggregateTestFixture#clearGivenWhenState after the repository is configured.

By clearing the GivenWhenState after repository configuration, we make
sure any events published in the constructor invoked in the givenState
method are no longer present in the expectEvents phase
@smcvb smcvb added Type: Bug Use to signal issues that describe a bug within the system. Priority 2: Should High priority. Ideally, these issues are part of the release they’re assigned to. Status: In Progress Use to signal this issue is actively worked on. labels Jul 21, 2021
@smcvb smcvb added this to the Release 4.5.4 milestone Jul 21, 2021
@smcvb smcvb self-assigned this Jul 21, 2021
@smcvb smcvb changed the title Clear givenWhen state after setting the repository for GivenState Clear givenWhen state after setting the repository for State-Stored Aggregate testing Jul 21, 2021
@sonarcloud
Copy link

sonarcloud bot commented Jul 21, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

Copy link
Contributor

@lfgcampos lfgcampos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@smcvb smcvb merged commit eaa8966 into axon-4.5.x Jul 21, 2021
@smcvb smcvb deleted the bug/clear-published-events-from-given-state branch July 21, 2021 15:26
@smcvb smcvb added Status: Resolved Use to signal that work on this issue is done. and removed Status: In Progress Use to signal this issue is actively worked on. labels Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority 2: Should High priority. Ideally, these issues are part of the release they’re assigned to. Status: Resolved Use to signal that work on this issue is done. Type: Bug Use to signal issues that describe a bug within the system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants