use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class YarnTransformerTest method doAllWorkspacesTest.
private void doAllWorkspacesTest(boolean yarn1Project) throws MissingExternalIdException {
// Unless filtered out, even workspaces that are not dependencies should be included
List<NameVersion> workspacesThatAreDependencies = new LinkedList<>();
workspacesThatAreDependencies.add(new NameVersion("workspace-isdep", "1.0.0"));
List<NameVersion> workspacesThatAreNotDependencies = new LinkedList<>();
workspacesThatAreNotDependencies.add(new NameVersion("workspace-notdep", "1.0.0"));
YarnLockResult yarnLockResult = buildTestYarnLockResult(workspacesThatAreDependencies, workspacesThatAreNotDependencies, yarn1Project);
List<CodeLocation> codeLocations = createTransformer().generateCodeLocations(yarnLockResult, new ArrayList<>(), ExcludedIncludedWildcardFilter.EMPTY);
assertEquals(3, codeLocations.size());
Iterator<CodeLocation> codeLocationIterator = codeLocations.iterator();
CodeLocation rootProjectCodeLocation = codeLocationIterator.next();
assertFalse(rootProjectCodeLocation.getExternalId().isPresent());
DependencyGraph rootProjectDependencyGraph = rootProjectCodeLocation.getDependencyGraph();
assertEquals(2, rootProjectDependencyGraph.getRootDependencies().size());
List<String> dependencyNames = rootProjectDependencyGraph.getRootDependencies().stream().map(Dependency::getName).collect(Collectors.toList());
assertTrue(dependencyNames.contains("foo"));
assertTrue(dependencyNames.contains("bar"));
for (int i = 1; i < 3; i++) {
CodeLocation workspaceCodeLocation = codeLocationIterator.next();
assertTrue(workspaceCodeLocation.getExternalId().get().getName().startsWith("packages/workspace-"));
assertTrue(workspaceCodeLocation.getExternalId().get().getName().endsWith("dep"));
assertEquals("local", workspaceCodeLocation.getExternalId().get().getVersion());
assertEquals("npmjs", workspaceCodeLocation.getExternalId().get().getForge().getName());
List<String> workspaceDependencyNames = workspaceCodeLocation.getDependencyGraph().getRootDependencies().stream().map(Dependency::getName).collect(Collectors.toList());
String workspaceName = StringUtils.substringAfter(workspaceCodeLocation.getExternalId().get().getName(), "packages/");
assertTrue(workspaceDependencyNames.contains(workspaceName + "-dep"));
assertTrue(workspaceDependencyNames.contains(workspaceName + "-dev-dep"));
}
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class PipenvTransformerTest method resolvesLowercaseNameWithFreezeCapital.
@Test
void resolvesLowercaseNameWithFreezeCapital() {
List<PipFreezeEntry> pipFreezeEntries = new ArrayList<>();
pipFreezeEntries.add(new PipFreezeEntry("Example", "2.0.0"));
PipFreeze pipFreeze = new PipFreeze(pipFreezeEntries);
List<PipenvGraphEntry> pipenvGraphEntries = new ArrayList<>();
pipenvGraphEntries.add(new PipenvGraphEntry("example", "fuzzy", new ArrayList<>()));
PipenvGraph pipenvGraph = new PipenvGraph(pipenvGraphEntries);
PipenvTransformer pipenvTransformer = new PipenvTransformer(new ExternalIdFactory());
CodeLocation codeLocation = pipenvTransformer.transform("", "", pipFreeze, pipenvGraph, false);
DependencyGraph graph = codeLocation.getDependencyGraph();
NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.PYPI, graph);
graphAssert.hasDependency("Example", "2.0.0");
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class PipenvTransformerTest method usesProjectDependencyAsRoot.
@Test
void usesProjectDependencyAsRoot() {
PipFreeze pipFreeze = new PipFreeze(new ArrayList<>());
List<PipenvGraphEntry> pipenvGraphEntries = new ArrayList<>();
List<PipenvGraphDependency> children = new ArrayList<>();
children.add(new PipenvGraphDependency("shouldBeAtRoot", "shouldbeAtRootVersion", new ArrayList<>()));
pipenvGraphEntries.add(new PipenvGraphEntry("projectName", "projectVersion", children));
PipenvGraph pipenvGraph = new PipenvGraph(pipenvGraphEntries);
PipenvTransformer pipenvTransformer = new PipenvTransformer(new ExternalIdFactory());
CodeLocation codeLocation = pipenvTransformer.transform("projectName", "projectVersion", pipFreeze, pipenvGraph, false);
DependencyGraph graph = codeLocation.getDependencyGraph();
NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.PYPI, graph);
graphAssert.hasRootDependency("shouldBeAtRoot", "shouldbeAtRootVersion");
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class PipenvTransformerTest method resolvesFuzzyVersion.
@Test
void resolvesFuzzyVersion() {
List<PipFreezeEntry> pipFreezeEntries = new ArrayList<>();
pipFreezeEntries.add(new PipFreezeEntry("example", "2.0.0"));
PipFreeze pipFreeze = new PipFreeze(pipFreezeEntries);
List<PipenvGraphEntry> pipenvGraphEntries = new ArrayList<>();
pipenvGraphEntries.add(new PipenvGraphEntry("example", "fuzzy", new ArrayList<>()));
PipenvGraph pipenvGraph = new PipenvGraph(pipenvGraphEntries);
PipenvTransformer pipenvTransformer = new PipenvTransformer(new ExternalIdFactory());
CodeLocation codeLocation = pipenvTransformer.transform("", "", pipFreeze, pipenvGraph, false);
DependencyGraph graph = codeLocation.getDependencyGraph();
NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.PYPI, graph);
graphAssert.hasDependency("example", "2.0.0");
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class PnpmYamlTransformerTest method testGenerateCodeLocation.
@Test
public void testGenerateCodeLocation() throws IntegrationException {
PnpmLockYaml pnpmLockYaml = createPnpmLockYaml();
PnpmYamlTransformer transformer = createTransformer();
CodeLocation codeLocation = transformer.generateCodeLocation(pnpmLockYamlFile, pnpmLockYaml, projectNameVersion, linkedPackageResolver);
assertTrue(codeLocation.getExternalId().isPresent(), "Expected the codelocation to produce an ExternalId.");
assertEquals("name", codeLocation.getExternalId().get().getName());
assertEquals("version", codeLocation.getExternalId().get().getVersion());
DependencyGraph dependencyGraph = codeLocation.getDependencyGraph();
NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.NPMJS, dependencyGraph);
graphAssert.hasRootSize(4);
graphAssert.hasRootDependency("dep", "1.0.0");
graphAssert.hasRootDependency("devDep", "2.0.0");
graphAssert.hasRootDependency("optDep", "3.0.0");
graphAssert.hasParentChildRelationship("dep", "1.0.0", "transitive", "1.1.0");
}
Aggregations