Skip to content

Commit

Permalink
chore: Simplify reflect-config.json and add a large spring native XML…
Browse files Browse the repository at this point in the history
… test
  • Loading branch information
Christopher-Chianelli committed Feb 16, 2024
1 parent c6ddac7 commit 86cbe2c
Show file tree
Hide file tree
Showing 5 changed files with 1,207 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -633,12 +633,24 @@
{
"name": "ai.timefold.solver.core.impl.io.jaxb.adapter.JaxbCustomPropertiesAdapter$JaxbAdaptedMap",
"allDeclaredFields": true,
"queryAllDeclaredMethods": true
"queryAllDeclaredMethods": true,
"methods": [
{
"name": "<init>",
"parameterTypes": []
}
]
},
{
"name": "ai.timefold.solver.core.impl.io.jaxb.adapter.JaxbCustomPropertiesAdapter$JaxbAdaptedMapEntry",
"allDeclaredFields": true,
"queryAllDeclaredMethods": true
"queryAllDeclaredMethods": true,
"methods": [
{
"name": "<init>",
"parameterTypes": []
}
]
},
{
"name": "jakarta.xml.bind.Binder"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"resources": {
"includes": [
{
"pattern": "solver.xsd"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
package ai.timefold.solver.spring.boot.it;

import static org.assertj.core.api.Assertions.assertThat;

import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;

import ai.timefold.solver.core.config.solver.SolverConfig;
import ai.timefold.solver.core.impl.io.jaxb.SolverConfigIO;
import ai.timefold.solver.spring.boot.it.domain.IntegrationTestEntity;
import ai.timefold.solver.spring.boot.it.domain.IntegrationTestSolution;
import ai.timefold.solver.spring.boot.it.domain.IntegrationTestValue;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.core.io.Resource;
import org.springframework.test.web.reactive.server.WebTestClient;

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
Expand All @@ -17,6 +25,9 @@ public class TimefoldSolverTestResourceIntegrationTest {
@LocalServerPort
String port;

@Value("classpath:solver-full.xml")
Resource exampleSolverConfigXml;

@Test
void testSolve() {
WebTestClient client = WebTestClient.bindToServer()
Expand Down Expand Up @@ -45,4 +56,17 @@ void testSolve() {
.jsonPath("entityList[2].value.id").isEqualTo("2");

}

@Test
void testSolverXmlParsing() throws IOException {
// Test to verify parsing a complex SolverConfig will work in native image.
// XML file was generated by taking the XSD file available at
// https://timefold.ai/xsd/solver and generating an XML file from it using
// the "Tools > XML Actions > Generate XML Document from XML Schema..." action in IDEA
SolverConfigIO solverConfigIO = new SolverConfigIO();
SolverConfig solverConfig = solverConfigIO.read(new InputStreamReader(exampleSolverConfigXml.getInputStream()));
assertThat(solverConfig).isNotNull();
assertThat(solverConfig.getSolutionClass()).isEqualTo(Object.class);
assertThat(solverConfig.getPhaseConfigList()).isNotEmpty();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"resources": {
"includes": [
{
"pattern": "solver-full.xml"
}
]
}
}
Loading

0 comments on commit 86cbe2c

Please sign in to comment.