use of com.synopsys.integration.detector.base.DetectorType in project synopsys-detect by blackducksoftware.
the class DetectorAggregateEvaluationResultTest method testMultiLevel.
@Test
public void testMultiLevel() {
DetectorType topLevelDetectorType = DetectorType.GRADLE;
DetectorType secondLevelDetectorType = DetectorType.MAVEN;
DetectorEvaluationTree topLevelEvaluationTree = generateDetectorEvaluationTreeMock(topLevelDetectorType);
DetectorEvaluationTree secondLevelEvaluationTree = generateDetectorEvaluationTreeMock(secondLevelDetectorType);
Set<DetectorEvaluationTree> secondLevelEvaluationTrees = new HashSet<>();
secondLevelEvaluationTrees.add(secondLevelEvaluationTree);
Mockito.when(topLevelEvaluationTree.getChildren()).thenReturn(secondLevelEvaluationTrees);
DetectorAggregateEvaluationResult result = new DetectorAggregateEvaluationResult(topLevelEvaluationTree);
assertEquals(1, result.getApplicableDetectorTypes().size());
assertEquals(2, result.getApplicableDetectorTypesRecursively().size());
assertTrue(result.getApplicableDetectorTypesRecursively().contains(topLevelDetectorType));
assertTrue(result.getApplicableDetectorTypesRecursively().contains(secondLevelDetectorType));
}
use of com.synopsys.integration.detector.base.DetectorType in project synopsys-detect by blackducksoftware.
the class DetectorTool method extractStatus.
private Map<DetectorType, StatusType> extractStatus(List<DetectorEvaluation> detectorEvaluations) {
EnumMap<DetectorType, StatusType> statusMap = new EnumMap<>(DetectorType.class);
for (DetectorEvaluation detectorEvaluation : detectorEvaluations) {
DetectorType detectorType = detectorEvaluation.getDetectorType();
Optional<StatusType> foundStatusType = determineDetectorExtractionStatus(detectorEvaluation);
if (foundStatusType.isPresent()) {
StatusType statusType = foundStatusType.get();
if (statusType == StatusType.FAILURE || !statusMap.containsKey(detectorType)) {
statusMap.put(detectorType, statusType);
}
}
}
return statusMap;
}
use of com.synopsys.integration.detector.base.DetectorType in project synopsys-detect by blackducksoftware.
the class DetectorTool method publishMissingDetectorEvents.
private void publishMissingDetectorEvents(List<DetectorType> requiredDetectors, Set<DetectorType> applicable) {
Set<DetectorType> missingDetectors = requiredDetectors.stream().filter(it -> !applicable.contains(it)).collect(Collectors.toSet());
if (!missingDetectors.isEmpty()) {
String missingDetectorDisplay = missingDetectors.stream().map(Enum::toString).collect(Collectors.joining(","));
logger.error("One or more required detector types were not found: {}", missingDetectorDisplay);
exitCodePublisher.publishExitCode(new ExitCodeRequest(ExitCodeType.FAILURE_DETECTOR_REQUIRED));
}
}
use of com.synopsys.integration.detector.base.DetectorType in project synopsys-detect by blackducksoftware.
the class DetectorNameVersionDecider method decideProjectNameVersionFromDetector.
private NameVersionDecision decideProjectNameVersionFromDetector(List<DetectorProjectInfo> projectNamePossibilities, DetectorType preferredDetectorType) {
if (preferredDetectorType != null) {
List<DetectorProjectInfo> preferredPossibilities = projectNamePossibilities.stream().filter(info -> info.getDetectorType() == preferredDetectorType).collect(Collectors.toList());
List<DetectorProjectInfo> lowestDepthPossibilities = projectNamesAtLowestDepth(preferredPossibilities);
List<DetectorProjectInfo> uniqueDetectorsAtLowestDepth = filterUniqueDetectorsOnly(lowestDepthPossibilities);
if (uniqueDetectorsAtLowestDepth.isEmpty()) {
return new PreferredDetectorNotFoundDecision(preferredDetectorType);
} else if (uniqueDetectorsAtLowestDepth.size() == 1) {
return new PreferredDetectorDecision(uniqueDetectorsAtLowestDepth.get(0));
} else {
return new TooManyPreferredDetectorTypesFoundDecision(preferredDetectorType);
}
} else {
List<DetectorProjectInfo> lowestDepthPossibilities = projectNamesAtLowestDepth(projectNamePossibilities);
List<DetectorProjectInfo> uniqueDetectorsAtLowestDepth = filterUniqueDetectorsOnly(lowestDepthPossibilities);
if (uniqueDetectorsAtLowestDepth.size() == 1) {
return new UniqueDetectorDecision(uniqueDetectorsAtLowestDepth.get(0));
} else if (uniqueDetectorsAtLowestDepth.size() > 1) {
return decideProjectNameVersionArbitrarily(lowestDepthPossibilities);
} else {
return new UniqueDetectorNotFoundDecision();
}
}
}
use of com.synopsys.integration.detector.base.DetectorType in project synopsys-detect by blackducksoftware.
the class DetectorProfiler method addAggregateByDetectorGroupType.
private void addAggregateByDetectorGroupType(Map<DetectorType, Long> aggregate, List<Timing<DetectorEvaluation>> timings) {
for (Timing<DetectorEvaluation> timing : timings) {
DetectorType type = timing.getKey().getDetectorType();
if (!aggregate.containsKey(type)) {
aggregate.put(type, 0L);
}
long time = timing.getMs();
Long currentTime = aggregate.get(type);
Long sum = time + currentTime;
aggregate.put(type, sum);
}
}
Aggregations