### Question:
PathMatchers { @Factory public static Matcher<Path> hasFilesCount(int expectedCount) { return new FilesCount(expectedCount); } PathMatchers(); @Factory static Matcher<Path> contains(String fileName); @Factory static Matcher<Path> isDirectory(); @Factory static Matcher<Path> exists(LinkOption... options); @Factory static Matcher<Path> hasFilesCount(int expectedCount); @Factory static Matcher<Path> hasFilesCount(int expectedCount, String glob);  }### Answer:
@Test public void shouldHasFilesCount() throws Exception { Files.write(directory.resolve("first"), "content".getBytes(StandardCharsets.UTF_8)); Files.write(directory.resolve("second"), "content".getBytes(StandardCharsets.UTF_8)); assertThat(directory, hasFilesCount(2)); }
@Test public void shouldHasFilesCountByGlob() throws Exception { Files.write(directory.resolve("first-file"), "content".getBytes(StandardCharsets.UTF_8)); Files.write(directory.resolve("second-file"), "content".getBytes(StandardCharsets.UTF_8)); Files.write(directory.resolve("other"), "content".getBytes(StandardCharsets.UTF_8)); assertThat(directory, hasFilesCount(2, "*-file")); }
@Test(expected = AssertionError.class) public void shouldFailIfNotHasSuchFiles() throws Exception { assertThat(directory, hasFilesCount(2)); }
@Test(expected = AssertionError.class) public void shouldFailIfNotHasSuchFilesByGlob() throws Exception { Files.write(directory.resolve("first"), "content".getBytes(StandardCharsets.UTF_8)); assertThat(directory, hasFilesCount(2, "*-file")); }