Package com.google.gson

Examples of com.google.gson.JsonObject


        for (PivotColumnSplit prs : pivotSpecification.getColumnSplits()) {
            Assert.assertTrue(prs instanceof BooleanPivotColumnSplit);
            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("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


        pivotSpecification.addColumnSplit("_time", TimestampBinning.DAY);

        Assert.assertEquals(1, pivotSpecification.getColumnSplits().size());
        for (PivotColumnSplit prs : pivotSpecification.getColumnSplits()) {
            Assert.assertTrue(prs instanceof TimestampPivotColumnSplit);
            JsonObject found = prs.toJson();

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

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

        pivotSpecification.addColumnSplit("host");

        Assert.assertEquals(1, pivotSpecification.getColumnSplits().size());
        for (PivotColumnSplit prs : pivotSpecification.getColumnSplits()) {
            Assert.assertTrue(prs instanceof StringPivotColumnSplit);
            JsonObject found = prs.toJson();

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

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

        PivotSpecification pivotSpecification = dataModelObject.createPivotSpecification();
        pivotSpecification.addCellValue("source", "Source Value", StatsFunction.DISTINCT_COUNT);

        Assert.assertEquals(1, pivotSpecification.getCellValues().size());
        for (PivotCellValue pcv : pivotSpecification.getCellValues()) {
            JsonObject found = pcv.toJson();
            JsonObject expected = new JsonObject();
            expected.addProperty("fieldName", "source");
            expected.addProperty("owner", "BaseEvent");
            expected.addProperty("type", "string");
            expected.addProperty("label", "Source Value");
            expected.addProperty("value", "dc");
            expected.addProperty("sparkline", false);

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

        PivotSpecification pivotSpecification = dataModelObject.createPivotSpecification();
        pivotSpecification.addCellValue("hostip", "Source Value", StatsFunction.DISTINCT_COUNT);

        Assert.assertEquals(1, pivotSpecification.getCellValues().size());
        for (PivotCellValue pcv : pivotSpecification.getCellValues()) {
            JsonObject found = pcv.toJson();
            JsonObject expected = new JsonObject();
            expected.addProperty("fieldName", "hostip");
            expected.addProperty("owner", "test_data");
            expected.addProperty("type", "ipv4");
            expected.addProperty("label", "Source Value");
            expected.addProperty("value", "dc");
            expected.addProperty("sparkline", false);

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

    @Test
    public void testConstructorArgs() {

        PivotSpecification pivotArgs = dataModelObject.createPivotSpecification();

        JsonObject root = pivotArgs.toJson();

        Assert.assertTrue(root.has("dataModel"));
        Assert.assertEquals(new JsonPrimitive(dataModelObject.getDataModel().getName()), root.get("dataModel"));

        Assert.assertTrue(root.has("baseClass"));
        Assert.assertEquals(new JsonPrimitive(dataModelObject.getName()), root.get("baseClass"));
    }
View Full Code Here

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    private static class SpoutStateAdapter implements JsonDeserializer<SpoutState> {

        @Override
        public SpoutState deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException {
            SpoutState r = new SpoutState();
            final JsonObject object = json.getAsJsonObject();
            r.oldFiles = context.deserialize(object.get("oldFiles"), new TypeToken<Set<File>>() {}.getType());
            r.offsets = Maps.newHashMap();
            for (Map.Entry<String, JsonElement> entry: object.get("offsets").getAsJsonObject().entrySet()) {
                r.offsets.put(new File(entry.getKey()), entry.getValue().getAsLong());
            }
            r.inputDirectory = object.get("inputDirectory").getAsString();
            r.filePattern = object.get("filePattern").getAsString();
            return r;
        }
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.