Skip to content

Commit

Permalink
Fix flaky SolverManagerTest
Browse files Browse the repository at this point in the history
  • Loading branch information
yurloc committed Jan 29, 2024
1 parent 3a817c2 commit 69c4530
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.optaplanner.core.api.solver;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.fail;
Expand Down Expand Up @@ -208,6 +209,9 @@ void exceptionInConsumer() throws InterruptedException {
assertThat(errorInConsumer.get())
.isInstanceOf(IllegalStateException.class)
.hasMessage("exceptionInConsumer");
// Accessing the job's final best solution is necessary to guarantee that the solver is no longer solving.
assertThatCode(solverJob1::getFinalBestSolution).doesNotThrowAnyException();
// Otherwise, the following assertion could fail.
assertThat(solverManager.getSolverStatus(1L)).isEqualTo(NOT_SOLVING);
assertThat(solverJob1.getSolverStatus()).isEqualTo(NOT_SOLVING);
}
Expand Down

0 comments on commit 69c4530

Please sign in to comment.