/** 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))); }
/** Test the method of {@link TimeAxisImpl#isAscending}. */ @Test public void testIsAscending() { assertTrue(tAxis.isAscending()); ArrayList<DateTime> dts = new ArrayList<>(); for (int i = 0; i < numberOfDate + 1; i++) { dts.add(start.minusDays(i)); } TimeAxis ta = new TimeAxisImpl(tAxisName, dts); assertFalse(ta.isAscending()); }
/** Test the method of {@link TimeAxisImpl#contains}. */ @Test public void testContains() { // pick up the fifth date in the range of t axis DateTime dt = start.plusDays(5); assertTrue(tAxis.contains(dt)); assertFalse(tAxis.contains(null)); // pick up a date out of the range of t axis dt = start.plusDays(25); assertFalse(tAxis.contains(dt)); // pick up a date out of the range of t axis dt = start.minusDays(5); assertFalse(tAxis.contains(dt)); }
/** 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#size}. */ @Test public void testSize() { assertEquals(numberOfDate + 1, tAxis.size()); }