}
@Test(dataProvider="minMax")
public void testMinMax(AxisOrientationSetting setting, TimeXYAxis axis) throws Exception {
plot.setAxisOrientationSetting(setting);
LinearXYAxis nonTime;
if (setting == AxisOrientationSetting.X_AXIS_AS_TIME) {
Mockito.when(plotView.getXAxis()).thenReturn(axis);
nonTime = new LinearXYAxis(XYDimension.Y);
Mockito.when(plotView.getYAxis()).thenReturn(nonTime);
} else {
Mockito.when(plotView.getYAxis()).thenReturn(axis);
nonTime = new LinearXYAxis(XYDimension.X);
Mockito.when(plotView.getXAxis()).thenReturn(nonTime);
}
plot.theNonTimeAxis = nonTime;
Assert.assertNotNull(plot.getPlotView().getXAxis());
Assert.assertNotNull(plot.getPlotView().getYAxis());
plot.setTimeAxis(axis);
plot.setNonTimeMinPadding(0);
plot.setNonTimeMaxPadding(0);
axis.setStart(100);
axis.setEnd(200);
double initialStart = 0;
double initialEnd = 10;
nonTime.setStart(initialStart);
nonTime.setEnd(initialEnd);
PlotDataManager dataManager = new PlotDataManager(plot);
setMemberVariable("plotDataManager", dataManager);
dataManager.addDataSet("TestData", Color.black);
PlotDataSeries dataSeries = dataManager.getDataSeries().get("TestData");
CompressingXYDataset dataSet = dataSeries.getData();
dataSet.setCompressionScale(1);
addToDataSet(setting, dataSet, 0, 100);
addToDataSet(setting, dataSet, 5, 101);
plot.newPointPlotted(100,0);
plot.newPointPlotted(101,5);
// test the case where the new point is less than the current data maximum, no change should occur
addToDataSet(setting, dataSet, 4, 101.5);
plot.newPointPlotted(new Double(101.5).longValue(), 4);
Assert.assertEquals(nonTime.getStart(),initialStart);
Assert.assertEquals(nonTime.getEnd(), 5.0);
// test the case where the new point is less than the current axis, no change should occur
// 2/26/12 Change in axis now occurs because non-Time axis responds to new max 6 in auto-adjust and semi-fixed mode.
addToDataSet(setting, dataSet, 6, 102);
plot.newPointPlotted(102, 6);
Assert.assertEquals(nonTime.getStart(),initialStart);
Assert.assertEquals(nonTime.getEnd(), 6.0);
// test the case where the new point is greater than the current axis, the axis should increase (or decrease)
// this should include the padding
double newMax = 15;
addToDataSet(setting, dataSet, newMax, 103);
plot.newPointPlotted(103, newMax);
Assert.assertEquals(nonTime.getStart(),initialStart);
Assert.assertEquals(nonTime.getEnd(), newMax);
// test the case where the axis has now been collapsed back to the settings value
// if a new value comes in that is below the max value but above the current state of the axis, the axis should
// increase to the maximum value
nonTime.setEnd(initialEnd);
double twelve = 12;
addToDataSet(setting, dataSet, twelve, 104);
plot.newPointPlotted(104, twelve);
Assert.assertEquals(nonTime.getStart(),initialStart);
Assert.assertEquals(nonTime.getEnd(), newMax);
// test where the max value has been truncated off the time line
// The axis should contract down to 12.0, because newMax has been truncated off
addToDataSet(setting, dataSet, 10, 105);
plot.newPointPlotted(105, 10);
addToDataSet(setting, dataSet, 10, 106);
plot.newPointPlotted(106, 10);
addToDataSet(setting, dataSet, 10, 107);
plot.newPointPlotted(107, 10);
dataSet.setTruncationOffset(0);
dataSet.setTruncationPoint(104);
addToDataSet(setting, dataSet, 10, 108);
plot.newPointPlotted(108, 10);
Assert.assertEquals(nonTime.getStart(),initialStart);
Assert.assertEquals(nonTime.getEnd(), 12.0);
}