use of com.jayway.restassured.path.json.JsonPath in project joynr by bmwcarit.
the class ServersUtil method areBounceProxiesRegisteredWithController.
private static boolean areBounceProxiesRegisteredWithController(String bpControllerUrl, String... bpIds) {
List<Matcher<? super JsonPath>> containsBounceProxyMatcher = new LinkedList<Matcher<? super JsonPath>>();
for (String bpId : bpIds) {
Matcher<? super JsonPath> matcher = CoreMatchers.anyOf(containsBounceProxy(bpId, "ALIVE"), containsBounceProxy(bpId, "ACTIVE"));
containsBounceProxyMatcher.add(matcher);
}
Matcher<JsonPath> matcher = CoreMatchers.allOf(containsBounceProxyMatcher);
Response bounceProxiesResponse = getBounceProxies(bpControllerUrl);
return matcher.matches(bounceProxiesResponse.jsonPath());
}
use of com.jayway.restassured.path.json.JsonPath in project webcert by sklintyg.
the class BaseRestIntegrationTest method createUtkast.
/**
* Helper method to create an utkast of a given type for a given patient.
* The request will be made with the current auth session.
*
* @param intygsTyp
* Type to create
* @param patientPersonNummer
* the patient to create the utkast for
* @return Id for the new utkast
*/
protected String createUtkast(String intygsTyp, String patientPersonNummer) {
CreateUtkastRequest utkastRequest = createUtkastRequest(intygsTyp, patientPersonNummer);
Response response = given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).pathParam("intygstyp", intygsTyp).contentType(ContentType.JSON).body(utkastRequest).expect().statusCode(200).when().post("api/utkast/{intygstyp}").then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-generic-utkast-response-schema.json")).body("intygsTyp", equalTo(utkastRequest.getIntygType())).extract().response();
// The type-specific model is a serialized json within the model property, need to extract that first.
JsonPath draft = new JsonPath(response.body().asString());
JsonPath model = new JsonPath(draft.getString("model"));
assertEquals(formatPersonnummer(patientPersonNummer), model.getString("grundData.patient.personId"));
final String utkastId = model.getString("id");
assertTrue(utkastId.length() > 0);
return utkastId;
}
use of com.jayway.restassured.path.json.JsonPath in project webcert by sklintyg.
the class BaseRestIntegrationTest method createQuestion.
/**
* Inserts a question for an existing certificate
*
* @param typ
* type to create
* @param intygId
* id of the intyg to create the question for
* @param personnummer
* patient to create it for
* @return
*/
protected int createQuestion(String typ, String intygId, String personnummer) {
FragaSvar fs = createTestQuestion(typ, intygId, personnummer);
Response response = given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).body(fs).expect().statusCode(200).when().post("testability/fragasvar").then().extract().response();
JsonPath model = new JsonPath(response.body().asString());
return model.get("internReferens");
}
use of com.jayway.restassured.path.json.JsonPath in project webcert by sklintyg.
the class UtkastApiControllerIT method testCreateUtkast.
/**
* Generic method that created an utkast of given type and validates basic generic model properties
*
* @param utkastType
* The type of utkast to create
*/
private JsonPath testCreateUtkast(String utkastType) {
// Set up auth precondition
RestAssured.sessionId = getAuthSession(DEFAULT_LAKARE);
CreateUtkastRequest utkastRequest = createUtkastRequest(utkastType, DEFAULT_PATIENT_PERSONNUMMER);
Response response = given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).body(utkastRequest).expect().statusCode(200).when().post("api/utkast/" + utkastType).then().body(matchesJsonSchemaInClasspath("jsonschema/webcert-generic-utkast-response-schema.json")).body("intygsTyp", equalTo(utkastRequest.getIntygType())).body("skapadAv.hsaId", equalTo(DEFAULT_LAKARE.getHsaId())).body("enhetsId", equalTo(DEFAULT_LAKARE.getEnhetId())).body("version", equalTo(0)).body("skapadAv.namn", equalTo(DEFAULT_LAKARE_NAME)).body("patientFornamn", equalTo(utkastRequest.getPatientFornamn())).body("patientEfternamn", equalTo(utkastRequest.getPatientEfternamn())).extract().response();
// The type-specific model is a serialized json "within" the model property, need to extract that first and then
// we can assert some basic things.
JsonPath draft = new JsonPath(response.body().asString());
JsonPath model = new JsonPath(draft.getString("model"));
assertTrue(model.getString("id").length() > 0);
assertEquals(utkastRequest.getPatientPersonnummer().getPersonnummer(), model.getString("grundData.patient.personId"));
return model;
}
use of com.jayway.restassured.path.json.JsonPath in project webcert by sklintyg.
the class UtkastApiControllerIT method testGetTsBasUtkast.
@Test
public void testGetTsBasUtkast() {
JsonPath model = testCreateUtkast("ts-bas");
// 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"));
}
Aggregations