VirusScannerRequestProcessor extends ComponentSupport implements RequestStrategy { @VisibleForTesting boolean hasVirus(final StorageFileItem item) { log.debug("Scanning item for viruses: {}", item.getPath()); boolean infected = false; for (VirusScanner scanner : scanners) { if (scanner.hasVirus(item)) { infected = true; eventBus.post(new InfectedItemFoundEvent(item.getRepositoryItemUid().getRepository(), item)); } } if (infected) { log.warn("Infection detected in item: {}", item.getPath()); } return infected; } @Inject  VirusScannerRequestProcessor(final EventBus eventBus,
                                      final List<VirusScanner> scanners); @Override void onHandle(final Repository repository, final ResourceStoreRequest resourceStoreRequest,
                       final Action action); @Override void onServing(final Repository repository, final ResourceStoreRequest resourceStoreRequest,
                        final StorageItem storageItem); @Override void onRemoteAccess(final ProxyRepository proxyRepository, final ResourceStoreRequest resourceStoreRequest,
                             final StorageItem storageItem); static final String ID; }
@Test public void allScannersConsulted() throws Exception { when(scanner1.hasVirus(any(StorageFileItem.class))).thenReturn(false); when(scanner2.hasVirus(any(StorageFileItem.class))).thenReturn(true); StorageFileItem item = mock(StorageFileItem.class, RETURNS_DEEP_STUBS); assertThat(underTest.hasVirus(item), is(true)); verify(scanner1).hasVirus(item); verify(scanner2).hasVirus(item); verify(eventBus).post(any(InfectedItemFoundEvent.class)); }