* RegularTimePeriod) method is functioning correctly.
*/
public void testCreateCopy1() {
TimeSeries series = new TimeSeries("Series", Month.class);
series.add(new Month(MonthConstants.JANUARY, 2003), 45.0);
series.add(new Month(MonthConstants.FEBRUARY, 2003), 55.0);
series.add(new Month(MonthConstants.JUNE, 2003), 35.0);
series.add(new Month(MonthConstants.NOVEMBER, 2003), 85.0);
series.add(new Month(MonthConstants.DECEMBER, 2003), 75.0);
try {
// copy a range before the start of the series data...
TimeSeries result1 = series.createCopy(
new Month(MonthConstants.NOVEMBER, 2002),
new Month(MonthConstants.DECEMBER, 2002));
assertEquals(0, result1.getItemCount());
// copy a range that includes only the first item in the series...
TimeSeries result2 = series.createCopy(
new Month(MonthConstants.NOVEMBER, 2002),
new Month(MonthConstants.JANUARY, 2003));
assertEquals(1, result2.getItemCount());
// copy a range that begins before and ends in the middle of the
// series...
TimeSeries result3 = series.createCopy(
new Month(MonthConstants.NOVEMBER, 2002),
new Month(MonthConstants.APRIL, 2003));
assertEquals(2, result3.getItemCount());
TimeSeries result4 = series.createCopy(
new Month(MonthConstants.NOVEMBER, 2002),
new Month(MonthConstants.DECEMBER, 2003));
assertEquals(5, result4.getItemCount());
TimeSeries result5 = series.createCopy(
new Month(MonthConstants.NOVEMBER, 2002),
new Month(MonthConstants.MARCH, 2004));
assertEquals(5, result5.getItemCount());
TimeSeries result6 = series.createCopy(
new Month(MonthConstants.JANUARY, 2003),
new Month(MonthConstants.JANUARY, 2003));
assertEquals(1, result6.getItemCount());
TimeSeries result7 = series.createCopy(
new Month(MonthConstants.JANUARY, 2003),
new Month(MonthConstants.APRIL, 2003));
assertEquals(2, result7.getItemCount());
TimeSeries result8 = series.createCopy(
new Month(MonthConstants.JANUARY, 2003),
new Month(MonthConstants.DECEMBER, 2003));
assertEquals(5, result8.getItemCount());
TimeSeries result9 = series.createCopy(
new Month(MonthConstants.JANUARY, 2003),
new Month(MonthConstants.MARCH, 2004));
assertEquals(5, result9.getItemCount());
TimeSeries result10 = series.createCopy(
new Month(MonthConstants.MAY, 2003),
new Month(MonthConstants.DECEMBER, 2003));
assertEquals(3, result10.getItemCount());
TimeSeries result11 = series.createCopy(
new Month(MonthConstants.MAY, 2003),
new Month(MonthConstants.MARCH, 2004));
assertEquals(3, result11.getItemCount());
TimeSeries result12 = series.createCopy(
new Month(MonthConstants.DECEMBER, 2003),
new Month(MonthConstants.DECEMBER, 2003));
assertEquals(1, result12.getItemCount());
TimeSeries result13 = series.createCopy(
new Month(MonthConstants.DECEMBER, 2003),
new Month(MonthConstants.MARCH, 2004));
assertEquals(1, result13.getItemCount());
TimeSeries result14 = series.createCopy(
new Month(MonthConstants.JANUARY, 2004),
new Month(MonthConstants.MARCH, 2004));
assertEquals(0, result14.getItemCount());
}
catch (CloneNotSupportedException e) {
assertTrue(false);
}