Search in sources :

Example 1 with Headers

use of com.jayway.restassured.response.Headers in project quality-measure-and-cohort-service by Alvearie.

the class DefaultVT method testCohortEvaluationWithLogging.

@Test
public void testCohortEvaluationWithLogging() {
    final String RESOURCE = getUrlBase() + "/{version}/cohort-evaluation";
    Assume.assumeTrue(isServiceDarkFeatureEnabled(CohortEngineRestConstants.DARK_LAUNCHED_VALUE_SET_UPLOAD));
    // Create the metadata part of the request
    CohortEvaluation requestData = new CohortEvaluation();
    requestData.setDataServerConfig(dataServerConfig);
    requestData.setTerminologyServerConfig(dataServerConfig);
    requestData.setDefineToRun("Male");
    requestData.setEntrypoint("cql/basic/Test-1.0.0.cql");
    requestData.setPatientIds(VALID_PATIENT_ID);
    requestData.setLoggingLevel(CqlDebug.TRACE);
    RequestSpecification request = buildBaseRequest(new Headers()).queryParam(CohortEngineRestHandler.VERSION, ServiceBuildConstants.DATE).multiPart(CohortEngineRestHandler.REQUEST_DATA_PART, requestData, "application/json").multiPart(CohortEngineRestHandler.CQL_DEFINITION, new File("src/test/resources/cql/zip/Test-1.0.0.zip"));
    ValidatableResponse response = request.post(RESOURCE, getServiceVersion()).then();
    ValidatableResponse vr = runSuccessValidation(response, ContentType.JSON, HttpStatus.SC_OK);
    String actual = vr.extract().response().getBody().prettyPrint();
    String expected = "{\n    \"result\": [\n        \n    ]\n}";
    assertEquals(expected, actual);
}
Also used : ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) CohortEvaluation(com.ibm.cohort.engine.api.service.model.CohortEvaluation) Headers(com.jayway.restassured.response.Headers) RequestSpecification(com.jayway.restassured.specification.RequestSpecification) File(java.io.File) Test(org.junit.Test)

Example 2 with Headers

use of com.jayway.restassured.response.Headers in project quality-measure-and-cohort-service by Alvearie.

the class DefaultVT method testValueSetOverride.

@Test
public void testValueSetOverride() {
    testValueSetUpload();
    final String RESOURCE = getUrlBase() + "/{version}/valueset";
    // Create the metadata part of the request
    ObjectMapper om = new ObjectMapper();
    String fhirConfigjson = "";
    try {
        fhirConfigjson = om.writeValueAsString(dataServerConfig);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
        fail();
    }
    RequestSpecification request = buildBaseRequest(new Headers()).param(CohortEngineRestHandler.VERSION, ServiceBuildConstants.DATE).queryParam(CohortEngineRestHandler.UPDATE_IF_EXISTS_PARM, true).multiPart(CohortEngineRestHandler.FHIR_DATA_SERVER_CONFIG_PART, fhirConfigjson, "application/json").multiPart(CohortEngineRestHandler.VALUE_SET_PART, new File("src/test/resources/2.16.840.1.113762.1.4.1114.7.xlsx"));
    ValidatableResponse response = request.post(RESOURCE, getServiceVersion()).then();
    runSuccessValidation(response, ContentType.JSON, HttpStatus.SC_CREATED);
}
Also used : ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) Headers(com.jayway.restassured.response.Headers) RequestSpecification(com.jayway.restassured.specification.RequestSpecification) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 3 with Headers

use of com.jayway.restassured.response.Headers in project quality-measure-and-cohort-service by Alvearie.

the class DefaultVT method testMeasureEvaluationByMeasureIdentifier.

// to tag a specific test to be part of DVT (deployment verification test)
@Category(DVT.class)
@Test
public /**
 * Test a successful measure evaluation using identifier and version as the lookup key
 */
void testMeasureEvaluationByMeasureIdentifier() throws Exception {
    // You want -Denabled.dark.features=all in your Liberty jvm.options
    Assume.assumeTrue(isServiceDarkFeatureEnabled(CohortEngineRestConstants.DARK_LAUNCHED_MEASURE_EVALUATION));
    final String RESOURCE = getUrlBase() + CohortServiceAPISpec.CREATE_DELETE_EVALUATION_PATH;
    FhirContext fhirContext = FhirContext.forR4();
    IParser parser = fhirContext.newJsonParser().setPrettyPrint(true);
    Library library = TestHelper.getTemplateLibrary();
    Identifier identifier = new Identifier().setValue("measure-identifier").setSystem("http://ibm.com/health/test");
    Measure measure = TestHelper.getTemplateMeasure(library);
    measure.setIdentifier(Arrays.asList(identifier));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    TestHelper.createMeasureArtifact(baos, parser, measure, library);
    // Files.write( baos.toByteArray(), new File("target/test_measure_v1_0_0.zip"));
    Map<String, Parameter> parameterOverrides = new HashMap<>();
    parameterOverrides.put("Measurement Period", new IntervalParameter(new DateParameter("2019-07-04"), true, new DateParameter("2020-07-04"), true));
    MeasureEvaluation requestData = new MeasureEvaluation();
    requestData.setDataServerConfig(dataServerConfig);
    requestData.setTerminologyServerConfig(termServerConfig);
    // This is a patient ID that is assumed to exist in the target FHIR server
    requestData.setPatientId(VALID_PATIENT_ID);
    requestData.setMeasureContext(new MeasureContext(null, parameterOverrides, new com.ibm.cohort.engine.measure.Identifier(identifier.getSystem(), identifier.getValue()), measure.getVersion()));
    requestData.setEvidenceOptions(new MeasureEvidenceOptions(false, MeasureEvidenceOptions.DefineReturnOptions.NONE));
    ObjectMapper om = new ObjectMapper();
    System.out.println(om.writeValueAsString(requestData));
    RequestSpecification request = buildBaseRequest(new Headers()).queryParam(CohortEngineRestHandler.VERSION, ServiceBuildConstants.DATE).multiPart(CohortEngineRestHandler.REQUEST_DATA_PART, requestData, "application/json").multiPart(CohortEngineRestHandler.MEASURE_PART, "test_measure_v1_0_0.zip", new ByteArrayInputStream(baos.toByteArray()));
    ValidatableResponse response = request.post(RESOURCE, getServiceVersion()).then();
    ValidatableResponse vr = runSuccessValidation(response, ContentType.JSON, HttpStatus.SC_OK);
    String expected = getJsonFromFile(ServiceAPIGlobalSpec.EXP_FOLDER_TYPE, "measure_evaluation_exp.json");
    String actual = vr.extract().asString();
    assertMeasureReportEquals(parser, expected, actual, false);
}
Also used : FhirContext(ca.uhn.fhir.context.FhirContext) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) HashMap(java.util.HashMap) MeasureEvaluation(com.ibm.cohort.engine.api.service.model.MeasureEvaluation) PatientListMeasureEvaluation(com.ibm.cohort.engine.api.service.model.PatientListMeasureEvaluation) Headers(com.jayway.restassured.response.Headers) RequestSpecification(com.jayway.restassured.specification.RequestSpecification) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MeasureEvidenceOptions(com.ibm.cohort.engine.measure.evidence.MeasureEvidenceOptions) MeasureContext(com.ibm.cohort.engine.measure.MeasureContext) Identifier(org.hl7.fhir.r4.model.Identifier) DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) ByteArrayInputStream(java.io.ByteArrayInputStream) Measure(org.hl7.fhir.r4.model.Measure) DateParameter(com.ibm.cohort.cql.evaluation.parameters.DateParameter) Parameter(com.ibm.cohort.cql.evaluation.parameters.Parameter) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) Library(org.hl7.fhir.r4.model.Library) IntervalParameter(com.ibm.cohort.cql.evaluation.parameters.IntervalParameter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IParser(ca.uhn.fhir.parser.IParser) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

Example 4 with Headers

use of com.jayway.restassured.response.Headers in project quality-measure-and-cohort-service by Alvearie.

the class DefaultVT method testValueSetAlreadyExists.

@Test
public void testValueSetAlreadyExists() {
    testValueSetUpload();
    final String RESOURCE = getUrlBase() + "/{version}/valueset";
    // Create the metadata part of the request
    ObjectMapper om = new ObjectMapper();
    String fhirConfigjson = "";
    try {
        fhirConfigjson = om.writeValueAsString(dataServerConfig);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
        fail();
    }
    RequestSpecification request = buildBaseRequest(new Headers()).param(CohortEngineRestHandler.VERSION, ServiceBuildConstants.DATE).queryParam(CohortEngineRestHandler.UPDATE_IF_EXISTS_PARM, false).multiPart(CohortEngineRestHandler.FHIR_DATA_SERVER_CONFIG_PART, fhirConfigjson, "application/json").multiPart(CohortEngineRestHandler.VALUE_SET_PART, new File("src/test/resources/2.16.840.1.113762.1.4.1114.7.xlsx"));
    ValidatableResponse response = request.post(RESOURCE, getServiceVersion()).then();
    runSuccessValidation(response, ContentType.JSON, HttpStatus.SC_CONFLICT);
}
Also used : ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) Headers(com.jayway.restassured.response.Headers) RequestSpecification(com.jayway.restassured.specification.RequestSpecification) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 5 with Headers

use of com.jayway.restassured.response.Headers in project newrelic-java-agent by newrelic.

the class SprayHttpRoutesTest method testSimpleRouteFutureCAT.

@Test
public void testSimpleRouteFutureCAT() throws UnsupportedEncodingException {
    String idHeader = Obfuscator.obfuscateNameUsingKey("1xyz234#1xyz3333", "cafebabedeadbeef8675309babecafe1beefdead");
    ValidatableResponse response = given().header(HeadersUtil.NEWRELIC_ID_HEADER, idHeader).baseUri("http://localhost:" + server.getPort()).when().get("/simple/route/future?query=value").then().body(containsString("Simple Route Future"));
    Headers responseHeaders = response.extract().headers();
    Assert.assertTrue(responseHeaders.hasHeaderWithName(HeadersUtil.NEWRELIC_APP_DATA_HEADER));
    Introspector introspector = InstrumentationTestRunner.getIntrospector();
    Assert.assertEquals(1, introspector.getFinishedTransactionCount(DEFAULT_TIMEOUT_MILLIS));
    Assert.assertTrue(introspector.getTransactionNames().toString(), introspector.getTransactionNames().contains(getTransactionPrefix() + "/simple/route/future"));
}
Also used : ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) Headers(com.jayway.restassured.response.Headers) Introspector(com.newrelic.agent.introspec.Introspector) Matchers.containsString(org.hamcrest.Matchers.containsString) Java13IncompatibleTest(com.newrelic.test.marker.Java13IncompatibleTest) Java16IncompatibleTest(com.newrelic.test.marker.Java16IncompatibleTest) Java17IncompatibleTest(com.newrelic.test.marker.Java17IncompatibleTest) Java14IncompatibleTest(com.newrelic.test.marker.Java14IncompatibleTest) Test(org.junit.Test) Java11IncompatibleTest(com.newrelic.test.marker.Java11IncompatibleTest) Java15IncompatibleTest(com.newrelic.test.marker.Java15IncompatibleTest) Java12IncompatibleTest(com.newrelic.test.marker.Java12IncompatibleTest)

Aggregations

Headers (com.jayway.restassured.response.Headers)15 Test (org.junit.Test)15 ValidatableResponse (com.jayway.restassured.response.ValidatableResponse)14 RequestSpecification (com.jayway.restassured.specification.RequestSpecification)10 File (java.io.File)8 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)6 CohortEvaluation (com.ibm.cohort.engine.api.service.model.CohortEvaluation)4 Introspector (com.newrelic.agent.introspec.Introspector)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 FhirContext (ca.uhn.fhir.context.FhirContext)3 IParser (ca.uhn.fhir.parser.IParser)3 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 DateParameter (com.ibm.cohort.cql.evaluation.parameters.DateParameter)3 IntervalParameter (com.ibm.cohort.cql.evaluation.parameters.IntervalParameter)3 Parameter (com.ibm.cohort.cql.evaluation.parameters.Parameter)3 PatientListMeasureEvaluation (com.ibm.cohort.engine.api.service.model.PatientListMeasureEvaluation)3 MeasureContext (com.ibm.cohort.engine.measure.MeasureContext)3 MeasureEvidenceOptions (com.ibm.cohort.engine.measure.evidence.MeasureEvidenceOptions)3 ByteArrayInputStream (java.io.ByteArrayInputStream)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3