forked from TimefoldAI/timefold-solver
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Add fail-fast when node sharing is enabled in SolverConfig inste…
…ad of application.properties (TimefoldAI#766)
- Loading branch information
1 parent
bc2d5a2
commit 6da1776
Showing
3 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...nt/src/test/java/ai/timefold/solver/quarkus/TimefoldProcessorNodeSharingFailFastTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package ai.timefold.solver.quarkus; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import ai.timefold.solver.quarkus.testdata.normal.constraints.TestdataQuarkusConstraintProvider; | ||
import ai.timefold.solver.quarkus.testdata.normal.domain.TestdataQuarkusEntity; | ||
import ai.timefold.solver.quarkus.testdata.normal.domain.TestdataQuarkusSolution; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class TimefoldProcessorNodeSharingFailFastTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.overrideConfigKey("quarkus.timefold.solver-config-xml", | ||
"ai/timefold/solver/quarkus/solverConfigWithNodeSharing.xml") | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(TestdataQuarkusEntity.class, | ||
TestdataQuarkusSolution.class, TestdataQuarkusConstraintProvider.class) | ||
.addAsResource("ai/timefold/solver/quarkus/solverConfigWithNodeSharing.xml")) | ||
.assertException(exception -> { | ||
assertThat(exception).isInstanceOf(IllegalStateException.class) | ||
.hasMessageContainingAll( | ||
"enabled automatic node sharing via SolverConfig, which is not allowed.", | ||
"Enable automatic node sharing with the property", | ||
"quarkus.timefold.solver.constraint-stream-automatic-node-sharing=true"); | ||
}); | ||
|
||
@Test | ||
void test() { | ||
fail("Should not call this method."); | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
.../deployment/src/test/resources/ai/timefold/solver/quarkus/solverConfigWithNodeSharing.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<solver xmlns="https://timefold.ai/xsd/solver" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="https://timefold.ai/xsd/solver https://timefold.ai/xsd/solver/solver.xsd"> | ||
<scoreDirectorFactory> | ||
<constraintStreamAutomaticNodeSharing>true</constraintStreamAutomaticNodeSharing> | ||
</scoreDirectorFactory> | ||
</solver> |