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