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