### Question:
DockerClient { public DockerImageDetails inspect(ImageReference imageReference) throws IOException, InterruptedException { Process inspectProcess = docker("inspect", "-f", "{{json .}}", "--type", "image", imageReference.toString()); if (inspectProcess.waitFor() != 0) { throw new IOException( "'docker inspect' command failed with error: " + getStderrOutput(inspectProcess)); } return JsonTemplateMapper.readJson(inspectProcess.getInputStream(), DockerImageDetails.class); } DockerClient(Path dockerExecutable, Map<String, String> dockerEnvironment); @VisibleForTesting  DockerClient(Function<List<String>, ProcessBuilder> processBuilderFactory); static boolean isDefaultDockerInstalled(); static boolean isDockerInstalled(Path dockerExecutable); String load(ImageTarball imageTarball, Consumer<Long> writtenByteCountListener); void save(
      ImageReference imageReference, Path outputPath, Consumer<Long> writtenByteCountListener); DockerImageDetails inspect(ImageReference imageReference); static final Path DEFAULT_DOCKER_CLIENT; }### Answer:
@Test public void testSize_fail() throws InterruptedException { DockerClient testDockerClient = new DockerClient( subcommand -> { Assert.assertEquals("inspect", subcommand.get(0)); return mockProcessBuilder; }); Mockito.when(mockProcess.waitFor()).thenReturn(1); Mockito.when(mockProcess.getErrorStream()) .thenReturn(new ByteArrayInputStream("error".getBytes(StandardCharsets.UTF_8))); try { testDockerClient.inspect(ImageReference.of(null, "image", null)); Assert.fail("docker inspect should have failed"); } catch (IOException ex) { Assert.assertEquals("'docker inspect' command failed with error: error", ex.getMessage()); } }