### Question:
SamplePointExporter { static List<SamplingPoint> extractSamples(List<SamplingPoint> samples, TimeRange extractRange) { if (samples instanceof LinkedList) { final LinkedList<SamplingPoint> extracted = new LinkedList<>(); final Iterator<SamplingPoint> iterator = samples.iterator(); while (iterator.hasNext()) { final SamplingPoint point = iterator.next(); if (extractRange.includes(point.getReferenceTime())) { extracted.add(point); iterator.remove(); } } return extracted; } else if (samples instanceof ArrayList) { final List<SamplingPoint> extracted = new LinkedList<>(); final List<SamplingPoint> remaining = new ArrayList<>(samples.size()); for (final SamplingPoint point : samples) { if (extractRange.includes(point.getReferenceTime())) { extracted.add(point); } else { remaining.add(point); } } samples.clear(); samples.addAll(remaining); return extracted; } else { throw new IllegalArgumentException("Sample list is neither a LinkedList nor an ArrayList."); } } SamplePointExporter(Configuration config); void setLogger(Logger logger); void export(List<SamplingPoint> samplingPoints, TimeRange samplingInterval);  }### Answer:
@Test public void testExtractByTimeRange_intersectingBeginning() throws ParseException { final List<SamplingPoint> samples = createSamplingPoints(); final Date extractStart = TimeUtil.parseCcsdsUtcFormat("2003-07-01T00:00:00Z"); final Date extractStop = TimeUtil.parseCcsdsUtcFormat("2003-07-31T23:59:59Z"); final TimeRange extractRange = new TimeRange(extractStart, extractStop); final List<SamplingPoint> julySamples = SamplePointExporter.extractSamples(samples, extractRange); assertNotNull(julySamples); assertEquals(49, julySamples.size()); assertEquals(151, samples.size()); TestHelper.assertPointsInTimeRange(extractStart, extractStop, julySamples); }
@Test public void testExtractByTimeRange_intersectingMiddle() throws ParseException { final List<SamplingPoint> samples = createSamplingPoints(); final Date extractStart = TimeUtil.parseCcsdsUtcFormat("2003-08-01T00:00:00Z"); final Date extractStop = TimeUtil.parseCcsdsUtcFormat("2003-08-31T23:59:59Z"); final TimeRange extractRange = new TimeRange(extractStart, extractStop); final List<SamplingPoint> augustSamples = SamplePointExporter.extractSamples(samples, extractRange); assertNotNull(augustSamples); assertEquals(102, augustSamples.size()); assertEquals(98, samples.size()); TestHelper.assertPointsInTimeRange(extractStart, extractStop, augustSamples); }
@Test public void testExtractByTimeRange_intersectingEnd() throws ParseException { final List<SamplingPoint> samples = createSamplingPoints(); final Date extractStart = TimeUtil.parseCcsdsUtcFormat("2003-09-01T00:00:00Z"); final Date extractStop = TimeUtil.parseCcsdsUtcFormat("2003-09-30T23:59:59Z"); final TimeRange extractRange = new TimeRange(extractStart, extractStop); final List<SamplingPoint> septemberSamples = SamplePointExporter.extractSamples(samples, extractRange); assertNotNull(septemberSamples); assertEquals(49, septemberSamples.size()); assertEquals(151, samples.size()); TestHelper.assertPointsInTimeRange(extractStart, extractStop, septemberSamples); }