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;
}
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());
}
Aggregations