PingExtension extends AbstractSampleExtension { @ExtensionDefinition(extensionPoint = ExtensionPoint.GRAPH) @ExtensionDescriptor(description = "a simple ping extension.") public ExtensionResponse evaluatePing(@RexsterContext RexsterResourceContext context, @RexsterContext Graph graph, @ExtensionRequestParameter(name = "reply", defaultValue = "pong (default)", description = "a value to reply with") String reply) { if (reply == null || reply.isEmpty()) { ExtensionMethod extMethod = context.getExtensionMethod(); return ExtensionResponse.error( "the reply parameter cannot be empty", null, Response.Status.BAD_REQUEST.getStatusCode(), null, generateErrorJson(extMethod.getExtensionApiAsJson())); } Map<String, String> map = new HashMap<String, String>(); map.put("ping", reply); return ExtensionResponse.ok(map); }  @ExtensionDefinition(extensionPoint = ExtensionPoint.GRAPH) @ExtensionDescriptor(description = "a simple ping extension.") ExtensionResponse evaluatePing(@RexsterContext RexsterResourceContext context,
                                          @RexsterContext Graph graph,
                                          @ExtensionRequestParameter(name = "reply", defaultValue = "pong (default)", description = "a value to reply with") String reply); static final String EXTENSION_NAME; }
@Test public void evaluatePingValid() { String replyToSend = "pong"; ExtensionResponse response = pingExtension.evaluatePing(null, null, replyToSend); Assert.assertNotNull(response); Response jerseyResponse = response.getJerseyResponse(); Assert.assertNotNull(jerseyResponse); Assert.assertEquals(Response.Status.OK.getStatusCode(), jerseyResponse.getStatus()); JSONObject json = (JSONObject) jerseyResponse.getEntity(); Assert.assertNotNull(json); Assert.assertTrue(json.has("ping")); Assert.assertEquals(replyToSend, json.optString("ping")); }