Examples of JsonPath


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

        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

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

        // 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

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

    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

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

                .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

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

                .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

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

        .expect()
            .statusCode(200)
        .when()
            .get("/group");

        JsonPath jsonPath = response.jsonPath();
        assert jsonPath.get("[0].name").equals(X_TEST_GROUP); // [0] as the query returns a list
        int groupId = jsonPath.get("[0].id");
        assert groupId == createdId;

        // Fetch id by id
        given()
            .pathParam("id",groupId)
View Full Code Here

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

            expect()
                .statusCode(200)
                .log().everything()
            .when()
                .get("/user/favorites/resource");
            JsonPath jp = r.jsonPath();
            assert jp.getList("resourceId").contains(_platformId);
        }
        finally {
            given()
                .pathParam("rid",_platformId)
            .expect()
View Full Code Here

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

            expect()
                .statusCode(200)
                .log().everything()
            .when()
                .get("/user/favorites/resource");
            JsonPath jp = r.jsonPath();
            assert jp.getList("resourceId").contains(_platformId);
        }
        finally {
            given()
                .pathParam("rid",_platformId)
            .expect()
View Full Code Here

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

        UnexpectedResponseException.verifyResponse(response, HttpStatus.SC_OK);

        List<EDITOR> editors = new ArrayList<EDITOR>();

        JsonPath jsonPath = response.jsonPath();

        List<Map<String, ?>> items = jsonPath.getList("");

        for (int i = 0; i < items.size(); i++) {
            jsonPath.setRoot("[" + i + "]");

            EDITOR editor = demarshall(context, jsonPath);
            editors.add(editor);
        }
View Full Code Here

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

        UnexpectedResponseException.verifyResponse(response, HttpStatus.SC_OK);

        List<PushApplicationEditor> applications = new ArrayList<PushApplicationEditor>();

        JsonPath jsonPath = response.jsonPath();

        List<Map<String, ?>> items = jsonPath.getList("");

        for (int i = 0; i < items.size(); i++) {
            jsonPath.setRoot("[" + i + "]");

            // FIXME this might not be the right implementation
            // it can actually leak values of previous implementation
            PushApplicationEditor pushApplication = demarshall(context, jsonPath);
            applications.add(pushApplication);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.