Package org.codehaus.jettison.json

Examples of org.codehaus.jettison.json.JSONArray.optJSONObject()


                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"));
                    }
                }

                // todo: hack around titan inability to drop key indices
                if (!testGraph.getGraphType().equals("com.thinkaurelius.titan.graphdb.database.StandardTitanGraph")) {
View Full Code Here


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

                JSONObject marko = results.optJSONObject(0);
                Assert.assertEquals(mappedId, marko.optString("_id"));
                Assert.assertEquals("marko", marko.optString("name"));
            }
        }
    }
View Full Code Here

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

                JSONObject marko = results.optJSONObject(0);
                Assert.assertEquals(mappedId, marko.optString("_id"));
                Assert.assertEquals("marko", marko.optString("name"));

                doGraphDelete(testGraph, "indices/newindex", "key=name&value=marko&id=" + encode(mappedId));
View Full Code Here

                Assert.assertNotNull(vertexJson);

                results = vertexJson.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));

                // get the first two elements without specifying the start parameter
                graphResponse = doGraphGet(testGraph, "vertices", "rexster.offset.end=2");
View Full Code Here

                results = vertexJson.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));

                // get the first two elements without specifying the start parameter
                graphResponse = doGraphGet(testGraph, "vertices", "rexster.offset.end=2");

                Assert.assertNotNull(graphResponse);
View Full Code Here

                Assert.assertNotNull(vertexJson);

                results = vertexJson.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

                results = vertexJson.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));
            }
        }
    }

    @Test
View Full Code Here

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

        JSONObject firstResult = jsonResults.optJSONObject(0);
        Assert.assertNotNull(firstResult);
        Assert.assertTrue(firstResult.has("name"));
        Assert.assertEquals("marko", firstResult.optString("name"));
    }
View Full Code Here

        final JSONArray results = json.optJSONArray(Tokens.RESULTS);
        Assert.assertEquals(4, results.length());
        final List<String> foundIds = new ArrayList<String>();
        for (int ix = 0; ix < results.length(); ix++) {
            foundIds.add(results.optJSONObject(ix).optString(Tokens._ID));
        }

        Assert.assertTrue(foundIds.contains("1"));
        Assert.assertTrue(foundIds.contains("2"));
        Assert.assertTrue(foundIds.contains("4"));
View Full Code Here

        final JSONArray results = json.optJSONArray(Tokens.RESULTS);
        Assert.assertEquals(2, results.length());
        final List<String> foundIds = new ArrayList<String>();
        for (int ix = 0; ix < results.length(); ix++) {
            foundIds.add(results.optJSONObject(ix).optString(Tokens._ID));
        }

        Assert.assertTrue(foundIds.contains("1"));
        Assert.assertTrue(foundIds.contains("6"));
    }
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.