Search in sources :

Example 1 with CondaDependencyCreator

use of com.synopsys.integration.detectable.detectables.conda.parser.CondaDependencyCreator in project synopsys-detect by blackducksoftware.

the class CondaDependencyCreatorTest method testCorrectVersionAndForge.

@Test
public void testCorrectVersionAndForge() {
    CondaDependencyCreator dependencyCreator = new CondaDependencyCreator(new ExternalIdFactory());
    String platform = "platform";
    CondaListElement pypiComponent = new CondaListElement();
    pypiComponent.version = "1.0.0";
    pypiComponent.name = "numpy";
    pypiComponent.channel = "pypi";
    pypiComponent.buildString = "build";
    String pypiComponentVersion = pypiComponent.version;
    Forge pypiComponentForge = Forge.PYPI;
    Dependency pypiDependency = dependencyCreator.createFromCondaListElement(pypiComponent, platform);
    Assertions.assertEquals(pypiComponentVersion, pypiDependency.getVersion());
    Assertions.assertEquals(pypiComponentForge, pypiDependency.getExternalId().getForge());
    CondaListElement condaComponent = new CondaListElement();
    condaComponent.version = "2.0.0";
    condaComponent.name = "test";
    condaComponent.channel = "defaults";
    condaComponent.buildString = "BUILD";
    String condaComponentVersion = String.format("%s-%s-%s", condaComponent.version, condaComponent.buildString, platform);
    Forge condaComponentForge = Forge.ANACONDA;
    Dependency condaDependency = dependencyCreator.createFromCondaListElement(condaComponent, platform);
    Assertions.assertEquals(condaComponentVersion, condaDependency.getVersion());
    Assertions.assertEquals(condaComponentForge, condaDependency.getExternalId().getForge());
}
Also used : CondaDependencyCreator(com.synopsys.integration.detectable.detectables.conda.parser.CondaDependencyCreator) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) Forge(com.synopsys.integration.bdio.model.Forge) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) CondaListElement(com.synopsys.integration.detectable.detectables.conda.model.CondaListElement) Test(org.junit.jupiter.api.Test)

Example 2 with CondaDependencyCreator

use of com.synopsys.integration.detectable.detectables.conda.parser.CondaDependencyCreator in project synopsys-detect by blackducksoftware.

the class CondaListParserTest method testForgesCorrectlyAssigned.

@Test
public void testForgesCorrectlyAssigned() throws IOException {
    ExternalIdFactory externalIdFactory = new ExternalIdFactory();
    CondaDependencyCreator dependencyCreator = new CondaDependencyCreator(externalIdFactory);
    CondaListParser condaListParser = new CondaListParser(new Gson(), dependencyCreator);
    File condaListFile = FunctionalTestFiles.asFile("/conda/condaListWithPypiAndCondaComponents.txt");
    String condaListText = FileUtils.readFileToString(condaListFile, StandardCharsets.UTF_8);
    DependencyGraph dependencyGraph = condaListParser.parse(condaListText, "{\n\"platform\":\"test\"\n}");
    ExternalId treeliteRuntimeExternalId = externalIdFactory.createNameVersionExternalId(Forge.PYPI, "treelite-runtime", "2.0.0");
    assertTrue(dependencyGraph.getRootDependencies().stream().map(Dependency::getExternalId).anyMatch(treeliteRuntimeExternalId::equals));
    ExternalId tkExternalId = externalIdFactory.createNameVersionExternalId(Forge.ANACONDA, "tk", "8.6.11-h5dbffcc_1-test");
    assertTrue(dependencyGraph.getRootDependencies().stream().map(Dependency::getExternalId).anyMatch(tkExternalId::equals));
}
Also used : CondaDependencyCreator(com.synopsys.integration.detectable.detectables.conda.parser.CondaDependencyCreator) CondaListParser(com.synopsys.integration.detectable.detectables.conda.parser.CondaListParser) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) Gson(com.google.gson.Gson) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)2 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)2 CondaDependencyCreator (com.synopsys.integration.detectable.detectables.conda.parser.CondaDependencyCreator)2 Test (org.junit.jupiter.api.Test)2 Gson (com.google.gson.Gson)1 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)1 Forge (com.synopsys.integration.bdio.model.Forge)1 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)1 CondaListElement (com.synopsys.integration.detectable.detectables.conda.model.CondaListElement)1 CondaListParser (com.synopsys.integration.detectable.detectables.conda.parser.CondaListParser)1 File (java.io.File)1