### Question:
ArchiveExtractor { public void extract(File archive, String member, File extractTo) throws ExtractionException { try { TFile tfile = new TFile(archive, member); LOGGER.info(EXTRACTING, tfile.getAbsolutePath(), extractTo.getAbsolutePath()); if (extractTo.getParentFile().exists() || extractTo.getParentFile().mkdirs()) { tfile.cp(extractTo); } } catch (IOException e) { throw new ExtractionException(String.format(UNABLE_TO_EXTRACT, archive), e); } finally { unmountArchive(); } }  void extract(File archive, String member, File extractTo);  }### Answer:
@Test public void shouldExtract() throws Exception { extractor.extract(archive, PATH_TO_EXECUTABLE, extractTo); assertThat(extractTo.exists()).isTrue(); }
@Test public void shouldNotExtract() throws Exception { extractTo = mock(File.class); when(extractTo.getParentFile()).thenReturn(extractToParent); when(extractTo.getAbsolutePath()).thenReturn(EXTRACT_TO_PATH); when(extractToParent.mkdirs()).thenReturn(false); extractor.extract(archive, PATH_TO_EXECUTABLE, extractTo); verify(extractTo, never()).setExecutable(true); }
@Test public void shouldFailToExtract() throws Exception { File invalidFile = new File(PROJECT_ROOT + "/target/doesnotexist"); assertThatThrownBy(() -> extractor.extract(invalidFile, PATH_TO_EXECUTABLE, extractTo)) .isInstanceOf(ExtractionException.class); }