use of org.openscoring.common.BatchModelResponse in project openscoring by openscoring.
the class ModelResource method queryBatch.
@GET
@Produces(MediaType.APPLICATION_JSON)
public BatchModelResponse queryBatch() {
BatchModelResponse batchResponse = new BatchModelResponse();
List<ModelResponse> responses = new ArrayList<>();
Collection<Map.Entry<String, Model>> entries = this.modelRegistry.entries();
for (Map.Entry<String, Model> entry : entries) {
ModelResponse response = createModelResponse(entry.getKey(), entry.getValue(), false);
responses.add(response);
}
Comparator<ModelResponse> comparator = new Comparator<ModelResponse>() {
@Override
public int compare(ModelResponse left, ModelResponse right) {
return (left.getId()).compareToIgnoreCase(right.getId());
}
};
Collections.sort(responses, comparator);
batchResponse.setResponses(responses);
return batchResponse;
}
use of org.openscoring.common.BatchModelResponse in project openscoring by openscoring.
the class ModelResourceTest method queryBatch.
private BatchModelResponse queryBatch() {
Response response = target("model").request(MediaType.APPLICATION_JSON).get();
assertEquals(200, response.getStatus());
return response.readEntity(BatchModelResponse.class);
}
use of org.openscoring.common.BatchModelResponse 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