Search in sources :

Example 1 with DetectorSearchRuleSet

use of com.blackducksoftware.integration.hub.detect.workflow.search.rules.DetectorSearchRuleSet 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)

Example 2 with DetectorSearchRuleSet

use of com.blackducksoftware.integration.hub.detect.workflow.search.rules.DetectorSearchRuleSet in project hub-detect by blackducksoftware.

the class DetectorFinder method processDirectory.

private List<DetectorEvaluation> processDirectory(final File directory, final Set<Detector> appliedBefore, final int depth, final DetectorFinderOptions options) {
    final DetectorEnvironment environment = new DetectorEnvironment(directory, appliedBefore, depth, options.getDetectorFilter(), options.getForceNestedSearch());
    final DetectorSearchRuleSet bomToolSet = options.getDetectorSearchProvider().createBomToolSearchRuleSet(environment);
    final List<DetectorEvaluation> evaluations = options.getDetectorSearchEvaluator().evaluate(bomToolSet, options.getEventSystem());
    return evaluations;
}
Also used : DetectorEnvironment(com.blackducksoftware.integration.hub.detect.detector.DetectorEnvironment) DetectorSearchRuleSet(com.blackducksoftware.integration.hub.detect.workflow.search.rules.DetectorSearchRuleSet) DetectorEvaluation(com.blackducksoftware.integration.hub.detect.workflow.search.result.DetectorEvaluation)

Aggregations

DetectorEnvironment (com.blackducksoftware.integration.hub.detect.detector.DetectorEnvironment)2 DetectorSearchRuleSet (com.blackducksoftware.integration.hub.detect.workflow.search.rules.DetectorSearchRuleSet)2 Detector (com.blackducksoftware.integration.hub.detect.detector.Detector)1 DetectorFactory (com.blackducksoftware.integration.hub.detect.detector.DetectorFactory)1 DetectorEvaluation (com.blackducksoftware.integration.hub.detect.workflow.search.result.DetectorEvaluation)1 DetectorSearchProvider (com.blackducksoftware.integration.hub.detect.workflow.search.rules.DetectorSearchProvider)1 Test (org.junit.Test)1