use of com.synopsys.integration.detectable.detectables.go.gomod.model.GoListModule in project synopsys-detect by blackducksoftware.
the class GoModGraphGenerator method generateGraph.
public CodeLocation generateGraph(GoListModule projectModule, GoRelationshipManager goRelationshipManager, GoModDependencyManager goModDependencyManager) {
DependencyGraph graph = new BasicDependencyGraph();
String moduleName = projectModule.getPath();
if (goRelationshipManager.hasRelationshipsFor(moduleName)) {
goRelationshipManager.getRelationshipsFor(moduleName).stream().map(relationship -> relationship.getChild().getName()).forEach(childName -> addModuleToGraph(childName, null, graph, goRelationshipManager, goModDependencyManager));
}
return new CodeLocation(graph, externalIdFactory.createNameVersionExternalId(Forge.GOLANG, projectModule.getPath(), projectModule.getVersion()));
}
use of com.synopsys.integration.detectable.detectables.go.gomod.model.GoListModule in project synopsys-detect by blackducksoftware.
the class GoModCliExtractor method extract.
public Extraction extract(File directory, ExecutableTarget goExe) throws ExecutableFailedException, JsonSyntaxException, DetectableException {
List<GoListModule> goListModules = listModules(directory, goExe);
List<GoListAllData> goListAllModules = listAllModules(directory, goExe);
List<GoGraphRelationship> goGraphRelationships = listGraphRelationships(directory, goExe);
Set<String> excludedModules = listExcludedModules(directory, goExe);
GoRelationshipManager goRelationshipManager = new GoRelationshipManager(goGraphRelationships, excludedModules);
GoModDependencyManager goModDependencyManager = new GoModDependencyManager(goListAllModules, externalIdFactory);
List<CodeLocation> codeLocations = goListModules.stream().map(goListModule -> goModGraphGenerator.generateGraph(goListModule, goRelationshipManager, goModDependencyManager)).collect(Collectors.toList());
// No project info - hoping git can help with that.
return new Extraction.Builder().success(codeLocations).build();
}
use of com.synopsys.integration.detectable.detectables.go.gomod.model.GoListModule in project synopsys-detect by blackducksoftware.
the class GoListParserTest method goListHappyPathTest.
@Test
void goListHappyPathTest() throws DetectableException {
List<String> goListOutput = Arrays.asList("{\n", "\t\"Path\": \"github.com/synopsys/moduleA\"\n", "}\n", "{\n", "\t\"Path\": \"github.com/synopsys/moduleB\",\n", "\t\"Version\": \"1.0.0\"\n", "}\n");
List<GoListModule> goListModules = goListParser.parseGoListModuleJsonOutput(goListOutput);
assertEquals(2, goListModules.size());
GoListModule moduleA = goListModules.get(0);
assertEquals("github.com/synopsys/moduleA", moduleA.getPath());
assertNull(moduleA.getVersion());
GoListModule moduleB = goListModules.get(1);
assertEquals("github.com/synopsys/moduleB", moduleB.getPath());
assertEquals("1.0.0", moduleB.getVersion());
}
Aggregations