-
Bug
-
Resolution: Done
-
Optional
-
None
-
None
-
2021 Week 07-09 (from Feb 15)
-
2
-
Undefined
-
NEW
-
NEW
With 8.2.0.Final (this might already be solved in 8.3, in which case just close this issue), I got this error message:
java.lang.IllegalStateException: The matchWeigher of UniConstraintStream.penalize(matchWeigher) of the constraint (org.acme.vaccinationscheduler.domain/Second dose must be assigned) must return a long. at org.optaplanner.core.impl.score.stream.bavet.uni.BavetScoringUniConstraintStream.createNode(BavetScoringUniConstraintStream.java:139) at org.optaplanner.core.impl.score.stream.bavet.uni.BavetScoringUniConstraintStream.createNode(BavetScoringUniConstraintStream.java:39) at org.optaplanner.core.impl.score.stream.bavet.uni.BavetAbstractUniConstraintStream.createNodeChain(BavetAbstractUniConstraintStream.java:297) at org.optaplanner.core.impl.score.stream.bavet.uni.BavetAbstractUniConstraintStream.createChildNodeChains(BavetAbstractUniConstraintStream.java:322) at org.optaplanner.core.impl.score.stream.bavet.uni.BavetAbstractUniConstraintStream.createNodeChain(BavetAbstractUniConstraintStream.java:299) at org.optaplanner.core.impl.score.stream.bavet.uni.BavetAbstractUniConstraintStream.createChildNodeChains(BavetAbstractUniConstraintStream.java:322) at org.optaplanner.core.impl.score.stream.bavet.uni.BavetAbstractUniConstraintStream.createNodeChain(BavetAbstractUniConstraintStream.java:299) at org.optaplanner.core.impl.score.stream.bavet.uni.BavetAbstractUniConstraintStream.createChildNodeChains(BavetAbstractUniConstraintStream.java:322) at org.optaplanner.core.impl.score.stream.bavet.uni.BavetAbstractUniConstraintStream.createNodeChain(BavetAbstractUniConstraintStream.java:299) at org.optaplanner.core.impl.score.stream.bavet.uni.BavetFromUniConstraintStream.createNodeChain(BavetFromUniConstraintStream.java:50) at org.optaplanner.core.impl.score.stream.bavet.BavetConstraint.createNodes(BavetConstraint.java:51) at org.optaplanner.core.impl.score.stream.bavet.BavetConstraintSession.lambda$new$0(BavetConstraintSession.java:70) at java.base/java.util.LinkedHashMap.forEach(LinkedHashMap.java:684) at org.optaplanner.core.impl.score.stream.bavet.BavetConstraintSession.<init>(BavetConstraintSession.java:69) at org.optaplanner.core.impl.score.stream.bavet.BavetConstraintSessionFactory.buildSession(BavetConstraintSessionFactory.java:57) at org.optaplanner.core.impl.score.director.stream.ConstraintStreamScoreDirectorFactory.newConstraintStreamingSession(ConstraintStreamScoreDirectorFactory.java:92) at org.optaplanner.test.impl.score.stream.DefaultSingleConstraintVerification.given(DefaultSingleConstraintVerification.java:41) at org.optaplanner.test.impl.score.stream.DefaultSingleConstraintVerification.given(DefaultSingleConstraintVerification.java:28) at org.acme.vaccinationscheduler.solver.VaccinationScheduleConstraintProviderTest.secondDoseMustBeAssigned(VaccinationScheduleConstraintProviderTest.java:213) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:688) at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131) at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84) at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115) at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:210) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:206) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:131) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:65) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at java.base/java.util.ArrayList.forEach(ArrayList.java:1540) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at java.base/java.util.ArrayList.forEach(ArrayList.java:1540) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:143) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:71) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:128)
for this code:
Constraint secondDoseMustBeAssigned(ConstraintFactory constraintFactory) { // If a person is coming for their 2nd dose, assign them to a dose, regardless of their age. return constraintFactory .from(Person.class) .filter(person -> person.getDoseNumber() > 1 && person.getVaccinationSlot() == null) .penalize("Second dose must be assigned", HardMediumSoftLongScore.ONE_HARD, person -> person.getDoseNumber() - 1); } @Test void secondDoseMustBeAssigned() { constraintVerifier.verifyThat(VaccinationScheduleConstraintProvider::secondDoseMustBeAssigned) .given( new Person(null, "Ann", null, null, 0, null), new Person(null, "Carl", null, null, 0, 2, PFIZER, null, null, null, PFIZER_MONDAY_SLOT)) .penalizesBy(0); constraintVerifier.verifyThat(VaccinationScheduleConstraintProvider::secondDoseMustBeAssigned) .given( new Person(null, "Ann", null, null, 0, PFIZER_MONDAY_SLOT), new Person(null, "Carl", null, null, 0, 2, PFIZER, null, null, null, null)) .penalizesBy(1); }
The fix was to use penalizeLong() instead of penalize(), but that might not be clear from the error message.