ScannerImpl implements Scanner { protected <I> boolean accepts(ScannerPlugin<I, ?> selectedPlugin, I item, String path, Scope scope) { boolean accepted = false; try { accepted = selectedPlugin.accepts(item, path, scope); } catch (IOException e) { LOGGER.error("Plugin " + selectedPlugin + " failed to check whether it can accept item " + path, e); } return accepted; } ScannerImpl(ScannerConfiguration configuration, Map<String, Object> pluginProperties, ScannerContext scannerContext,
            ScannerPluginRepository scannerPluginRepository); @Override D scan(final I item, final String path, final Scope scope); @Override D scan(I item, D descriptor, String path, Scope scope); @Override ScannerContext getContext(); @Override Scope resolveScope(String name);  }
@Test public void acceptReturnTrueIfPluginAcceptsResource() throws IOException { Properties resource = mock(Properties.class); String path = "/a/b/c.properties"; ScannerPlugin<Properties, ?> selectedPlugin = mock(ScannerPlugin.class); doReturn(Boolean.TRUE).when(selectedPlugin).accepts(Mockito.<Properties> anyObject(), Mockito.eq(path), Mockito.eq(scope)); ScannerImpl scanner = new ScannerImpl(configuration, emptyMap(), context, scannerPluginRepository); boolean result = scanner.accepts(selectedPlugin, resource, path, scope); assertThat(result, is(true)); }
@Test public void acceptReturnFalseIfPluginRefusesResource() throws IOException { Properties resource = mock(Properties.class); String path = "/a/b/c.properties"; ScannerPlugin<Properties, ?> selectedPlugin = mock(ScannerPlugin.class); doReturn(Boolean.FALSE).when(selectedPlugin).accepts(Mockito.anyObject(), Mockito.eq(path), Mockito.eq(scope)); ScannerImpl scanner = new ScannerImpl(configuration, emptyMap(), context, scannerPluginRepository); boolean result = scanner.accepts(selectedPlugin, resource, path, scope); assertThat(result, is(false)); }