Search in sources :

Example 6 with SolverResponse

use of org.acme.schooltimetabling.message.SolverResponse 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)");
}
Also used : SolverRequest(org.acme.schooltimetabling.message.SolverRequest) TimeTable(org.acme.schooltimetabling.domain.TimeTable) SolverResponse(org.acme.schooltimetabling.message.SolverResponse) Timeslot(org.acme.schooltimetabling.domain.Timeslot) Room(org.acme.schooltimetabling.domain.Room) Lesson(org.acme.schooltimetabling.domain.Lesson) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test) Timeout(org.junit.jupiter.api.Timeout)

Aggregations

SolverResponse (org.acme.schooltimetabling.message.SolverResponse)6 TimeTable (org.acme.schooltimetabling.domain.TimeTable)4 QuarkusTest (io.quarkus.test.junit.QuarkusTest)3 SolverRequest (org.acme.schooltimetabling.message.SolverRequest)3 Test (org.junit.jupiter.api.Test)3 Timeout (org.junit.jupiter.api.Timeout)3 Lesson (org.acme.schooltimetabling.domain.Lesson)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 Room (org.acme.schooltimetabling.domain.Room)1 Timeslot (org.acme.schooltimetabling.domain.Timeslot)1 Acknowledgment (org.eclipse.microprofile.reactive.messaging.Acknowledgment)1 Incoming (org.eclipse.microprofile.reactive.messaging.Incoming)1