ParametersExtension extends AbstractSampleExtension { @ExtensionDefinition(extensionPoint = ExtensionPoint.GRAPH, path = "list-raw") @ExtensionDescriptor(description = "pass a square bracket enclosed string parameter to be used in the response.") public ExtensionResponse evaluateSomeListRaw(@RexsterContext RexsterResourceContext context, @RexsterContext Graph graph, @ExtensionRequestParameter(name = "some-list", description = "a list to reply with", parseToJson = false) String reply) { if (reply == null || reply.isEmpty()) { ExtensionMethod extMethod = context.getExtensionMethod(); return ExtensionResponse.error( "the some-list parameter cannot be empty", null, Response.Status.BAD_REQUEST.getStatusCode(), null, generateErrorJson(extMethod.getExtensionApiAsJson())); } Map<String, String> map = new HashMap<String, String>(); map.put("some-list", reply); return ExtensionResponse.ok(map); }  @ExtensionDefinition(extensionPoint = ExtensionPoint.GRAPH, path = "string") @ExtensionDescriptor(description = "pass a string parameter to be used in the response.") ExtensionResponse evaluateSomeString(@RexsterContext RexsterResourceContext context,
                                                @RexsterContext Graph graph,
                                                @ExtensionRequestParameter(name = "some-string", description = "a string to reply with") String reply); @ExtensionDefinition(extensionPoint = ExtensionPoint.GRAPH, path = "integer") @ExtensionDescriptor(description = "pass an integer parameter to be used in the response.") ExtensionResponse evaluateSomeInteger(@RexsterContext RexsterResourceContext context,
                                                 @RexsterContext Graph graph,
                                                 @ExtensionRequestParameter(name = "some-integer", description = "an integer to reply with") Integer reply); @ExtensionDefinition(extensionPoint = ExtensionPoint.GRAPH, path = "float") @ExtensionDescriptor(description = "pass a string parameter to be used in the response.") ExtensionResponse evaluateSomeFloat(@RexsterContext RexsterResourceContext context,
                                               @RexsterContext Graph graph,
                                               @ExtensionRequestParameter(name = "some-float", description = "a float to reply with") Float reply); @ExtensionDefinition(extensionPoint = ExtensionPoint.GRAPH, path = "list") @ExtensionDescriptor(description = "pass a list parameter to be used in the response.") ExtensionResponse evaluateSomeList(@RexsterContext RexsterResourceContext context,
                                              @RexsterContext Graph graph,
                                              @ExtensionRequestParameter(name = "some-list", description = "a list to reply with") JSONArray reply); @ExtensionDefinition(extensionPoint = ExtensionPoint.GRAPH, path = "list-raw") @ExtensionDescriptor(description = "pass a square bracket enclosed string parameter to be used in the response.") ExtensionResponse evaluateSomeListRaw(@RexsterContext RexsterResourceContext context,
                                                 @RexsterContext Graph graph,
                                                 @ExtensionRequestParameter(name = "some-list", description = "a list to reply with", parseToJson = false) String reply); @ExtensionDefinition(extensionPoint = ExtensionPoint.GRAPH, path = "object") @ExtensionDescriptor(description = "pass an object parameter to be used in the response.") ExtensionResponse evaluateSomeObject(@RexsterContext RexsterResourceContext context,
                                                @RexsterContext Graph graph,
                                                @ExtensionRequestParameter(name = "a", description = "an integer to reply with") Integer reply,
                                                @ExtensionRequestParameter(name = "b", description = "an object to reply with") JSONObject replyObject,
                                                @ExtensionRequestParameter(name = "c", description = "a list to reply with") JSONArray replyList); @ExtensionDefinition(extensionPoint = ExtensionPoint.GRAPH, path = "object-default") @ExtensionDescriptor(description = "pass an object parameter to be used in the response.") ExtensionResponse evaluateSomeObjectWithDefaults(@RexsterContext RexsterResourceContext context,
                                                            @RexsterContext Graph graph,
                                                            @ExtensionRequestParameter(name = "a", defaultValue = "1", description = "an integer to reply with") Integer reply,
                                                            @ExtensionRequestParameter(name = "b", defaultValue = "{\"a\":\"marko\",\"b\":true, \"c\": {\"a\":\"peter\"}}", description = "an object to reply with") JSONObject replyObject,
                                                            @ExtensionRequestParameter(name = "c", defaultValue = "[\"marko\",\"povel\"]", description = "a list to reply with") JSONArray replyList); static final String EXTENSION_NAME; }
@Test public void evaluateSomeListRawValid() { String replyToSend = "[1,2,3,4]"; ExtensionResponse response = parametersExtension.evaluateSomeListRaw(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("some-list")); Assert.assertEquals(replyToSend, json.optString("some-list")); }