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"));
}
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));
}
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()));
}
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);
}
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"));
}
Aggregations