Reputation: 1358
I have a constraint that uses impactConfigurable
, but the SingleConstraintAssertion
interface only supports testing if a constraint rewards or penalises. For example, I cannot do the following:
constraintVerifier.verifyThat(myConstraint).given(obj1, obj2).impactsBy(1);
or
constraintVerifier.verifyThat(myConstraint).given(obj1, obj2).impactsBy(-1);
Is there a way around this?
I am using OptaPlanner version 8.25.0.Final.
Upvotes: 0
Views: 139
Reputation: 5702
That is by design. Regardless of whether your constraint does penalize, reward or impact, the end result still is either a penalty or a reward. Therefore in your tests, you are expected to specify the expected outcome. For example, if you expect a negative impact, you are, in fact, expecting a penalty:
constraintVerifier.verifyThat(myConstraint).given(obj1, obj2).penalizesBy(1);
As a side note: we are really curious what constraints in the real world actually require the use of impact()
instead of penalize()
or reward()
. We were not able to think of any realistic constraint that would be positive and negative at the same time.
Upvotes: 1