GrokServiceImpl implements GrokService { public String getStatementFromClasspath(String path) throws RestException { try { return IOUtils.toString(getClass().getResourceAsStream(path)); } catch (Exception e) { throw new RestException("Could not find a statement at path " + path); } } @Autowired  GrokServiceImpl(Environment environment, Grok commonGrok, HdfsService hdfsService); @Override Map<String, String> getCommonGrokPatterns(); @Override GrokValidation validateGrokStatement(GrokValidation grokValidation); @Override Path saveTemporary(String statement, String name); void deleteTemporary(); String getStatementFromClasspath(String path);  }
@Test public void getStatementFromClasspathShouldReturnStatement() throws Exception { String expected = FileUtils.readFileToString(new File( "../../metron-platform/metron-parsing/metron-parsers/src/main/resources/patterns/squid")); assertEquals(expected, grokService.getStatementFromClasspath("/patterns/squid")); }
@Test public void getStatementFromClasspathShouldThrowRestException() { RestException e = assertThrows(RestException.class, () -> grokService.getStatementFromClasspath("/bad/path")); assertEquals("Could not find a statement at path /bad/path", e.getMessage()); }