GrokServiceImpl implements GrokService { @Override public Map<String, String> getCommonGrokPatterns() { return commonGrok.getPatterns(); } @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 getCommonGrokPattersShouldCallGrokToGetPatterns() { grokService.getCommonGrokPatterns(); verify(grok).getPatterns(); }
@Test public void getCommonGrokPattersShouldCallGrokToGetPatternsAndNotAlterValue() { final Map<String, String> actual = new HashMap<String, String>() {{ put("k", "v"); put("k1", "v1"); }}; when(grok.getPatterns()).thenReturn(actual); Map<String, String> expected = new HashMap<String, String>() {{ put("k", "v"); put("k1", "v1"); }}; assertEquals(expected, grokService.getCommonGrokPatterns()); }