Search in sources :

Example 11 with MavenCodeLocationPackager

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

the class MavenCodeLocationPackagerTest method testDoesLineContainSegmentsInOrder.

@Test
public void testDoesLineContainSegmentsInOrder() {
    MavenCodeLocationPackager mavenCodeLocationPackager = new MavenCodeLocationPackager(null);
    assertFalse(mavenCodeLocationPackager.doesLineContainSegmentsInOrder(""));
    assertFalse(mavenCodeLocationPackager.doesLineContainSegmentsInOrder("stuff and things"));
    assertFalse(mavenCodeLocationPackager.doesLineContainSegmentsInOrder("stuff and things", "things", "and"));
    assertFalse(mavenCodeLocationPackager.doesLineContainSegmentsInOrder("stuff and things", "things", "and", "stuff"));
    assertTrue(mavenCodeLocationPackager.doesLineContainSegmentsInOrder("stuff and things", "stuff"));
    assertTrue(mavenCodeLocationPackager.doesLineContainSegmentsInOrder("stuff and things", "stuff", "and"));
    assertTrue(mavenCodeLocationPackager.doesLineContainSegmentsInOrder("stuff and things", "stuff", "and", "things"));
    assertTrue(mavenCodeLocationPackager.doesLineContainSegmentsInOrder("stuff and things", "and"));
    assertTrue(mavenCodeLocationPackager.doesLineContainSegmentsInOrder("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 12 with MavenCodeLocationPackager

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

the class MavenCodeLocationPackagerTest method testLineWithBadColonPlacement.

@Test
public void testLineWithBadColonPlacement() {
    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);
    String cleanedLine = mavenCodeLocationPackager.calculateCurrentLevelAndCleanLine(line);
    Dependency dependency = mavenCodeLocationPackager.textToDependency(cleanedLine);
    assertEquals("org.eclipse.scout.sdk.deps:org.eclipse.core.jobs:pants (version selected from", 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 13 with MavenCodeLocationPackager

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

the class MavenCodeLocationPackagerTest method testIsLineRelevant.

@Test
public void testIsLineRelevant() {
    MavenCodeLocationPackager mavenCodeLocationPackager = new MavenCodeLocationPackager(null);
    assertTrue(mavenCodeLocationPackager.isLineRelevant("weird garbage 3525356 [thingsINFO 346534623465] stuff"));
    assertTrue(mavenCodeLocationPackager.isLineRelevant("[thingsINFO 346534623465]stuff"));
    assertTrue(mavenCodeLocationPackager.isLineRelevant("[thingsINFO]  stuff"));
    assertFalse(mavenCodeLocationPackager.isLineRelevant(" [INFO]     "));
    assertFalse(mavenCodeLocationPackager.isLineRelevant("weird garbage 3525356 [thingsINFO 346534623465]"));
    assertFalse(mavenCodeLocationPackager.isLineRelevant("[thingsINFO 346534623465]"));
    assertFalse(mavenCodeLocationPackager.isLineRelevant("[thingsINFO]"));
    assertFalse(mavenCodeLocationPackager.isLineRelevant(" [INFO]"));
    assertFalse(mavenCodeLocationPackager.isLineRelevant(" "));
    assertFalse(mavenCodeLocationPackager.isLineRelevant("[INFO] Downloaded"));
    assertFalse(mavenCodeLocationPackager.isLineRelevant("[INFO] stuff and thingsDownloaded stuff and things"));
    assertFalse(mavenCodeLocationPackager.isLineRelevant("[INFO] Downloading"));
    assertFalse(mavenCodeLocationPackager.isLineRelevant("[INFO] stuff and things Downloadingstuff and 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 14 with MavenCodeLocationPackager

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

the class MavenCorruptOutputTest 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)

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