Package com.google.gson

Examples of com.google.gson.JsonObject


  private void setQueryString(JsonElement queryStringParams) {
    JsonArray array_params = JsonUtils.asJsonArray(queryStringParams);
    if (array_params != null) {
      for (JsonElement jQueryParam : array_params) {
        JsonObject queryParam = JsonUtils.asJsonObject(jQueryParam);
        String name = queryParam.get("name").getAsString();
        String value = queryParam.get("value").getAsString();
        this.addQueryStringParam(name, value);
        if (Parameter.isParameter(value)) {
          this.addParameter(new Parameter(value));
        }
      }
View Full Code Here


        Assert.assertEquals(1, pivotSpec.getFilters().size());
        for (PivotFilter pf : pivotSpec.getFilters()) {
            Assert.assertTrue(pf instanceof NumberPivotFilter);
            JsonElement obj = pf.toJson();
            Assert.assertTrue(obj instanceof JsonObject);
            JsonObject o = (JsonObject)obj;

            Assert.assertTrue(o.has("fieldName"));
            Assert.assertEquals(new JsonPrimitive("epsilon"), o.get("fieldName"));

            Assert.assertTrue(o.has("type"));
            Assert.assertEquals(new JsonPrimitive("number"), o.get("type"));

            Assert.assertTrue(o.has("comparator"));
            Assert.assertEquals(new JsonPrimitive(">="), o.get("comparator"));

            Assert.assertTrue(o.has("compareTo"));
            Assert.assertEquals(new JsonPrimitive((double)2.3), o.get("compareTo"));
        }
    }
View Full Code Here

        for (PivotFilter pf : pivotSpecification.getFilters()) {
            Assert.assertTrue(pf instanceof LimitPivotFilter);
            JsonElement obj = pf.toJson();

            Assert.assertTrue(obj instanceof JsonObject);
            JsonObject o = (JsonObject)obj;

            Assert.assertTrue(o.has("fieldName"));
            Assert.assertEquals(new JsonPrimitive("epsilon"), o.get("fieldName"));

            Assert.assertTrue(o.has("owner"));
            Assert.assertEquals(new JsonPrimitive("test_data"), o.get("owner"));

            Assert.assertTrue(o.has("type"));
            Assert.assertEquals(new JsonPrimitive("number"), o.get("type"));

            Assert.assertTrue(o.has("attributeName"));
            Assert.assertEquals(new JsonPrimitive("host"), o.get("attributeName"));

            Assert.assertTrue(o.has("attributeOwner"));
            Assert.assertEquals(new JsonPrimitive("BaseEvent"), o.get("attributeOwner"));

            Assert.assertTrue(o.has("limitType"));
            Assert.assertEquals(new JsonPrimitive("lowest"), o.get("limitType"));

            Assert.assertTrue(o.has("limitAmount"));
            Assert.assertEquals(new JsonPrimitive(500), o.get("limitAmount"));

            Assert.assertTrue(o.has("statsFn"));
            Assert.assertEquals(new JsonPrimitive("average"), o.get("statsFn"));
        }
    }
View Full Code Here

        for (PivotRowSplit prs : pivotSpecification.getRowSplits()) {
            Assert.assertTrue(prs instanceof NumberPivotRowSplit);
            JsonElement obj = prs.toJson();

            Assert.assertTrue(obj instanceof JsonObject);
            JsonObject o = (JsonObject)obj;

            Assert.assertTrue(o.has("fieldName"));
            Assert.assertEquals(new JsonPrimitive("epsilon"), o.get("fieldName"));

            Assert.assertTrue(o.has("owner"));
            Assert.assertEquals(new JsonPrimitive("test_data"), o.get("owner"));

            Assert.assertTrue(o.has("type"));
            Assert.assertEquals(new JsonPrimitive("number"), o.get("type"));

            Assert.assertTrue(o.has("label"));
            Assert.assertEquals(new JsonPrimitive("My Label"), o.get("label"));

            Assert.assertTrue(o.has("display"));
            Assert.assertEquals(new JsonPrimitive("all"), o.get("display"));
        }
    }
View Full Code Here

        for (PivotRowSplit prs : pivotSpecification.getRowSplits()) {
            Assert.assertTrue(prs instanceof RangePivotRowSplit);
            JsonElement obj = prs.toJson();

            Assert.assertTrue(obj instanceof JsonObject);
            JsonObject o = (JsonObject)obj;

            Assert.assertTrue(o.has("fieldName"));
            Assert.assertEquals(new JsonPrimitive("epsilon"), o.get("fieldName"));

            Assert.assertTrue(o.has("owner"));
            Assert.assertEquals(new JsonPrimitive("test_data"), o.get("owner"));

            Assert.assertTrue(o.has("type"));
            Assert.assertEquals(new JsonPrimitive("number"), o.get("type"));

            Assert.assertTrue(o.has("label"));
            Assert.assertEquals(new JsonPrimitive("My Label"), o.get("label"));

            Assert.assertTrue(o.has("display"));
            Assert.assertEquals(new JsonPrimitive("ranges"), o.get("display"));

            JsonObject ranges = new JsonObject();
            ranges.add("start", new JsonPrimitive(0));
            ranges.add("end", new JsonPrimitive(100));
            ranges.add("size", new JsonPrimitive(20));
            ranges.add("maxNumberOf", new JsonPrimitive(5));
            Assert.assertTrue(o.has("ranges"));
            Assert.assertEquals(ranges, o.get("ranges"));
        }
    }
View Full Code Here

        for (PivotRowSplit prs : pivotSpecification.getRowSplits()) {
            Assert.assertTrue(prs instanceof BooleanPivotRowSplit);
            JsonElement obj = prs.toJson();

            Assert.assertTrue(obj instanceof JsonObject);
            JsonObject o = (JsonObject)obj;

            JsonObject expected = new JsonObject();
            expected.add("fieldName", new JsonPrimitive("has_boris"));
            expected.add("label", new JsonPrimitive("My Label"));
            expected.add("owner", new JsonPrimitive("test_data"));
            expected.addProperty("type", "boolean");
            expected.addProperty("trueLabel", "is_true");
            expected.addProperty("falseLabel", "is_false");

            Assert.assertEquals(expected, o);
        }
    }
View Full Code Here

        for (PivotRowSplit prs : pivotSpecification.getRowSplits()) {
            Assert.assertTrue(prs instanceof TimestampPivotRowSplit);
            JsonElement obj = prs.toJson();

            Assert.assertTrue(obj instanceof JsonObject);
            JsonObject o = (JsonObject)obj;

            JsonObject expected = new JsonObject();
            expected.add("fieldName", new JsonPrimitive("_time"));
            expected.add("label", new JsonPrimitive("My Label"));
            expected.add("owner", new JsonPrimitive("BaseEvent"));
            expected.addProperty("type", "timestamp");
            expected.addProperty("period", "day");

            Assert.assertEquals(expected, o);
        }
    }
View Full Code Here

        Assert.assertEquals(1, pivotSpecification.getRowSplits().size());
        for (PivotRowSplit prs : pivotSpecification.getRowSplits()) {
            Assert.assertTrue(prs instanceof StringPivotRowSplit);
            JsonElement found = prs.toJson();

            JsonObject expected = new JsonObject();
            expected.addProperty("fieldName", "host");
            expected.addProperty("label", "My Label");
            expected.addProperty("owner", "BaseEvent");
            expected.addProperty("type", "string");

            Assert.assertEquals(expected, found);
        }
    }
View Full Code Here

        for (PivotColumnSplit prs : pivotSpecification.getColumnSplits()) {
            Assert.assertTrue(prs instanceof NumericPivotColumnSplit);
            JsonElement obj = prs.toJson();

            Assert.assertTrue(obj instanceof JsonObject);
            JsonObject o = (JsonObject)obj;

            Assert.assertTrue(o.has("fieldName"));
            Assert.assertEquals(new JsonPrimitive("epsilon"), o.get("fieldName"));

            Assert.assertTrue(o.has("owner"));
            Assert.assertEquals(new JsonPrimitive("test_data"), o.get("owner"));

            Assert.assertTrue(o.has("type"));
            Assert.assertEquals(new JsonPrimitive("number"), o.get("type"));

            Assert.assertTrue(o.has("display"));
            Assert.assertEquals(new JsonPrimitive("all"), o.get("display"));
        }
    }
View Full Code Here

        for (PivotColumnSplit prs : pivotSpecification.getColumnSplits()) {
            Assert.assertTrue(prs instanceof RangePivotColumnSplit);
            JsonElement obj = prs.toJson();

            Assert.assertTrue(obj instanceof JsonObject);
            JsonObject o = (JsonObject)obj;

            Assert.assertTrue(o.has("fieldName"));
            Assert.assertEquals(new JsonPrimitive("epsilon"), o.get("fieldName"));

            Assert.assertTrue(o.has("owner"));
            Assert.assertEquals(new JsonPrimitive("test_data"), o.get("owner"));

            Assert.assertTrue(o.has("type"));
            Assert.assertEquals(new JsonPrimitive("number"), o.get("type"));

            Assert.assertTrue(o.has("display"));
            Assert.assertEquals(new JsonPrimitive("ranges"), o.get("display"));

            JsonObject ranges = new JsonObject();
            ranges.add("start", new JsonPrimitive("0"));
            ranges.add("end", new JsonPrimitive("100"));
            ranges.add("size", new JsonPrimitive("20"));
            ranges.add("maxNumberOf", new JsonPrimitive("5"));
            Assert.assertTrue(o.has("ranges"));
            Assert.assertEquals(ranges, o.get("ranges"));
        }
    }
View Full Code Here

TOP

Related Classes of com.google.gson.JsonObject

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.