feat: implement direct testing of score/impact of constraints#2306
Merged
triceo merged 3 commits intoMay 14, 2026
Merged
Conversation
triceo
reviewed
May 14, 2026
Collaborator
triceo
left a comment
There was a problem hiding this comment.
I agree that the solution presented here is the better of the proposals.
Let's mention this feature in the docs where we talk about constraint testing - I envision a new subsection, something to the tune to "Employing custom assertions", showing how to use this feature with AssertJ. (Much like the Javadoc snippets already do.)
…straint testing in test API
triceo
approved these changes
May 14, 2026
Collaborator
|
Thanks, @PatrickDiallo23! |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



This PR is introducing the capability to get the score/impact of the constraints given a set of entities or an entire solution addressing the #2007 .
Even though it was proposed to add in
ConstraintVerifierthe getScore and getImpact methods, I observed that it was counterintuitive for the user to use such methods because it would change the chaining method (also making the implementation more complex than it should be) toconstraintVerifier.getScore().forConstraint(constraint).given(entities).I was thinking of providing a new chaining to obtain the score like
constraintVerifier.evaluate(constraint).given(entities).score(), whereevaluate()would be the same asverifyThat()resulting in duplicated code which is not a good idea.So I used the solution provided by the author of the issue, which is the most efficient and straightforward solution that allows writing custom assertions to compare different solutions or subsets of solutions.