Uploaded image for project: 'OptaPlanner'
  1. OptaPlanner
  2. PLANNER-2384

ConstraintVerifier should not force non-null planningIds, but optaplanner-core should

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Do
    • Icon: Minor Minor
    • None
    • 8.4.0.Final
    • optaplanner-test
    • None
    • Undefined
    • NEW
    • NEW

      Current situation:
      ConstraintVerifier enforces unique planningIds of different entity instances. If one is null, that's fine. If two are null, it fails fast, which the error message below.

      Instead, ConstraintVerifier should only enforce unique planningIds for non-null planningIds. For constraints that don't rely on planningId's, it's a PITA to have to invent planningId's.

      java.lang.IllegalStateException: Multiple instances of PlanningEntity-annotated class (PersonAssignment) share the same PlanningId value (null).
      The instances are ([Ann(null), Beth(null)]).
      Make sure that IDs of entities passed into the given(...) method are unique.
      
      	at org.optaplanner.test.impl.score.stream.DefaultSingleConstraintVerification.lambda$assertDistinctPlanningIds$5(DefaultSingleConstraintVerification.java:87)
      	at java.base/java.util.Optional.ifPresent(Optional.java:183)
      	at org.optaplanner.test.impl.score.stream.DefaultSingleConstraintVerification.lambda$assertDistinctPlanningIds$6(DefaultSingleConstraintVerification.java:79)
      	at java.base/java.util.concurrent.ConcurrentHashMap.forEach(ConcurrentHashMap.java:1603)
      	at org.optaplanner.test.impl.score.stream.DefaultSingleConstraintVerification.assertDistinctPlanningIds(DefaultSingleConstraintVerification.java:62)
      	at org.optaplanner.test.impl.score.stream.DefaultSingleConstraintVerification.given(DefaultSingleConstraintVerification.java:95)
      	at org.optaplanner.test.impl.score.stream.DefaultSingleConstraintVerification.given(DefaultSingleConstraintVerification.java:39)
      

              gdesmet@redhat.com Geoffrey De Smet (Inactive)
              gdesmet@redhat.com Geoffrey De Smet (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: