package com.hazelcast.stabilizer.common;

import com.hazelcast.stabilizer.common.probes.impl.LatencyDistributionResult;
import org.junit.Ignore;
import org.junit.Test;

import static org.junit.Assert.*;

public class LinearHistogramTest {

    private int STEP = 1;

    @Test
    @Ignore
    public void testGetPercentile() throws Exception {
        LinearHistogram linearHistogram = createNewHistogram(500);
        HistogramPart percentile = linearHistogram.getPercentile(1.0);
        assertEquals(499, percentile.getValues());
    }

    @Test
    public void foo() {
        LinearHistogram linearHistogram = createNewHistogram(50000);
        LatencyDistributionResult latencyDistributionResult = new LatencyDistributionResult(linearHistogram);
        System.out.println(latencyDistributionResult.toHumanString());
    }

    @Test
    @Ignore
    public void testCombine() throws Exception {
        LinearHistogram linearHistogram1 = createNewHistogram(500);
        LinearHistogram linearHistogram2 = createNewHistogram(500);

        LinearHistogram combinedHistogram = linearHistogram1.combine(linearHistogram2);
        HistogramPart percentile = combinedHistogram.getPercentile(1.0);
        assertEquals(499, percentile.getValues());
    }

    private LinearHistogram createNewHistogram(int values) {
        LinearHistogram linearHistogram = new LinearHistogram(values, STEP);
        for (int i = 0; i < values; i ++) {
            linearHistogram.addValue(i);
        }
        return linearHistogram;
    }
}
@@ -117,33 +117,8 @@
 lt;%0A
-import org.junit.Ignore;%0A
 impo
@@ -136,16 +136,16 @@
 t.Test;%0A
+
 %0Aimport 
@@ -241,36 +241,24 @@
 %0A%0A    @Test%0A
-    @Ignore%0A
     public v
@@ -451,35 +451,35 @@
    assertEquals(
-499
+500
 , percentile.get
@@ -801,20 +801,8 @@
 est%0A
-    @Ignore%0A
     
@@ -1169,11 +1169,12 @@
 als(
-499
+1000
 , pe
@@ -1188,32 +1188,83 @@
 e.getValues());%0A
+        assertEquals(500, percentile.getBucket());%0A
     %7D%0A%0A    priva

test fixed