use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class GradleReplacementDetectableTest method assertExtraction.
@Override
public void assertExtraction(@NotNull Extraction extraction) {
ExtractionUtil.assertSuccessWithCodeLocationCount(extraction, 3);
CodeLocation root = ExtractionUtil.assertAndGetCodeLocationNamed("root", extraction);
CodeLocation projectA = ExtractionUtil.assertAndGetCodeLocationNamed("projectA", extraction);
CodeLocation projectB = ExtractionUtil.assertAndGetCodeLocationNamed("projectB", extraction);
MavenGraphAssert rootGraph = new MavenGraphAssert(root.getDependencyGraph());
MavenGraphAssert projectAGraph = new MavenGraphAssert(projectA.getDependencyGraph());
MavenGraphAssert projectBGraph = new MavenGraphAssert(projectB.getDependencyGraph());
rootGraph.hasDependency("org.replacement:replaced:3.0.0");
projectAGraph.hasRootDependency("org.replacement:replaced:2.0.0");
projectBGraph.hasRootDependency("org.replacement:replaced:1.0.0");
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class GradleReportParserFunctionalTest method extractCodeLocationTest.
@Test
void extractCodeLocationTest() throws JSONException, IOException {
// Does not work on windows due to path issues.
Assumptions.assumeFalse(SystemUtils.IS_OS_WINDOWS);
GradleReportParser gradleReportParser = new GradleReportParser();
Optional<GradleReport> gradleReport = gradleReportParser.parseReport(FunctionalTestFiles.asFile("/gradle/dependencyGraph.txt"));
Assertions.assertTrue(gradleReport.isPresent());
GradleReportTransformer transformer = new GradleReportTransformer(EnumListFilter.excludeNone());
CodeLocation codeLocation = transformer.transform(gradleReport.get());
Assertions.assertNotNull(codeLocation);
Assertions.assertEquals("hub-detect", gradleReport.get().getProjectName());
Assertions.assertEquals("2.0.0-SNAPSHOT", gradleReport.get().getProjectVersionName());
String actual = new GsonBuilder().setPrettyPrinting().create().toJson(codeLocation);
JSONAssert.assertEquals(FunctionalTestFiles.asString("/gradle/dependencyGraph-expected.json"), actual, false);
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class GradleReportParserFunctionalTest method complexTest.
@Test
void complexTest() {
Optional<CodeLocation> codeLocation = buildCodeLocation("/gradle/complex_dependencyGraph.txt", true);
Assertions.assertTrue(codeLocation.isPresent());
DependencyGraph graph = codeLocation.get().getDependencyGraph();
MavenGraphAssert graphAssert = new MavenGraphAssert(graph);
graphAssert.hasDependency("non-project:with-nested:1.0.0");
graphAssert.hasDependency("solo:component:4.12");
graphAssert.hasDependency("some.group:child:2.2.2");
graphAssert.hasDependency("terminal:child:6.2.3");
// TODO: Get this to work in a sensible way
// graphAssert.noDependency("child-project");
// graphAssert.noDependency("nested-parent");
// graphAssert.noDependency("spring-webflux");
// graphAssert.noDependency("spring-beans");
// graphAssert.noDependency("spring-core");
// graphAssert.noDependency("spring-web");
// graphAssert.noDependency("should-suppress");
graphAssert.hasRootDependency("solo:component:4.12");
graphAssert.hasRootDependency("non-project:with-nested:1.0.0");
graphAssert.hasRootDependency("some.group:parent:5.0.0");
graphAssert.hasRootDependency("terminal:child:6.2.3");
ExternalId parent = graphAssert.hasDependency("some.group:parent:5.0.0");
ExternalId child = graphAssert.hasDependency("some.group:child:2.2.2");
graphAssert.hasParentChildRelationship(parent, child);
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class MavenProjectInspectorTest method assertExtraction.
@Override
public void assertExtraction(@NotNull Extraction extraction) {
List<CodeLocation> codeLocations = extraction.getCodeLocations();
Assertions.assertEquals(1, codeLocations.size());
CodeLocation codeLocation = codeLocations.get(0);
Set<Dependency> dependencies = codeLocation.getDependencyGraph().getRootDependencies();
Assertions.assertEquals(1, dependencies.size());
Dependency first = dependencies.iterator().next();
Assertions.assertNotNull(first);
Assertions.assertEquals("COORDINATE_ARTIFACT", first.getName());
Assertions.assertEquals("COORDINATE_VERSION", first.getVersion());
ExternalId firstId = first.getExternalId();
Assertions.assertEquals("COORDINATE_ARTIFACT", firstId.getName());
Assertions.assertEquals("COORDINATE_VERSION", firstId.getVersion());
Assertions.assertEquals("COORDINATE_GROUP", firstId.getGroup());
}
use of com.synopsys.integration.detectable.detectable.codelocation.CodeLocation in project synopsys-detect by blackducksoftware.
the class GoVendorExtractor method extract.
public Extraction extract(File vendorJsonFile) {
try {
GoVendorJsonParser vendorJsonParser = new GoVendorJsonParser(externalIdFactory);
String vendorJsonContents = FileUtils.readFileToString(vendorJsonFile, StandardCharsets.UTF_8);
logger.debug(vendorJsonContents);
DependencyGraph dependencyGraph = vendorJsonParser.parseVendorJson(gson, vendorJsonContents);
CodeLocation codeLocation = new CodeLocation(dependencyGraph);
return new Extraction.Builder().success(codeLocation).build();
} catch (Exception e) {
return new Extraction.Builder().exception(e).build();
}
}
Aggregations