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

ScoreVerifier to test ConstraintProvider: easy to use

XMLWordPrintable

    • 2020 Week 10-12 (from Mar 2), 2020 Week 13-15 (from Mar 23), 2020 Week 16-18 (from Apr 13)
    • 5
    • NEW
    • NEW

      Reqs

      • ScoreVerifier must ignore constraintWeight
      • Only for ConstraintStreams
        • DRL and EasySC will cause leaky abstraction:
          • EasySC doesn’t have justification
          • DRL hardcodes constraint names
      class MyConstraintProvider extends … {
      
         Constraint[] createConstraints() { ….}
      
        Constraint teacherConflict(ConstraintFactory factory) {
          return factory.from(Lecture.class).join(...).penalize();
        }
        Constraint roomConflict(ConstraintFactory factory) {
          return factory.from(Lecture.class).join(...).penalize();
        }
      
      }
      
      class MyConstraintProviderTest {
      
        @Test
        public void teacherConflict() {
           ScoreVerifier.of(MyConstraintProvider::teacherConflict)
      	.withData(Ann, Beth, Carl)
                  .returns(Ann, Beth);
                  .returns(Ann matchWeight == 4, Beth matchWeight == 7
        }
      
      }
      
      

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

                Created:
                Updated:
                Resolved: