MetricsResource { @GET @Produces({Constants.PRODUCE_JSON_WITH_QUALITY_SOURCE, MediaType.TEXT_HTML}) public Response getMetrics() { return getMetrics("all"); }  @Path("/list") @GET @Produces({Constants.PRODUCE_JSON_WITH_QUALITY_SOURCE, MediaType.TEXT_HTML}) Response listMetrics(); @GET @Produces({Constants.PRODUCE_JSON_WITH_QUALITY_SOURCE, MediaType.TEXT_HTML}) Response getMetrics(); @GET @Produces({Constants.PRODUCE_JSON_WITH_QUALITY_SOURCE, MediaType.TEXT_HTML}) @Path("/{group}") Response getMetrics(@DefaultValue("all") @PathParam("group") String group); @GET @Produces({Constants.PRODUCE_JSON_WITH_QUALITY_SOURCE, MediaType.TEXT_HTML}) @Path("/{group}/level/{level}") Response getMetricByLevel(final @PathParam("group") String group,
                                     final @PathParam("level") String level,
                                     final @QueryParam("above") boolean above); @GET @Produces({Constants.PRODUCE_JSON_WITH_QUALITY_SOURCE, MediaType.TEXT_HTML}) @Path("/{group}/{metric}") Response getMetric(final @PathParam("group") String group,
                              final @PathParam("metric") String metricName,
                              final @QueryParam("tagKey") List<String> tagKeys,
                              final @QueryParam("tagValue") List<String> tagValues); @GET @Produces({Constants.PRODUCE_JSON_WITH_QUALITY_SOURCE, MediaType.TEXT_HTML}) @Path("/specific") Response getMetric(final @QueryParam("metric") Set<String> metricNames, @QueryParam("zeroIgnore") boolean zeroIgnore); @POST @Produces({Constants.PRODUCE_JSON_WITH_QUALITY_SOURCE, MediaType.TEXT_HTML}) @Path("/specific") Response getMetricsByPost(MultivaluedMap<String, String> params, @QueryParam("zeroIgnore") boolean zeroIgnore); @POST @Consumes(MediaType.APPLICATION_JSON) @Produces({Constants.PRODUCE_JSON_WITH_QUALITY_SOURCE, MediaType.TEXT_HTML}) @Path("/search") Response searchMetrics(String metricsSearch, @HeaderParam("REMOTE_ADDR") String remoteAddr,
            @HeaderParam("X-Forwarded-For") String xForwardedFor, @Context HttpServletRequest httpServletRequest);  }
@SuppressWarnings("unchecked") @Test public void testGetMetrics() { Counter c1 = MetricManager.getCounter("product111", MetricName.build("middleware.product.provider")); c1.inc(); Meter m1 = MetricManager.getMeter("carts111", MetricName.build("shared.carts.my_cart")); m1.mark(); Meter m2 = MetricManager.getMeter("carts111", MetricName.build("shared.carts.my_cart").tagged("source", "taobao")); m2.mark(10); Response productResponse = target("metrics/product111").request().accept(MediaType.APPLICATION_JSON_TYPE).get(Response.class); Map<String, Object> res = productResponse.readEntity(Map.class); Assert.assertEquals(true, res.get("success")); List objs = (List)res.get("data"); Assert.assertEquals(3, objs.size()); Response cartsResponse = target("metrics/carts111").request().accept(MediaType.APPLICATION_JSON_TYPE).get(Response.class); res = cartsResponse.readEntity(Map.class); Assert.assertEquals(true, res.get("success")); objs = (List)res.get("data"); Assert.assertEquals(12, objs.size()); }