Search in sources :

Example 1 with ConanLockfileParser

use of com.synopsys.integration.detectable.detectables.conan.lockfile.parser.ConanLockfileParser in project synopsys-detect by blackducksoftware.

the class ConanLockfileParserFunctionalTest method testRelativePath.

@Test
public void testRelativePath() throws IOException, IntegrationException {
    File lockfile = FunctionalTestFiles.asFile("/conan/lockfile/conan_relpath.lock");
    EnumListFilter<ConanDependencyType> dependencyTypeFilter = EnumListFilter.excludeNone();
    ConanLockfileParser parser = new ConanLockfileParser(new Gson(), new ConanCodeLocationGenerator(dependencyTypeFilter, true), new ExternalIdFactory());
    String conanLockfileContents = FileUtils.readFileToString(lockfile, StandardCharsets.UTF_8);
    ConanDetectableResult result = parser.generateCodeLocationFromConanLockfileContents(conanLockfileContents);
    assertEquals(1, result.getCodeLocation().getDependencyGraph().getRootDependencies().size());
}
Also used : ConanCodeLocationGenerator(com.synopsys.integration.detectable.detectables.conan.ConanCodeLocationGenerator) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) ConanLockfileParser(com.synopsys.integration.detectable.detectables.conan.lockfile.parser.ConanLockfileParser) Gson(com.google.gson.Gson) ConanDetectableResult(com.synopsys.integration.detectable.detectables.conan.ConanDetectableResult) ConanDependencyType(com.synopsys.integration.detectable.detectables.conan.cli.config.ConanDependencyType) File(java.io.File) Test(org.junit.jupiter.api.Test) FunctionalTest(com.synopsys.integration.detectable.annotations.FunctionalTest)

Example 2 with ConanLockfileParser

use of com.synopsys.integration.detectable.detectables.conan.lockfile.parser.ConanLockfileParser in project synopsys-detect by blackducksoftware.

the class DetectableFactory method conanLockfileExtractor.

private ConanLockfileExtractor conanLockfileExtractor(ConanLockfileExtractorOptions options) {
    ConanCodeLocationGenerator conanCodeLocationGenerator = new ConanCodeLocationGenerator(options.getDependencyTypeFilter(), options.preferLongFormExternalIds());
    ConanLockfileParser conanLockfileParser = new ConanLockfileParser(gson, conanCodeLocationGenerator, externalIdFactory);
    return new ConanLockfileExtractor(conanLockfileParser);
}
Also used : ConanCodeLocationGenerator(com.synopsys.integration.detectable.detectables.conan.ConanCodeLocationGenerator) ConanLockfileExtractor(com.synopsys.integration.detectable.detectables.conan.lockfile.ConanLockfileExtractor) ConanLockfileParser(com.synopsys.integration.detectable.detectables.conan.lockfile.parser.ConanLockfileParser)

Example 3 with ConanLockfileParser

use of com.synopsys.integration.detectable.detectables.conan.lockfile.parser.ConanLockfileParser in project synopsys-detect by blackducksoftware.

the class ConanLockfileParserFunctionalTest method testNoProjectRef.

@Test
public void testNoProjectRef() throws IOException, IntegrationException {
    File lockfile = FunctionalTestFiles.asFile("/conan/lockfile/conan.lock");
    EnumListFilter<ConanDependencyType> dependencyTypeFilter = EnumListFilter.excludeNone();
    ConanLockfileParser parser = new ConanLockfileParser(new Gson(), new ConanCodeLocationGenerator(dependencyTypeFilter, false), new ExternalIdFactory());
    String conanLockfileContents = FileUtils.readFileToString(lockfile, StandardCharsets.UTF_8);
    ConanDetectableResult result = parser.generateCodeLocationFromConanLockfileContents(conanLockfileContents);
    assertEquals(3, result.getCodeLocation().getDependencyGraph().getRootDependencies().size());
    DependencyGraph actualDependencyGraph = result.getCodeLocation().getDependencyGraph();
    GraphCompare.assertEqualsResource("/conan/lockfile/noProjectRef_graph.json", actualDependencyGraph);
}
Also used : ConanCodeLocationGenerator(com.synopsys.integration.detectable.detectables.conan.ConanCodeLocationGenerator) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) ConanLockfileParser(com.synopsys.integration.detectable.detectables.conan.lockfile.parser.ConanLockfileParser) Gson(com.google.gson.Gson) ConanDetectableResult(com.synopsys.integration.detectable.detectables.conan.ConanDetectableResult) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) ConanDependencyType(com.synopsys.integration.detectable.detectables.conan.cli.config.ConanDependencyType) File(java.io.File) Test(org.junit.jupiter.api.Test) FunctionalTest(com.synopsys.integration.detectable.annotations.FunctionalTest)

Example 4 with ConanLockfileParser

use of com.synopsys.integration.detectable.detectables.conan.lockfile.parser.ConanLockfileParser in project synopsys-detect by blackducksoftware.

the class ConanLockfileParserFunctionalTest method testWithDevDependencies.

@Test
public void testWithDevDependencies() throws IOException, IntegrationException {
    File lockfile = FunctionalTestFiles.asFile("/conan/lockfile/conan_buildrequirements.lock");
    EnumListFilter<ConanDependencyType> dependencyTypeFilter = EnumListFilter.excludeNone();
    ConanLockfileParser parser = new ConanLockfileParser(new Gson(), new ConanCodeLocationGenerator(dependencyTypeFilter, false), new ExternalIdFactory());
    String conanLockfileContents = FileUtils.readFileToString(lockfile, StandardCharsets.UTF_8);
    ConanDetectableResult result = parser.generateCodeLocationFromConanLockfileContents(conanLockfileContents);
    assertEquals(3, result.getCodeLocation().getDependencyGraph().getRootDependencies().size());
    DependencyGraph actualDependencyGraph = result.getCodeLocation().getDependencyGraph();
    GraphCompare.assertEqualsResource("/conan/lockfile/noProjectRef_graph.json", actualDependencyGraph);
}
Also used : ConanCodeLocationGenerator(com.synopsys.integration.detectable.detectables.conan.ConanCodeLocationGenerator) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) ConanLockfileParser(com.synopsys.integration.detectable.detectables.conan.lockfile.parser.ConanLockfileParser) Gson(com.google.gson.Gson) ConanDetectableResult(com.synopsys.integration.detectable.detectables.conan.ConanDetectableResult) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) ConanDependencyType(com.synopsys.integration.detectable.detectables.conan.cli.config.ConanDependencyType) File(java.io.File) Test(org.junit.jupiter.api.Test) FunctionalTest(com.synopsys.integration.detectable.annotations.FunctionalTest)

Example 5 with ConanLockfileParser

use of com.synopsys.integration.detectable.detectables.conan.lockfile.parser.ConanLockfileParser in project synopsys-detect by blackducksoftware.

the class ConanLockfileParserFunctionalTest method testNoProjectRefLongFormExternalIds.

@Test
public void testNoProjectRefLongFormExternalIds() throws IOException, IntegrationException {
    File lockfile = FunctionalTestFiles.asFile("/conan/lockfile/conan.lock");
    EnumListFilter<ConanDependencyType> dependencyTypeFilter = EnumListFilter.excludeNone();
    ConanLockfileParser parser = new ConanLockfileParser(new Gson(), new ConanCodeLocationGenerator(dependencyTypeFilter, true), new ExternalIdFactory());
    String conanLockfileContents = FileUtils.readFileToString(lockfile, StandardCharsets.UTF_8);
    ConanDetectableResult result = parser.generateCodeLocationFromConanLockfileContents(conanLockfileContents);
    assertEquals(3, result.getCodeLocation().getDependencyGraph().getRootDependencies().size());
    DependencyGraph actualDependencyGraph = result.getCodeLocation().getDependencyGraph();
    GraphCompare.assertEqualsResource("/conan/lockfile/noProjectRefLongForm_graph.json", actualDependencyGraph);
}
Also used : ConanCodeLocationGenerator(com.synopsys.integration.detectable.detectables.conan.ConanCodeLocationGenerator) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) ConanLockfileParser(com.synopsys.integration.detectable.detectables.conan.lockfile.parser.ConanLockfileParser) Gson(com.google.gson.Gson) ConanDetectableResult(com.synopsys.integration.detectable.detectables.conan.ConanDetectableResult) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) ConanDependencyType(com.synopsys.integration.detectable.detectables.conan.cli.config.ConanDependencyType) File(java.io.File) Test(org.junit.jupiter.api.Test) FunctionalTest(com.synopsys.integration.detectable.annotations.FunctionalTest)

Aggregations

ConanCodeLocationGenerator (com.synopsys.integration.detectable.detectables.conan.ConanCodeLocationGenerator)6 ConanLockfileParser (com.synopsys.integration.detectable.detectables.conan.lockfile.parser.ConanLockfileParser)6 Gson (com.google.gson.Gson)5 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)5 FunctionalTest (com.synopsys.integration.detectable.annotations.FunctionalTest)5 ConanDetectableResult (com.synopsys.integration.detectable.detectables.conan.ConanDetectableResult)5 ConanDependencyType (com.synopsys.integration.detectable.detectables.conan.cli.config.ConanDependencyType)5 File (java.io.File)5 Test (org.junit.jupiter.api.Test)5 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)3 ConanLockfileExtractor (com.synopsys.integration.detectable.detectables.conan.lockfile.ConanLockfileExtractor)1