ZipFileData implements FileData { @Override public Path getPathWithinModule() { if (cachedPathWithinModule != null) { return cachedPathWithinModule; } Path fullPath = getPathWithinRoot(); if (fullPath.getNameCount() <= 1 || fullPath.startsWith("BUNDLE-METADATA") || fullPath.startsWith("META-INF")) { cachedPathWithinModule = fullPath; } else { cachedPathWithinModule = fullPath.subpath(1, fullPath.getNameCount()); } return cachedPathWithinModule; } ZipFileData(ZipFile zipFile, ZipEntry entry); @Override @MustBeClosed InputStream getInputStream(); @Override Path getPathWithinRoot(); @Override Path getPathWithinModule(); @Override long getSize(); long getCompressedSize();  }
@Test public void givesPathWithinModule() throws Exception { File bundleFile = TestUtils.getTestDataFile(APP_BUNDLE); try (ZipFile zipFile = new ZipFile(bundleFile)) { ZipEntry entry = zipFile.getEntry("base/manifest/AndroidManifest.xml"); ZipFileData data = new ZipFileData(zipFile, entry); assertThat((Object) data.getPathWithinModule()) .isEqualTo(Paths.get("manifest/AndroidManifest.xml")); } }
@Test public void givesPathWithinModule_succeedsForNonModuleFile() throws Exception { File bundleFile = TestUtils.getTestDataFile(APP_BUNDLE); try (ZipFile zipFile = new ZipFile(bundleFile)) { ZipEntry entry = zipFile.getEntry("BundleConfig.pb"); ZipFileData data = new ZipFileData(zipFile, entry); assertThat((Object) data.getPathWithinModule()).isEqualTo(Paths.get("BundleConfig.pb")); } }