Finder { public List<RegisterEntry> find(final Optional<RegisterEntry> re) { try { List<RegisterEntry> entries = findDir(new File(config.getOutputDir())); if (re.isPresent()) { entries = entries.stream().filter(e -> e.matches(re.get())) .collect(Collectors.toList()); } return entries; } catch (Exception e) { logger.error("Failed to find entries. Error: {}", e.getMessage(), e); return Collections.emptyList(); } } @Autowired  Finder(RegisterConfig config); List<RegisterEntry> find(final Optional<RegisterEntry> re);  }
@Test public void testFind() { writer.register(entry); List<RegisterEntry> list = finder.find(Optional.empty()); assertThat(list.size(), greaterThan(0)); assertThat(list.get(0).getContext(), equalTo("context")); }