@Override
    public int delete(String patternId) {
        final GrokPattern grokPattern;
        try {
            grokPattern = load(patternId);
        } catch (NotFoundException e) {
            log.debug("Couldn't find grok pattern with ID <{}> for deletion", patternId, e);
            return 0;
        }

        final ObjectId id = new ObjectId(patternId);
        final String name = grokPattern.name();

        final int deletedPatterns = dbCollection.removeById(id).getN();
        clusterBus.post(GrokPatternsDeletedEvent.create(ImmutableSet.of(name)));

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

        final int deletedRecords = service.delete("56250da2d4000000deadbeef");
        assertThat(deletedRecords).isEqualTo(0);
        assertThat(collection.countDocuments()).isEqualTo(3);
        verify(clusterEventBus, never()).post(any(GrokPatternsDeletedEvent.class));
    }