EdgeResource extends AbstractSubResource { @GET @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON}) @Timed(name = "http.rest.edges.collection.get", absolute = true) public Response getAllEdges(@PathParam("graphname") final String graphName) { return this.getAllEdges(graphName, false); } EdgeResource();  EdgeResource(final UriInfo ui, final HttpServletRequest req, final RexsterApplication ra); @OPTIONS Response optionsAllEdges(); @GET @Produces({MediaType.APPLICATION_JSON, RexsterMediaType.APPLICATION_REXSTER_JSON}) @Timed(name = "http.rest.edges.collection.get", absolute = true) Response getAllEdges(@PathParam("graphname") final String graphName); @GET @Produces({RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.edges.collection.get", absolute = true) Response getAllEdgesRexsterTypedJson(@PathParam("graphname") final String graphName); @OPTIONS @Path("/{id}") Response optionsSingleEdge(); @GET @Path("/{id}") @Produces({MediaType.APPLICATION_JSON}) @Timed(name = "http.rest.edges.object.get", absolute = true) Response getSingleEdge(@PathParam("graphname") final String graphName, @PathParam("id") final String id); @GET @Path("/{id}") @Produces({RexsterMediaType.APPLICATION_REXSTER_JSON}) @Timed(name = "http.rest.edges.object.get", absolute = true) Response getSingleEdgeRexsterJson(@PathParam("graphname") final String graphName, @PathParam("id") final String id); @GET @Path("/{id}") @Produces({RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.edges.object.get", absolute = true) Response getSingleEdgeRexsterTypedJson(@PathParam("graphname") final String graphName, @PathParam("id") final String id); @HEAD @Path("/{id}/{extension: .+}") @Consumes(MediaType.APPLICATION_JSON) Response headEdgeExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id, final JSONObject json); @HEAD @Path("/{id}/{extension: .+}") Response headEdgeExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id); @PUT @Path("/{id}/{extension: .+}") @Consumes(MediaType.APPLICATION_JSON) @Timed(name = "http.rest.edges.object.put", absolute = true) Response putEdgeExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id, final JSONObject json); @PUT @Path("/{id}/{extension: .+}") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Timed(name = "http.rest.edges.object.put", absolute = true) Response putEdgeExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id, final MultivaluedMap<String, String> formParams); @PUT @Path("/{id}/{extension: .+}") @Timed(name = "http.rest.edges.object.put", absolute = true) Response putEdgeExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id); @OPTIONS @Path("/{id}/{extension: .+}") @Consumes(MediaType.APPLICATION_JSON) Response optionsEdgeExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id, final JSONObject json); @OPTIONS @Path("/{id}/{extension: .+}") Response optionsEdgeExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id); @DELETE @Path("/{id}/{extension: .+}") @Consumes(MediaType.APPLICATION_JSON) @Timed(name = "http.rest.edges.object.delete", absolute = true) Response deleteEdgeExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id, final JSONObject json); @DELETE @Path("/{id}/{extension: .+}") @Timed(name = "http.rest.edges.object.delete", absolute = true) Response deleteEdgeExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id); @POST @Path("/{id}/{extension: .+}") @Consumes(MediaType.APPLICATION_JSON) @Timed(name = "http.rest.edges.object.post", absolute = true) Response postEdgeExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id, final JSONObject json); @POST @Path("/{id}/{extension: .+}") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Timed(name = "http.rest.edges.object.post", absolute = true) Response postEdgeExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id, final MultivaluedMap<String, String> formParams); @POST @Path("/{id}/{extension: .+}") @Timed(name = "http.rest.edges.object.post", absolute = true) Response postEdgeExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id); @GET @Path("/{id}/{extension: .+}") @Timed(name = "http.rest.edges.object.get", absolute = true) Response getEdgeExtension(@PathParam("graphname") final String graphName, @PathParam("id") final String id); @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.edges.object.post", absolute = true) Response postNullEdgeConsumesJson(@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.edges.object.post", absolute = true) Response postNullEdgeConsumesTypedJson(@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.edges.object.post", absolute = true) Response postNullEdgeConsumesUri(@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.edges.object.post", absolute = true) Response postEdgeConsumesJson(@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.edges.object.post", absolute = true) Response postEdgeConsumesTypedJson(@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.edges.object.post", absolute = true) Response postEdgeConsumesUri(@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.edges.object.put", absolute = true) Response putEdgeConsumesJson(@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.edges.object.put", absolute = true) Response putEdgeConsumesTypedJson(@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.edges.object.put", absolute = true) Response putEdgeOnUri(@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.edges.object.delete", absolute = true) Response deleteEdge(@PathParam("graphname") String graphName, @PathParam("id") String id);  }
@Test public void getAllEdgesNoOffset() { final EdgeResource resource = this.constructEdgeResourceWithToyGraph().getResource(); final Response response = resource.getAllEdges(graphName); this.assertEdgesOkResponseJsonStructure(6, 6, response); }
@Test public void getEdgesKeyIndexed() { final HashMap<String, Object> parameters = new HashMap<String, Object>(); parameters.put(Tokens.KEY, "weight"); parameters.put(Tokens.VALUE, "(f,0.4)"); final EdgeResource resource = this.constructEdgeResource(true, parameters).getResource(); final KeyIndexableGraph graph = (KeyIndexableGraph) this.toyGraph; graph.createKeyIndex("weight", Edge.class); assertEdgesOkResponseJsonStructure(2, 2, resource.getAllEdges(graphName)); }
@Test public void getAllEdgesNoResults() { final EdgeResource resource = this.constructEdgeResourceWithEmptyGraph().getResource(); final Response response = resource.getAllEdges(graphName); this.assertEdgesOkResponseJsonStructure(0, 0, response); }
@Test public void getAllEdgesWithValidOffset() { 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 EdgeResource resource = this.constructEdgeResource(true, parameters).getResource(); final Response response = resource.getAllEdges(graphName); this.assertEdgesOkResponseJsonStructure(2, 2, response); }
@Test public void getAllEdgesWithInvalidOffsetNotEnoughResults() { 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 EdgeResource resource = this.constructEdgeResource(true, parameters).getResource(); final Response response = resource.getAllEdges(graphName); this.assertEdgesOkResponseJsonStructure(0, 0, response); }
@Test public void getAllEdgesWithInvalidOffsetStartAfterEnd() { final HashMap<String, Object> parameters = new HashMap<String, Object>(); parameters.put(Tokens.REXSTER + "." + Tokens.OFFSET_START, "100"); parameters.put(Tokens.REXSTER + "." + Tokens.OFFSET_END, "20"); final EdgeResource resource = this.constructEdgeResource(true, parameters).getResource(); final Response response = resource.getAllEdges(graphName); this.assertEdgesOkResponseJsonStructure(0, 0, response); }