Package org.codehaus.jettison.json

Examples of org.codehaus.jettison.json.JSONObject.optDouble()


        valueAsJson = json.optJSONObject("keyFloat");
        Assert.assertNotNull(valueAsJson);
        Assert.assertTrue(valueAsJson.has(GraphSONTokens.TYPE));
        Assert.assertEquals(GraphSONTokens.TYPE_FLOAT, valueAsJson.optString(GraphSONTokens.TYPE));
        Assert.assertTrue(valueAsJson.has(GraphSONTokens.VALUE));
        Assert.assertEquals(3.3f, (float) valueAsJson.optDouble(GraphSONTokens.VALUE), 0);

        valueAsJson = json.optJSONObject("keyDouble");
        Assert.assertNotNull(valueAsJson);
        Assert.assertTrue(valueAsJson.has(GraphSONTokens.TYPE));
        Assert.assertEquals(GraphSONTokens.TYPE_DOUBLE, valueAsJson.optString(GraphSONTokens.TYPE));
View Full Code Here


        valueAsJson = json.optJSONObject("keyDouble");
        Assert.assertNotNull(valueAsJson);
        Assert.assertTrue(valueAsJson.has(GraphSONTokens.TYPE));
        Assert.assertEquals(GraphSONTokens.TYPE_DOUBLE, valueAsJson.optString(GraphSONTokens.TYPE));
        Assert.assertTrue(valueAsJson.has(GraphSONTokens.VALUE));
        Assert.assertEquals(4.4, valueAsJson.optDouble(GraphSONTokens.VALUE), 0);

        valueAsJson = json.optJSONObject("keyShort");
        Assert.assertNotNull(valueAsJson);
        Assert.assertTrue(valueAsJson.has(GraphSONTokens.TYPE));
        Assert.assertEquals(GraphSONTokens.TYPE_SHORT, valueAsJson.optString(GraphSONTokens.TYPE));
View Full Code Here

        Assert.assertTrue(json.has(GraphSONTokens._IN_V));
        Assert.assertEquals(2, json.optInt(GraphSONTokens._IN_V));
        Assert.assertTrue(json.has(GraphSONTokens._OUT_V));
        Assert.assertEquals(1, json.optInt(GraphSONTokens._OUT_V));
        Assert.assertTrue(json.has("weight"));
        Assert.assertEquals(0.5d, json.optDouble("weight"), 0.0d);
    }

    @Test
    public void jsonFromElementEdgeCompactIdOnlyAsInclude() throws JSONException {
        Vertex v1 = this.graph.addVertex(1);
View Full Code Here

        Assert.assertTrue(json.has(GraphSONTokens._ID));
        Assert.assertTrue(json.has(GraphSONTokens._TYPE));
        Assert.assertTrue(json.has(GraphSONTokens._LABEL));
        Assert.assertTrue(json.has(GraphSONTokens._IN_V));
        Assert.assertTrue(json.has(GraphSONTokens._OUT_V));
        Assert.assertEquals(0.5d, json.optDouble("weight"), 0.0d);
    }


    @Test
    public void jsonFromElementVertexNoPropertiesNoKeysNoTypes() throws JSONException {
View Full Code Here

        Assert.assertTrue(json.has("keyLong"));
        Assert.assertEquals(1L, json.optLong("keyLong"));
        Assert.assertTrue(json.has("keyInt"));
        Assert.assertEquals(2, json.optInt("keyInt"));
        Assert.assertTrue(json.has("keyFloat"));
        Assert.assertEquals(3.3f, (float) json.optDouble("keyFloat"), 0);
        Assert.assertTrue(json.has("keyExponentialDouble"));
        Assert.assertEquals(1312928167.626012, json.optDouble("keyExponentialDouble"), 0);
        Assert.assertTrue(json.has("keyDouble"));
        Assert.assertEquals(4.4, json.optDouble("keyDouble"), 0);
        Assert.assertTrue(json.has("keyBoolean"));
View Full Code Here

        Assert.assertTrue(json.has("keyInt"));
        Assert.assertEquals(2, json.optInt("keyInt"));
        Assert.assertTrue(json.has("keyFloat"));
        Assert.assertEquals(3.3f, (float) json.optDouble("keyFloat"), 0);
        Assert.assertTrue(json.has("keyExponentialDouble"));
        Assert.assertEquals(1312928167.626012, json.optDouble("keyExponentialDouble"), 0);
        Assert.assertTrue(json.has("keyDouble"));
        Assert.assertEquals(4.4, json.optDouble("keyDouble"), 0);
        Assert.assertTrue(json.has("keyBoolean"));
        Assert.assertTrue(json.optBoolean("keyBoolean"));
    }
View Full Code Here

        Assert.assertTrue(json.has("keyFloat"));
        Assert.assertEquals(3.3f, (float) json.optDouble("keyFloat"), 0);
        Assert.assertTrue(json.has("keyExponentialDouble"));
        Assert.assertEquals(1312928167.626012, json.optDouble("keyExponentialDouble"), 0);
        Assert.assertTrue(json.has("keyDouble"));
        Assert.assertEquals(4.4, json.optDouble("keyDouble"), 0);
        Assert.assertTrue(json.has("keyBoolean"));
        Assert.assertTrue(json.optBoolean("keyBoolean"));
    }

    @Test
View Full Code Here

            JSONObject json = response.getEntity(JSONObject.class);
            Assert.assertNotNull(json);
            Assert.assertTrue(json.has("name"));
            Assert.assertEquals(tg.getGraphName(), json.optString("name"));
            Assert.assertTrue(json.has(Tokens.QUERY_TIME));
            Assert.assertTrue(json.optDouble(Tokens.QUERY_TIME) > 0);
            Assert.assertTrue(json.has(Tokens.UP_TIME));
            Assert.assertTrue(json.has(Tokens.READ_ONLY));
            Assert.assertTrue(json.has("version"));
            Assert.assertTrue(json.has("type"));
            Assert.assertEquals(tg.getGraphType(), json.optString("type"));
View Full Code Here

    }

    private void assertPostedEdgeComplexProperties(JSONObject createdEdgeJson) {
        JSONObject mapRootProperty = createdEdgeJson.optJSONObject("complex");
        Assert.assertEquals(123, mapRootProperty.optInt("propertya"));
        Assert.assertEquals(321.5, mapRootProperty.optDouble("propertyb"));

        JSONArray listInMapProperty = mapRootProperty.optJSONArray("propertyc");
        Assert.assertEquals(3, listInMapProperty.length());

        JSONObject mapInMapProperty = mapRootProperty.optJSONObject("propertyd");
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.