package ro.hasna.ts.math.distribution;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import ro.hasna.ts.math.util.TimeSeriesPrecision;

import java.util.Map;

/**
 * @since 1.0
 */
@RunWith(MockitoJUnitRunner.class)
public class NormalDistributionDividerTest {

    @Mock
    private Map<Integer, double[]> breakpoints;

    @InjectMocks
    private NormalDistributionDivider divider;

    @Test
    public void testGetBreakpointsWithCaching() throws Exception {
        divider.setCachingEnabled(true);
        double[] v = divider.getBreakpoints(1000);

        Mockito.verify(breakpoints).put(1000, v);
    }

    @Test
    public void testGetBreakpointsWithoutCaching() throws Exception {
        divider.setCachingEnabled(false);
        double[] v = divider.getBreakpoints(1000);

        Mockito.verify(breakpoints, Mockito.never()).put(1000, v);
    }

    @Test
    public void testGetBreakpoints1() throws Exception {
        NormalDistributionDivider divider = new NormalDistributionDivider();
        double[] expected = {-0.4307272992954576, 0.4307272992954576};
        double[] v = divider.getBreakpoints(3);

        Assert.assertArrayEquals(expected, v, TimeSeriesPrecision.EPSILON);
    }

    @Test
    public void testGetBreakpoints2() throws Exception {
        double[] expected = {-0.6744897501960816, 0, 0.6744897501960816};
        double[] v = divider.getBreakpoints(4);

        Assert.assertArrayEquals(expected, v, TimeSeriesPrecision.EPSILON);
    }
}
@@ -1640,10 +1640,450 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testIsCachingEnabled1() throws Exception %7B%0A        NormalDistributionDivider divider = new NormalDistributionDivider();%0A%0A        Assert.assertEquals(true, divider.isCachingEnabled());%0A    %7D%0A%0A    @Test%0A    public void testIsCachingEnabled2() throws Exception %7B%0A        NormalDistributionDivider divider = new NormalDistributionDivider(false);%0A%0A        Assert.assertEquals(false, divider.isCachingEnabled());%0A    %7D
 %0A%7D

add more tests