@Test
public void testCalculateZoom() {

    ZoomEstimator estimator = spy(new ZoomEstimator());
    SampledXYSeries series =
            spy(new SampledXYSeries(TestUtils
                    .generateXYSeries("test series", 1000), 2, 100));
    series.resample();
    when(xyPlot.getBounds())
            .thenReturn(new RectRegion(0, 1000, 0, 1000));
    // fully zoomed out so max zoom factor should be applied:
    assertEquals(series.getMaxZoomFactor(), estimator.calculateZoom(series, new RectRegion(0, 1000, 0, 1000)));
    // fully zoomed in so min zoom factor should be applied:
    assertEquals(1d, estimator.calculateZoom(series, new RectRegion(0, 1, 0, 1)));
}