Search in sources :

Example 26 with JsonPath

use of com.jayway.restassured.path.json.JsonPath in project webcert by sklintyg.

the class UtkastApiControllerIT method testGetTsDiabetesUtkast.

@Test
public void testGetTsDiabetesUtkast() {
    JsonPath model = testCreateUtkast("ts-diabetes");
    // INTYG-4086 - do NOT store name or address for FK intyg in DB
    assertEquals(DEFAULT_UTKAST_PATIENT_FORNAMN, model.getString("grundData.patient.fornamn"));
    assertEquals(DEFAULT_UTKAST_PATIENT_EFTERNAMN, model.getString("grundData.patient.efternamn"));
}
Also used : JsonPath(com.jayway.restassured.path.json.JsonPath) Test(org.junit.Test) BaseRestIntegrationTest(se.inera.intyg.webcert.web.web.controller.integrationtest.BaseRestIntegrationTest)

Example 27 with JsonPath

use of com.jayway.restassured.path.json.JsonPath in project webcert by sklintyg.

the class IntygModuleApiControllerIT method testCompletionContainsCommentStringInOvrigt.

@Test
public void testCompletionContainsCommentStringInOvrigt() throws Exception {
    final String personnummer = "19121212-1212";
    final String kommentar = "Testkommentar";
    Personnummer pers = Personnummer.createPersonnummer(personnummer).get();
    RestAssured.sessionId = getAuthSession(DEFAULT_LAKARE);
    String intygsTyp = "lisjp";
    String intygsId = createSignedIntyg(intygsTyp, personnummer);
    createArendeQuestion(intygsTyp, intygsId, personnummer, ArendeAmne.KOMPLT);
    Map<String, String> pathParams = new HashMap<>();
    pathParams.put("intygsTyp", intygsTyp);
    pathParams.put("intygsId", intygsId);
    CopyIntygRequest copyIntygRequest = new CopyIntygRequest();
    copyIntygRequest.setPatientPersonnummer(pers);
    copyIntygRequest.setKommentar(kommentar);
    final Response response = given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).and().pathParams(pathParams).and().body(copyIntygRequest).expect().statusCode(200).when().post("moduleapi/intyg/{intygsTyp}/{intygsId}/komplettera").then().body("intygsUtkastId", not(isEmptyString())).body("intygsUtkastId", not(equalTo(intygsId))).body("intygsTyp", equalTo(intygsTyp)).extract().response();
    JsonPath intygJson = new JsonPath(response.body().asString());
    String newUtkastId = intygJson.getString("intygsUtkastId");
    given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).expect().statusCode(200).when().get("moduleapi/intyg/" + intygsTyp + "/" + newUtkastId).then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-get-intyg-response-schema.json")).body("contents.ovrigt", containsString(kommentar));
}
Also used : Personnummer(se.inera.intyg.schemas.contract.Personnummer) Response(com.jayway.restassured.response.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) CopyIntygRequest(se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest) HashMap(java.util.HashMap) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) Matchers.containsString(org.hamcrest.Matchers.containsString) JsonPath(com.jayway.restassured.path.json.JsonPath) BaseRestIntegrationTest(se.inera.intyg.webcert.web.web.controller.integrationtest.BaseRestIntegrationTest) Test(org.junit.Test)

Example 28 with JsonPath

use of com.jayway.restassured.path.json.JsonPath in project webcert by sklintyg.

the class UtkastModuleApiControllerIT method testDiscardDraft.

@Test
public void testDiscardDraft() {
    RestAssured.sessionId = getAuthSession(DEFAULT_LAKARE);
    String intygsTyp = "luse";
    String intygsId = createUtkast(intygsTyp, DEFAULT_PATIENT_PERSONNUMMER);
    Response responseIntyg = given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).expect().statusCode(200).when().get(MODULEAPI_UTKAST_BASE + "/" + intygsTyp + "/" + intygsId).then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-get-utkast-response-schema.json")).extract().response();
    JsonPath model = new JsonPath(responseIntyg.body().asString());
    String version = model.getString("version");
    given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).expect().statusCode(200).when().delete(MODULEAPI_UTKAST_BASE + "/" + intygsTyp + "/" + intygsId + "/" + version);
    given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).expect().statusCode(500).when().get(MODULEAPI_UTKAST_BASE + "/" + intygsTyp + "/" + intygsId).then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-error-response-schema.json")).body("errorCode", equalTo(WebCertServiceErrorCodeEnum.DATA_NOT_FOUND.name())).body("message", not(isEmptyString()));
}
Also used : Response(com.jayway.restassured.response.Response) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) JsonPath(com.jayway.restassured.path.json.JsonPath) Test(org.junit.Test) BaseRestIntegrationTest(se.inera.intyg.webcert.web.web.controller.integrationtest.BaseRestIntegrationTest)

Example 29 with JsonPath

use of com.jayway.restassured.path.json.JsonPath in project webcert by sklintyg.

the class UtkastModuleApiControllerIT method createIntyg.

private Intyg createIntyg() throws IOException {
    String intygsTyp = "lisjp";
    String intygsId = createUtkast(intygsTyp, DEFAULT_PATIENT_PERSONNUMMER);
    Response responseIntyg = given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).expect().statusCode(200).when().get(MODULEAPI_UTKAST_BASE + "/" + intygsTyp + "/" + intygsId).then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-get-utkast-response-schema.json")).extract().response();
    ObjectMapper mapper = new ObjectMapper();
    ObjectNode rootNode = (ObjectNode) mapper.readTree(responseIntyg.body().asString());
    String version = rootNode.get("version").asText();
    ObjectNode content = (ObjectNode) rootNode.get("content");
    content.put("avstangningSmittskydd", true);
    content.putArray("diagnoser");
    ArrayNode diagnoser = (ArrayNode) content.get("diagnoser");
    ObjectNode diagnos = JsonNodeFactory.instance.objectNode();
    diagnos.put("diagnosBeskrivning", "Klämskada");
    diagnos.put("diagnosKodSystem", "ICD_10_SE");
    diagnos.put("diagnosKod", "S47");
    diagnoser.add(diagnos);
    content.putArray("sjukskrivningar");
    ArrayNode sjukskrivningar = (ArrayNode) content.get("sjukskrivningar");
    ObjectNode sjukskrivning = new ObjectNode(JsonNodeFactory.instance);
    sjukskrivning.putObject("period");
    ObjectNode period = (ObjectNode) sjukskrivning.get("period");
    period.put("from", "2016-01-19");
    period.put("tom", "2016-01-25");
    sjukskrivning.put("sjukskrivningsgrad", "TRE_FJARDEDEL");
    sjukskrivningar.add(sjukskrivning);
    responseIntyg = given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).body(content).log().all().expect().statusCode(200).when().put(MODULEAPI_UTKAST_BASE + "/" + intygsTyp + "/" + intygsId + "/" + version).then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-save-draft-response-schema.json")).body("version", equalTo(Integer.parseInt(version) + 1)).extract().response();
    JsonPath model = new JsonPath(responseIntyg.body().asString());
    version = model.getString("version");
    return new Intyg(version, intygsId, intygsTyp);
}
Also used : Response(com.jayway.restassured.response.Response) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) JsonPath(com.jayway.restassured.path.json.JsonPath) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 30 with JsonPath

use of com.jayway.restassured.path.json.JsonPath in project webcert by sklintyg.

the class UtkastModuleApiControllerIT method testBiljettStatus.

@Test
public void testBiljettStatus() throws IOException {
    RestAssured.sessionId = getAuthSession(DEFAULT_LAKARE);
    Intyg intyg = createIntyg();
    Response responseTicket = given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).expect().statusCode(200).when().post(MODULEAPI_UTKAST_BASE + "/" + intyg.getIntygsTyp() + "/" + intyg.getId() + "/" + intyg.getVersion() + "/signeringshash").then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-signatur-response-schema.json")).extract().response();
    JsonPath model = new JsonPath(responseTicket.body().asString());
    String biljettId = model.getString("id");
    given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).expect().statusCode(200).when().get(MODULEAPI_UTKAST_BASE + "/" + intyg.getIntygsTyp() + "/" + biljettId + "/signeringsstatus").then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-signatur-response-schema.json"));
}
Also used : Response(com.jayway.restassured.response.Response) Matchers.isEmptyString(org.hamcrest.Matchers.isEmptyString) JsonPath(com.jayway.restassured.path.json.JsonPath) Test(org.junit.Test) BaseRestIntegrationTest(se.inera.intyg.webcert.web.web.controller.integrationtest.BaseRestIntegrationTest)

Aggregations

JsonPath (com.jayway.restassured.path.json.JsonPath)83 Test (org.junit.Test)56 Response (com.jayway.restassured.response.Response)25 BaseRestTest (integration.BaseRestTest)11 BaseRestIntegrationTest (se.inera.intyg.webcert.web.web.controller.integrationtest.BaseRestIntegrationTest)10 Matchers.isEmptyString (org.hamcrest.Matchers.isEmptyString)9 Matchers.anyString (org.mockito.Matchers.anyString)8 ValidatableResponse (com.jayway.restassured.response.ValidatableResponse)6 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)6 Matchers.containsString (org.hamcrest.Matchers.containsString)6 UsingDataSet (com.lordofthejars.nosqlunit.annotation.UsingDataSet)5 HttpServletResponse (javax.servlet.http.HttpServletResponse)5 Ignore (org.junit.Ignore)5 MongoDbSeed (integration.MongoDbSeed)4 HashMap (java.util.HashMap)3 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)2 BaseMatcher (org.hamcrest.BaseMatcher)2 Description (org.hamcrest.Description)2 UserPreparation (org.talend.dataprep.preparation.service.UserPreparation)2 Application (org.talend.dataprep.transformation.Application)2