Search in sources :

Example 21 with JsonPath

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

the class JsonConvTest method testManagedAclFull.

@Test
public void testManagedAclFull() {
    String json = JsonConv.full(macl).toJson();
    logger.info(json);
    JsonPath jp = from(json);
    assertEquals(4, ((Map) jp.get()).size());
    assertEquals(new Integer(1), jp.get("id"));
    assertEquals("default_org", jp.get("organizationId"));
    assertEquals("Public", jp.get("name"));
    assertEquals(1, ((List) jp.get("acl.ace")).size());
}
Also used : JsonPath(com.jayway.restassured.path.json.JsonPath) Test(org.junit.Test)

Example 22 with JsonPath

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

the class JsonsTest method testComposition4.

@Test
public void testComposition4() {
    final Jsons.Arr j = append(arr(v("hallo"), ZERO_VAL, v("hello")), arr(v("hola")));
    final JsonPath p = JsonPath.from(toJson(j));
    assertThat(p.<String>getList(""), contains("hallo", "hello", "hola"));
}
Also used : JsonPath(com.jayway.restassured.path.json.JsonPath) Test(org.junit.Test)

Example 23 with JsonPath

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

the class JsonsTest method testComposition2.

@Test
public void testComposition2() {
    final Jsons.Obj x = obj(p("name", "Karl"), p("city", "Paris"));
    final Jsons.Obj y = obj(p("name", "Peter"));
    final JsonPath p = JsonPath.from(toJson(append(x, y)));
    assertEquals("Peter", p.get("name"));
    assertEquals("Paris", p.get("city"));
}
Also used : JsonPath(com.jayway.restassured.path.json.JsonPath) Test(org.junit.Test)

Example 24 with JsonPath

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

the class JsonsTest method testComposition1.

@Test
public void testComposition1() {
    final Jsons.Obj j = append(obj(p("name", "Karl"), p("city", "Paris"), p("remove_me", ZERO_VAL)), obj(p("age", 79)));
    final JsonPath p = JsonPath.from(toJson(j));
    logger.info(p.prettyPrint());
    assertEquals("Karl", p.get("name"));
    assertEquals("Paris", p.get("city"));
    assertNull(p.get("remove_me"));
    assertEquals(new Integer(79), p.get("age"));
}
Also used : JsonPath(com.jayway.restassured.path.json.JsonPath) Test(org.junit.Test)

Example 25 with JsonPath

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

the class BaseRestIntegrationTest method createArendeQuestion.

/**
 * Inserts a question of type arende for an existing certificate
 *
 * @param intygTyp
 *            type to create
 * @param intygsId
 *            id of the intyg to create the arende for
 * @param personnummer
 *            patient to create it for
 * @return
 */
protected String createArendeQuestion(String intygTyp, String intygsId, String personnummer, ArendeAmne messageType) {
    Arende arende;
    switch(messageType) {
        case AVSTMN:
            arende = createAvstamningArendeFromFktoWebcertUser(intygTyp, intygsId, personnummer);
            break;
        case KOMPLT:
            arende = createKompletteringArendeFromFkToWebcertUser(intygTyp, intygsId, personnummer);
            break;
        default:
            throw new IllegalArgumentException();
    }
    Response response = given().cookie("ROUTEID", BaseRestIntegrationTest.routeId).contentType(ContentType.JSON).body(arende).expect().statusCode(200).when().post("testability/arendetest").then().extract().response();
    JsonPath model = new JsonPath(response.body().asString());
    return model.get("meddelandeId");
}
Also used : Response(com.jayway.restassured.response.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) JsonPath(com.jayway.restassured.path.json.JsonPath)

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