Search in sources :

Example 1 with DetectorSearchProvider

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;
}
Also used : DetectorSearchEvaluator(com.blackducksoftware.integration.hub.detect.workflow.search.rules.DetectorSearchEvaluator) NameVersion(com.synopsys.integration.util.NameVersion) SearchManager(com.blackducksoftware.integration.hub.detect.workflow.search.SearchManager) ExtractionManager(com.blackducksoftware.integration.hub.detect.workflow.extraction.ExtractionManager) DetectorFactory(com.blackducksoftware.integration.hub.detect.detector.DetectorFactory) DetectorSearchProvider(com.blackducksoftware.integration.hub.detect.workflow.search.rules.DetectorSearchProvider) DetectorManager(com.blackducksoftware.integration.hub.detect.workflow.detector.DetectorManager) PreparationManager(com.blackducksoftware.integration.hub.detect.workflow.extraction.PreparationManager) DetectorEvaluationNameVersionDecider(com.blackducksoftware.integration.hub.detect.workflow.project.DetectorEvaluationNameVersionDecider) DetectorNameVersionDecider(com.blackducksoftware.integration.hub.detect.workflow.project.DetectorNameVersionDecider) EventSystem(com.blackducksoftware.integration.hub.detect.workflow.event.EventSystem)

Example 2 with DetectorSearchProvider

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);
}
Also used : Detector(com.blackducksoftware.integration.hub.detect.detector.Detector) DetectorFactory(com.blackducksoftware.integration.hub.detect.detector.DetectorFactory) DetectorSearchProvider(com.blackducksoftware.integration.hub.detect.workflow.search.rules.DetectorSearchProvider) DetectorEnvironment(com.blackducksoftware.integration.hub.detect.detector.DetectorEnvironment) DetectorSearchRuleSet(com.blackducksoftware.integration.hub.detect.workflow.search.rules.DetectorSearchRuleSet) Test(org.junit.Test)

Aggregations

DetectorFactory (com.blackducksoftware.integration.hub.detect.detector.DetectorFactory)2 DetectorSearchProvider (com.blackducksoftware.integration.hub.detect.workflow.search.rules.DetectorSearchProvider)2 Detector (com.blackducksoftware.integration.hub.detect.detector.Detector)1 DetectorEnvironment (com.blackducksoftware.integration.hub.detect.detector.DetectorEnvironment)1 DetectorManager (com.blackducksoftware.integration.hub.detect.workflow.detector.DetectorManager)1 EventSystem (com.blackducksoftware.integration.hub.detect.workflow.event.EventSystem)1 ExtractionManager (com.blackducksoftware.integration.hub.detect.workflow.extraction.ExtractionManager)1 PreparationManager (com.blackducksoftware.integration.hub.detect.workflow.extraction.PreparationManager)1 DetectorEvaluationNameVersionDecider (com.blackducksoftware.integration.hub.detect.workflow.project.DetectorEvaluationNameVersionDecider)1 DetectorNameVersionDecider (com.blackducksoftware.integration.hub.detect.workflow.project.DetectorNameVersionDecider)1 SearchManager (com.blackducksoftware.integration.hub.detect.workflow.search.SearchManager)1 DetectorSearchEvaluator (com.blackducksoftware.integration.hub.detect.workflow.search.rules.DetectorSearchEvaluator)1 DetectorSearchRuleSet (com.blackducksoftware.integration.hub.detect.workflow.search.rules.DetectorSearchRuleSet)1 NameVersion (com.synopsys.integration.util.NameVersion)1 Test (org.junit.Test)1