Examples of MDataPoint


Examples of org.rhq.modules.integrationTests.restApi.d.MDataPoint

        List<Map<String,Object>> list = response.as(List.class);
        assert  list.size()>0;

        boolean found = false;
        for (Map<String, Object> map : list) {
            MDataPoint mp = new MDataPoint(map);
            if (mp.getTimeStamp()==now && mp.getScheduleId()==numericScheduleId && mp.getValue().compareTo(1.5d)==0)
                found = true;
        }
        assert found;

    }
View Full Code Here

Examples of org.rhq.modules.integrationTests.restApi.d.MDataPoint

    @Test
    public void testPostGetRawData() throws Exception {

        long now = System.currentTimeMillis();

        MDataPoint dataPoint = new MDataPoint();
        dataPoint.setScheduleId(numericScheduleId);
        dataPoint.setTimeStamp(now);
        dataPoint.setValue(1.5);
        List<MDataPoint> points = new ArrayList<MDataPoint>(1);
        points.add(dataPoint);

        given()
            .header(acceptJson)
            .contentType(ContentType.JSON)
            .body(points)
        .expect()
            .statusCode(204)
            .log().ifError()
        .when()
            .post("/metric/data/raw");

        Response response =
        given()
            .header(acceptJson)
            .pathParam("id", numericScheduleId)
            // no start and end time -> last 8h of data
        .expect()
            .statusCode(200)
            .log().ifError()
            .body("", not(emptyIterable()))
        .when()
            .get("/metric/data/{id}/raw");

        List<Map<String,Object>> list = response.as(List.class);
        assert  list.size()>0 : "No data retrieved";

        boolean found = false;
        for (Map<String, Object> map : list) {
            MDataPoint mp = new MDataPoint(map);
            if (mp.equals(dataPoint))
                found = true;
        }
        assert found;

    }
View Full Code Here

Examples of org.rhq.modules.integrationTests.restApi.d.MDataPoint

     */
    @Test
    public void testPostRawDataRejectSome() throws Exception {
        long now = System.currentTimeMillis();

        MDataPoint dataPoint = new MDataPoint();
        dataPoint.setScheduleId(numericScheduleId);
        dataPoint.setTimeStamp(now);
        dataPoint.setValue(1.5);
        List<MDataPoint> points = new ArrayList<MDataPoint>(2);
        points.add(dataPoint);

        dataPoint = new MDataPoint();
        dataPoint.setTimeStamp(now);
        dataPoint.setValue(9999.0);
        dataPoint.setScheduleId(99999);
        points.add(dataPoint);

        Response response = given()
            .header(acceptJson)
            .contentType(ContentType.JSON)
            .body(points)
        .expect()
            .statusCode(201)
            .log().ifError()
        .when()
            .post("/metric/data/raw");

        Map<String, Object> map = response.as(Map.class);
        assert map.size() > 0 : "No rejected data retrieved";
        List<Map<String, Object>> rejected = (List<Map<String, Object>>) map.get("rejected");
        assert rejected.size() == 1 : "Got unexpected count of rejected values";
        MDataPoint point = new MDataPoint(rejected.get(0));
        assert point.equals(dataPoint) : "Got unexpected rejected datapoint";
    }
View Full Code Here

Examples of org.rhq.modules.integrationTests.restApi.d.MDataPoint

    @Test
    public void testPostRawDataRejectAll() throws Exception {
        long now = System.currentTimeMillis();

        List<MDataPoint> points = new ArrayList<MDataPoint>(1);
        MDataPoint dataPoint = new MDataPoint();
        dataPoint.setTimeStamp(now);
        dataPoint.setValue(9999.0);
        dataPoint.setScheduleId(99999);
        points.add(dataPoint);

        Response response = given()
            .header(acceptJson)
            .contentType(ContentType.JSON)
            .body(points)
        .expect()
            .statusCode(403)
            .log().ifError()
        .when()
            .post("/metric/data/raw");

        Map<String, Object> map = response.as(Map.class);
        assert map.size() > 0 : "No rejected data retrieved";
        List<Map<String, Object>> rejected = (List<Map<String, Object>>) map.get("rejected");
        assert rejected.size() == 1 : "Got unexpected count of rejected values";
        MDataPoint point = new MDataPoint(rejected.get(0));
        assert point.equals(dataPoint) : "Got unexpected rejected datapoint";
    }
View Full Code Here

Examples of org.rhq.modules.integrationTests.restApi.d.MDataPoint

    @Test
    public void testPostGetRawData3() throws Exception {

        long now = System.currentTimeMillis();

        MDataPoint dataPoint = new MDataPoint();
        dataPoint.setScheduleId(numericScheduleId);
        dataPoint.setTimeStamp(now);
        dataPoint.setValue(1.5);
        List<MDataPoint> points = new ArrayList<MDataPoint>(1);
        points.add(dataPoint);

        given()
            .header(acceptJson)
            .contentType(ContentType.JSON)
            .body(points)
        .expect()
            .statusCode(204)
            .log().ifError()
        .when()
            .post("/metric/data/raw");

        Response response =
        given()
            .header(acceptJson)
            .pathParam("id", numericScheduleId)
            .queryParam("startTime",now)
            .queryParam("endTime",now)
        .expect()
            .statusCode(200)
            .log().ifError()
            .body("", not(emptyIterable()))
        .when()
            .get("/metric/data/{id}/raw");

        List<Map<String,Object>> list = response.as(List.class);
        assert  list.size()>0 : "No data retrieved";

        boolean found = false;
        for (Map<String, Object> map : list) {
            MDataPoint mp = new MDataPoint(map);
            if (mp.equals(dataPoint))
                found = true;
        }
        assert found;

    }
View Full Code Here

Examples of org.rhq.modules.integrationTests.restApi.d.MDataPoint

        long now = System.currentTimeMillis();
        long tenMinutes = 10 * 60 * 1000L; // 10 mins

        // Post some data points
        List<MDataPoint> points = new ArrayList<MDataPoint>(howMany);
        MDataPoint dataPoint = new MDataPoint();
        dataPoint.setScheduleId(numericScheduleId);
        dataPoint.setTimeStamp(now);
        dataPoint.setValue(1.5);
        points.add(dataPoint);

        for (int i=1; i < howMany; i++) {
            dataPoint = new MDataPoint();
            dataPoint.setScheduleId(numericScheduleId);
            dataPoint.setTimeStamp(now-(i*tenMinutes));
            dataPoint.setValue(i+3.0);
            points.add(dataPoint);
        }

        given()
            .header(acceptJson)
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.