use of org.openscoring.common.BatchEvaluationResponse in project openscoring by openscoring.
the class ModelResourceTest method associationRulesShopping.
@Test
public void associationRulesShopping() throws Exception {
String id = "AssociationRulesShopping";
assertEquals("Shopping", extractSuffix(id));
deployForm(id);
query(id);
List<EvaluationRequest> evaluationRequests = loadRecords(id);
BatchEvaluationRequest batchEvaluationRequest = new BatchEvaluationRequest();
batchEvaluationRequest.setRequests(evaluationRequests);
BatchEvaluationResponse batchEvaluationResponse = evaluateBatch(id, batchEvaluationRequest);
assertEquals(batchEvaluationRequest.getId(), batchEvaluationResponse.getId());
List<EvaluationRequest> aggregatedEvaluationRequests = ModelResource.aggregateRequests(FieldName.create("transaction"), evaluationRequests);
batchEvaluationRequest = new BatchEvaluationRequest("aggregate");
batchEvaluationRequest.setRequests(aggregatedEvaluationRequests);
batchEvaluationResponse = evaluateBatch(id, batchEvaluationRequest);
assertEquals(batchEvaluationRequest.getId(), batchEvaluationResponse.getId());
evaluateCsv(id);
evaluateCsvForm(id);
undeployForm(id);
}
use of org.openscoring.common.BatchEvaluationResponse in project openscoring by openscoring.
the class ModelResource method evaluateBatch.
@POST
@Path("{id: " + ModelRegistry.ID_REGEX + "}/batch")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public BatchEvaluationResponse evaluateBatch(@PathParam("id") String id, BatchEvaluationRequest request) {
BatchEvaluationResponse batchResponse = new BatchEvaluationResponse(request.getId());
List<EvaluationRequest> requests = request.getRequests();
List<EvaluationResponse> responses = doEvaluate(id, requests, false, "evaluate.batch");
batchResponse.setResponses(responses);
return batchResponse;
}
use of org.openscoring.common.BatchEvaluationResponse in project openscoring by openscoring.
the class ModelResourceTest method evaluateBatch.
private BatchEvaluationResponse evaluateBatch(String id, BatchEvaluationRequest batchRequest) {
Entity<BatchEvaluationRequest> entity = Entity.json(batchRequest);
Response response = target("model/" + id + "/batch").request(MediaType.APPLICATION_JSON).post(entity);
assertEquals(200, response.getStatus());
return response.readEntity(BatchEvaluationResponse.class);
}
use of org.openscoring.common.BatchEvaluationResponse in project openscoring by openscoring.
the class ModelResourceTest method decisionTreeIris.
@Test
public void decisionTreeIris() throws Exception {
String id = "DecisionTreeIris";
assertEquals("Iris", extractSuffix(id));
BatchModelResponse batchModelResponse = queryBatch();
List<ModelResponse> modelResponses = batchModelResponse.getResponses();
assertNull(modelResponses);
deploy(id);
batchModelResponse = queryBatch();
modelResponses = batchModelResponse.getResponses();
assertEquals(1, modelResponses.size());
download(id);
List<EvaluationRequest> evaluationRequests = loadRecords(id);
EvaluationRequest evaluationRequest = evaluationRequests.get(0);
EvaluationResponse evaluationResponse = evaluate(id, evaluationRequest);
assertEquals(evaluationRequest.getId(), evaluationResponse.getId());
EvaluationRequest invalidEvaluationRequest = invalidate(evaluationRequests.get(50));
evaluationRequests = Arrays.asList(evaluationRequests.get(0), invalidEvaluationRequest, evaluationRequests.get(100));
BatchEvaluationRequest batchEvaluationRequest = new BatchEvaluationRequest();
batchEvaluationRequest.setRequests(evaluationRequests);
BatchEvaluationResponse batchEvaluationResponse = evaluateBatch(id, batchEvaluationRequest);
assertEquals(batchEvaluationRequest.getId(), batchEvaluationResponse.getId());
List<EvaluationResponse> evaluationResponses = batchEvaluationResponse.getResponses();
assertEquals(evaluationRequests.size(), evaluationResponses.size());
EvaluationResponse invalidEvaluationResponse = evaluationResponses.get(1);
assertEquals(invalidEvaluationRequest.getId(), invalidEvaluationResponse.getId());
assertNotNull(invalidEvaluationResponse.getMessage());
undeploy(id);
}
Aggregations