@Override
    public int deleteAll() {
        final Set<GrokPattern> grokPatterns = loadAll();
        final Set<String> patternNames = grokPatterns.stream()
                .map(GrokPattern::name)
                .collect(Collectors.toSet());

        final int deletedPatterns = dbCollection.remove(DBQuery.empty()).getN();
        clusterBus.post(GrokPatternsDeletedEvent.create(patternNames));

        return deletedPatterns;
    }
@Test
    @MongoDBFixtures("MongoDbGrokPatternServiceTest.json")
    public void deleteAll() {
        assertThat(collection.countDocuments()).isEqualTo(3);

        final int deletedRecords = service.deleteAll();
        assertThat(deletedRecords).isEqualTo(3);
        assertThat(collection.countDocuments()).isEqualTo(0);
        verify(clusterEventBus, times(1)).post(any(GrokPatternsDeletedEvent.class));
    }