VertexResource extends AbstractSubResource { @GET @Path("/{id}/{direction}") @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON}) @Timed(name = "http.rest.vertices.object.edges.collection.get", absolute = true) public Response getVertexEdges(@PathParam("graphname") String graphName, @PathParam("id") String vertexId, @PathParam("direction") String direction) { return this.getVertexEdges(graphName, vertexId, direction, false); } VertexResource();  VertexResource(final UriInfo ui, final HttpServletRequest req, final RexsterApplication ra); @OPTIONS Response optionsVertices(); @GET @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON}) @Timed(name = "http.rest.vertices.collection.get", absolute = true) Response getVertices(@PathParam("graphname") final String graphName); @GET @Produces({RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.vertices.collection.get", absolute = true) Response getVerticesRexsterJson(@PathParam("graphname") final String graphName); @OPTIONS @Path("/{id}") Response optionsSingleVertex(); @GET @Path("/{id}") @Produces({MediaType.APPLICATION_JSON}) @Timed(name = "http.rest.vertices.object.get", absolute = true) Response getSingleVertex(@PathParam("graphname") final String graphName, @PathParam("id") final String id); @GET @Path("/{id}") @Produces({RexsterMediaType.APPLICATION_REXSTER_JSON}) @Timed(name = "http.rest.vertices.object.get", absolute = true) Response getSingleVertexRexsterJson(@PathParam("graphname") final String graphName, @PathParam("id") final String id); @GET @Path("/{id}") @Produces({RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.vertices.object.get", absolute = true) Response getSingleVertexRexsterTypedJson(@PathParam("graphname") final String graphName, @PathParam("id") final String id); @HEAD @Path("/{id}/{extension: (?!outE)(?!bothE)(?!inE)(?!out)(?!both)(?!in)(?!query).+}") @Consumes(MediaType.APPLICATION_JSON) Response headVertexExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id, final JSONObject json); @HEAD @Path("/{id}/{extension: (?!outE)(?!bothE)(?!inE)(?!out)(?!both)(?!in)(?!query).+}") Response headVertexExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id); @PUT @Path("/{id}/{extension: (?!outE)(?!bothE)(?!inE)(?!out)(?!both)(?!in)(?!query).+}") @Consumes(MediaType.APPLICATION_JSON) @Timed(name = "http.rest.vertices.extension.put", absolute = true) Response putVertexExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id, final JSONObject json); @PUT @Path("/{id}/{extension: (?!outE)(?!bothE)(?!inE)(?!out)(?!both)(?!in)(?!query).+}") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Timed(name = "http.rest.vertices.extension.put", absolute = true) Response putVertexExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id, final MultivaluedMap<String, String> formParams); @PUT @Path("/{id}/{extension: (?!outE)(?!bothE)(?!inE)(?!out)(?!both)(?!in)(?!query).+}") @Timed(name = "http.rest.vertices.extension.put", absolute = true) Response putVertexExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id); @OPTIONS @Path("/{id}/{extension: (?!outE)(?!bothE)(?!inE)(?!out)(?!both)(?!in)(?!query).+}") @Consumes(MediaType.APPLICATION_JSON) Response optionsVertexExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id, final JSONObject json); @OPTIONS @Path("/{id}/{extension: (?!outE)(?!bothE)(?!inE)(?!out)(?!both)(?!in)(?!query).+}") Response optionsVertexExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id); @DELETE @Path("/{id}/{extension: (?!outE)(?!bothE)(?!inE)(?!out)(?!both)(?!in)(?!query).+}") @Consumes(MediaType.APPLICATION_JSON) @Timed(name = "http.rest.vertices.extension.delete", absolute = true) Response deleteVertexExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id, final JSONObject json); @DELETE @Path("/{id}/{extension: (?!outE)(?!bothE)(?!inE)(?!out)(?!both)(?!in)(?!query).+}") @Timed(name = "http.rest.vertices.extension.delete", absolute = true) Response deleteVertexExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id); @POST @Path("/{id}/{extension: (?!outE)(?!bothE)(?!inE)(?!out)(?!both)(?!in)(?!query).+}") @Consumes(MediaType.APPLICATION_JSON) @Timed(name = "http.rest.vertices.extension.post", absolute = true) Response postVertexExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id, final JSONObject json); @POST @Path("/{id}/{extension: (?!outE)(?!bothE)(?!inE)(?!out)(?!both)(?!in)(?!query).+}") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Timed(name = "http.rest.vertices.extension.post", absolute = true) Response postVertexExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id, final MultivaluedMap<String, String> formParams); @POST @Path("/{id}/{extension: (?!outE)(?!bothE)(?!inE)(?!out)(?!both)(?!in)(?!query).+}") @Timed(name = "http.rest.vertices.extension.post", absolute = true) Response postVertexExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id); @GET @Path("/{id}/{extension: (?!outE)(?!bothE)(?!inE)(?!out)(?!both)(?!in)(?!query).+}") @Timed(name = "http.rest.vertices.extension.get", absolute = true) Response getVertexExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id); @OPTIONS @Path("/{id}/{direction}") Response optionsVertexEdges(); @GET @Path("/{id}/{direction}") @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON}) @Timed(name = "http.rest.vertices.object.edges.collection.get", absolute = true) Response getVertexEdges(@PathParam("graphname") String graphName, @PathParam("id") String vertexId, @PathParam("direction") String direction); @GET @Path("/{id}/{direction}") @Produces({RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.vertices.object.edges.collection.get", absolute = true) Response getVertexEdgesRexsterTypedJson(@PathParam("graphname") String graphName, @PathParam("id") String vertexId, @PathParam("direction") String direction); @POST @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Consumes({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON}) @Timed(name = "http.rest.vertices.object.post", absolute = true) Response postNullVertexRexsterConsumesJson(@Context final Request request, @PathParam("graphname") final String graphName, final JSONObject json); @POST @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Consumes({RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.vertices.object.post", absolute = true) Response postNullVertexRexsterConsumesTypedJson(@Context final Request request, @PathParam("graphname") final String graphName, final JSONObject json); @POST @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.vertices.object.post", absolute = true) Response postNullVertexOnUri(@Context final Request request, @PathParam("graphname") final String graphName); @POST @Path("/{id}") @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Consumes({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON}) @Timed(name = "http.rest.vertices.object.post", absolute = true) Response postVertexConsumesJson(@Context final Request request, @PathParam("graphname") final String graphName, @PathParam("id") final String id, final JSONObject json); @POST @Path("/{id}") @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Consumes({RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.vertices.object.post", absolute = true) Response postVertexRexsterConsumesTypedJson(@Context final Request request, @PathParam("graphname") final String graphName, @PathParam("id") final String id, final JSONObject json); @POST @Path("/{id}") @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.vertices.object.post", absolute = true) Response postVertexOnUri(@Context final Request request, @PathParam("graphname") final String graphName, @PathParam("id") final String id); @PUT @Path("/{id}") @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Consumes({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON}) @Timed(name = "http.rest.vertices.object.put", absolute = true) Response putVertexConsumesJson(@Context Request request, @PathParam("graphname") String graphName, @PathParam("id") String id, JSONObject json); @PUT @Path("/{id}") @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Consumes(RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON) @Timed(name = "http.rest.vertices.object.put", absolute = true) Response putVertexConsumesTypedJson(@Context Request request, @PathParam("graphname") String graphName, @PathParam("id") String id, JSONObject json); @PUT @Path("/{id}") @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.vertices.object.put", absolute = true) Response putVertexConsumesUri(@Context Request request, @PathParam("graphname") String graphName, @PathParam("id") String id); @DELETE @Path("/{id}") @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.vertices.object.delete", absolute = true) Response deleteVertex(@PathParam("graphname") String graphName, @PathParam("id") String id);  }
@Test public void getVertexEdgesFoundVertexReturnInEdgesNoOffset() { final VertexResource resource = this.constructVertexResourceWithToyGraph().getResource(); final Response response = resource.getVertexEdges(graphName, "3", Tokens.IN_E); final JSONObject json = assertEdgesOkResponseJsonStructure(response, 3); final JSONArray jsonResultArray = json.optJSONArray(Tokens.RESULTS); this.assertFoundElementsInResults(jsonResultArray, Tokens.EDGE, "9", "11", "12"); }
@Test public void getVertexEdgesFoundVertexReturnOutEdgesNoOffsetWithLabel() { final HashMap<String, Object> map = new HashMap<String, Object>() {{ put(Tokens._LABEL, "created"); }}; final VertexResource resource = this.constructVertexResource(true, map).getResource(); final Response response = resource.getVertexEdges(graphName, "1", Tokens.OUT_E); final JSONObject json = assertEdgesOkResponseJsonStructure(response, 1); final JSONArray jsonResultArray = json.optJSONArray(Tokens.RESULTS); this.assertFoundElementsInResults(jsonResultArray, Tokens.EDGE, "9"); }
@Test public void getVertexEdgesFoundVertexReturnInVerticesNoOffset() { final VertexResource resource = this.constructVertexResourceWithToyGraph().getResource(); final Response response = resource.getVertexEdges(graphName, "3", Tokens.IN); final JSONObject json = assertEdgesOkResponseJsonStructure(response, 3); final JSONArray jsonResultArray = json.optJSONArray(Tokens.RESULTS); this.assertFoundElementsInResults(jsonResultArray, Tokens.VERTEX, "1", "6", "4"); }
@Test public void getVertexEdgesFoundVertexReturnInVerticesNoOffsetWithLabel() { final Vertex vertexMarko = this.toyGraph.getVertex(1); final Vertex vertexStephen = this.toyGraph.addVertex(null); this.toyGraph.addEdge(null, vertexStephen, vertexMarko, "knows"); final HashMap<String, Object> map = new HashMap<String, Object>() {{ put(Tokens._LABEL, "knows"); }}; final VertexResource resource = this.constructVertexResource(true, map).getResource(); final Response response = resource.getVertexEdges("graph", "1", Tokens.IN); final JSONObject json = assertEdgesOkResponseJsonStructure(response, 1); final JSONArray jsonResultArray = json.optJSONArray(Tokens.RESULTS); this.assertFoundElementsInResults(jsonResultArray, Tokens.VERTEX, vertexStephen.getId().toString()); }
@Test public void getVertexEdgesFoundVertexOutEdgesNoOffset() { final VertexResource resource = this.constructVertexResourceWithToyGraph().getResource(); final Response response = resource.getVertexEdges(graphName, "6", Tokens.OUT_E); final JSONObject json = assertEdgesOkResponseJsonStructure(response, 1); final JSONArray jsonResultArray = json.optJSONArray(Tokens.RESULTS); this.assertFoundElementsInResults(jsonResultArray, Tokens.EDGE, "12"); }
@Test public void getVertexEdgesFoundVertexOutVerticesNoOffset() { final VertexResource resource = this.constructVertexResourceWithToyGraph().getResource(); final Response response = resource.getVertexEdges(graphName, "6", Tokens.OUT); final JSONObject json = assertEdgesOkResponseJsonStructure(response, 1); final JSONArray jsonResultArray = json.optJSONArray(Tokens.RESULTS); this.assertFoundElementsInResults(jsonResultArray, Tokens.VERTEX, "3"); }
@Test public void getVertexEdgesFoundVertexBothEdgesNoOffset() { final VertexResource resource = this.constructVertexResourceWithToyGraph().getResource(); final Response response = resource.getVertexEdges(graphName, "4", Tokens.BOTH_E); final JSONObject json = assertEdgesOkResponseJsonStructure(response, 3); final JSONArray jsonResultArray = json.optJSONArray(Tokens.RESULTS); this.assertFoundElementsInResults(jsonResultArray, Tokens.EDGE, "8", "10", "11"); }
@Test public void getVertexEdgesFoundVertexBothVerticesNoOffset() { final VertexResource resource = this.constructVertexResourceWithToyGraph().getResource(); final Response response = resource.getVertexEdges(graphName, "4", Tokens.BOTH); final JSONObject json = assertEdgesOkResponseJsonStructure(response, 3); final JSONArray jsonResultArray = json.optJSONArray(Tokens.RESULTS); this.assertFoundElementsInResults(jsonResultArray, Tokens.VERTEX, "1", "3", "5"); }
@Test public void getVertexEdgesFoundVertexBothEdgesWithValidOffset() { final HashMap<String, Object> parameters = new HashMap<String, Object>(); parameters.put(Tokens.REXSTER + "." + Tokens.OFFSET_START, "1"); parameters.put(Tokens.REXSTER + "." + Tokens.OFFSET_END, "3"); final VertexResource resource = this.constructVertexResource(true, parameters).getResource(); final Response response = resource.getVertexEdges(graphName, "1", Tokens.BOTH_E); final JSONObject json = assertEdgesOkResponseJsonStructure(response, 3); final JSONArray jsonResultArray = json.optJSONArray(Tokens.RESULTS); this.assertFoundElementsInResults(jsonResultArray, Tokens.EDGE, "8", "9"); }
@Test public void getVertexEdgesFoundVertexBothEdgesWithOffsetNotEnoughResults() { final HashMap<String, Object> parameters = new HashMap<String, Object>(); parameters.put(Tokens.REXSTER + "." + Tokens.OFFSET_START, "10"); parameters.put(Tokens.REXSTER + "." + Tokens.OFFSET_END, "20"); final VertexResource resource = this.constructVertexResource(true, parameters).getResource(); final Response response = resource.getVertexEdges(graphName, "1", Tokens.BOTH_E); final JSONObject json = assertEdgesOkResponseJsonStructure(response, 3); final JSONArray jsonResultArray = json.optJSONArray(Tokens.RESULTS); Assert.assertNotNull(jsonResultArray); Assert.assertEquals(0, jsonResultArray.length()); }
@Test public void getVertexEdgesFoundVertexBothEdgesWithOffsetStartAfterEnd() { final HashMap<String, Object> parameters = new HashMap<String, Object>(); parameters.put(Tokens.REXSTER + "." + Tokens.OFFSET_START, "30"); parameters.put(Tokens.REXSTER + "." + Tokens.OFFSET_END, "20"); final VertexResource resource = this.constructVertexResource(true, parameters).getResource(); final Response response = resource.getVertexEdges(graphName, "1", Tokens.BOTH_E); final JSONObject json = assertEdgesOkResponseJsonStructure(response, 3); final JSONArray jsonResultArray = json.optJSONArray(Tokens.RESULTS); Assert.assertNotNull(jsonResultArray); Assert.assertEquals(0, jsonResultArray.length()); }