@Test
public void otherProcessesCpuUsage() {

  mySeries = new LegacyCpuUsageDataSeries(
    new ProfilerClient(myGrpcChannel.getName()).getCpuClient(), ProfilersTestData.SESSION_DATA, true);
  int systemTime = (int)(0.6 * FakeCpuService.TOTAL_ELAPSED_TIME);
  myService.setSystemTimeMs(systemTime);
  List<SeriesData<Long>> seriesData = mySeries.getDataForRange(ANY_RANGE);
  assertEquals(1, seriesData.size());
  SeriesData<Long> systemUsageData = seriesData.get(0);
  assertNotNull(systemUsageData);
  assertEquals(60, (long)systemUsageData.value); // 60% of total elapsed time
  systemTime = (int)(1.5 * FakeCpuService.TOTAL_ELAPSED_TIME);
  myService.setSystemTimeMs(systemTime);
  seriesData = mySeries.getDataForRange(ANY_RANGE);
  assertEquals(1, seriesData.size());
  systemUsageData = seriesData.get(0);
  assertNotNull(systemUsageData);
  // System usage shouldn't be greater than 100%. If that happens, we cap the value to 100%.
  assertEquals(100, (long)systemUsageData.value);
  systemTime = (int)(-0.5 * FakeCpuService.TOTAL_ELAPSED_TIME);
  myService.setSystemTimeMs(systemTime);
  seriesData = mySeries.getDataForRange(ANY_RANGE);
  assertEquals(1, seriesData.size());
  systemUsageData = seriesData.get(0);
  assertNotNull(systemUsageData);
  // System usage shouldn't be less than 0%. If that happens, we cap the value to 0%.
  assertEquals(0, (long)systemUsageData.value);
}