### Question:
DefaultTimeSpanSet implements TimeSpanSet { @Override public TimeSpanSet union(TimeSpanSet other) { DefaultTimeSpanSet newSet = new DefaultTimeSpanSet(this); newSet.add(other); return newSet; } DefaultTimeSpanSet();  DefaultTimeSpanSet(TimeSpan ts);  DefaultTimeSpanSet(TimeSpanSet other); @Override boolean add(TimeSpan e); @Override final boolean add(TimeSpanSet other); @Override boolean addAll(Collection<? extends TimeSpan> c); @Override void clear(); @Override boolean contains(Date aDate); @Override boolean contains(long aTime); @Override boolean contains(Object o); @Override boolean contains(TimeSpan value); @Override boolean containsAll(Collection<?> c); @Override boolean equals(Object obj); @Override List<TimeSpan> getTimeSpans(); @Override int hashCode(); @Override TimeSpanSet intersection(TimeSpan ts); @Override TimeSpanSet intersection(TimeSpanSet otherSet); @Override boolean intersects(TimeSpan value); @Override boolean intersects(TimeSpanProvider ts); @Override boolean intersects(TimeSpanSet other); @Override boolean isEmpty(); @Override Iterator<TimeSpan> iterator(); @Override boolean remove(Object o); @Override boolean remove(TimeSpan spanToRemove); @Override boolean remove(TimeSpanSet other); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override int size(); @Override Object[] toArray(); @Override T[] toArray(T[] a); @Override String toString(); @Override TimeSpanSet union(TimeSpanSet other);  }### Answer:
@Test public void testUnion() { long[] setA = { 1, 2, 5, 6, 8, 9, 11, 12, 13, 14, 15, 55, 56, 57 }; DefaultTimeSpanSet rlsA = new DefaultTimeSpanSet(); rlsA.addAll(createTestTimeSpans(setA)); long[] setB = { 1, 2, 5, 7, 15, 17, 50, 51, 52, 57 }; DefaultTimeSpanSet rlsB = new DefaultTimeSpanSet(); rlsB.addAll(createTestTimeSpans(setB)); TimeSpanSet unionedSet = rlsA.union(rlsB); assertEquals(6, unionedSet.size()); assertEquals(1, unionedSet.getTimeSpans().get(0).getStart()); assertEquals(3, unionedSet.getTimeSpans().get(0).getEnd()); assertEquals(5, unionedSet.getTimeSpans().get(1).getStart()); assertEquals(10, unionedSet.getTimeSpans().get(1).getEnd()); assertEquals(11, unionedSet.getTimeSpans().get(2).getStart()); assertEquals(16, unionedSet.getTimeSpans().get(2).getEnd()); assertEquals(17, unionedSet.getTimeSpans().get(3).getStart()); assertEquals(18, unionedSet.getTimeSpans().get(3).getEnd()); assertEquals(50, unionedSet.getTimeSpans().get(4).getStart()); assertEquals(53, unionedSet.getTimeSpans().get(4).getEnd()); assertEquals(55, unionedSet.getTimeSpans().get(5).getStart()); assertEquals(58, unionedSet.getTimeSpans().get(5).getEnd()); }