use of com.blackducksoftware.integration.hub.detect.workflow.search.rules.DetectorSearchProvider in project hub-detect by blackducksoftware.
the class DetectorTool method performDetectors.
public DetectorToolResult performDetectors(SearchOptions searchOptions, String projectBomTool) throws DetectUserFriendlyException {
logger.info("Preparing to initialize detectors.");
DetectorFactory detectorFactory = detectContext.getBean(DetectorFactory.class);
EventSystem eventSystem = detectContext.getBean(EventSystem.class);
logger.info("Building detector system.");
DetectorSearchProvider detectorSearchProvider = new DetectorSearchProvider(detectorFactory);
DetectorSearchEvaluator detectorSearchEvaluator = new DetectorSearchEvaluator();
SearchManager searchManager = new SearchManager(searchOptions, detectorSearchProvider, detectorSearchEvaluator, eventSystem);
PreparationManager preparationManager = new PreparationManager(eventSystem);
ExtractionManager extractionManager = new ExtractionManager();
DetectorManager detectorManager = new DetectorManager(searchManager, extractionManager, preparationManager, eventSystem);
logger.info("Running detectors.");
DetectorToolResult detectorToolResult = detectorManager.runDetectors();
logger.info("Finished running detectors.");
eventSystem.publishEvent(Event.DetectorsComplete, detectorToolResult);
logger.info("Evaluating detectors for project info.");
DetectorEvaluationNameVersionDecider detectorEvaluationNameVersionDecider = new DetectorEvaluationNameVersionDecider(new DetectorNameVersionDecider());
Optional<NameVersion> bomToolNameVersion = detectorEvaluationNameVersionDecider.decideSuggestion(detectorToolResult.evaluatedDetectors, projectBomTool);
detectorToolResult.bomToolProjectNameVersion = bomToolNameVersion;
logger.info("Finished evaluating detectors for project info.");
return detectorToolResult;
}
use of com.blackducksoftware.integration.hub.detect.workflow.search.rules.DetectorSearchProvider in project hub-detect by blackducksoftware.
the class DetectorFactoryTest method testNewBomToolsCreatedEveryTime.
@Test
public void testNewBomToolsCreatedEveryTime() {
DetectorFactory detectorFactory = runContext.getBean(DetectorFactory.class);
DetectorSearchProvider provider = new DetectorSearchProvider(detectorFactory);
DetectorEnvironment mockEnv = Mockito.mock(DetectorEnvironment.class);
DetectorSearchRuleSet ruleSet1 = provider.createBomToolSearchRuleSet(mockEnv);
DetectorSearchRuleSet ruleSet2 = provider.createBomToolSearchRuleSet(mockEnv);
Detector detector1 = ruleSet1.getOrderedBomToolRules().get(0).getDetector();
Detector detector2 = ruleSet2.getOrderedBomToolRules().get(0).getDetector();
// Sanity check they are the same class
Assert.assertTrue(detector1.getClass().isInstance(detector2));
// And check they are not the same instance
Assert.assertFalse(detector1 == detector2);
}
Aggregations