Search in sources :

Example 11 with EvaluationRequest

use of org.openscoring.common.EvaluationRequest 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);
}
Also used : BatchEvaluationResponse(org.openscoring.common.BatchEvaluationResponse) BatchEvaluationRequest(org.openscoring.common.BatchEvaluationRequest) EvaluationRequest(org.openscoring.common.EvaluationRequest) BatchModelResponse(org.openscoring.common.BatchModelResponse) BatchModelResponse(org.openscoring.common.BatchModelResponse) ModelResponse(org.openscoring.common.ModelResponse) BatchEvaluationRequest(org.openscoring.common.BatchEvaluationRequest) EvaluationResponse(org.openscoring.common.EvaluationResponse) BatchEvaluationResponse(org.openscoring.common.BatchEvaluationResponse) JerseyTest(org.glassfish.jersey.test.JerseyTest) Test(org.junit.Test)

Aggregations

EvaluationRequest (org.openscoring.common.EvaluationRequest)11 BatchEvaluationRequest (org.openscoring.common.BatchEvaluationRequest)9 BatchEvaluationResponse (org.openscoring.common.BatchEvaluationResponse)7 EvaluationResponse (org.openscoring.common.EvaluationResponse)7 ArrayList (java.util.ArrayList)3 JerseyTest (org.glassfish.jersey.test.JerseyTest)3 Test (org.junit.Test)3 IOException (java.io.IOException)2 BadRequestException (javax.ws.rs.BadRequestException)2 InternalServerErrorException (javax.ws.rs.InternalServerErrorException)2 NotFoundException (javax.ws.rs.NotFoundException)2 Response (javax.ws.rs.core.Response)2 JAXBException (javax.xml.bind.JAXBException)2 EvaluationException (org.jpmml.evaluator.EvaluationException)2 BatchModelResponse (org.openscoring.common.BatchModelResponse)2 ModelResponse (org.openscoring.common.ModelResponse)2 Counter (com.codahale.metrics.Counter)1 Timer (com.codahale.metrics.Timer)1 ArrayListMultimap (com.google.common.collect.ArrayListMultimap)1 ListMultimap (com.google.common.collect.ListMultimap)1