use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class NugetInspectorParserTest method createCodeLocationDWService.
@Test
public void createCodeLocationDWService() {
Assertions.assertTimeout(Duration.ofMillis(5000L), () -> {
String dependencyNodeFile = FunctionalTestFiles.asString("/nuget/dwCheckApi_inspection_martin.json");
ExternalIdFactory externalIdFactory = new ExternalIdFactory();
NugetInspectorParser packager = new NugetInspectorParser(gson, externalIdFactory);
NugetParseResult result = packager.createCodeLocation(dependencyNodeFile);
for (CodeLocation codeLocation : result.getCodeLocations()) {
BdioPropertyHelper bdioPropertyHelper = new BdioPropertyHelper();
BdioNodeFactory bdioNodeFactory = new BdioNodeFactory(bdioPropertyHelper);
DependencyGraphTransformer dependencyNodeTransformer = new DependencyGraphTransformer(bdioPropertyHelper, bdioNodeFactory);
BdioExternalIdentifier projectId = bdioPropertyHelper.createExternalIdentifier(codeLocation.getExternalId().get());
BdioProject project = bdioNodeFactory.createProject(result.getProjectName(), result.getProjectVersion(), BdioId.createFromPieces(Forge.NUGET.toString()), projectId);
Map<ExternalId, BdioNode> components = new HashMap<>();
components.put(codeLocation.getExternalId().get(), project);
List<BdioComponent> bdioComponents = dependencyNodeTransformer.transformDependencyGraph(codeLocation.getDependencyGraph(), project, codeLocation.getDependencyGraph().getRootDependencies(), components);
assertEquals(bdioComponents.size(), bdioComponents.size());
}
});
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class NugetInspectorParserTest method createCodeLocation.
private void createCodeLocation(String dependencyNodeFile, List<String> expectedOutputFiles) {
ExternalIdFactory externalIdFactory = new ExternalIdFactory();
NugetInspectorParser packager = new NugetInspectorParser(gson, externalIdFactory);
NugetParseResult result = packager.createCodeLocation(dependencyNodeFile);
for (int i = 0; i < expectedOutputFiles.size(); i++) {
CodeLocation codeLocation = result.getCodeLocations().get(i);
String expectedOutputFile = expectedOutputFiles.get(i);
GraphCompare.assertEqualsResource(expectedOutputFile, codeLocation.getDependencyGraph());
}
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class NugetProjectInspectorParseTest method checkParse.
@Test
void checkParse() {
String inspectorOutput = FunctionalTestFiles.asString("/nuget/project_inspector/ConsoleApp.json");
List<CodeLocation> codeLocations = new ProjectInspectorParser(new Gson(), new ExternalIdFactory()).parse(inspectorOutput);
Assertions.assertEquals(2, codeLocations.size());
Assertions.assertEquals(new File("C:\\Users\\jordanp\\source\\repos\\ConsoleApp3\\ConsoleApp1\\ConsoleApp1.csproj"), codeLocations.get(0).getSourcePath().orElse(null));
Assertions.assertEquals(new File("C:\\Users\\jordanp\\source\\repos\\ConsoleApp3\\ConsoleApp3\\ConsoleApp3.csproj"), codeLocations.get(1).getSourcePath().orElse(null));
NameVersionGraphAssert consoleApp1 = new NameVersionGraphAssert(Forge.NUGET, codeLocations.get(0).getDependencyGraph());
consoleApp1.hasDependency("DocumentFormat.OpenXml", "2.13.0");
NameVersionGraphAssert consoleApp3 = new NameVersionGraphAssert(Forge.NUGET, codeLocations.get(1).getDependencyGraph());
consoleApp3.hasDependency("Newtonsoft.Json.Bson", "1.0.2");
consoleApp3.hasDependency("Serilog", "2.10.0");
consoleApp3.hasParentChildRelationship("Newtonsoft.Json.Bson", "1.0.2", "Newtonsoft.Json", "12.0.1");
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class NugetProjectInspectorTest method assertExtraction.
@Override
public void assertExtraction(@NotNull Extraction extraction) {
List<CodeLocation> codeLocations = extraction.getCodeLocations();
Assertions.assertEquals(2, codeLocations.size());
Assertions.assertEquals(new File("C:\\Users\\jordanp\\source\\repos\\ConsoleApp3\\ConsoleApp1\\ConsoleApp1.csproj"), codeLocations.get(0).getSourcePath().orElse(null));
Assertions.assertEquals(new File("C:\\Users\\jordanp\\source\\repos\\ConsoleApp3\\ConsoleApp3\\ConsoleApp3.csproj"), codeLocations.get(1).getSourcePath().orElse(null));
NameVersionGraphAssert consoleApp1 = new NameVersionGraphAssert(Forge.NUGET, codeLocations.get(0).getDependencyGraph());
consoleApp1.hasDependency("DocumentFormat.OpenXml", "2.13.0");
NameVersionGraphAssert consoleApp3 = new NameVersionGraphAssert(Forge.NUGET, codeLocations.get(1).getDependencyGraph());
consoleApp3.hasDependency("Newtonsoft.Json.Bson", "1.0.2");
consoleApp3.hasDependency("Serilog", "2.10.0");
consoleApp3.hasParentChildRelationship("Newtonsoft.Json.Bson", "1.0.2", "Newtonsoft.Json", "12.0.1");
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class XcodeWorkspaceDetectableTest method assertExtraction.
@Override
public void assertExtraction(@NotNull Extraction extraction) {
assertEquals(3, extraction.getCodeLocations().size(), "Expected 1 code location from local and 2 defined in the workspace data file.");
NameVersionGraphAssert graphAssert;
CodeLocation workspaceLocalCodeLocation = extraction.getCodeLocations().get(0);
graphAssert = new NameVersionGraphAssert(Forge.GITHUB, workspaceLocalCodeLocation.getDependencyGraph());
graphAssert.hasRootDependency("apple/swift-argument-parser", "1.0.1");
graphAssert.hasNoDependency("invalid/url", "1.2.3");
graphAssert.hasRootSize(1);
CodeLocation myLibraryCodeLocation = extraction.getCodeLocations().get(1);
graphAssert = new NameVersionGraphAssert(Forge.GITHUB, myLibraryCodeLocation.getDependencyGraph());
graphAssert.hasRootDependency("auth0/Auth0.swift", "1.35.0");
graphAssert.hasRootSize(1);
CodeLocation xcodeProjectCodeLocation = extraction.getCodeLocations().get(2);
graphAssert = new NameVersionGraphAssert(Forge.GITHUB, xcodeProjectCodeLocation.getDependencyGraph());
graphAssert.hasRootDependency("mac-cain13/R.swift.Library", "5.4.0");
graphAssert.hasRootSize(1);
}
Aggregations