diff --git a/optaplanner-test/src/main/java/org/optaplanner/test/impl/score/stream/DefaultSingleConstraintAssertion.java b/optaplanner-test/src/main/java/org/optaplanner/test/impl/score/stream/DefaultSingleConstraintAssertion.java index e825b6ab657..3ee4bd76557 100644 --- a/optaplanner-test/src/main/java/org/optaplanner/test/impl/score/stream/DefaultSingleConstraintAssertion.java +++ b/optaplanner-test/src/main/java/org/optaplanner/test/impl/score/stream/DefaultSingleConstraintAssertion.java @@ -235,9 +235,9 @@ private long determineMatchCount(ScoreImpactType scoreImpactType) { if (actualImpactType == ScoreImpactType.MIXED) { boolean isImpactPositive = constraintMatchTotal.getScore().compareTo(zeroScore) > 0; boolean isImpactNegative = constraintMatchTotal.getScore().compareTo(zeroScore) < 0; - if (isImpactPositive && scoreImpactType == ScoreImpactType.PENALTY) { + if (isImpactPositive && scoreImpactType == ScoreImpactType.REWARD) { return constraintMatchTotal.getConstraintMatchSet().size(); - } else if (isImpactNegative && scoreImpactType == ScoreImpactType.REWARD) { + } else if (isImpactNegative && scoreImpactType == ScoreImpactType.PENALTY) { return constraintMatchTotal.getConstraintMatchSet().size(); } else { return 0; diff --git a/optaplanner-test/src/test/java/org/optaplanner/test/api/score/stream/SingleConstraintAssertionTest.java b/optaplanner-test/src/test/java/org/optaplanner/test/api/score/stream/SingleConstraintAssertionTest.java index 6ff5a887503..5aff3855bac 100644 --- a/optaplanner-test/src/test/java/org/optaplanner/test/api/score/stream/SingleConstraintAssertionTest.java +++ b/optaplanner-test/src/test/java/org/optaplanner/test/api/score/stream/SingleConstraintAssertionTest.java @@ -72,21 +72,21 @@ void impacts() { .penalizes(0, "There should be no penalties")) .doesNotThrowAnyException(); assertThatCode(() -> constraintVerifier.verifyThat(TestdataConstraintVerifierConstraintProvider::impactEveryEntity) - .given(new TestdataConstraintVerifierFirstEntity("A", new TestdataValue())) + .given(new TestdataConstraintVerifierFirstEntity("PENALIZE", new TestdataValue())) .penalizes(0, "There should be no penalties")) .hasMessageContaining("There should be no penalties") .hasMessageContaining("Expected penalty"); assertThatCode(() -> constraintVerifier.verifyThat(TestdataConstraintVerifierConstraintProvider::impactEveryEntity) - .given(new TestdataConstraintVerifierFirstEntity("A", new TestdataValue())) + .given(new TestdataConstraintVerifierFirstEntity("PENALIZE", new TestdataValue())) .penalizes(1, "There should be penalties")) .doesNotThrowAnyException(); assertThatCode(() -> constraintVerifier.verifyThat(TestdataConstraintVerifierConstraintProvider::impactEveryEntity) - .given(new TestdataConstraintVerifierFirstEntity("A", new TestdataValue())) + .given(new TestdataConstraintVerifierFirstEntity("PENALIZE", new TestdataValue())) .penalizes(2, "There should only be one penalty")) .hasMessageContaining("There should only be one penalty") .hasMessageContaining("Expected penalty"); assertThatCode(() -> constraintVerifier.verifyThat(TestdataConstraintVerifierConstraintProvider::impactEveryEntity) - .given(new TestdataConstraintVerifierFirstEntity("A", new TestdataValue())) + .given(new TestdataConstraintVerifierFirstEntity("PENALIZE", new TestdataValue())) .rewards(1, "There should not be rewards")) .hasMessageContaining("There should not be rewards") .hasMessageContaining("Expected reward"); @@ -96,21 +96,21 @@ void impacts() { .rewards(0, "There should be no rewards")) .doesNotThrowAnyException(); assertThatCode(() -> constraintVerifier.verifyThat(TestdataConstraintVerifierConstraintProvider::impactEveryEntity) - .given(new TestdataConstraintVerifierFirstEntity("B", new TestdataValue())) + .given(new TestdataConstraintVerifierFirstEntity("REWARD", new TestdataValue())) .rewards(0, "There should be no rewards")) .hasMessageContaining("There should be no rewards") .hasMessageContaining("Expected reward"); assertThatCode(() -> constraintVerifier.verifyThat(TestdataConstraintVerifierConstraintProvider::impactEveryEntity) - .given(new TestdataConstraintVerifierFirstEntity("B", new TestdataValue())) + .given(new TestdataConstraintVerifierFirstEntity("REWARD", new TestdataValue())) .rewards(1, "There should be rewards")) .doesNotThrowAnyException(); assertThatCode(() -> constraintVerifier.verifyThat(TestdataConstraintVerifierConstraintProvider::impactEveryEntity) - .given(new TestdataConstraintVerifierFirstEntity("B", new TestdataValue())) + .given(new TestdataConstraintVerifierFirstEntity("REWARD", new TestdataValue())) .rewards(2, "There should only be one reward")) .hasMessageContaining("There should only be one reward") .hasMessageContaining("Expected reward"); assertThatCode(() -> constraintVerifier.verifyThat(TestdataConstraintVerifierConstraintProvider::impactEveryEntity) - .given(new TestdataConstraintVerifierFirstEntity("B", new TestdataValue())) + .given(new TestdataConstraintVerifierFirstEntity("REWARD", new TestdataValue())) .penalizes(1, "There should not be penalties")) .hasMessageContaining("There should not be penalties") .hasMessageContaining("Expected penalty"); @@ -123,21 +123,21 @@ void impactsBy() { .penalizesBy(0, "There should no penalties")) .doesNotThrowAnyException(); assertThatCode(() -> constraintVerifier.verifyThat(TestdataConstraintVerifierConstraintProvider::impactEveryEntity) - .given(new TestdataConstraintVerifierFirstEntity("A", new TestdataValue())) + .given(new TestdataConstraintVerifierFirstEntity("PENALIZE", new TestdataValue())) .penalizesBy(0, "There should be no penalties")) .hasMessageContaining("There should be no penalties") .hasMessageContaining("Expected penalty"); assertThatCode(() -> constraintVerifier.verifyThat(TestdataConstraintVerifierConstraintProvider::impactEveryEntity) - .given(new TestdataConstraintVerifierFirstEntity("A", new TestdataValue())) + .given(new TestdataConstraintVerifierFirstEntity("PENALIZE", new TestdataValue())) .penalizesBy(1, "There should be penalties")) .doesNotThrowAnyException(); assertThatCode(() -> constraintVerifier.verifyThat(TestdataConstraintVerifierConstraintProvider::impactEveryEntity) - .given(new TestdataConstraintVerifierFirstEntity("A", new TestdataValue())) + .given(new TestdataConstraintVerifierFirstEntity("PENALIZE", new TestdataValue())) .penalizesBy(2, "There should only be one penalty")) .hasMessageContaining("There should only be one penalty") .hasMessageContaining("Expected penalty"); assertThatCode(() -> constraintVerifier.verifyThat(TestdataConstraintVerifierConstraintProvider::impactEveryEntity) - .given(new TestdataConstraintVerifierFirstEntity("A", new TestdataValue())) + .given(new TestdataConstraintVerifierFirstEntity("PENALIZE", new TestdataValue())) .rewardsWith(1, "There should not be rewards")) .hasMessageContaining("There should not be rewards") .hasMessageContaining("Expected reward"); @@ -147,21 +147,21 @@ void impactsBy() { .rewardsWith(0, "There should no rewards")) .doesNotThrowAnyException(); assertThatCode(() -> constraintVerifier.verifyThat(TestdataConstraintVerifierConstraintProvider::impactEveryEntity) - .given(new TestdataConstraintVerifierFirstEntity("B", new TestdataValue())) + .given(new TestdataConstraintVerifierFirstEntity("REWARD", new TestdataValue())) .rewardsWith(0, "There should be no rewards")) .hasMessageContaining("There should be no rewards") .hasMessageContaining("Expected reward"); assertThatCode(() -> constraintVerifier.verifyThat(TestdataConstraintVerifierConstraintProvider::impactEveryEntity) - .given(new TestdataConstraintVerifierFirstEntity("B", new TestdataValue())) + .given(new TestdataConstraintVerifierFirstEntity("REWARD", new TestdataValue())) .rewardsWith(1, "There should be rewards")) .doesNotThrowAnyException(); assertThatCode(() -> constraintVerifier.verifyThat(TestdataConstraintVerifierConstraintProvider::impactEveryEntity) - .given(new TestdataConstraintVerifierFirstEntity("B", new TestdataValue())) + .given(new TestdataConstraintVerifierFirstEntity("REWARD", new TestdataValue())) .rewardsWith(2, "There should only be one reward")) .hasMessageContaining("There should only be one reward") .hasMessageContaining("Expected reward"); assertThatCode(() -> constraintVerifier.verifyThat(TestdataConstraintVerifierConstraintProvider::impactEveryEntity) - .given(new TestdataConstraintVerifierFirstEntity("B", new TestdataValue())) + .given(new TestdataConstraintVerifierFirstEntity("REWARD", new TestdataValue())) .penalizesBy(1, "There should not be penalties")) .hasMessageContaining("There should not be penalties") .hasMessageContaining("Expected penalty"); diff --git a/optaplanner-test/src/test/java/org/optaplanner/test/api/score/stream/testdata/TestdataConstraintVerifierConstraintProvider.java b/optaplanner-test/src/test/java/org/optaplanner/test/api/score/stream/testdata/TestdataConstraintVerifierConstraintProvider.java index 09b89124740..605f14343d6 100644 --- a/optaplanner-test/src/test/java/org/optaplanner/test/api/score/stream/testdata/TestdataConstraintVerifierConstraintProvider.java +++ b/optaplanner-test/src/test/java/org/optaplanner/test/api/score/stream/testdata/TestdataConstraintVerifierConstraintProvider.java @@ -53,7 +53,7 @@ public Constraint rewardEveryEntity(ConstraintFactory constraintFactory) { public Constraint impactEveryEntity(ConstraintFactory constraintFactory) { return constraintFactory.forEach(TestdataConstraintVerifierFirstEntity.class) .impact(HardSoftScore.ofHard(4), - entity -> Objects.equals(entity.getCode(), "A") ? 1 : -1) + entity -> Objects.equals(entity.getCode(), "REWARD") ? 1 : -1) .asConstraint("Impact every standard entity"); }