use of org.drools.scenariosimulation.api.model.ScenarioSimulationModel in project drools by kiegroup.
the class ScenarioSimulationXMLPersistenceTest method commonCheckBackground.
private void commonCheckBackground(Document toCheck) throws Exception {
String migrated = DOMParserUtil.getString(toCheck);
ScenarioSimulationModel scenarioSimulationModel = instance.internalUnmarshal(migrated);
commonCheckBackground(scenarioSimulationModel);
}
use of org.drools.scenariosimulation.api.model.ScenarioSimulationModel in project drools by kiegroup.
the class ScenarioSimulationXMLPersistenceTest method versionAttributeExists.
@Test
public void versionAttributeExists() {
final String xml = instance.marshal(new ScenarioSimulationModel());
assertTrue(xml.startsWith("<ScenarioSimulationModel version=\"" + ScenarioSimulationXMLPersistence.getCurrentVersion() + "\">"));
}
use of org.drools.scenariosimulation.api.model.ScenarioSimulationModel in project drools by kiegroup.
the class ScenarioSimulationXMLPersistenceTest method unmarshalDMN.
@Test
public void unmarshalDMN() throws Exception {
String toUnmarshal = getFileContent("scesim-dmn.scesim");
final ScenarioSimulationModel retrieved = ScenarioSimulationXMLPersistence.getInstance().unmarshal(toUnmarshal);
assertEquals(ScenarioSimulationModel.Type.DMN, retrieved.getSettings().getType());
commonCheckSimulation(retrieved);
}
use of org.drools.scenariosimulation.api.model.ScenarioSimulationModel in project droolsjbpm-integration by kiegroup.
the class ScenarioSimulationResource method executeSimulation.
@ApiOperation(value = "Execute given test scenario against specified container", response = ServiceResponse.class, code = 200)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Unexpected error"), @ApiResponse(code = 404, message = "Container not found"), @ApiResponse(code = 400, message = "Malformed test scenario file") })
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response executeSimulation(@Context HttpHeaders headers, @ApiParam(value = "Container id", required = true) @PathParam(CONTAINER_ID) String containerId, @ApiParam(value = "Test scenario file content to be executed", required = true) String rawContent) {
KieContainer kieContainer = null;
ScenarioSimulationModel model = null;
Variant v = getVariant(headers);
Header conversationIdHeader = buildConversationIdHeader(containerId, scenarioSimulationService.getKieServerRegistry(), headers);
try {
kieContainer = scenarioSimulationService.getKieContainerById(containerId);
} catch (Exception e) {
return createCorrectVariant(createFailedServiceResponse("Impossible to find container with id " + containerId, e), headers, Response.Status.NOT_FOUND, conversationIdHeader);
}
try {
model = scenarioSimulationService.parseModel(rawContent);
} catch (Exception e) {
return createCorrectVariant(createFailedServiceResponse("Test scenario parsing error", e), headers, Response.Status.BAD_REQUEST, conversationIdHeader);
}
try {
return createCorrectVariant(scenarioSimulationService.executeScenario(kieContainer, model), headers, Response.Status.OK, conversationIdHeader);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return internalServerError(e.getMessage(), v, conversationIdHeader);
}
}
use of org.drools.scenariosimulation.api.model.ScenarioSimulationModel in project drools by kiegroup.
the class ScenarioSimulationXMLPersistenceTest method commonCheckSimulation.
private void commonCheckSimulation(Document toCheck) throws Exception {
String migrated = DOMParserUtil.getString(toCheck);
ScenarioSimulationModel scenarioSimulationModel = instance.internalUnmarshal(migrated);
commonCheckSimulation(scenarioSimulationModel);
}
Aggregations