Examples of JsonPath


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

            .statusCode(200)
            .log().ifError()
        .when()
            .get("/resource/{id}/schedules");

        JsonPath jsonPath = response.jsonPath();
        int definitionId = jsonPath.getInt("[0].definitionId");

        return definitionId;
    }
View Full Code Here

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

            .statusCode(200)
            .log().ifError()
        .when()
            .get("/resource/{rid}/schedules");

        JsonPath jp = r.jsonPath();
        numericScheduleId = jp.getInt("[0].scheduleId");
        numericScheduleDefinitionId = jp.getInt("[0].definitionId");
        defaultInterval = jp.getLong("[0].collectionInterval");
        scheduleName = jp.getString("[0].scheduleName");
    }
View Full Code Here

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

            .statusCode(200)
            .log().ifError()
        .when()
            .get("/resource/{rid}/schedules");

        JsonPath jp = r.jsonPath();
        int tsId = jp.getInt("[0].scheduleId");

        String trait = "{\"value\":\"Hello World!\" }";
        given()
            .header(acceptJson)
            .pathParam("timeStamp",System.currentTimeMillis())
View Full Code Here

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

    public void testGetAggregateForResource() throws Exception {

        addDataToSchedule(1);


        JsonPath jp =
        given()
            .header(acceptJson)
            .pathParam("resourceId", _platformId)
            .queryParam("includeDataPoints",true)
        .expect()
            .statusCode(200)
            .body("scheduleId", hasItem(numericScheduleId))
            .body("", not(emptyIterable()))
            .log().everything()
        .when()
            .get("/metric/data/resource/{resourceId}")
        .jsonPath();

        List<Map<String,Object>> map = jp.getList("");
        for (Map<String,Object> entry : map) {
            if (((Integer)entry.get("scheduleId")) == numericScheduleId) {

//                assert entry.get("avg").equals(1.5f) : "Expected an avg of 1.5, but was " + entry.get("avg");
                assert entry.get("min").equals(1.5f) : "Expected an min of 1.5, but was " + entry.get("min");
View Full Code Here

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

    public void testGetAggregateForResource77DataPoints() throws Exception {

        addDataToSchedule(1);


        JsonPath jp =
        given()
            .header(acceptJson)
            .pathParam("resourceId", _platformId)
            .queryParam("includeDataPoints",true)
            .queryParam("dataPoints",77)
        .expect()
            .statusCode(200)
            .body("scheduleId", hasItem(numericScheduleId))
            .body("[0].dataPoints", iterableWithSize(77))
            .body("[0].numDataPoints",is(77))
            .log().everything()
        .when()
            .get("/metric/data/resource/{resourceId}")
        .jsonPath();

        List<Map<String,Object>> map = jp.getList("");
        for (Map<String,Object> entry : map) {
            if (((Integer)entry.get("scheduleId")) == numericScheduleId) {

//                assert entry.get("avg").equals(1.5f) : "Expected an avg of 1.5, but was " + entry.get("avg");
                assert entry.get("min").equals(1.5f) : "Expected an min of 1.5, but was " + entry.get("min");
View Full Code Here

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

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

    @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

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

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

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

        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

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

    @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
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.