static MetricDimensions convert(Point p) {
        if (p == null) {
            return StateMetricContext.newInstance(null);
        }
        List<String> dimensions = p.dimensions();
        List<Value> location = p.location();
        Map<String, Object> pointWrapper = new HashMap<>(dimensions.size());
        for (int i = 0; i < dimensions.size(); ++i) {
            pointWrapper.put(dimensions.get(i), valueAsString(location.get(i)));
        }
        return StateMetricContext.newInstance(pointWrapper);
    }
@Test
    void testConversion() {
        MetricReceiver mock = new MetricReceiver.MockReceiver();
        mock.declareCounter("foo").add(1);
        mock.declareGauge("quuux").sample(42.25);
        mock.declareCounter("bar", new Point(new HashMap<String, String>())).add(4);

        MetricSnapshot snapshot = new SnapshotConverter(mock.getSnapshot()).convert();

        for (Map.Entry<MetricDimensions, MetricSet> entry : snapshot) {
            for (Map.Entry<String, String> dv : entry.getKey()) {
                fail();
            }

            int cnt = 0;
            for (Map.Entry<String, MetricValue> mv : entry.getValue()) {
                ++cnt;
                if ("foo".equals(mv.getKey())) {
                    assertTrue(mv.getValue() instanceof CountMetric);
                    assertEquals(1, ((CountMetric) mv.getValue()).getCount());
                } else if ("bar".equals(mv.getKey())) {
                    assertTrue(mv.getValue() instanceof CountMetric);
                    assertEquals(4, ((CountMetric) mv.getValue()).getCount());
                } else if ("quuux".equals(mv.getKey())) {
                    assertTrue(mv.getValue() instanceof GaugeMetric);
                    assertEquals(42.25, ((GaugeMetric) mv.getValue()).getLast(), 0.001);
                    assertEquals(1, ((GaugeMetric) mv.getValue()).getCount());
                } else {
                    fail();
                }
            }
            assertEquals(3, cnt);
        }
    }