### Question:
WebHookTeamCityRestApiZipPluginFixer { protected boolean deleteFilesFromRestApiZipFile(File restApiZip, String[] filenames, JarReport jarReport) throws IOException { Map<String, String> zipProperties = new HashMap<>(); zipProperties.put("create", "false"); URI zipDisk = null; try { Path path = Paths.get(restApiZip.getAbsolutePath()); zipDisk = new URI("jar",path.toUri().toString().replace("\\","/"), null); } catch(URISyntaxException e) { Loggers.SERVER.warn("WebHookTeamCityRestApiZipPluginFixer :: Could not convert to JAR URI.", e); } boolean fileDeletedInZip = false; try (FileSystem zipfs = FileSystems.newFileSystem(zipDisk, zipProperties)) { for (String filename : filenames) { Path pathInZipfile = zipfs.getPath(filename); if (Files.exists(pathInZipfile)) { Files.delete(pathInZipfile); fileDeletedInZip = true; jarReport.setJarAsRemovedFromZip(filename, true); } } } return fileDeletedInZip; } WebHookTeamCityRestApiZipPluginFixer(SBuildServer sBuildServer); List<Path> getFoundApiZipFilesContainingJaxbJars(); boolean foundApiZipFilesContainingJaxbJars(); synchronized void findRestApiZipPlugins(); synchronized JarReport fixRestApiZipPlugin(Path p); static final String UNPACKED_LOCATION; }### Answer:
@Test public void testDeleteFilesFromRestApiZipFile() throws IOException { when(sBuildServer.getServerRootPath()).thenReturn("src/test/resources/empty_teamcity_home/webapps/ROOT"); FileUtils.copyDirectoryToDirectory(new File("src/test/resources/catalina_home"), new File("target")); WebHookTeamCityRestApiZipPluginFixer fixer = new WebHookTeamCityRestApiZipPluginFixer(sBuildServer); List<Path> filesFound = fixer.findRestApiZipFileInTomcatDir(new File("target/catalina_home"), "rest-api.zip"); assertEquals(1, filesFound.size()); String restApiUnpackedDir = filesFound.get(0).toFile().getParent() + WebHookTeamCityRestApiZipPluginFixer.UNPACKED_LOCATION; JarReport jarReport = new JarReport(filesFound.get(0), restApiUnpackedDir, WebHookTeamCityRestApiZipPluginFixer.getFilenames()); assertTrue(fixer.doesRestApiZipFileContainJaxJars(filesFound.get(0).toFile(), WebHookTeamCityRestApiZipPluginFixer.getFilenames(), jarReport)); fixer.deleteFilesFromRestApiZipFile(filesFound.get(0).toFile(), WebHookTeamCityRestApiZipPluginFixer.getFilenames(), jarReport); assertFalse(fixer.doesRestApiZipFileContainJaxJars(filesFound.get(0).toFile(), WebHookTeamCityRestApiZipPluginFixer.getFilenames(), jarReport)); }