use of com.synopsys.integration.detector.base.DetectorEvaluationTree in project synopsys-detect by blackducksoftware.
the class DetectorAggregateEvaluationResultTest method generateDetectorEvaluationTreeMock.
@NotNull
private DetectorEvaluationTree generateDetectorEvaluationTreeMock(DetectorType detectorType) {
DetectorEvaluationTree evaluationTree = Mockito.mock(DetectorEvaluationTree.class);
List<DetectorEvaluation> evaluations = new ArrayList<>();
DetectorEvaluation topLevelEvaluation = Mockito.mock(DetectorEvaluation.class);
Mockito.when(topLevelEvaluation.isApplicable()).thenReturn(true);
DetectorRule rule = Mockito.mock(DetectorRule.class);
Mockito.when(rule.getDetectorType()).thenReturn(detectorType);
Mockito.when(topLevelEvaluation.getDetectorRule()).thenReturn(rule);
evaluations.add(topLevelEvaluation);
Mockito.when(evaluationTree.getOrderedEvaluations()).thenReturn(evaluations);
return evaluationTree;
}
use of com.synopsys.integration.detector.base.DetectorEvaluationTree in project synopsys-detect by blackducksoftware.
the class DetectorAggregateEvaluationResultTest method testSingleLevel.
@Test
public void testSingleLevel() {
DetectorType detectorType = DetectorType.GRADLE;
DetectorEvaluationTree evaluationTree = generateDetectorEvaluationTreeMock(detectorType);
DetectorAggregateEvaluationResult result = new DetectorAggregateEvaluationResult(evaluationTree);
assertEquals(1, result.getApplicableDetectorTypes().size());
assertTrue(result.getApplicableDetectorTypes().contains(detectorType));
}
use of com.synopsys.integration.detector.base.DetectorEvaluationTree in project synopsys-detect by blackducksoftware.
the class DetectorEvaluatorTest method testEvaluation.
@Test
public void testEvaluation() {
DetectorEvaluatorListener listener = Mockito.mock(DetectorEvaluatorListener.class);
DetectorEvaluationOptions evaluationOptions = Mockito.mock(DetectorEvaluationOptions.class);
ExtractionEnvironment extractionEnvironment = Mockito.mock(ExtractionEnvironment.class);
Function<DetectorEvaluation, ExtractionEnvironment> extractionEnvironmentProvider = (detectorEvaluation) -> extractionEnvironment;
DetectorEvaluationTree rootEvaluation = Mockito.mock(DetectorEvaluationTree.class);
DetectorEvaluator detectorEvaluator = new DetectorEvaluator(evaluationOptions, extractionEnvironmentProvider);
detectorEvaluator.setDetectorEvaluatorListener(listener);
DetectorAggregateEvaluationResult result = detectorEvaluator.evaluate(rootEvaluation);
Optional<DetectorEvaluatorListener> actualListener = detectorEvaluator.getDetectorEvaluatorListener();
assertTrue(actualListener.isPresent());
assertEquals(listener, actualListener.get());
assertEquals(rootEvaluation, result.getEvaluationTree());
}
use of com.synopsys.integration.detector.base.DetectorEvaluationTree in project synopsys-detect by blackducksoftware.
the class ExtractableEvaluatorTest method testEvaluationExtractableAlreadyPerformed.
@Test
public void testEvaluationExtractableAlreadyPerformed() throws DetectableException {
DetectorEvaluationOptions evaluationOptions = Mockito.mock(DetectorEvaluationOptions.class);
ExtractionEnvironment extractionEnvironment = Mockito.mock(ExtractionEnvironment.class);
Function<DetectorEvaluation, ExtractionEnvironment> extractionEnvironmentProvider = (detectorEvaluation) -> extractionEnvironment;
ExtractableEvaluator evaluator = new ExtractableEvaluator(evaluationOptions, extractionEnvironmentProvider);
DetectorEvaluationTree detectorEvaluationTree = Mockito.mock(DetectorEvaluationTree.class);
Mockito.when(detectorEvaluationTree.getDirectory()).thenReturn(new File("."));
DetectorEvaluatorListener detectorEvaluatorListener = Mockito.mock(DetectorEvaluatorListener.class);
evaluator.setDetectorEvaluatorListener(detectorEvaluatorListener);
DetectorEvaluation detectorEvaluation = createEvaluationMocks(evaluationOptions, detectorEvaluationTree, true, false);
DetectorAggregateEvaluationResult result = evaluator.evaluate(detectorEvaluationTree);
assertEquals(detectorEvaluationTree, result.getEvaluationTree());
Mockito.verify(detectorEvaluatorListener).extractableStarted(detectorEvaluation);
Mockito.verify(detectorEvaluation).setExtractable(Mockito.any(DetectorResult.class));
Mockito.verify(detectorEvaluatorListener).extractableEnded(detectorEvaluation);
}
use of com.synopsys.integration.detector.base.DetectorEvaluationTree in project synopsys-detect by blackducksoftware.
the class ExtractionEvaluatorTest method testEvaluationSuccess.
@Test
public void testEvaluationSuccess() throws DetectableException, ExecutableFailedException, IOException, CycleDetectedException, MissingExternalIdException, ExecutableRunnerException, ParserConfigurationException, SAXException {
DetectorEvaluationOptions evaluationOptions = Mockito.mock(DetectorEvaluationOptions.class);
ExtractionEvaluator evaluator = new ExtractionEvaluator(evaluationOptions);
DetectorEvaluationTree detectorEvaluationTree = Mockito.mock(DetectorEvaluationTree.class);
Mockito.when(detectorEvaluationTree.getDirectory()).thenReturn(new File("."));
DetectorEvaluatorListener detectorEvaluatorListener = Mockito.mock(DetectorEvaluatorListener.class);
evaluator.setDetectorEvaluatorListener(detectorEvaluatorListener);
DetectorEvaluation detectorEvaluation = createEvaluationMocks(evaluationOptions, detectorEvaluationTree, false, false);
DetectorAggregateEvaluationResult result = evaluator.evaluate(detectorEvaluationTree);
assertEquals(detectorEvaluationTree, result.getEvaluationTree());
Mockito.verify(detectorEvaluatorListener).extractionStarted(detectorEvaluation);
Mockito.verify(detectorEvaluation).setExtraction(Mockito.any(Extraction.class));
Mockito.verify(detectorEvaluatorListener).extractionEnded(detectorEvaluation);
}
Aggregations