Search in sources :

Example 6 with MavenCodeLocationPackager

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

the class MavenCodeLocationPackagerTest method testLineWithExtraTextAfterScope.

@Test
public void testLineWithExtraTextAfterScope() {
    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);
    String cleanedLine = mavenCodeLocationPackager.calculateCurrentLevelAndCleanLine(line);
    Dependency dependency = mavenCodeLocationPackager.textToDependency(cleanedLine);
    assertEquals("org.eclipse.scout.sdk.deps:org.eclipse.core.jobs:3.8.0.v20160509-0411", dependency.getExternalId().createExternalId());
}
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 7 with MavenCodeLocationPackager

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

the class MavenComplexOutputTest method test.

@Test
public void test() {
    ExternalIdFactory externalIdFactory = new ExternalIdFactory();
    MavenCodeLocationPackager packager = new MavenCodeLocationPackager(externalIdFactory);
    List<MavenParseResult> results = packager.extractCodeLocations("", getInput(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList());
    NameVersionGraphAssert graphAssert = new NameVersionGraphAssert(Forge.MAVEN, results.get(0).getCodeLocation().getDependencyGraph());
    graphAssert.hasRootSize(1);
    ExternalId hubCommon = externalIdFactory.createMavenExternalId("com.blackducksoftware.integration", "hub-common", "13.1.2");
    ExternalId integrationCommon = externalIdFactory.createMavenExternalId("com.blackducksoftware.integration", "integration-common", "6.0.2");
    ExternalId hubCommonRest = externalIdFactory.createMavenExternalId("com.blackducksoftware.integration", "hub-common-rest", "2.1.3");
    graphAssert.hasRootDependency(hubCommon);
    graphAssert.hasParentChildRelationship(hubCommonRest, integrationCommon);
    graphAssert.hasParentChildRelationship(hubCommon, hubCommonRest);
}
Also used : ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) MavenParseResult(com.synopsys.integration.detectable.detectables.maven.cli.MavenParseResult) MavenCodeLocationPackager(com.synopsys.integration.detectable.detectables.maven.cli.MavenCodeLocationPackager) Test(org.junit.jupiter.api.Test)

Example 8 with MavenCodeLocationPackager

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

the class MavenCodeLocationPackagerTest method testIsDependencyTreeUpdates.

@Test
public void testIsDependencyTreeUpdates() {
    MavenCodeLocationPackager mavenCodeLocationPackager = new MavenCodeLocationPackager(null);
    assertTrue(mavenCodeLocationPackager.isDependencyTreeUpdates("artifact com.google.guava:guava:jar:15.0:compile checking for updates from"));
    assertTrue(mavenCodeLocationPackager.isDependencyTreeUpdates("         artifact       com.google.guava:guava:         checking for updates"));
    assertTrue(mavenCodeLocationPackager.isDependencyTreeUpdates("      checking for updates   artifact       com.google.guava:guava:      "));
    assertTrue(mavenCodeLocationPackager.isDependencyTreeUpdates("checking for updates"));
    assertFalse(mavenCodeLocationPackager.isDependencyTreeUpdates("com.google.guava:guava:jar:15.0:compile"));
    assertFalse(mavenCodeLocationPackager.isDependencyTreeUpdates("+- com.google.guava:guava:jar:15.0:compile"));
    assertFalse(mavenCodeLocationPackager.isDependencyTreeUpdates("|  \\- com.google.guava:guava:jar:15.0:compile"));
}
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 9 with MavenCodeLocationPackager

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

the class MavenCodeLocationPackagerTest method testIsGav.

@Test
public void testIsGav() {
    MavenCodeLocationPackager mavenCodeLocationPackager = new MavenCodeLocationPackager(null);
    assertFalse(mavenCodeLocationPackager.isGav(" "));
    assertFalse(mavenCodeLocationPackager.isGav("       "));
    assertFalse(mavenCodeLocationPackager.isGav("::::"));
    assertFalse(mavenCodeLocationPackager.isGav(" : : : : "));
    assertFalse(mavenCodeLocationPackager.isGav("group"));
    assertFalse(mavenCodeLocationPackager.isGav("group:artifact"));
    assertFalse(mavenCodeLocationPackager.isGav("group:artifact:version"));
    assertFalse(mavenCodeLocationPackager.isGav("group-artifact:type-classifier-version:scope-garbage"));
    assertFalse(mavenCodeLocationPackager.isGav("group:artifact::classifier:version: :garbage"));
    assertTrue(mavenCodeLocationPackager.isGav("group:artifact:type:version"));
    assertTrue(mavenCodeLocationPackager.isGav("group:artifact:type:classifier:version"));
    assertTrue(mavenCodeLocationPackager.isGav("group:artifact:type:classifier:version:scope"));
    assertTrue(mavenCodeLocationPackager.isGav("group:artifact:type:classifier:version:scope:garbage"));
}
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 10 with MavenCodeLocationPackager

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

the class MavenCodeLocationPackagerTest method testTrimLogLevel.

@Test
public void testTrimLogLevel() {
    MavenCodeLocationPackager mavenCodeLocationPackager = new MavenCodeLocationPackager(null);
    String actualLine = "";
    final String expectedValue = "thing";
    actualLine = mavenCodeLocationPackager.trimLogLevel("weird garbage 3525356 [thingsINFO 346534623465]" + expectedValue);
    assertEquals(expectedValue, actualLine);
    actualLine = mavenCodeLocationPackager.trimLogLevel("[thingsINFO 346534623465]" + expectedValue);
    assertEquals(expectedValue, actualLine);
    actualLine = mavenCodeLocationPackager.trimLogLevel("[thingsINFO]" + expectedValue);
    assertEquals(expectedValue, actualLine);
    actualLine = mavenCodeLocationPackager.trimLogLevel(" [INFO] " + expectedValue);
    assertEquals(expectedValue, actualLine);
}
Also used : 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