Search in sources :

Example 21 with Dependency

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

the class GoVendorJsonParserTest method test.

@Test
public void test() throws IOException {
    ExternalIdFactory externalIdFactory = new ExternalIdFactory();
    GoVendorJsonParser parser = new GoVendorJsonParser(externalIdFactory);
    File vendorJsonFile = new File("src/test/resources/go/vendor/vendor.json");
    String vendorJsonContents = FileUtils.readFileToString(vendorJsonFile, StandardCharsets.UTF_8);
    DependencyGraph graph = parser.parseVendorJson(new Gson(), vendorJsonContents);
    assertEquals(2, graph.getRootDependencies().size());
    boolean foundErrorsPkg = false;
    boolean foundMathPkg = false;
    for (Dependency dep : graph.getRootDependencies()) {
        if ("github.com/pkg/errors".equals(dep.name)) {
            foundErrorsPkg = true;
            assertEquals("github.com/pkg/errors", dep.externalId.name);
            assertEquals("059132a15dd08d6704c67711dae0cf35ab991756", dep.externalId.version);
        }
        if ("github.com/pkg/math".equals(dep.name)) {
            foundMathPkg = true;
            assertEquals("github.com/pkg/math", dep.externalId.name);
            assertEquals("f2ed9e40e245cdeec72c4b642d27ed4553f90667", dep.externalId.version);
        }
    }
    assertTrue(foundErrorsPkg);
    assertTrue(foundMathPkg);
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) Gson(com.google.gson.Gson) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) File(java.io.File) Test(org.junit.Test)

Example 22 with Dependency

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

the class MavenCodeLocationPackagerTest method testLineWithBadColonPlacement.

@Test
public void testLineWithBadColonPlacement() {
    final MavenCodeLocationPackager mavenCodeLocationPackager = new MavenCodeLocationPackager(new ExternalIdFactory());
    String line = "[INFO] |  |  |  \\- org.eclipse.scout.sdk.deps:org.eclipse.core.jobs:jar:3.8.0.v20160509-0411:pants (version selected from: [3.8.0,3.8.1))";
    line = mavenCodeLocationPackager.trimLogLevel(line);
    final String cleanedLine = mavenCodeLocationPackager.calculateCurrentLevelAndCleanLine(line);
    final Dependency dependency = mavenCodeLocationPackager.textToDependency(cleanedLine);
    assertEquals("org.eclipse.scout.sdk.deps:org.eclipse.core.jobs:pants (version selected from", dependency.externalId.createExternalId());
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) Test(org.junit.Test)

Example 23 with Dependency

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

the class MavenCodeLocationPackagerTest method testLineWithExtraTextAfterScope.

@Test
public void testLineWithExtraTextAfterScope() {
    final MavenCodeLocationPackager mavenCodeLocationPackager = new MavenCodeLocationPackager(new ExternalIdFactory());
    String line = "[INFO] |  |  |  \\- org.eclipse.scout.sdk.deps:org.eclipse.core.jobs:jar:3.8.0.v20160509-0411:compile (version selected from constraint [3.8.0,3.8.1))";
    line = mavenCodeLocationPackager.trimLogLevel(line);
    final String cleanedLine = mavenCodeLocationPackager.calculateCurrentLevelAndCleanLine(line);
    final Dependency dependency = mavenCodeLocationPackager.textToDependency(cleanedLine);
    assertEquals("org.eclipse.scout.sdk.deps:org.eclipse.core.jobs:3.8.0.v20160509-0411", dependency.externalId.createExternalId());
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) Test(org.junit.Test)

Example 24 with Dependency

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

the class CondaListParserTest method condaListElementToDependencyNodeTransformerTest.

@Test
public void condaListElementToDependencyNodeTransformerTest() {
    final String platform = "linux";
    final CondaListElement element = new CondaListElement();
    element.name = "sampleName";
    element.version = "sampleVersion";
    element.buildString = "py36_0";
    final Dependency dependency = condaListParser.condaListElementToDependency(platform, element);
    assertEquals("sampleName", dependency.name);
    assertEquals("sampleVersion-py36_0-linux", dependency.version);
    assertEquals("sampleName=sampleVersion-py36_0-linux", dependency.externalId.createExternalId());
}
Also used : Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) Test(org.junit.Test)

Example 25 with Dependency

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

the class GoVendorExtractorTest method test.

@Test
public void test() {
    GoVendorExtractor extractor = new GoVendorExtractor(new Gson(), new ExternalIdFactory());
    Extraction extraction = extractor.extract(new File("src/test/resources/go"), new File("src/test/resources/go/vendor/vendor.json"));
    DependencyGraph graph = extraction.codeLocations.get(0).getDependencyGraph();
    assertEquals(2, graph.getRootDependencies().size());
    boolean foundErrorsPkg = false;
    boolean foundMathPkg = false;
    for (Dependency dep : graph.getRootDependencies()) {
        if ("github.com/pkg/errors".equals(dep.name)) {
            foundErrorsPkg = true;
            assertEquals("github.com/pkg/errors", dep.externalId.name);
            assertEquals("059132a15dd08d6704c67711dae0cf35ab991756", dep.externalId.version);
        }
        if ("github.com/pkg/math".equals(dep.name)) {
            foundMathPkg = true;
            assertEquals("github.com/pkg/math", dep.externalId.name);
            assertEquals("f2ed9e40e245cdeec72c4b642d27ed4553f90667", dep.externalId.version);
        }
    }
    assertTrue(foundErrorsPkg);
    assertTrue(foundMathPkg);
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) Gson(com.google.gson.Gson) Extraction(com.blackducksoftware.integration.hub.detect.workflow.extraction.Extraction) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Dependency(com.synopsys.integration.bdio.model.dependency.Dependency) File(java.io.File) 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