### Question:
WorkerProcess extends Process { @Override public int waitFor() throws InterruptedException { int waitFor = delegate.waitFor(); shutdownHookRegistrar.removeShutdownHook(shutdownHook); return waitFor; } WorkerProcess(ProcessBuilder processBuilder); @VisibleForTesting  WorkerProcess(ShutdownHookRegistrar shutdownHookRegistrar, Process process); @Override OutputStream getOutputStream(); @Override InputStream getInputStream(); @Override InputStream getErrorStream(); @Override int waitFor(); @Override int exitValue(); @Override void destroy();  }### Answer:
@Test public void shutdownHook_waitFor() throws Exception { verify(registrar).addShutdownHook(hookCaptor.capture()); when(delegate.waitFor()).thenReturn(0); workerProcess.waitFor(); verify(registrar).removeShutdownHook(hookCaptor.getValue()); }