### Question:
ProcessHelper { @SuppressLint("NewApi") public static boolean isAlive(Process process) { if (ApiWrap.hasOreo()) { return process.isAlive(); } else { try { process.exitValue(); return false; } catch (IllegalThreadStateException e) { return true; } } }  @SuppressLint("NewApi") static boolean isAlive(Process process);  }### Answer:
@Test public void testIsAlive_legacy() { ApiWrap.setSDKInt(16); doThrow(new IllegalThreadStateException()).when(process).exitValue(); assertThat(ProcessHelper.isAlive(process), is(true)); doReturn(0).when(process).exitValue(); assertThat(ProcessHelper.isAlive(process), is(false)); }
@Test public void testIsAlive_oreo() { ApiWrap.setSDKInt(26); when(process.isAlive()).thenReturn(true); assertThat(ProcessHelper.isAlive(process), is(true)); when(process.isAlive()).thenReturn(false); assertThat(ProcessHelper.isAlive(process), is(false)); }