Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Improve error messages from loading YAML files (#637)
This PR improves the loading error messages for YAML files. We now enforce the kebab-case format from version 1.7.0 onwards. This may affect the Spring Boot module as older versions did not enforce kebab-case format.
- Loading branch information
Showing
17 changed files
with
309 additions
and
4 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
32 changes: 32 additions & 0 deletions
32
...nt/src/test/java/ai/timefold/solver/quarkus/TimefoldProcessorMultipleSolversYamlTest.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,32 @@ | ||
package ai.timefold.solver.quarkus; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import ai.timefold.solver.quarkus.rest.TestdataQuarkusSolutionConfigResource; | ||
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; | ||
import io.restassured.RestAssured; | ||
|
||
class TimefoldProcessorMultipleSolversYamlTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(TestdataQuarkusEntity.class, TestdataQuarkusSolution.class, | ||
TestdataQuarkusConstraintProvider.class, TestdataQuarkusSolutionConfigResource.class) | ||
.addAsResource("ai/timefold/solver/quarkus/multiple-solvers/application.yaml", "application.yaml")); | ||
|
||
@Test | ||
void solverProperties() { | ||
String resp = RestAssured.get("/solver-config/seconds-spent-limit").asString(); | ||
assertEquals("secondsSpentLimit=0.06;secondsSpentLimit=0.12", resp); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
.../deployment/src/test/java/ai/timefold/solver/quarkus/TimefoldProcessorSolverYamlTest.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,57 @@ | ||
package ai.timefold.solver.quarkus; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import java.time.Duration; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import ai.timefold.solver.core.api.domain.common.DomainAccessType; | ||
import ai.timefold.solver.core.api.score.buildin.simple.SimpleScore; | ||
import ai.timefold.solver.core.api.solver.SolverFactory; | ||
import ai.timefold.solver.core.config.solver.EnvironmentMode; | ||
import ai.timefold.solver.core.config.solver.SolverConfig; | ||
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; | ||
|
||
class TimefoldProcessorSolverYamlTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest config = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) | ||
.addClasses(TestdataQuarkusEntity.class, TestdataQuarkusSolution.class, | ||
TestdataQuarkusConstraintProvider.class) | ||
.addAsResource("ai/timefold/solver/quarkus/single-solver/application.yaml", "application.yaml")); | ||
|
||
@Inject | ||
SolverConfig solverConfig; | ||
@Inject | ||
SolverFactory<TestdataQuarkusSolution> solverFactory; | ||
|
||
@Test | ||
void solverProperties() { | ||
assertEquals(EnvironmentMode.FULL_ASSERT, solverConfig.getEnvironmentMode()); | ||
assertTrue(solverConfig.getDaemon()); | ||
assertEquals("2", solverConfig.getMoveThreadCount()); | ||
assertEquals(DomainAccessType.REFLECTION, solverConfig.getDomainAccessType()); | ||
assertEquals(null, | ||
solverConfig.getScoreDirectorFactoryConfig().getConstraintStreamImplType()); | ||
|
||
assertNotNull(solverFactory); | ||
} | ||
|
||
@Test | ||
void terminationProperties() { | ||
assertEquals(Duration.ofHours(4), solverConfig.getTerminationConfig().getSpentLimit()); | ||
assertEquals(Duration.ofHours(5), solverConfig.getTerminationConfig().getUnimprovedSpentLimit()); | ||
assertEquals(SimpleScore.of(0).toString(), solverConfig.getTerminationConfig().getBestScoreLimit()); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...eployment/src/test/resources/ai/timefold/solver/quarkus/multiple-solvers/application.yaml
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,10 @@ | ||
quarkus: | ||
timefold: | ||
solver: | ||
solver1: | ||
termination: | ||
spent-limit: 8s | ||
solver2: | ||
termination: | ||
spent-limit: 4s | ||
|
11 changes: 11 additions & 0 deletions
11
...s/deployment/src/test/resources/ai/timefold/solver/quarkus/single-solver/application.yaml
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,11 @@ | ||
quarkus: | ||
timefold: | ||
solver: | ||
environment-mode: FULL_ASSERT | ||
daemon: true | ||
move-thread-count: 2 | ||
domain-access-type: REFLECTION | ||
termination: | ||
spent-limit: 4h | ||
unimproved-spent-limit: 5h | ||
best-score-limit: 0 |
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
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
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
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
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
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
8 changes: 8 additions & 0 deletions
8
.../resources/ai/timefold/solver/spring/boot/autoconfigure/multiple-solvers/application.yaml
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,8 @@ | ||
timefold: | ||
solver: | ||
solver1: | ||
termination: | ||
best-score-limit: 0 | ||
solver2: | ||
termination: | ||
best-score-limit: 0 |
Oops, something went wrong.