public void testGetEarliestValue() {
   ObjectTimeSeries<E, T> empty = createEmptyTimeSeries();
   ObjectTimeSeries<E, T> dts = createStandardTimeSeries();
   T[] values = testValues();
   assertEquals(values[0], dts.getEarliestValue());
   try {
     empty.getEarliestValue();
   } catch (NoSuchElementException nsee) {
     return;
   }
   fail();
 }
 public void testArrayConstructor() {
   ObjectTimeSeries<E, T> dts = createTimeSeries(emptyTimes(), emptyValues());
   assertEquals(0, dts.size());
   E[] times = testTimes();
   T[] values = testValues();
   dts = createTimeSeries(times, values);
   assertEquals(6, dts.size());
   Iterator<T> valuesIter = dts.valuesIterator();
   for (int i = 0; i < values.length; i++) {
     assertTrue(ObjectUtils.equals(values[i], valuesIter.next()));
   }
 }
 public void testGetLatestInstant() {
   ObjectTimeSeries<E, T> empty = createEmptyTimeSeries();
   ObjectTimeSeries<E, T> dts = createStandardTimeSeries();
   E[] testDates = testTimes();
   assertEquals(testDates[5], dts.getLatestTime());
   try {
     empty.getLatestTime();
   } catch (NoSuchElementException nsee) {
     return;
   }
   fail();
 }
 public void testTail() {
   ObjectTimeSeries<E, T> dts = createStandardTimeSeries();
   ObjectTimeSeries<E, T> tail5 = (ObjectTimeSeries<E, T>) dts.tail(5);
   Iterator<Entry<E, T>> iterator = tail5.iterator();
   for (int i = 1; i < 6; i++) {
     Entry<E, T> entry = iterator.next();
     assertEquals(testTimes()[i], entry.getKey());
     assertEquals(testValues()[i], entry.getValue());
   }
   assertEquals(dts.tail(0), createEmptyTimeSeries());
   assertEquals(createEmptyTimeSeries().tail(0), createEmptyTimeSeries());
 }
 public void testHead() {
   ObjectTimeSeries<E, T> dts = createStandardTimeSeries();
   ObjectTimeSeries<E, T> head5 = (ObjectTimeSeries<E, T>) dts.head(5);
   Iterator<Entry<E, T>> iterator = head5.iterator();
   for (int i = 0; i < 5; i++) {
     Entry<E, T> entry = iterator.next();
     assertEquals(testTimes()[i], entry.getKey());
     assertEquals(testValues()[i], entry.getValue());
   }
   assertEquals(dts.head(0), createEmptyTimeSeries());
   assertEquals(createEmptyTimeSeries().head(0), createEmptyTimeSeries());
 }
 @Test(expectedExceptions = IndexOutOfBoundsException.class)
 public void testGetDataPoint() {
   ObjectTimeSeries<E, T> emptyTS = createEmptyTimeSeries();
   ObjectTimeSeries<E, T> dts = createStandardTimeSeries();
   E[] testDates = testTimes();
   T[] testValues = testValues();
   for (int i = 0; i < 6; i++) {
     T val = dts.getValue(testDates[i]);
     assertEquals(val, testValues[i]);
     val = dts.getValueAt(i);
     assertEquals(val, testValues[i]);
   }
   emptyTS.getValueAt(0);
 }
 public void testListConstructor() {
   ObjectTimeSeries<E, T> dts = createTimeSeries(new ArrayList<E>(), new ArrayList<T>());
   assertEquals(0, dts.size());
   E[] times = testTimes();
   T[] values = testValues();
   List<E> timesList = new ArrayList<E>();
   List<T> valuesList = new ArrayList<T>();
   for (int i = 0; i < times.length; i++) {
     timesList.add(times[i]);
     valuesList.add(values[i]);
   }
   dts = createTimeSeries(timesList, valuesList);
   assertEquals(6, dts.size());
   Iterator<T> valuesIter = dts.valuesIterator();
   for (int i = 0; i < 6; i++) {
     assertTrue(ObjectUtils.equals(values[i], valuesIter.next()));
   }
 }
 @SuppressWarnings("cast")
 public void testSubSeriesInstantProviderInstantProvider() {
   ObjectTimeSeries<E, T> emptyTS = createEmptyTimeSeries();
   ObjectTimeSeries<E, T> dts = createStandardTimeSeries();
   E[] testDates = testTimes();
   T[] testValues = testValues();
   ObjectTimeSeries<E, T> threeToFive = dts.subSeries(testDates[3], testDates[5]);
   assertEquals(2, threeToFive.size());
   Iterator<Entry<E, T>> iterator = threeToFive.iterator();
   for (int i = 3; i < 5; i++) {
     Entry<E, T> item = iterator.next();
     assertEquals(testDates[i], item.getKey());
     assertEquals(testValues[i], item.getValue());
   }
   assertEquals(4, dts.subSeries(testDates[0], testDates[4]).size());
   assertEquals(5, dts.subSeries(testDates[0], true, testDates[4], true).size());
   assertEquals(1, dts.subSeries(testDates[4], testDates[5]).size());
   assertEquals(0, dts.subSeries(testDates[4], false, testDates[5], false).size());
   assertEquals(emptyTS, emptyTS.subSeries(testDates[1], testDates[1]));
 }
 public void testIsEmpty() {
   ObjectTimeSeries<E, T> empty = createEmptyTimeSeries();
   ObjectTimeSeries<E, T> dts = createStandardTimeSeries();
   assertTrue(empty.isEmpty());
   assertFalse(dts.isEmpty());
 }
 public void testSize() {
   ObjectTimeSeries<E, T> dts = createStandardTimeSeries();
   assertEquals(6, dts.size());
   ObjectTimeSeries<E, T> emptyTS = createEmptyTimeSeries();
   assertEquals(0, emptyTS.size());
 }