@Test
public void nonEmptyRange() {

  // Range of the threads from FakeCpuService#buildThreads
  Range range = new Range(TimeUnit.SECONDS.toMicros(1), TimeUnit.SECONDS.toMicros(15));
  // Create a series with the range that contains both thread1 and thread2 and thread2 tid
  DataSeries<CpuProfilerStage.ThreadState> series = createThreadSeries(2);
  List<SeriesData<CpuProfilerStage.ThreadState>> dataSeries = series.getDataForRange(range);
  assertNotNull(dataSeries);
  // thread2 state changes are RUNNING, STOPPED, SLEEPING, WAITING and DEAD
  assertEquals(5, dataSeries.size());
  assertEquals(CpuProfilerStage.ThreadState.RUNNING, dataSeries.get(0).value);
  // Any state different than RUNNING, SLEEPING, WAITING or DEAD (expected states) is mapped to UNKNOWN
  assertEquals(CpuProfilerStage.ThreadState.UNKNOWN, dataSeries.get(1).value);
  assertEquals(CpuProfilerStage.ThreadState.SLEEPING, dataSeries.get(2).value);
  assertEquals(CpuProfilerStage.ThreadState.WAITING, dataSeries.get(3).value);
  assertEquals(CpuProfilerStage.ThreadState.DEAD, dataSeries.get(4).value);
}