AvgHistogramFunction extends Metrics implements AcceptableValue<BucketedValues> { @Override public Class<? extends AvgHistogramFunctionBuilder> builder() { return AvgHistogramFunctionBuilder.class; }  @Override void accept(final MeterEntity entity, final BucketedValues value); @Override void combine(final Metrics metrics); @Override void calculate(); @Override Metrics toHour(); @Override Metrics toDay(); @Override int remoteHashCode(); @Override void deserialize(final RemoteData remoteData); @Override RemoteData.Builder serialize(); @Override String id(); @Override Class<? extends AvgHistogramFunctionBuilder> builder(); @Override boolean equals(Object o); @Override int hashCode(); static final String DATASET; }
@Test public void testBuilder() throws IllegalAccessException, InstantiationException { HistogramFunctionInst inst = new HistogramFunctionInst(); inst.accept( MeterEntity.newService("service-test"), new BucketedValues( BUCKETS, new long[] { 1, 4, 10, 10 }) ); inst.calculate(); final StorageBuilder storageBuilder = inst.builder().newInstance(); Map<String, Object> map = storageBuilder.data2Map(inst); map.put(SUMMATION, ((DataTable) map.get(SUMMATION)).toStorageData()); map.put(COUNT, ((DataTable) map.get(COUNT)).toStorageData()); map.put(DATASET, ((DataTable) map.get(DATASET)).toStorageData()); final AvgHistogramFunction inst2 = (AvgHistogramFunction) storageBuilder.map2Data(map); Assert.assertEquals(inst, inst2); Assert.assertEquals(inst.getDataset(), inst2.getDataset()); }