Search in sources :

Example 1 with CondaListElement

use of com.synopsys.integration.detectable.detectables.conda.model.CondaListElement in project synopsys-detect by blackducksoftware.

the class CondaListParser method parse.

public DependencyGraph parse(String listJsonText, String infoJsonText) {
    Type listType = new TypeToken<ArrayList<CondaListElement>>() {
    }.getType();
    List<CondaListElement> condaList = gson.fromJson(listJsonText, listType);
    CondaInfo condaInfo = gson.fromJson(infoJsonText, CondaInfo.class);
    String platform = condaInfo.platform;
    DependencyGraph graph = new BasicDependencyGraph();
    condaList.stream().map(condaListElement -> dependencyCreator.createFromCondaListElement(condaListElement, platform)).forEach(graph::addChildToRoot);
    return graph;
}
Also used : List(java.util.List) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) TypeToken(com.google.gson.reflect.TypeToken) Type(java.lang.reflect.Type) Gson(com.google.gson.Gson) CondaListElement(com.synopsys.integration.detectable.detectables.conda.model.CondaListElement) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) ArrayList(java.util.ArrayList) CondaInfo(com.synopsys.integration.detectable.detectables.conda.model.CondaInfo) Type(java.lang.reflect.Type) ArrayList(java.util.ArrayList) CondaInfo(com.synopsys.integration.detectable.detectables.conda.model.CondaInfo) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) BasicDependencyGraph(com.synopsys.integration.bdio.graph.BasicDependencyGraph) CondaListElement(com.synopsys.integration.detectable.detectables.conda.model.CondaListElement)

Example 2 with CondaListElement

use of com.synopsys.integration.detectable.detectables.conda.model.CondaListElement 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)

Aggregations

CondaListElement (com.synopsys.integration.detectable.detectables.conda.model.CondaListElement)2 Gson (com.google.gson.Gson)1 TypeToken (com.google.gson.reflect.TypeToken)1 BasicDependencyGraph (com.synopsys.integration.bdio.graph.BasicDependencyGraph)1 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)1 Forge (com.synopsys.integration.bdio.model.Forge)1 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)1 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)1 CondaInfo (com.synopsys.integration.detectable.detectables.conda.model.CondaInfo)1 CondaDependencyCreator (com.synopsys.integration.detectable.detectables.conda.parser.CondaDependencyCreator)1 Type (java.lang.reflect.Type)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Test (org.junit.jupiter.api.Test)1