Search in sources :

Example 26 with ExternalIdFactory

use of com.synopsys.integration.bdio.model.externalid.ExternalIdFactory in project hub-detect by blackducksoftware.

the class NpmLockfileParserTest method init.

@Before
public void init() {
    testUtil = new TestUtil();
    npmLockfileParser = new NpmLockfileParser(new GsonBuilder().setPrettyPrinting().create(), new ExternalIdFactory());
}
Also used : DependencyGraphResourceTestUtil(com.blackducksoftware.integration.hub.detect.testutils.DependencyGraphResourceTestUtil) TestUtil(com.blackducksoftware.integration.hub.detect.testutils.TestUtil) GsonBuilder(com.google.gson.GsonBuilder) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) Before(org.junit.Before)

Example 27 with ExternalIdFactory

use of com.synopsys.integration.bdio.model.externalid.ExternalIdFactory in project hub-detect by blackducksoftware.

the class PearDependencyTest method init.

@Before
public void init() {
    detectConfiguration = Mockito.mock(DetectConfiguration.class);
    pearParser = new PearParser(new ExternalIdFactory(), detectConfiguration);
    testUtil = new TestUtil();
}
Also used : DetectConfiguration(com.blackducksoftware.integration.hub.detect.configuration.DetectConfiguration) DependencyGraphResourceTestUtil(com.blackducksoftware.integration.hub.detect.testutils.DependencyGraphResourceTestUtil) TestUtil(com.blackducksoftware.integration.hub.detect.testutils.TestUtil) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) Before(org.junit.Before)

Example 28 with ExternalIdFactory

use of com.synopsys.integration.bdio.model.externalid.ExternalIdFactory 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 29 with ExternalIdFactory

use of com.synopsys.integration.bdio.model.externalid.ExternalIdFactory in project hub-detect by blackducksoftware.

the class GradleReportParserTest method testImplementationsGraph.

@Test
public void testImplementationsGraph() throws IOException {
    final File file = new File("src/test/resources/gradle/gradle_implementations_dependencyGraph.txt");
    final GradleReportParser gradleReportParser = new GradleReportParser(new ExternalIdFactory());
    final Optional<DetectCodeLocation> result = gradleReportParser.parseDependencies(file);
    assertTrue(result.isPresent());
    System.out.println(new GsonBuilder().setPrettyPrinting().create().toJson(result.get()));
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) DetectCodeLocation(com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) File(java.io.File) Test(org.junit.Test)

Example 30 with ExternalIdFactory

use of com.synopsys.integration.bdio.model.externalid.ExternalIdFactory in project hub-detect by blackducksoftware.

the class GradleReportParserTest method build.

private DetectCodeLocation build(final String resource) throws IOException {
    final File file = new File(resource);
    final GradleReportParser gradleReportParser = new GradleReportParser(new ExternalIdFactory());
    final Optional<DetectCodeLocation> result = gradleReportParser.parseDependencies(file);
    if (result.isPresent()) {
        return result.get();
    } else {
        return null;
    }
}
Also used : DetectCodeLocation(com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) File(java.io.File)

Aggregations

ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)46 Test (org.junit.Test)33 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)17 File (java.io.File)13 ArrayList (java.util.ArrayList)12 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)11 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)10 DetectCodeLocation (com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation)8 DetectFileFinder (com.blackducksoftware.integration.hub.detect.workflow.file.DetectFileFinder)7 Extraction (com.blackducksoftware.integration.hub.detect.workflow.extraction.Extraction)5 ExtractionId (com.blackducksoftware.integration.hub.detect.detector.ExtractionId)4 TestUtil (com.blackducksoftware.integration.hub.detect.testutils.TestUtil)4 ExecutableOutput (com.blackducksoftware.integration.hub.detect.util.executable.ExecutableOutput)4 DependencyGraphResourceTestUtil (com.blackducksoftware.integration.hub.detect.testutils.DependencyGraphResourceTestUtil)3 ExecutableRunner (com.blackducksoftware.integration.hub.detect.util.executable.ExecutableRunner)3 DirectoryManager (com.blackducksoftware.integration.hub.detect.workflow.file.DirectoryManager)3 Gson (com.google.gson.Gson)3 GsonBuilder (com.google.gson.GsonBuilder)3 HashSet (java.util.HashSet)3 Set (java.util.Set)3