public void testCreateWithCustomPatterns() throws Exception {
    GrokProcessor.Factory factory = new GrokProcessor.Factory(Collections.emptyMap());

    Map<String, Object> config = new HashMap<>();
    config.put("field", "_field");
    config.put("patterns", Collections.singletonList("%{MY_PATTERN:name}!"));
    config.put("pattern_definitions", Collections.singletonMap("MY_PATTERN", "foo"));
    GrokProcessor processor = factory.create(null, config);
    assertThat(processor.getMatchField(), equalTo("_field"));
    assertThat(processor.getGrok(), notNullValue());
    assertThat(processor.getGrok().match("foo!"), equalTo(true));
  }
  public void testBuild() throws Exception {
    GrokProcessor.Factory factory = new GrokProcessor.Factory(Collections.emptyMap());

    Map<String, Object> config = new HashMap<>();
    config.put("field", "_field");
    config.put("patterns", Collections.singletonList("(?<foo>\\w+)"));
    String processorTag = randomAsciiOfLength(10);
    GrokProcessor processor = factory.create(processorTag, config);
    assertThat(processor.getTag(), equalTo(processorTag));
    assertThat(processor.getMatchField(), equalTo("_field"));
    assertThat(processor.getGrok(), notNullValue());
  }