    @Test
    public void testResultLength() {

        List<DataPoint> points = Arrays.asList(new DataPoint(1D, 0L), new DataPoint(1D, 5L),
                new DataPoint(1D, 10L), new DataPoint(1D, 15L), new DataPoint(1D, 20L), new DataPoint(1D, 25L),
                new DataPoint(1D, 30L));

        WeightedMovingAverage weightedMovingAverage = new WeightedMovingAverage(points, new double[]{1, 1});
        List<DataPoint> result = weightedMovingAverage.learn();
        int nullAtBeginning = nullAt(result, true);
        int nullAtEnd = nullAt(result, false);
        Assert.assertTrue(nullAtBeginning == 0);
        Assert.assertTrue(nullAtEnd == 1);
        long timestamp = 0;
        for (DataPoint point: result) {
            if (point.getValue() != null) {
                Assert.assertTrue(point.getValue().equals(2.0));
            }
            // timestamps should be equal
            Assert.assertTrue(point.getTimestamp().equals(timestamp));
            timestamp += 5;
        }

        weightedMovingAverage = new WeightedMovingAverage(points, new double[]{0.5, 0.5});
        result = weightedMovingAverage.learn();
        nullAtBeginning = nullAt(result, true);
        nullAtEnd = nullAt(result, false);
        Assert.assertTrue(nullAtBeginning == 0);
        Assert.assertTrue(nullAtEnd == 1);
        for (DataPoint point: result) {
            if (point.getValue() != null) {
                Assert.assertTrue(point.getValue().equals(1.0));
            }
        }

        weightedMovingAverage = new WeightedMovingAverage(points, new double[]{0.5, 0.5, 0.5, 0.5});
        result = weightedMovingAverage.learn();
        nullAtBeginning = nullAt(result, true);
        nullAtEnd = nullAt(result, false);
        Assert.assertTrue(nullAtBeginning == 1);
        Assert.assertTrue(nullAtEnd == 2);

        weightedMovingAverage = new WeightedMovingAverage(points, new double[]{0.5, 0.5, 0.5, 0.5, 0.5});
        result = weightedMovingAverage.learn();
        nullAtBeginning = nullAt(result, true);
        nullAtEnd = nullAt(result, false);
        Assert.assertTrue(nullAtBeginning == 2);
        Assert.assertTrue(nullAtEnd == 2);
    }