Package org.codehaus.jettison.json

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


        JSONObject jsonObject = converted.getJSONObject(0);
        Assert.assertNotNull(jsonObject);

        JSONObject mapValue = jsonObject.optJSONObject("1");
        Assert.assertEquals(1000, mapValue.optInt(Tokens._VALUE));

        JSONObject element = mapValue.optJSONObject(Tokens._KEY);
        Assert.assertNotNull(element);
        Assert.assertEquals("1", element.optString(Tokens._ID));
    }
View Full Code Here


        Assert.assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());

        final JSONObject entity = (JSONObject) r.getEntity();
        Assert.assertNotNull(entity);
        Assert.assertEquals("marko", entity.optString("name"));
        Assert.assertEquals(29, entity.optInt("age"));
    }

    @Test
    public void okForGraphElements() {
        final Graph g = TinkerGraphFactory.createTinkerGraph();
View Full Code Here

        JSONObject entity = (JSONObject) response.getJerseyResponse().getEntity();

        Assert.assertNotNull(entity);
        Assert.assertTrue(entity.has("txProcessed"));

        Assert.assertEquals(6, entity.optInt("txProcessed"));

        Vertex v100 = graph.getVertex(100);
        Assert.assertNotNull(v100);
        Assert.assertEquals("v1", v100.getProperty("k1"));
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());
View Full Code Here

            Assert.assertEquals(ClientResponse.Status.OK, graphResponse.getClientResponseStatus());

            json = graphResponse.getEntity(JSONObject.class);
            Assert.assertNotNull(json);

            Assert.assertEquals(2, json.optInt(Tokens.TOTAL_SIZE));

            // get out vertex ids filtered by label and weight
            graphResponse = doGraphGet(testGraph, "vertices/" + encode(id) + "/outIds", "_label=[knows]&_properties=[[weight,=,(d,1)]]");

            Assert.assertNotNull(graphResponse);
View Full Code Here

            request.setEntity(new JSONObject(postData));

            final ClientResponse response = httpClient.handle(request);
            final JSONObject json = response.getEntity(JSONObject.class);
            final JSONObject result = json.optJSONObject("results");
            Assert.assertEquals(ix, result.optInt("someId"));
        }
    }
}
View Full Code Here

        JSONObject jsonObject = (JSONObject) response.getEntity();
        Assert.assertNotNull(jsonObject);
        Assert.assertTrue(jsonObject.has("name"));
        Assert.assertEquals("marko", jsonObject.optString("name"));
        Assert.assertTrue(jsonObject.has("age"));
        Assert.assertEquals(29, jsonObject.optInt("age"));
    }

    @Test
    public void doFramesWorkOnEdgeShortUrl() {
        final UriInfo uri = mockTheUri(false, "");
View Full Code Here

        Assert.assertNotNull(json);

        // the JSON has an output property and it contains the data from the toString call on the
        // requested element.
        Assert.assertTrue(json.has("some-integer"));
        Assert.assertEquals(replyToSend.intValue(), json.optInt("some-integer"));
    }

    @Test
    public void evaluateSomeListValid() {
        JSONArray replyToSend = new JSONArray() {{
View Full Code Here

        Assert.assertNotNull(json);

        // the JSON has an output property and it contains the data from the toString call on the
        // requested element.
        Assert.assertTrue(json.has("a"));
        Assert.assertEquals(100, json.optInt("a"));

        JSONObject innerToAssert = json.optJSONObject("b");
        Assert.assertEquals("test", innerToAssert.optString("a"));
        Assert.assertEquals(101, innerToAssert.optInt("b"));
View Full Code Here

        Assert.assertTrue(json.has("a"));
        Assert.assertEquals(100, json.optInt("a"));

        JSONObject innerToAssert = json.optJSONObject("b");
        Assert.assertEquals("test", innerToAssert.optString("a"));
        Assert.assertEquals(101, innerToAssert.optInt("b"));

        Assert.assertEquals(3, json.optJSONArray("c").length());
    }
}
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.