Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade OptaPlanner to 8.18.0.Final #1083

Merged
merged 1 commit into from
Mar 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion optaplanner-quickstart/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.version>999-SNAPSHOT</quarkus.platform.version>
<optaplanner-quarkus.version>8.16.1.Final</optaplanner-quarkus.version>
<optaplanner-quarkus.version>8.18.0.Final</optaplanner-quarkus.version>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
<docker-plugin.version>0.28.0</docker-plugin.version>
Expand Down Expand Up @@ -91,6 +91,11 @@
<artifactId>optaplanner-quarkus-benchmark</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>

<!-- UI -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
package org.acme.optaplanner.rest;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static io.restassured.RestAssured.get;
import static io.restassured.RestAssured.given;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;

import javax.inject.Inject;
import java.time.Duration;

import org.acme.optaplanner.rest.TimeTableResource;
import org.acme.optaplanner.domain.TimeTable;
import org.acme.optaplanner.domain.Lesson;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.optaplanner.core.api.solver.SolverStatus;

import io.quarkus.test.junit.QuarkusTest;
import io.restassured.http.ContentType;

@QuarkusTest
public class TimeTableResourceTest {

@Inject
TimeTableResource timeTableResource;

@Test
@Timeout(600_000)
public void solveDemoDataUntilFeasible() throws InterruptedException {
timeTableResource.solve();
TimeTable timeTable;
do { // Use do-while to give the solver some time and avoid retrieving an early infeasible solution.
// Quick polling (not a Test Thread Sleep anti-pattern)
// Test is still fast on fast machines and doesn't randomly fail on slow machines.
Thread.sleep(20L);
timeTable = timeTableResource.getTimeTable();
} while (timeTable.getSolverStatus() != SolverStatus.NOT_SOLVING);

assertFalse(timeTable.getLessonList().isEmpty());
for (Lesson lesson : timeTable.getLessonList()) {
assertNotNull(lesson.getTimeslot());
assertNotNull(lesson.getRoom());
}
assertTrue(timeTable.getScore().isFeasible());
given()
.contentType(ContentType.JSON)
.when().post("/timeTable/solve")
.then()
.statusCode(204);

await()
.atMost(Duration.ofMinutes(1))
.pollDelay(Duration.ofSeconds(5))
.pollInterval(Duration.ofSeconds(5))
.until(() -> SolverStatus.NOT_SOLVING.name().equals(get("/timeTable").body().path("solverStatus")));

get("/timeTable").then().assertThat()
.body("solverStatus", equalTo(SolverStatus.NOT_SOLVING.name()))
.body("timeslotList", is(not(empty())))
.body("roomList", is(not(empty())))
.body("lessonList", is(not(empty())))
.body("lessonList.timeslot", not(nullValue()))
.body("lessonList.room", not(nullValue()));
}

}