MockManifest implements FileManifest { @Override public Path writeFile(Path path, Reader fileContentsReader) { StringBuilder builder = new StringBuilder(); char[] buffer = new char[8 * 1024]; int numCharsRead; try { while ((numCharsRead = fileContentsReader.read(buffer, 0, buffer.length)) != -1) { builder.append(buffer, 0, numCharsRead); } } catch (IOException e) { throw new SmithyBuildException(e); } return storeFile(path, builder.toString().getBytes(Charset.forName("UTF-8"))); } 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);  }
@Test public void findsFilesUnderPrefix() { MockManifest a = new MockManifest(); a.writeFile("foo/bar/a", "hello"); a.writeFile("foo/bar/b", "hello"); a.writeFile("foo/bam/qux", "hello"); assertThat(a.getFilesIn("foo"), contains( Paths.get("/foo/bam/qux"), Paths.get("/foo/bar/a"), Paths.get("/foo/bar/b"))); assertThat(a.getFilesIn("foo/bam"), contains(Paths.get("/foo/bam/qux"))); assertThat(a.getFilesIn("foo/bar"), contains(Paths.get("/foo/bar/a"), Paths.get("/foo/bar/b"))); assertThat(a.getFilesIn("foo/bam"), contains(Paths.get("/foo/bam/qux"))); }