Search in sources :

Example 11 with ExternalIdFactory

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

the class NugetInspectorPackagerTest method createCodeLocationDWService.

@Test(timeout = 5000L)
public void createCodeLocationDWService() throws IOException {
    final File dependencyNodeFile = new File(getClass().getResource("/nuget/dwCheckApi_inspection_martin.json").getFile());
    final ExternalIdFactory externalIdFactory = new ExternalIdFactory();
    final NugetInspectorPackager packager = new NugetInspectorPackager(gson, externalIdFactory);
    final NugetParseResult result = packager.createDetectCodeLocation(dependencyNodeFile);
    for (final DetectCodeLocation codeLocation : result.codeLocations) {
        final BdioPropertyHelper bdioPropertyHelper = new BdioPropertyHelper();
        final BdioNodeFactory bdioNodeFactory = new BdioNodeFactory(bdioPropertyHelper);
        final DependencyGraphTransformer dependencyNodeTransformer = new DependencyGraphTransformer(bdioPropertyHelper, bdioNodeFactory);
        final BdioExternalIdentifier projectId = bdioPropertyHelper.createExternalIdentifier(codeLocation.getExternalId());
        final BdioProject project = bdioNodeFactory.createProject(result.projectName, result.projectVersion, Forge.NUGET.toString(), projectId);
        final Map<ExternalId, BdioNode> components = new HashMap<>();
        components.put(codeLocation.getExternalId(), project);
        final List<BdioComponent> bdioComponents = dependencyNodeTransformer.transformDependencyGraph(codeLocation.getDependencyGraph(), project, codeLocation.getDependencyGraph().getRootDependencies(), components);
        assertEquals(bdioComponents.size(), bdioComponents.size());
    }
}
Also used : BdioNode(com.synopsys.integration.bdio.model.BdioNode) HashMap(java.util.HashMap) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) BdioComponent(com.synopsys.integration.bdio.model.BdioComponent) BdioExternalIdentifier(com.synopsys.integration.bdio.model.BdioExternalIdentifier) BdioProject(com.synopsys.integration.bdio.model.BdioProject) BdioNodeFactory(com.synopsys.integration.bdio.BdioNodeFactory) DetectCodeLocation(com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation) DependencyGraphTransformer(com.synopsys.integration.bdio.graph.DependencyGraphTransformer) BdioPropertyHelper(com.synopsys.integration.bdio.BdioPropertyHelper) File(java.io.File) Test(org.junit.Test)

Example 12 with ExternalIdFactory

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

the class NugetInspectorPackagerTest method createCodeLocation.

private void createCodeLocation(final File dependencyNodeFile, final List<String> expectedOutputFiles) throws IOException {
    final ExternalIdFactory externalIdFactory = new ExternalIdFactory();
    final NugetInspectorPackager packager = new NugetInspectorPackager(gson, externalIdFactory);
    final NugetParseResult result = packager.createDetectCodeLocation(dependencyNodeFile);
    for (int i = 0; i < expectedOutputFiles.size(); i++) {
        final DetectCodeLocation codeLocation = result.codeLocations.get(i);
        final String expectedOutputFile = expectedOutputFiles.get(i);
        DependencyGraphResourceTestUtil.assertGraph(expectedOutputFile, codeLocation.getDependencyGraph());
    }
}
Also used : DetectCodeLocation(com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)

Example 13 with ExternalIdFactory

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

the class RubygemsNodePackagerTest method findsAllVersions.

@Test
public void findsAllVersions() {
    // Finds all versions of the package not just the first matching architecture.
    final List<String> actualText = Arrays.asList(testUtils.getResourceAsUTF8String("/rubygems/Gemfile-rails.lock").split("\n"));
    final GemlockParser rubygemsNodePackager = new GemlockParser(new ExternalIdFactory());
    final DependencyGraph graph = rubygemsNodePackager.parseProjectDependencies(actualText);
    assertNoDependency("nokogiri", "", graph);
    assertDependency("nokogiri", "1.8.2", graph);
    assertDependency("nokogiri", "1.8.2-java", graph);
    assertDependency("nokogiri", "1.8.2-x86-mingw32", graph);
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.Test)

Example 14 with ExternalIdFactory

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

the class RubygemsNodePackagerTest method packagerTest.

@Test
public void packagerTest() {
    final List<String> actualText = Arrays.asList(testUtils.getResourceAsUTF8String("/rubygems/Gemfile.lock").split("\n"));
    final GemlockParser rubygemsNodePackager = new GemlockParser(new ExternalIdFactory());
    final DependencyGraph projects = rubygemsNodePackager.parseProjectDependencies(actualText);
    Assert.assertEquals(8, projects.getRootDependencies().size());
    DependencyGraphResourceTestUtil.assertGraph("/rubygems/expectedPackager_graph.json", projects);
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.Test)

Example 15 with ExternalIdFactory

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

the class VndrParserTest method vndrParserTest.

@Test
public void vndrParserTest() throws IOException {
    final TestUtil testUtil = new TestUtil();
    final VndrParser vndrParser = new VndrParser(new ExternalIdFactory());
    final String text = testUtil.getResourceAsUTF8String("/go/vendor.conf");
    final List<String> vendorConfContents = Arrays.asList(text.split("\r?\n"));
    final DependencyGraph dependencyGraph = vndrParser.parseVendorConf(vendorConfContents);
    Assert.assertNotNull(dependencyGraph);
    DependencyGraphResourceTestUtil.assertGraph("/go/Go_VndrExpected_graph.json", dependencyGraph);
}
Also used : DependencyGraphResourceTestUtil(com.blackducksoftware.integration.hub.detect.testutils.DependencyGraphResourceTestUtil) TestUtil(com.blackducksoftware.integration.hub.detect.testutils.TestUtil) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) Test(org.junit.Test)

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