use of org.acme.schooltimetabling.domain.Lesson in project optaplanner-quickstarts by kiegroup.
the class LessonResourceTest method addAndRemove.
@Test
void addAndRemove() {
Lesson lesson = given().when().contentType(ContentType.JSON).body(new Lesson("Test subject", "Test teacher", "test studentGroup")).post("/lessons").then().statusCode(201).extract().as(Lesson.class);
given().when().delete("/lessons/{id}", lesson.getId()).then().statusCode(204);
}
use of org.acme.schooltimetabling.domain.Lesson in project optaplanner-quickstarts by kiegroup.
the class TimeTableResourceTest method solveDemoDataUntilFeasible.
@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 || !timeTable.getScore().isFeasible());
assertFalse(timeTable.getLessonList().isEmpty());
for (Lesson lesson : timeTable.getLessonList()) {
assertNotNull(lesson.getTimeslot());
assertNotNull(lesson.getRoom());
}
assertTrue(timeTable.getScore().isFeasible());
}
use of org.acme.schooltimetabling.domain.Lesson in project optaplanner-quickstarts by kiegroup.
the class TimeTableMessagingHandlerTest method solvingThrowsException.
@Test
@Timeout(TEST_TIMEOUT_SECONDS)
void solvingThrowsException() {
long problemId = 10L;
// OptaPlanner doesn't tolerate a null planningId.
TimeTable timeTableWithIncorrectLesson = new TimeTable(Arrays.asList(new Timeslot(1L, DayOfWeek.MONDAY, LocalTime.NOON, LocalTime.NOON.plusMinutes(30))), Arrays.asList(new Room(1L, "room-A")), Arrays.asList(new Lesson(null, "Math", "A. Touring", "10th grade")));
sendSolverRequest(new SolverRequest(problemId, timeTableWithIncorrectLesson));
SolverResponse solverResponse = receiveSolverResponse(MESSAGE_RECEIVE_TIMEOUT_SECONDS);
assertThat(SolverResponse.ResponseStatus.FAILURE == solverResponse.getResponseStatus());
assertThat(problemId == solverResponse.getProblemId());
assertThat(solverResponse.getErrorInfo().getExceptionClassName()).isEqualTo(IllegalArgumentException.class.getName());
assertThat(solverResponse.getErrorInfo().getExceptionMessage()).startsWith("The planningId (null)");
}
Aggregations