ai.timefold.solver.quarkus.jackson.it.TimefoldTestResource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of timefold-solver-quarkus-jackson-integration-test Show documentation
Show all versions of timefold-solver-quarkus-jackson-integration-test Show documentation
Quarkus integration tests for Timefold with Jackson
The newest version!
package ai.timefold.solver.quarkus.jackson.it;
import java.util.concurrent.ExecutionException;
import jakarta.inject.Inject;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import ai.timefold.solver.core.api.solver.SolverJob;
import ai.timefold.solver.core.api.solver.SolverManager;
import ai.timefold.solver.quarkus.jackson.it.domain.ITestdataPlanningSolution;
@Path("/timefold/test")
public class TimefoldTestResource {
private final SolverManager solverManager;
@Inject
public TimefoldTestResource(SolverManager solverManager) {
this.solverManager = solverManager;
}
@POST
@Path("/solver-factory")
public ITestdataPlanningSolution solveWithSolverFactory(ITestdataPlanningSolution problem) {
SolverJob solverJob = solverManager.solve(1L, problem);
try {
return solverJob.getFinalBestSolution();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IllegalStateException("Solving was interrupted.", e);
} catch (ExecutionException e) {
throw new IllegalStateException("Solving failed.", e);
}
}
}