GraphResource extends AbstractSubResource { @GET @Produces({MediaType.APPLICATION_JSON}) @Timed(name = "http.rest.graphs.object.get", absolute = true) public Response getGraphProducesJson(@PathParam("graphname") final String graphName) { return getGraph(graphName, false); } GraphResource();  GraphResource(final UriInfo ui, final HttpServletRequest req, final RexsterApplication ra); @OPTIONS Response optionsGraph(); @GET @Produces({MediaType.APPLICATION_JSON}) @Timed(name = "http.rest.graphs.object.get", absolute = true) Response getGraphProducesJson(@PathParam("graphname") final  String graphName); @GET @Produces({RexsterMediaType.APPLICATION_REXSTER_JSON, RexsterMediaType.APPLICATION_REXSTER_TYPED_JSON}) @Timed(name = "http.rest.graphs.object.get", absolute = true) Response getGraphProducesRexsterJson(@PathParam("graphname") final String graphName); @HEAD @Path("{extension: (?!vertices)(?!edges)(?!indices)(?!keyindices)(?!prefixes).+}") @Consumes(MediaType.APPLICATION_JSON) Response headGraphExtension(@PathParam("graphname") final String graphName, final JSONObject json); @HEAD @Path("{extension: (?!vertices)(?!edges)(?!indices)(?!keyindices)(?!prefixes).+}") Response headGraphExtension(@PathParam("graphname") final String graphName); @PUT @Path("{extension: (?!vertices)(?!edges)(?!indices)(?!keyindices)(?!prefixes).+}") @Consumes(MediaType.APPLICATION_JSON) @Timed(name = "http.rest.graphs.extension.put", absolute = true) Response putGraphExtension(@PathParam("graphname") final String graphName, final JSONObject json); @PUT @Path("{extension: (?!vertices)(?!edges)(?!indices)(?!keyindices)(?!prefixes).+}") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Timed(name = "http.rest.graphs.extension.put", absolute = true) Response putGraphExtension(@PathParam("graphname") final String graphName, final MultivaluedMap<String, String> formParams); @PUT @Path("{extension: (?!vertices)(?!edges)(?!indices)(?!keyindices)(?!prefixes).+}") @Timed(name = "http.rest.graphs.extension.put", absolute = true) Response putGraphExtension(@PathParam("graphname") final String graphName); @OPTIONS @Path("{extension: (?!vertices)(?!edges)(?!indices)(?!keyindices)(?!prefixes).+}") @Consumes(MediaType.APPLICATION_JSON) Response optionsGraphExtension(@PathParam("graphname") final String graphName, final JSONObject json); @OPTIONS @Path("{extension: (?!vertices)(?!edges)(?!indices)(?!keyindices)(?!prefixes).+}") Response optionsGraphExtension(@PathParam("graphname") final String graphName); @DELETE @Path("{extension: (?!vertices)(?!edges)(?!indices)(?!keyindices)(?!prefixes).+}") @Consumes(MediaType.APPLICATION_JSON) @Timed(name = "http.rest.graphs.extension.delete", absolute = true) Response deleteGraphExtension(@PathParam("graphname") final String graphName, final JSONObject json); @DELETE @Path("{extension: (?!vertices)(?!edges)(?!indices)(?!keyindices)(?!prefixes).+}") @Timed(name = "http.rest.graphs.extension.delete", absolute = true) Response deleteGraphExtension(@PathParam("graphname") final String graphName); @POST @Path("{extension: (?!vertices)(?!edges)(?!indices)(?!keyindices)(?!prefixes).+}") @Consumes(MediaType.APPLICATION_JSON) @Timed(name = "http.rest.graphs.extension.post", absolute = true) Response postGraphExtension(@PathParam("graphname") final String graphName, final JSONObject json); @POST @Path("{extension: (?!vertices)(?!edges)(?!indices)(?!keyindices)(?!prefixes).+}") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) @Timed(name = "http.rest.graphs.extension.post", absolute = true) Response postGraphExtension(@PathParam("graphname") String graphName, final MultivaluedMap<String, String> formParams); @POST @Path("{extension: (?!vertices)(?!edges)(?!indices)(?!keyindices)(?!prefixes).+}") @Timed(name = "http.rest.graphs.extension.post", absolute = true) Response postGraphExtension(@PathParam("graphname") final String graphName); @GET @Path("{extension: (?!vertices)(?!edges)(?!indices)(?!keyindices)(?!prefixes).+}") @Timed(name = "http.rest.graphs.extension.post", absolute = true) Response getGraphExtension(@PathParam("graphname") final String graphName);  }
@Test public void getGraphProducesJsonValid() { final GraphResource resource = constructGraphResourceWithToyGraph().getResource(); final Response response = resource.getGraphProducesJson(graphName); Assert.assertNotNull(response); Assert.assertEquals(Status.OK.getStatusCode(), response.getStatus()); Assert.assertNotNull(response.getEntity()); Assert.assertTrue(response.getEntity() instanceof JSONObject); final JSONObject json = (JSONObject) response.getEntity(); Assert.assertEquals(graphName, json.optString("name")); Assert.assertTrue(json.has(Tokens.QUERY_TIME)); Assert.assertTrue(json.has(Tokens.UP_TIME)); Assert.assertTrue(json.has(Tokens.READ_ONLY)); Assert.assertTrue(json.has(Tokens.VERSION)); Assert.assertTrue(json.has(Tokens.TYPE)); Assert.assertTrue(json.has(Tokens.FEATURES)); }