@Override
    public int delete(String patternId) {
        final GrokPattern grokPattern = store.remove(patternId);
        if (grokPattern != null) {
            clusterBus.post(GrokPatternsDeletedEvent.create(ImmutableSet.of(grokPattern.name())));
        }

        return grokPattern == null ? 0 : 1;
    }
@Test
    public void delete() throws Exception {
        final GrokPattern saved = service.save(GrokPattern.create("NAME", "name"));
        try {
            service.load(saved.id());
        } catch (Exception e) {
            fail("Should not throw");
        }
        assertThat(service.delete(saved.id())).isEqualTo(1);

        try {
            service.load(saved.id());
            fail("Should throw");
        } catch (NotFoundException ignored) {
        } catch (Exception e) {
            fail("Should not throw any other exceptions");
        }
    }