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

Quarkus/Spring Boot: @Inject/@Autowire ConstraintVerifier

XMLWordPrintable

    • 2021 Week 10-12 (from Mar 8), 2021 Week 13-15 (from Mar 29), 2021 Week 16-18 (from Apr 19), 2021 Week 19-21 (from May 10)
    • 1
    • Undefined
    • NEW
    • NEW

      By not injecting the ConstraintVerifier, we might not be testing it the same way as it's used in production. Let's fix that for Quarkus and Spring Boot.

          // TODO Quarkus should inject ConstraintVerifier so its 100% in sync with the real solver config
          private final ConstraintVerifier<VaccinationScheduleConstraintProvider, VaccinationSchedule> constraintVerifier =
                  ConstraintVerifier.build(new VaccinationScheduleConstraintProvider(), VaccinationSchedule.class, Person.class)
                  // To scale up to 200 000 persons and more
                  .withConstraintStreamImplType(ConstraintStreamImplType.BAVET);
      
          @Test
          void vaccinationSlotCapacity() {
              VaccinationCenter vaccinationCenter = new VaccinationCenter(1L, "Uptown", new Location(0, 0), 1, 3);
              VaccinationSlot vaccinationSlot = new VaccinationSlot(null, vaccinationCenter, null, null, 0, 1, 3);
              constraintVerifier.verifyThat(VaccinationScheduleConstraintProvider::vaccinationSlotCapacity)
                      .given(
                              vaccinationSlot, PFIZER_MONDAY_SLOT,
                              new Person(null, "Ann", null, null, 0, vaccinationSlot),
                              new Person(null, "Beth", null, null, 0, vaccinationSlot),
                              new Person(null, "Carl", null, null, 0, vaccinationSlot),
                              new Person(null, "Dan", null, null, 0, vaccinationSlot),
                              new Person(null, "Ed", null, null, 0, vaccinationSlot),
                              new Person(null, "Flo", null, null, 0, PFIZER_MONDAY_SLOT))
                      .penalizesBy(2);
          }
      

      I think the spring-boot starter needs a optional dependency on optaplanner-test to make this work, which is then a test scope dependency in spring-boot-school-timetabling.

      For quarkus, we either use:

      • A) the same "optional" approach and show that in quarkus-school-timetabling (and kotlin-quarkus-school-timetabling too of course!)... not sure if that works
      • B) Or we make a new module optaplanner-quarkus-test... meh but seems to follow quakrus philosophy, like PLANNER-2341 does.
      • C) Or we merge optaplanner-test into optaplanner-core... veto (optaplanner-core compile scope cannot depend on JUnit)

      Reqs:

      • quarkus + spring boot
      • all quickstarts that use quarkus or spring boot and use a ConstraintVerifier. We will sync the quarkus-quickstarts one later.
      • quarkus guide (over at quarkus repo) + spring boot guide
      • mention injection in docs section constraint streams section testing with ConstraintVerifier

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

                Created:
                Updated:
                Resolved: