Search in sources :

Example 66 with JsonPath

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

the class JsonConvTest method testTransitionResultDigest.

@Test
public void testTransitionResultDigest() {
    String json = JsonConv.digest(tresult).toJson();
    logger.info(json);
    JsonPath jp = from(json);
}
Also used : JsonPath(com.jayway.restassured.path.json.JsonPath) Test(org.junit.Test)

Example 67 with JsonPath

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

the class JsonConvTest method testManagedAclDigest.

@Test
public void testManagedAclDigest() {
    String json = JsonConv.digest(macl).toJson();
    JsonPath jp = from(json);
    logger.info(json);
    assertEquals(2, ((Map) jp.get()).size());
    assertEquals(new Integer(1), jp.get("id"));
    assertEquals("Public", jp.get("name"));
}
Also used : JsonPath(com.jayway.restassured.path.json.JsonPath) Test(org.junit.Test)

Example 68 with JsonPath

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

the class JsonsTest method testComposition3.

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

Example 69 with JsonPath

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

the class ClusteredBounceProxyControllerTest method testBounceProxyRegistrationAtBpc1.

@Test
@Ignore("Ignore until servers are started in a separate JVM. Guice static problem")
public void testBounceProxyRegistrationAtBpc1() throws Exception {
    RestAssured.baseURI = bpcUrl1;
    Response responseRegister = given().log().all().queryParam("url4cc", "http://testurl/url4cc").and().queryParam("url4bpc", "http://testurl/url4bpc").when().put("bounceproxies/?bpid=0.0");
    assertEquals(201, /* Created */
    responseRegister.getStatusCode());
    waitForReplication();
    RestAssured.baseURI = bpcUrl2;
    JsonPath listBps = given().log().all().get("bounceproxies").body().jsonPath();
    assertThat(listBps, containsBounceProxy("0.0", "ALIVE"));
}
Also used : Response(com.jayway.restassured.response.Response) JsonPath(com.jayway.restassured.path.json.JsonPath) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 70 with JsonPath

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

the class ChannelServiceResponseMatchers method numberOfChannels.

public static Matcher<JsonPath> numberOfChannels(final int size) {
    return new BaseMatcher<JsonPath>() {

        @Override
        public boolean matches(Object item) {
            JsonPath jsonPath = (JsonPath) item;
            List<String> channelIds = jsonPath.getList("name");
            return channelIds.size() == size;
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("contains " + size + " channels");
        }

        @Override
        public void describeMismatch(Object item, Description description) {
            JsonPath jsonPath = (JsonPath) item;
            List<String> channelIds = jsonPath.getList("name");
            description.appendText("contains " + channelIds.size() + " channels");
        }
    };
}
Also used : Description(org.hamcrest.Description) BaseMatcher(org.hamcrest.BaseMatcher) JsonPath(com.jayway.restassured.path.json.JsonPath)

Aggregations

JsonPath (com.jayway.restassured.path.json.JsonPath)87 Test (org.junit.Test)56 Response (com.jayway.restassured.response.Response)29 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 Then (cucumber.api.java.en.Then)2 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)2 BaseMatcher (org.hamcrest.BaseMatcher)2 Description (org.hamcrest.Description)2 PreparationDTO (org.talend.dataprep.api.preparation.PreparationDTO)2