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

ConstraintVerifier: when the acutal penalty is 0 (long), the error message confuses the user by stating int

    XMLWordPrintable

Details

    Description

      To reproduce, adjust VehicleRoutingConstraintProviderTest to adjust a unit test that a zero score and assert that it has a different score (for example 3000L).

      The error message looks like this:

      java.lang.AssertionError: Broken expectation.
              Constraint: org.optaplanner.examples.vehiclerouting.domain/arrivalAfterDueTime
        Expected penalty: 3000 (class java.lang.Long)
          Actual penalty: 0 (class java.lang.Integer)
      

      At this point, the "(class java.lang.Integer)" is a "red herring". It's very confusing.

      Proposal A)
      Remove "(class ...)" if the score is zero

      Proposal B)
      Fix it properly if possible Have it deduct that it's should say 0 (class java.lang.Long) there.

      In fact, if we use a penalisesBy(int) for a BigDecimalSoftScore, I 'd love to see a second line in the error message that says "Maybe call the correct penalizesBy() overloaded method."
      Look for usages of the word "Maybe" in optaplanner-core error messages. The idea is the first line shows the problem and the second line suggest a solution that might or might not work (hence the word "maybe").

      Attachments

        Activity

          People

            lpetrovi@redhat.com Lukáš Petrovický (Inactive)
            gdesmet@redhat.com Geoffrey De Smet (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: