FileExtensionFilter implements RecordFilter<Path> { public Record<Path> processRecord(Record<Path> record) { for (String extension : extensions) { if (record.getPayload().toAbsolutePath().toString().endsWith(extension)) { return null; } } return record; } FileExtensionFilter(String... extensions); Record<Path> processRecord(Record<Path> record);  }
@Test public void whenTheFileNameEndsWithOneOfTheGivenExtensions_ThenItShouldBeFiltered() { when(path.toAbsolutePath().toString()).thenReturn("test.txt"); assertThat(filter.processRecord(fileRecord)).isNull(); }
@Test public void whenTheFileNameDoesNotEndWithOneOfTheGivenExtensions_ThenItShouldBeFiltered() { when(path.toAbsolutePath().toString()).thenReturn("test.jpeg"); assertThat(filter.processRecord(fileRecord)).isEqualTo(fileRecord); }