### Question:
TimeSpanList extends AbstractList<TimeSpan> implements Serializable { public abstract TimeSpanList intersection(TimeSpan ts);  static TimeSpanList emptyList(); static void mergeOverlaps(final List<TimeSpan> list); static void mergeOverlaps(final List<TimeSpan> list, boolean mergeTouching); static TimeSpanList singleton(TimeSpan obj); abstract TimeSpanList clone(Collection<? extends TimeSpan> spans); boolean covers(TimeSpan other); boolean covers(TimeSpanList other); TimeSpan getExtent(); abstract TimeSpanList intersection(TimeSpan ts); abstract TimeSpanList intersection(TimeSpanList other); boolean intersects(TimeSpan timeSpan); abstract TimeSpanList union(TimeSpan ts); abstract TimeSpanList union(TimeSpanList other); static final TimeSpanList TIMELESS; }### Answer:
@Test public void testSingleTimeSpanIntersection() { List<TimeSpan> tsList = new ArrayList<>(); tsList.add(TimeSpan.get(10L, 20L)); tsList.add(TimeSpan.get(30L, 40L)); tsList.add(TimeSpan.get(50L, 60L)); TimeSpanArrayList tsl = new TimeSpanArrayList(tsList); TimeSpan overlapTS = TimeSpan.get(15, 55); TimeSpanList result = tsl.intersection(overlapTS); Assert.assertEquals(result.size(), 3); Assert.assertEquals(result.get(0), TimeSpan.get(15L, 20L)); Assert.assertEquals(result.get(1), TimeSpan.get(30L, 40L)); Assert.assertEquals(result.get(2), TimeSpan.get(50L, 55L)); result = tsl.intersection(TimeSpan.get(1L, 2L)); Assert.assertEquals(result.size(), 0); }
@Test public void testTimeSpanListIntersection() { List<TimeSpan> tsList1 = new ArrayList<>(); tsList1.add(TimeSpan.get(10L, 20L)); tsList1.add(TimeSpan.get(30L, 40L)); tsList1.add(TimeSpan.get(50L, 60L)); List<TimeSpan> tsList2 = new ArrayList<>(); tsList2.add(TimeSpan.get(32L, 35L)); tsList2.add(TimeSpan.get(39L, 44L)); tsList2.add(TimeSpan.get(47L, 80L)); TimeSpanArrayList tsl1 = new TimeSpanArrayList(tsList1); TimeSpanArrayList tsl2 = new TimeSpanArrayList(tsList2); TimeSpanList result = tsl1.intersection(tsl2); Assert.assertEquals(result.size(), 3); Assert.assertEquals(result.get(0), TimeSpan.get(32L, 35L)); Assert.assertEquals(result.get(1), TimeSpan.get(39L, 40L)); Assert.assertEquals(result.get(2), TimeSpan.get(50L, 60L)); }