Search in sources :

Example 16 with Dependency

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

the class MavenCodeLocationPackagerTest method testParseProject.

@Test
public void testParseProject() {
    final MavenCodeLocationPackager mavenCodeLocationPackager = new MavenCodeLocationPackager(new ExternalIdFactory());
    Dependency dependency = mavenCodeLocationPackager.textToProject("stuff:things:jar:0.0.1");
    assertNotNull(dependency);
    dependency = mavenCodeLocationPackager.textToProject("stuff:things:jar:classifier:0.0.1");
    assertNotNull(dependency);
    dependency = mavenCodeLocationPackager.textToProject("stuff:things:jar");
    assertNull(dependency);
    dependency = mavenCodeLocationPackager.textToProject("stuff:things:jar:classifier:0.0.1:monkey");
    assertNull(dependency);
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) Test(org.junit.Test)

Example 17 with Dependency

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

the class ClangExtractorTest method checkGeneratedDependenciesComplex.

private void checkGeneratedDependenciesComplex(Extraction extraction) {
    final Set<Dependency> dependencies = extraction.codeLocations.get(0).getDependencyGraph().getRootDependencies();
    assertEquals(6, dependencies.size());
    for (final Dependency dependency : dependencies) {
        System.out.printf("Checking dependency: %s:%s / %s\n", dependency.name, dependency.version, dependency.externalId.forge.getName());
        final char indexChar = dependency.name.charAt(15);
        assertTrue(indexChar == '1' || indexChar == '2' || indexChar == '3');
        final String forge = dependency.externalId.forge.getName();
        assertTrue("centos".equals(forge) || "fedora".equals(forge) || "redhat".equals(forge));
        assertEquals(String.format("testPackageName%c", indexChar), dependency.name);
        assertEquals(String.format("testPackageVersion%c", indexChar), dependency.version);
        assertEquals(String.format("testPackageArch%c", indexChar), dependency.externalId.architecture);
        assertEquals(forge, dependency.externalId.forge.getName());
        assertEquals(null, dependency.externalId.group);
        assertEquals(String.format("testPackageName%c", indexChar), dependency.externalId.name);
        assertEquals(null, dependency.externalId.path);
        assertEquals(String.format("testPackageVersion%c", indexChar), dependency.externalId.version);
    }
}
Also used : Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Example 18 with Dependency

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

the class ClangExtractorTest method checkGeneratedDependenciesSimple.

private void checkGeneratedDependenciesSimple(Extraction extraction) {
    boolean ubuntuComponentVerified = false;
    Set<Dependency> dependencies = extraction.codeLocations.get(0).getDependencyGraph().getRootDependencies();
    Iterator<Dependency> iter = dependencies.iterator();
    while (iter.hasNext()) {
        Dependency dependency = iter.next();
        System.out.printf("Checking dependency %s\n", dependency.externalId);
        if ("ubuntu".equals(dependency.externalId.forge.getName())) {
            assertEquals("testPackageName", dependency.name);
            assertEquals("testPackageVersion", dependency.version);
            assertEquals("testPackageArch", dependency.externalId.architecture);
            assertEquals("ubuntu", dependency.externalId.forge.getName());
            assertEquals(null, dependency.externalId.group);
            assertEquals("testPackageName", dependency.externalId.name);
            assertEquals(null, dependency.externalId.path);
            assertEquals("testPackageVersion", dependency.externalId.version);
            ubuntuComponentVerified = true;
        }
    }
    assertTrue(ubuntuComponentVerified);
}
Also used : Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Example 19 with Dependency

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

the class GradleReportLineTest method assertDependency.

private void assertDependency(final String line, final String[] expectedResults) {
    final ExternalIdFactory externalIdFactory = new ExternalIdFactory();
    final GradleReportLine gradleReportLine = new GradleReportLine(line);
    final Dependency dependency = gradleReportLine.createDependencyNode(externalIdFactory);
    Assert.assertEquals(expectedResults[0], dependency.name);
    Assert.assertEquals(expectedResults[1], dependency.version);
    Assert.assertEquals(expectedResults[2], dependency.externalId.createExternalId());
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency)

Example 20 with Dependency

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

the class RebarParserTest method testCreateDependencyFromLine.

@Test
public void testCreateDependencyFromLine() {
    final String expectedName = "cf";
    final String expectedVersion = "0.2.2";
    final ExternalId expectedExternalId = externalIdFactory.createNameVersionExternalId(Forge.HEX, expectedName, expectedVersion);
    final Dependency actualDependency = rebar3TreeParser.createDependencyFromLine("   \u2502  \u2502  \u2514\u2500 cf\u25000.2.2 (hex package)");
    assertEquals(expectedName, actualDependency.name);
    assertEquals(expectedVersion, actualDependency.version);
    assertEquals(expectedExternalId.name, actualDependency.externalId.name);
    assertEquals(expectedExternalId.version, actualDependency.externalId.version);
}
Also used : ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) Test(org.junit.Test)

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