Search in sources :

Example 31 with ExternalIdFactory

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

the class GradleReportParserTest method testSpringFrameworkAop.

@Test
public void testSpringFrameworkAop() throws IOException {
    final File file = new File("src/test/resources/gradle/spring-framework/spring_aop_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 32 with ExternalIdFactory

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

the class GradleReportParserTest method createNewCodeLocationTest.

private void createNewCodeLocationTest(final String gradleInspectorOutputFilePath, final String expectedResourcePath, final String rootProjectFilePath, final String rootProjectName, final String rootProjectVersionName) throws IOException {
    final GradleReportParser gradleReportParser = new GradleReportParser(new ExternalIdFactory());
    final Optional<DetectCodeLocation> result = gradleReportParser.parseDependencies(new File(gradleInspectorOutputFilePath));
    final Optional<NameVersion> rootProjectNameVersion = gradleReportParser.parseRootProjectNameVersion(new File(rootProjectFilePath));
    assertTrue(result.isPresent());
    assertTrue(rootProjectNameVersion.isPresent());
    assertEquals(rootProjectName, rootProjectNameVersion.get().getName());
    assertEquals(rootProjectVersionName, rootProjectNameVersion.get().getVersion());
    testUtil.testJsonResource(expectedResourcePath, result.get());
}
Also used : NameVersion(com.synopsys.integration.util.NameVersion) DetectCodeLocation(com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) File(java.io.File)

Example 33 with ExternalIdFactory

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

the class MavenCodeLocationPackagerTest method testParseDependency.

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

Example 34 with ExternalIdFactory

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

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

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