@@ -0,0 +1,2087 @@
+/*%0A * Copyright 2014 Timothy Brooks%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A *%0A */%0A%0Apackage net.uncontended.precipice.metrics;%0A%0Aimport org.HdrHistogram.AtomicHistogram;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.mockito.Mock;%0Aimport org.mockito.MockitoAnnotations;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.mockito.Mockito.when;%0A%0Apublic class DefaultLatencyMetricsTest %7B%0A%0A    @Mock%0A    private AtomicHistogram histogram;%0A%0A    private DefaultLatencyMetrics metrics;%0A%0A    @Before%0A    public void setup() %7B%0A        MockitoAnnotations.initMocks(this);%0A%0A        metrics = new DefaultLatencyMetrics(histogram);%0A    %7D%0A%0A    @Test%0A    public void latencyIsStoredInHistogram() %7B%0A        when(histogram.getMaxValue()).thenReturn(10L);%0A        when(histogram.getValueAtPercentile(50.0)).thenReturn(2L);%0A        when(histogram.getValueAtPercentile(90.0)).thenReturn(7L);%0A        when(histogram.getValueAtPercentile(99.0)).thenReturn(8L);%0A        when(histogram.getValueAtPercentile(99.9)).thenReturn(9L);%0A        when(histogram.getValueAtPercentile(99.99)).thenReturn(9L);%0A        when(histogram.getValueAtPercentile(99.999)).thenReturn(10L);%0A%0A        LatencyBucket snapshot = metrics.getLatencySnapshot();%0A%0A        assertEquals(10L, snapshot.latencyMax);%0A        assertEquals(2L, snapshot.latency50);%0A        assertEquals(7L, snapshot.latency90);%0A        assertEquals(8L, snapshot.latency99);%0A        assertEquals(9L, snapshot.latency999);%0A        assertEquals(9L, snapshot.latency9999);%0A        assertEquals(10L, snapshot.latency99999);%0A%0A    %7D%0A%7D%0A

Add tests for latency util