コード例 #1
0
  /** Test the get methods in {@link TimeAxisImpl}. */
  @Test
  public void testGetMethods() {
    assertEquals(chronology, tAxis.getChronology());
    Extent<DateTime> dateExtent = tAxis.getCoordinateExtent();
    Extent<DateTime> expectedDateExtent = Extents.newExtent(start, start.plusDays(numberOfDate));
    assertEquals(expectedDateExtent, dateExtent);

    Array<Extent<DateTime>> dates = tAxis.getDomainObjects();
    int dateCounter = 0;
    for (Extent<DateTime> tExtent : dates) {
      Extent<DateTime> expectedExtent =
          Extents.newExtent(start.plusDays(dateCounter), start.plusDays(dateCounter));
      dateCounter++;
      assertEquals(expectedExtent, tExtent);
    }

    int expectedIndex = 4;
    // the first date is index 0
    DateTime fifthDate = tAxis.getCoordinateValue(expectedIndex);
    assertEquals(start.plusDays(expectedIndex), fifthDate);

    Extent<DateTime> expectedFifthDateBound = Extents.newExtent(fifthDate, fifthDate);
    assertEquals(expectedFifthDateBound, tAxis.getCoordinateBounds(expectedIndex));
    assertEquals(datetimes, tAxis.getCoordinateValues());
    assertEquals(tAxisName, tAxis.getName());
  }
コード例 #2
0
 /** Test the method of {@link TimeAxisImpl#findIndexOf}. */
 @Test
 public void testFindIndexOf() {
   // the first date is index 0
   int expectedIndex = 4;
   DateTime fifthDate = tAxis.getCoordinateValue(expectedIndex);
   assertEquals(expectedIndex, tAxis.findIndexOf(fifthDate));
   int notFoundIndex = -1;
   // a date is outside t axis.
   assertEquals(notFoundIndex, tAxis.findIndexOf(start.plusDays(25)));
 }