StartsWithStringRecordFilter implements RecordFilter<String> { public Record<String> processRecord(final Record<String> record) { String payload = record.getPayload(); for (String prefix : prefixes) { if (payload.startsWith(prefix)) { return null; } } return record; } StartsWithStringRecordFilter(final String... prefixes); Record<String> processRecord(final Record<String> record);  }
@Test public void recordsStartingWithOneOfThePrefixesShouldBeFiltered() { when(record.getPayload()).thenReturn("foofoo"); assertThat(filter.processRecord(record)).isNull(); when(record.getPayload()).thenReturn("barbar"); assertThat(filter.processRecord(record)).isNull(); }
@Test public void recordsNotStartingWithOneOfTheSuffixesShouldNotNotBeFiltered() { when(record.getPayload()).thenReturn("fodd"); assertThat(filter.processRecord(record)).isEqualTo(record); when(record.getPayload()).thenReturn("bazr"); assertThat(filter.processRecord(record)).isEqualTo(record); }