@Test public void pathsMustBeWithinBaseDir() { Exception thrown = Assertions.assertThrows(SmithyBuildException.class, () -> { FileManifest a = new MockManifest(Paths.get("/foo")); a.addFile(Paths.get("/not/within/parent")); }); assertThat(thrown.getMessage(), containsString("must be relative to the base directory")); }
@Override public Path addFile(Path path) { if (!path.startsWith(baseDir) || !path.isAbsolute()) { path = resolvePath(path); } files.put(path, new byte[0]); return path; }
MockManifest implements FileManifest { @Override public Path addFile(Path path) { if (!path.startsWith(baseDir) || !path.isAbsolute()) { path = resolvePath(path); } files.put(path, new byte[0]); return path; } }
MockManifest implements FileManifest { @Override public Path addFile(Path path) { if (!path.startsWith(baseDir) || !path.isAbsolute()) { path = resolvePath(path); } files.put(path, new byte[0]); return path; } MockManifest(Path baseDir, MockManifest.StoreMode storeMode);  MockManifest(Path baseDir);  MockManifest(); }
MockManifest implements FileManifest { @Override public Path addFile(Path path) { if (!path.startsWith(baseDir) || !path.isAbsolute()) { path = resolvePath(path); } files.put(path, new byte[0]); return path; } MockManifest(Path baseDir, MockManifest.StoreMode storeMode);  MockManifest(Path baseDir);  MockManifest(); @Override Path getBaseDir(); @Override Set<Path> getFiles(); @Override Path addFile(Path path); @Override Path writeFile(Path path, Reader fileContentsReader); @Override Path writeFile(Path path, InputStream fileContentsInputStream); Optional<String> getFileString(Path file); Optional<String> getFileString(String file); String expectFileString(Path file); String expectFileString(String file); Optional<byte[]> getFileBytes(Path file); Optional<byte[]> getFileBytes(String file); byte[] expectFileBytes(Path file); byte[] expectFileBytes(String file); }
MockManifest implements FileManifest { @Override public Path addFile(Path path) { if (!path.startsWith(baseDir) || !path.isAbsolute()) { path = resolvePath(path); } files.put(path, new byte[0]); return path; } MockManifest(Path baseDir, MockManifest.StoreMode storeMode);  MockManifest(Path baseDir);  MockManifest(); @Override Path getBaseDir(); @Override Set<Path> getFiles(); @Override Path addFile(Path path); @Override Path writeFile(Path path, Reader fileContentsReader); @Override Path writeFile(Path path, InputStream fileContentsInputStream); Optional<String> getFileString(Path file); Optional<String> getFileString(String file); String expectFileString(Path file); String expectFileString(String file); Optional<byte[]> getFileBytes(Path file); Optional<byte[]> getFileBytes(String file); byte[] expectFileBytes(Path file); byte[] expectFileBytes(String file);  }