Package com.jayway.restassured.path.json

Examples of com.jayway.restassured.path.json.JsonPath


    @Test
    public void testGetMetricDataOneSchedule() throws Exception {

        int num = 13;
        addDataToSchedule(num);
JsonPath jp =
        given()
            .header(acceptJson)
            .queryParam("sid", numericScheduleId)
        .expect()
            .statusCode(200)
View Full Code Here


    @Test
    public void testGetMetricDataOneSchedule99Points() throws Exception {

        int num = 13;
        addDataToSchedule(num);
JsonPath jp =
        given()
            .header(acceptJson)
            .queryParam("sid", numericScheduleId)
            .queryParam("dataPoints", 99)
        .expect()
View Full Code Here

           // .header("Link", allOf(containsString("page=2"), containsString("current")))
            .header("Link", not(containsString("prev")))
            .body("links.self", notNullValue())
        .when()
            .get("/resource/" + _platformId + "/children");
        JsonPath jsonPath = r.jsonPath();
        assert jsonPath.getList("").size() == 2;
    }
View Full Code Here

        int currentPage = 0;
        Set<Integer> seen = new HashSet<Integer>();

        for(;;) {
            JsonPath path =
            given()
                .header("Accept", "application/vnd.rhq.wrapped+json")
            .with()
                .queryParam("page", currentPage)
                .queryParam("ps", 5// Unusually small to provoke having more than 1 page
                .queryParam("status","COMMITTED")
            .expect()
                .statusCode(200)
                .log().ifError()
            .when()
                .get("/resource")
            .jsonPath();

            List<Integer> ids = path.getList("data.resourceId");

            for (Integer id : ids ) {
                assert !seen.contains(id);
                seen.add(id);
            }

            currentPage++;
            if (currentPage > path.getInt("lastPage")) {
                break;
            }
            System.out.print("+");
        }
        System.out.println();
View Full Code Here

    @Test
    public void testPagingWrappingCorrectness() throws Exception {

        // First get the lastPage from the paging side

        JsonPath path =
        given()
            .header("Accept", "application/vnd.rhq.wrapped+json")
        .with()
            .queryParam("page", 0)
            .queryParam("ps", 5// Unusually small to provoke having more than 1 page
            .queryParam("status","COMMITTED")
        .expect()
            .statusCode(200)
            .log().ifError()
        .when()
            .get("/resource")
        .jsonPath();

        int pagingLastPage = path.getInt("lastPage");
        int pagingTotalSize = path.getInt("totalSize");

        // Now get resource counts from status

        JsonPath statusPath =
        given()
            .header(acceptJson)
        .expect()
            .statusCode(200)
            .log().ifError()
        .when()
            .get("/status")
        .jsonPath();

        int platforms = statusPath.getInt("values.PlatformCount");
        int servers = statusPath.getInt("values.ServerCount");
        int services = statusPath.getInt("values.ServiceCount");

        int resources = platforms + servers + services;

        assert resources == pagingTotalSize;
View Full Code Here

        System.out.flush();
        int pagingLastPage = Integer.parseInt(tmp);

        // Now get resource counts from status

        JsonPath statusPath =
        given()
            .header(acceptJson)
        .expect()
            .statusCode(200)
            .log().ifError()
        .when()
            .get("/status")
        .jsonPath();

        int platforms = statusPath.getInt("values.PlatformCount");
        int servers = statusPath.getInt("values.ServerCount");
        int services = statusPath.getInt("values.ServiceCount");

        int resources = platforms + servers + services;

        assert resources == pagingTotalSize;
View Full Code Here

        // extract the internal json data
        String body = bodyString.substring(6,bodyString.length()-2);

        // validate
        JsonPath jsonPath = new JsonPath(body);
        assert jsonPath.getInt("pageSize") == 2;
        assert jsonPath.getInt("currentPage") == 1;
    }
View Full Code Here

    private void waitForTerminationAndDelete(String historyId) throws InterruptedException {
        boolean done = false;
        int count = 0;
        String status = "bla";
        JsonPath jsonPath = null;

        while (!done) {
            Response response =
            given()
                .header(acceptJson)
                .pathParam("hid", historyId)
            .expect()
                .log().everything()
            .when()
                .get("/operation/history/{hid}");


            jsonPath = response.jsonPath();
            status = jsonPath.getString("status");
            int code = response.statusCode();

            if (code==200 && (status.equals("Success") || status.equals("Failed"))) {
                done = true;
            } else {
                Thread.sleep(2000);
            }
            count ++;
            assert count < 10 :"Waited for 20sec -- something is wrong";
        }

        if (done && status.equals("Success")) {
            Object result = jsonPath.get("result"); // Can not test on result.operationResult, as not every op has this.
            assert result != null;
            String errorMessage = jsonPath.getString("errorMessage");
            assert errorMessage == null;
        }

        // Delete the history item
        given()
View Full Code Here

                .header(acceptJson)
                .queryParam("q", X_TEST_GROUP)
            .when()
                .get("/group");

        JsonPath jsonPath = response.jsonPath();
        if (jsonPath.get("id[0]")!=null) {
            int groupId = jsonPath.getInt("id[0]");
            given()
                .pathParam("id", groupId)
            .delete("/group/{id}");
        }
    }
View Full Code Here

                .statusCode(200)
                .log().ifError()
            .when()
                .get("/resource");

        JsonPath jp = r.jsonPath();

        int coreGuiId = jp.getInt("[0].resourceId");
        // now list it's children
        r =
            given()
                .header(acceptJson)
                .pathParam("rid", coreGuiId)
            .expect()
                .statusCode(200)
                .log().ifError()
            .when()
                .get("/resource/{rid}/children");

        jp = r.jsonPath();

        webRuntimeResourceId = jp.getInt("[0].resourceId");

        // finally lookup calltime
        r =
            given()
                .header(acceptJson)
                .queryParam("type", "calltime")
                .queryParam("enabledOnly", false)
                .pathParam("rid", webRuntimeResourceId)
            .expect()
                .statusCode(200)
                .log().ifError()
            .when()
                .get("/resource/{rid}/schedules");

        jp = r.jsonPath();
        callTimeScheduleId = jp.getInt("[0].scheduleId");

    }
View Full Code Here

TOP

Related Classes of com.jayway.restassured.path.json.JsonPath

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.