EndsWithStringRecordFilter implements RecordFilter<String> { @Override public Record<String> processRecord(Record<String> record) { String payload = record.getPayload(); for (String prefix : suffixes) { if (payload.endsWith(prefix)) { return null; } } return record; } EndsWithStringRecordFilter(final String... suffixes); @Override Record<String> processRecord(Record<String> record);  }
@Test public void recordsEndingWithOneOfTheSuffixesShouldBeFiltered() { when(record.getPayload()).thenReturn("foofoo"); assertThat(filter.processRecord(record)).isNull(); when(record.getPayload()).thenReturn("bar"); assertThat(filter.processRecord(record)).isNull(); }
@Test public void recordsNotEndingWithOneOfTheSuffixesShouldNotBeFiltered() { when(record.getPayload()).thenReturn("food"); assertThat(filter.processRecord(record)).isEqualTo(record); when(record.getPayload()).thenReturn("barz"); assertThat(filter.processRecord(record)).isEqualTo(record); }