Search in sources :

Example 11 with Dependency

use of com.synopsys.integration.bdio.model.dependency.Dependency in project hub-detect by blackducksoftware.

the class MavenCodeLocationPackager method createMavenParseResult.

private MavenParseResult createMavenParseResult(final String sourcePath, final String line, final DependencyGraph graph) {
    final Dependency dependency = textToProject(line);
    if (null != dependency) {
        String codeLocationSourcePath = sourcePath;
        if (!sourcePath.endsWith(dependency.name)) {
            codeLocationSourcePath += "/" + dependency.name;
        }
        final DetectCodeLocation codeLocation = new DetectCodeLocation.Builder(DetectCodeLocationType.MAVEN, codeLocationSourcePath, dependency.externalId, graph).build();
        return new MavenParseResult(dependency.name, dependency.version, codeLocation);
    }
    return null;
}
Also used : DetectCodeLocation(com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Example 12 with Dependency

use of com.synopsys.integration.bdio.model.dependency.Dependency in project hub-detect by blackducksoftware.

the class CondaListParser method condaListElementToDependency.

public Dependency condaListElementToDependency(final String platform, final CondaListElement element) {
    final String name = element.name;
    final String version = String.format("%s-%s-%s", element.version, element.buildString, platform);
    final ExternalId externalId = externalIdFactory.createNameVersionExternalId(Forge.ANACONDA, name, version);
    return new Dependency(name, version, externalId);
}
Also used : ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Example 13 with Dependency

use of com.synopsys.integration.bdio.model.dependency.Dependency in project hub-detect by blackducksoftware.

the class RebarParserTest method testParseRebarTreeOutput.

@Test
public void testParseRebarTreeOutput() {
    final MutableMapDependencyGraph expectedGraph = new MutableMapDependencyGraph();
    final Dependency gitInnerParentDependency = buildDependency("git_inner_parent_dependency", "0.0.2");
    final Dependency hexInnerChildDependency = buildDependency("hex_inner_child_dependency", "0.3.0");
    final Dependency hexGrandchildDependency = buildDependency("hex_grandchild_dependency", "4.0.0");
    final Dependency gitInnerChildDependency = buildDependency("git_inner_child_dependency", "0.5.0");
    final Dependency gitGrandchildDependency = buildDependency("git_grandchild_dependency", "6.0.0");
    final Dependency gitOuterParentDependency = buildDependency("git_outer_parent_dependency", "0.0.7");
    final Dependency gitOuterChildDependency = buildDependency("git_outer_child_dependency", "0.8.0");
    expectedGraph.addChildrenToRoot(gitInnerParentDependency, gitOuterParentDependency);
    expectedGraph.addChildWithParent(hexInnerChildDependency, gitInnerParentDependency);
    expectedGraph.addChildWithParents(hexGrandchildDependency, hexInnerChildDependency);
    expectedGraph.addChildWithParent(gitInnerChildDependency, gitInnerParentDependency);
    expectedGraph.addChildWithParents(gitGrandchildDependency, gitInnerChildDependency);
    expectedGraph.addChildWithParents(gitOuterChildDependency, gitOuterParentDependency);
    final DetectCodeLocation codeLocation = build("/hex/dependencyTree.txt");
    final DependencyGraph actualGraph = codeLocation.getDependencyGraph();
    assertGraph(expectedGraph, actualGraph);
}
Also used : DetectCodeLocation(com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation) MutableMapDependencyGraph(com.synopsys.integration.bdio.graph.MutableMapDependencyGraph) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) MutableMapDependencyGraph(com.synopsys.integration.bdio.graph.MutableMapDependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) Test(org.junit.Test)

Example 14 with Dependency

use of com.synopsys.integration.bdio.model.dependency.Dependency in project hub-detect by blackducksoftware.

the class DependencyGraphAssertions method assertParentHasChildMavenGav.

public static void assertParentHasChildMavenGav(final String parentGav, final DependencyGraph dependencyGraph, final String targetGavChild) {
    final ExternalId parentId = mavenGavToExternalId(parentGav);
    final ExternalId childId = mavenGavToExternalId(targetGavChild);
    final Dependency dep = dependencyGraph.getDependency(parentId);
    assertNotNull("Graph does not have gav '" + parentGav + "'", dep);
    final Set<ExternalId> children = dependencyGraph.getChildrenExternalIdsForParent(dep);
    assertTrue("Parent gav '" + parentGav + "' does not have child gav '" + targetGavChild + "'", children.contains(childId));
}
Also used : ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Example 15 with Dependency

use of com.synopsys.integration.bdio.model.dependency.Dependency in project hub-detect by blackducksoftware.

the class DependencyGraphAssertions method assertHasRootMavenGav.

public static void assertHasRootMavenGav(final DependencyGraph dependencyGraph, final String targetGav) {
    final ExternalId targetId = mavenGavToExternalId(targetGav);
    final Dependency dep = dependencyGraph.getDependency(targetId);
    assertNotNull(dep);
}
Also used : ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Aggregations

Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)46 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)23 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)12 MutableMapDependencyGraph (com.synopsys.integration.bdio.graph.MutableMapDependencyGraph)11 Test (org.junit.Test)11 MutableDependencyGraph (com.synopsys.integration.bdio.graph.MutableDependencyGraph)10 DetectCodeLocation (com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation)9 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)5 File (java.io.File)5 DependencyHistory (com.blackducksoftware.integration.hub.detect.util.DependencyHistory)4 ArrayList (java.util.ArrayList)3 Extraction (com.blackducksoftware.integration.hub.detect.workflow.extraction.Extraction)2 Gson (com.google.gson.Gson)2 Forge (com.synopsys.integration.bdio.model.Forge)2 NpmDependency (com.blackducksoftware.integration.hub.detect.detector.npm.model.NpmDependency)1 PackageLockDependency (com.blackducksoftware.integration.hub.detect.detector.npm.model.PackageLockDependency)1 DetectUserFriendlyException (com.blackducksoftware.integration.hub.detect.exception.DetectUserFriendlyException)1 DetectCodeLocationType (com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocationType)1 JsonObject (com.google.gson.JsonObject)1 JsonPrimitive (com.google.gson.JsonPrimitive)1