/** 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()); }
/** 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))); }