This is an automated email from the ASF dual-hosted git repository.

lucamolteni pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-kie-optaplanner.git


The following commit(s) were added to refs/heads/main by this push:
     new 085c0697a3 Fix flaky SolverManagerTest (#3060)
085c0697a3 is described below

commit 085c0697a32f1edbe35e436a28caf413c0e82b8b
Author: Jiří Locker <[email protected]>
AuthorDate: Mon Jan 29 17:48:38 2024 +0100

    Fix flaky SolverManagerTest (#3060)
---
 .../test/java/org/optaplanner/core/api/solver/SolverManagerTest.java  | 4 ++++
 1 file changed, 4 insertions(+)

diff --git 
a/core/optaplanner-core-impl/src/test/java/org/optaplanner/core/api/solver/SolverManagerTest.java
 
b/core/optaplanner-core-impl/src/test/java/org/optaplanner/core/api/solver/SolverManagerTest.java
index 7926a0504f..21b22ff9d8 100644
--- 
a/core/optaplanner-core-impl/src/test/java/org/optaplanner/core/api/solver/SolverManagerTest.java
+++ 
b/core/optaplanner-core-impl/src/test/java/org/optaplanner/core/api/solver/SolverManagerTest.java
@@ -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;
@@ -208,6 +209,9 @@ class SolverManagerTest {
         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);
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to