Search in sources :

Example 1 with MavenCodeLocationPackager

use of com.synopsys.integration.detectable.detectables.maven.cli.MavenCodeLocationPackager in project synopsys-detect by blackducksoftware.

the class MavenCodeLocationPackagerTest method testParseDependency.

@Test
public void testParseDependency() {
    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 : ScopedDependency(com.synopsys.integration.detectable.detectables.maven.cli.ScopedDependency) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) MavenCodeLocationPackager(com.synopsys.integration.detectable.detectables.maven.cli.MavenCodeLocationPackager) Test(org.junit.jupiter.api.Test) UnitTest(com.synopsys.integration.detectable.annotations.UnitTest)

Example 2 with MavenCodeLocationPackager

use of com.synopsys.integration.detectable.detectables.maven.cli.MavenCodeLocationPackager in project synopsys-detect by blackducksoftware.

the class MavenCodeLocationPackagerTest method testIsProjectSection.

@Test
public void testIsProjectSection() {
    MavenCodeLocationPackager mavenCodeLocationPackager = new MavenCodeLocationPackager(null);
    assertFalse(mavenCodeLocationPackager.isProjectSection(" "));
    assertFalse(mavenCodeLocationPackager.isProjectSection("       "));
    assertFalse(mavenCodeLocationPackager.isProjectSection("---maven-dependency-plugin:"));
    assertFalse(mavenCodeLocationPackager.isProjectSection("---maven-dependency-plugin:other      stuff"));
    assertFalse(mavenCodeLocationPackager.isProjectSection("maven-dependency-plugin:tree      stuff"));
    assertTrue(mavenCodeLocationPackager.isProjectSection("---maven-dependency-plugin:tree      stuff"));
    assertTrue(mavenCodeLocationPackager.isProjectSection("things --- stuff maven-dependency-plugin garbage:tree      stuff"));
    assertTrue(mavenCodeLocationPackager.isProjectSection("things --- stuff maven-dependency-plugin:tree      stuff"));
    assertTrue(mavenCodeLocationPackager.isProjectSection("---maven-dependency-plugin:tree"));
    assertTrue(mavenCodeLocationPackager.isProjectSection("      ---       maven-dependency-plugin      :       tree"));
}
Also used : MavenCodeLocationPackager(com.synopsys.integration.detectable.detectables.maven.cli.MavenCodeLocationPackager) Test(org.junit.jupiter.api.Test) UnitTest(com.synopsys.integration.detectable.annotations.UnitTest)

Example 3 with MavenCodeLocationPackager

use of com.synopsys.integration.detectable.detectables.maven.cli.MavenCodeLocationPackager in project synopsys-detect by blackducksoftware.

the class MavenCodeLocationPackagerTest method testParseProject.

@Test
public void testParseProject() {
    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) ScopedDependency(com.synopsys.integration.detectable.detectables.maven.cli.ScopedDependency) MavenCodeLocationPackager(com.synopsys.integration.detectable.detectables.maven.cli.MavenCodeLocationPackager) Test(org.junit.jupiter.api.Test) UnitTest(com.synopsys.integration.detectable.annotations.UnitTest)

Example 4 with MavenCodeLocationPackager

use of com.synopsys.integration.detectable.detectables.maven.cli.MavenCodeLocationPackager in project synopsys-detect by blackducksoftware.

the class MavenCodeLocationPackagerTest method testIndexOfEndOfSegments.

@Test
public void testIndexOfEndOfSegments() {
    MavenCodeLocationPackager mavenCodeLocationPackager = new MavenCodeLocationPackager(null);
    assertEquals(-1, mavenCodeLocationPackager.indexOfEndOfSegments(""));
    assertEquals(-1, mavenCodeLocationPackager.indexOfEndOfSegments("stuff and things"));
    assertEquals(-1, mavenCodeLocationPackager.indexOfEndOfSegments("stuff and things", "things", "and"));
    assertEquals(-1, mavenCodeLocationPackager.indexOfEndOfSegments("stuff and things", "things", "and", "stuff"));
    assertEquals(5, mavenCodeLocationPackager.indexOfEndOfSegments("stuff and things", "stuff"));
    assertEquals(9, mavenCodeLocationPackager.indexOfEndOfSegments("stuff and things", "stuff", "and"));
    assertEquals(16, mavenCodeLocationPackager.indexOfEndOfSegments("stuff and things", "stuff", "and", "things"));
    assertEquals(9, mavenCodeLocationPackager.indexOfEndOfSegments("stuff and things", "and"));
    assertEquals(16, mavenCodeLocationPackager.indexOfEndOfSegments("stuff and things", "things"));
}
Also used : MavenCodeLocationPackager(com.synopsys.integration.detectable.detectables.maven.cli.MavenCodeLocationPackager) Test(org.junit.jupiter.api.Test) UnitTest(com.synopsys.integration.detectable.annotations.UnitTest)

Example 5 with MavenCodeLocationPackager

use of com.synopsys.integration.detectable.detectables.maven.cli.MavenCodeLocationPackager in project synopsys-detect by blackducksoftware.

the class MavenCodeLocationPackagerTest method testLineWithUnknownScope.

@Test
public void testLineWithUnknownScope() {
    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 constraint [3.8.0,3.8.1))";
    line = mavenCodeLocationPackager.trimLogLevel(line);
    String cleanedLine = mavenCodeLocationPackager.calculateCurrentLevelAndCleanLine(line);
    ScopedDependency scopedDependency = mavenCodeLocationPackager.textToDependency(cleanedLine);
    assertEquals("org.eclipse.scout.sdk.deps:org.eclipse.core.jobs:3.8.0.v20160509-0411", scopedDependency.getExternalId().createExternalId());
}
Also used : ScopedDependency(com.synopsys.integration.detectable.detectables.maven.cli.ScopedDependency) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) MavenCodeLocationPackager(com.synopsys.integration.detectable.detectables.maven.cli.MavenCodeLocationPackager) Test(org.junit.jupiter.api.Test) UnitTest(com.synopsys.integration.detectable.annotations.UnitTest)

Aggregations

MavenCodeLocationPackager (com.synopsys.integration.detectable.detectables.maven.cli.MavenCodeLocationPackager)14 Test (org.junit.jupiter.api.Test)14 UnitTest (com.synopsys.integration.detectable.annotations.UnitTest)12 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)7 ScopedDependency (com.synopsys.integration.detectable.detectables.maven.cli.ScopedDependency)5 Dependency (com.synopsys.integration.bdio.model.dependency.Dependency)3 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)2 MavenParseResult (com.synopsys.integration.detectable.detectables.maven.cli.MavenParseResult)2 NameVersionGraphAssert (com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert)2