MeterProcessor { public void read(MeterData data) { EvalData evalData; switch (data.getMetricCase()) { case SINGLEVALUE: evalData = EvalSingleData.build(data.getSingleValue(), this); break; case HISTOGRAM: evalData = EvalHistogramData.build(data.getHistogram(), this); break; default: return; } final EvalMultipleData multipleEvalData = meters.computeIfAbsent(evalData.getName(), k -> new EvalMultipleData(k)); multipleEvalData.appendData(evalData); if (StringUtil.isNotEmpty(data.getService())) { service = data.getService(); } if (StringUtil.isNotEmpty(data.getServiceInstance())) { serviceInstance = data.getServiceInstance(); } if (data.getTimestamp() > 0) { timestamp = data.getTimestamp(); } } MeterProcessor(MeterProcessService processService); void read(MeterData data); void process();  }
@Test public void testRead() { Assert.assertEquals("service", processor.service()); Assert.assertEquals("instance", processor.serviceInstance()); Assert.assertEquals(timestamp, processor.timestamp().longValue()); final Map<String, EvalMultipleData> meters = (Map<String, EvalMultipleData>) Whitebox.getInternalState( processor, "meters"); Assert.assertEquals(2, meters.size()); EvalSingleData singleData = verifyBaseData( meters.get("test_count1"), "test_count1", Collections.singletonMap("k1", "v1")); Assert.assertEquals(1, singleData.getValue(), 0.0); EvalHistogramData histogramData = verifyBaseData( meters.get("test_histogram"), "test_histogram", Collections.singletonMap("k2", "v2")); Assert.assertEquals(3, histogramData.getBuckets().size()); Assert.assertEquals(10, histogramData.getBuckets().get(1d).longValue()); Assert.assertEquals(15, histogramData.getBuckets().get(5d).longValue()); Assert.assertEquals(3, histogramData.getBuckets().get(10d).longValue()); }