use of com.synopsys.integration.detectable.detectables.nuget.parse.NugetInspectorParser 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.detectables.nuget.parse.NugetInspectorParser 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.detectables.nuget.parse.NugetInspectorParser in project synopsys-detect by blackducksoftware.
the class NugetInspectorParserPerfTest method performanceTestNuget.
@Disabled
@Test
public void performanceTestNuget() {
Assertions.assertTimeout(Duration.ofSeconds(120), () -> {
String dependencyGraphFile = FunctionalTestFiles.asString("/nuget/dwCheckApi_inspection.json");
NugetInspectorParser packager = new NugetInspectorParser(gson, externalIdFactory);
NugetParseResult result = packager.createCodeLocation(dependencyGraphFile);
CodeLocation codeLocation = result.getCodeLocations().get(0);
BdioPropertyHelper bdioPropertyHelper = new BdioPropertyHelper();
BdioNodeFactory bdioNodeFactory = new BdioNodeFactory(bdioPropertyHelper);
DependencyGraphTransformer dependencyGraphTransformer = new DependencyGraphTransformer(bdioPropertyHelper, bdioNodeFactory);
BdioProject bdioNode = bdioNodeFactory.createProject("test", "1.0.0", BdioId.createFromPieces("bdioId"), externalIdFactory.createMavenExternalId("group", "name", "version"));
List<BdioComponent> components = dependencyGraphTransformer.transformDependencyGraph(codeLocation.getDependencyGraph(), bdioNode, codeLocation.getDependencyGraph().getRootDependencies(), new HashMap<>());
assertEquals(211, components.size());
});
}
use of com.synopsys.integration.detectable.detectables.nuget.parse.NugetInspectorParser in project synopsys-detect by blackducksoftware.
the class NugetParserTest method handlesNullContainer.
@Test
public void handlesNullContainer() {
NugetInspection result = new NugetInspection();
result.containers.add(null);
String resultText = gson.toJson(result);
NugetInspectorParser parser = new NugetInspectorParser(gson, new ExternalIdFactory());
NugetParseResult parsed = parser.createCodeLocation(resultText);
Assertions.assertEquals(0, parsed.getCodeLocations().size());
}
use of com.synopsys.integration.detectable.detectables.nuget.parse.NugetInspectorParser in project synopsys-detect by blackducksoftware.
the class NugetParserTest method handlesNullChild.
@Test
public void handlesNullChild() {
NugetInspection result = new NugetInspection();
NugetContainer container = new NugetContainer();
container.type = NugetContainerType.SOLUTION;
container.children = new ArrayList<>();
container.children.add(null);
result.containers.add(container);
String resultText = gson.toJson(result);
NugetInspectorParser parser = new NugetInspectorParser(gson, new ExternalIdFactory());
NugetParseResult parsed = parser.createCodeLocation(resultText);
Assertions.assertEquals(0, parsed.getCodeLocations().size());
}
Aggregations