use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class PackageJsonExtractorFunctionalTest method extractWithNoDevDependencies.
@Test
void extractWithNoDevDependencies() {
Extraction extraction = createExtractor(NpmDependencyType.PEER, NpmDependencyType.DEV).extract(packageJsonInputStream);
assertEquals(1, extraction.getCodeLocations().size());
CodeLocation codeLocation = extraction.getCodeLocations().get(0);
DependencyGraph dependencyGraph = codeLocation.getDependencyGraph();
GraphAssert graphAssert = new GraphAssert(Forge.RUBYGEMS, dependencyGraph);
graphAssert.hasRootDependency(testDep1);
graphAssert.hasRootDependency(testDep2);
graphAssert.hasNoDependency(testDevDep1);
graphAssert.hasNoDependency(testDevDep2);
graphAssert.hasNoDependency(testPeerDep1);
graphAssert.hasNoDependency(testPeerDep2);
graphAssert.hasRootSize(2);
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class PackageJsonExtractorTest method extractWithNoDevOrPeerDependencies.
@Test
void extractWithNoDevOrPeerDependencies() {
PackageJson packageJson = createPackageJson();
Extraction extraction = createExtractor(NpmDependencyType.DEV, NpmDependencyType.PEER).extract(packageJson);
assertEquals(1, extraction.getCodeLocations().size());
CodeLocation codeLocation = extraction.getCodeLocations().get(0);
DependencyGraph dependencyGraph = codeLocation.getDependencyGraph();
GraphAssert graphAssert = new GraphAssert(Forge.RUBYGEMS, dependencyGraph);
graphAssert.hasRootDependency(testDep1);
graphAssert.hasRootDependency(testDep2);
graphAssert.hasNoDependency(testDevDep1);
graphAssert.hasNoDependency(testDevDep2);
graphAssert.hasRootSize(2);
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class PackageJsonExtractorTest method extractWithDevNoPeerDependencies.
@Test
void extractWithDevNoPeerDependencies() {
PackageJson packageJson = createPackageJson();
Extraction extraction = createExtractor(NpmDependencyType.PEER).extract(packageJson);
assertEquals(1, extraction.getCodeLocations().size());
CodeLocation codeLocation = extraction.getCodeLocations().get(0);
DependencyGraph dependencyGraph = codeLocation.getDependencyGraph();
GraphAssert graphAssert = new GraphAssert(Forge.RUBYGEMS, dependencyGraph);
graphAssert.hasRootDependency(testDep1);
graphAssert.hasRootDependency(testDep2);
graphAssert.hasRootDependency(testDevDep1);
graphAssert.hasRootDependency(testDevDep2);
graphAssert.hasRootSize(4);
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation 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.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class DependencyFileDetailGeneratorTest method testDependencyCreatedWithEachForge.
@Test
public void testDependencyCreatedWithEachForge() {
File mockFile = Mockito.mock(File.class);
Mockito.when(mockFile.toString()).thenReturn("Example");
Set<PackageDetails> packages = new HashSet<>();
packages.add(new PackageDetails("testPackageName1", "testPackageVersion1", "testPackageArch1"));
packages.add(new PackageDetails("testPackageName2", "testPackageVersion2", "testPackageArch2"));
ExternalIdFactory externalIdFactory = new ExternalIdFactory();
ClangPackageDetailsTransformer clangPackageDetailsTransformer = new ClangPackageDetailsTransformer(externalIdFactory);
CodeLocation codeLocation = clangPackageDetailsTransformer.toCodeLocation(Arrays.asList(Forge.CENTOS, Forge.FEDORA, Forge.REDHAT), packages);
Set<Dependency> dependencies = codeLocation.getDependencyGraph().getRootDependencies();
assertEquals(6, dependencies.size());
for (Dependency dependency : dependencies) {
System.out.printf("Checking dependency: %s:%s / %s\n", dependency.getName(), dependency.getVersion(), dependency.getExternalId().getForge().getName());
char indexChar = dependency.getName().charAt(15);
assertTrue(indexChar == '1' || indexChar == '2' || indexChar == '3');
String forge = dependency.getExternalId().getForge().getName();
assertTrue("centos".equals(forge) || "fedora".equals(forge) || "redhat".equals(forge));
assertEquals(String.format("testPackageName%c", indexChar), dependency.getName());
assertEquals(String.format("testPackageVersion%c", indexChar), dependency.getVersion());
assertEquals(String.format("testPackageArch%c", indexChar), dependency.getExternalId().getArchitecture());
assertEquals(forge, dependency.getExternalId().getForge().getName());
assertEquals(String.format("testPackageName%c", indexChar), dependency.getExternalId().getName());
assertEquals(String.format("testPackageVersion%c", indexChar), dependency.getExternalId().getVersion());
}
}
Aggregations