Package org.codehaus.jettison.json

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


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

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

                results = edgeJson.optJSONArray(Tokens.RESULTS);
                Assert.assertEquals(2, results.length());

                Assert.assertFalse(uniqueIds.contains(results.optJSONObject(1).optString(Tokens._ID)));
                uniqueIds.add(results.optJSONObject(0).optString(Tokens._ID));
View Full Code Here


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

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

                results = edgeJson.optJSONArray(Tokens.RESULTS);
                Assert.assertEquals(2, results.length());

                Assert.assertEquals(uniqueIds.get(4), results.optJSONObject(0).optString(Tokens._ID));
                Assert.assertEquals(uniqueIds.get(5), results.optJSONObject(1).optString(Tokens._ID));
View Full Code Here

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

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

                results = edgeJson.optJSONArray(Tokens.RESULTS);
                Assert.assertEquals(2, results.length());

                Assert.assertEquals(uniqueIds.get(0), results.optJSONObject(0).optString(Tokens._ID));
                Assert.assertEquals(uniqueIds.get(1), results.optJSONObject(1).optString(Tokens._ID));
            }
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");
        Assert.assertEquals("xyz", mapInMapProperty.optString("x"));
    }
View Full Code Here

        ClientRequest request = ClientRequest.create().build(createUri("/"), "GET");
        ClientResponse response = this.client.handle(request);

        JSONObject json = response.getEntity(JSONObject.class);
        JSONArray jsonArray = json.optJSONArray("graphs");

        TinkerGraph testGraph = TinkerGraphFactory.createTinkerGraph();

        this.testGraphs = new ArrayList<GraphTestHolder>();
        for (int ix = 0; ix < jsonArray.length(); ix++) {
View Full Code Here

    public void tearDown() throws Exception {
        try {
            for (GraphTestHolder testGraph : this.testGraphs) {
                ClientResponse response = doGraphGet(testGraph, "vertices");
                JSONObject verticesJson = response.getEntity(JSONObject.class);
                JSONArray verticesToDelete = verticesJson.optJSONArray(Tokens.RESULTS);
                for (int ix = 0; ix < verticesToDelete.length(); ix++) {
                    this.client.handle(ClientRequest.create().build(createUri("/" + testGraph.getGraphName() + "/vertices/" + encode(verticesToDelete.optJSONObject(ix).optString(Tokens._ID))), "DELETE"));
                }

                if (testGraph.getFeatures().supportsIndices) {
View Full Code Here

                }

                if (testGraph.getFeatures().supportsIndices) {
                    response = doGraphGet(testGraph, "indices");
                    JSONObject indicesJson = response.getEntity(JSONObject.class);
                    JSONArray indicesToDelete = indicesJson.optJSONArray(Tokens.RESULTS);
                    for (int ix = 0; ix < indicesToDelete.length(); ix++) {
                        this.client.handle(ClientRequest.create().build(createUri("/" + testGraph.getGraphName() + "/indices/" + indicesToDelete.optJSONObject(ix).optString("name")), "DELETE"));
                    }
                }
View Full Code Here

                // todo: hack around titan inability to drop key indices
                if (!testGraph.getGraphType().equals("com.thinkaurelius.titan.graphdb.database.StandardTitanGraph")) {
                    response = doGraphGet(testGraph, "keyindices/vertex");
                    JSONObject keyIndicesVertexJson = response.getEntity(JSONObject.class);
                    JSONArray keyIndicesVertexToDelete = keyIndicesVertexJson.optJSONArray(Tokens.RESULTS);
                    for (int ix = 0; ix < keyIndicesVertexToDelete.length(); ix++) {
                        this.client.handle(ClientRequest.create().build(createUri("/" + testGraph.getGraphName() + "/keyindices/vertex/" + encode(keyIndicesVertexToDelete.optString(ix))), "DELETE"));
                    }

                    response = doGraphGet(testGraph, "keyindices/edge");
View Full Code Here

                        this.client.handle(ClientRequest.create().build(createUri("/" + testGraph.getGraphName() + "/keyindices/vertex/" + encode(keyIndicesVertexToDelete.optString(ix))), "DELETE"));
                    }

                    response = doGraphGet(testGraph, "keyindices/edge");
                    JSONObject keyIndicesEdgeJson = response.getEntity(JSONObject.class);
                    JSONArray keyIndicesEdgeToDelete = keyIndicesEdgeJson.optJSONArray(Tokens.RESULTS);
                    for (int ix = 0; ix < keyIndicesEdgeToDelete.length(); ix++) {
                        this.client.handle(ClientRequest.create().build(createUri("/" + testGraph.getGraphName() + "/keyindices/edge/" + keyIndicesEdgeToDelete.optString(ix)), "DELETE"));
                    }
                }
            }
View Full Code Here

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

                JSONObject result = indexGetResponse.getEntity(JSONObject.class);
                Assert.assertNotNull(result);

                JSONArray results = result.optJSONArray("results");
                Assert.assertNotNull(results);
                Assert.assertEquals(1, results.length());

                JSONObject marko = results.optJSONObject(0);
                Assert.assertEquals(mappedId, marko.optString("_id"));
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.