### Question:
ToolScanScheduler extends AbstractSchedulingManager { public void scheduledToolScan() { core.scheduledToolScan(); } @Autowired  ToolScanScheduler(final ToolScanSchedulerCore core); @PostConstruct void init(); @PreDestroy void shutDown(); void scheduledToolScan(); Future<ToolVersionScanResult> forceScheduleScanTool(final String registry, final String id,
                                                               final String version, final Boolean rescan);  }### Answer:
@Test @Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = Throwable.class) public void testScheduledToolScan() { PreferenceManager preferenceManager = mock(PreferenceManager.class); Whitebox.setInternalState(toolScanScheduler, PREFERENCE_MANAGER, preferenceManager); Whitebox.setInternalState(core, PREFERENCE_MANAGER, preferenceManager); when(preferenceManager.getPreference(SystemPreferences.DOCKER_SECURITY_TOOL_SCAN_ENABLED)).thenReturn(true); when(preferenceManager.getPreference(SystemPreferences.DOCKER_SECURITY_TOOL_SCAN_ALL_REGISTRIES)) .thenReturn(false); registry.setPath(TEST_REPO); registry.setOwner(TEST_USER); registry.setSecurityScanEnabled(true); dockerRegistryDao.createDockerRegistry(registry); toolGroup.setName("testGroup"); toolGroup.setRegistryId(registry.getId()); toolGroup.setOwner(TEST_USER); toolGroupDao.createToolGroup(toolGroup); tool.setId(1L); tool.setRegistryId(registry.getId()); tool.setToolGroupId(toolGroup.getId()); toolManager.create(tool, false); toolScanScheduler.scheduledToolScan(); ToolVersionScanResult versionScanResult = toolManager.loadToolVersionScan(tool.getId(), LATEST_VERSION).get(); Assert.assertNotNull(versionScanResult); Assert.assertEquals(ToolScanStatus.COMPLETED, versionScanResult.getStatus()); Assert.assertNotNull(versionScanResult.getScanDate()); Vulnerability loaded = versionScanResult.getVulnerabilities().get(0); TestUtils.checkEquals(vulnerability, loaded, objectMapper); Optional<String> loadedRef = toolManager.loadToolVersionScan(tool.getId(), LATEST_VERSION) .map(ToolVersionScanResult::getLastLayerRef); Assert.assertTrue(loadedRef.isPresent()); Assert.assertEquals(TEST_LAYER_REF, loadedRef.get()); }