HelloWorldRestEndpoint { @GET @Path("helloname") @Produces(MediaType.TEXT_PLAIN) @RestQuery(name = "helloname", description = "example service call with parameter", restParameters = { @RestParameter(description = "name to output", isRequired = false, name = "name", type = RestParameter.Type.TEXT) }, responses = {@RestResponse(description = "Hello or Hello Name", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The underlying service could not output something.", responseCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR) }, returnDescription = "The text that the service returns.") public Response helloName(@FormParam("name") String name) throws Exception { logger.info("REST call for Hello Name"); return Response.ok().entity(helloWorldService.helloName(name)).build(); }  @GET @Path("helloworld") @Produces(MediaType.TEXT_PLAIN) @RestQuery(name = "helloworld", description = "example service call", responses = {@RestResponse(description = "Hello World", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The underlying service could not output something.", responseCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR) }, returnDescription = "The text that the service returns.") Response helloWorld(); @GET @Path("helloname") @Produces(MediaType.TEXT_PLAIN) @RestQuery(name = "helloname", description = "example service call with parameter", restParameters = { @RestParameter(description = "name to output", isRequired = false, name = "name", type = RestParameter.Type.TEXT) }, responses = {@RestResponse(description = "Hello or Hello Name", responseCode = HttpServletResponse.SC_OK), @RestResponse(description = "The underlying service could not output something.", responseCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR) }, returnDescription = "The text that the service returns.") Response helloName(@FormParam("name") String name); @GET @Produces(MediaType.TEXT_HTML) @Path("docs") String getDocs(); @Reference(name = "helloworld-service") void setHelloWorldService(HelloWorldService service);  }
@Test public void testHelloNameEmpty() throws Exception { Response response = rest.helloName(""); Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); Assert.assertEquals("Hello!", response.getEntity()); }
@Test public void testHelloName() throws Exception { Response response = rest.helloName("Peter"); Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); Assert.assertEquals("Hello Peter!", response.getEntity()); }