use of com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation in project hub-detect by blackducksoftware.
the class GradleReportParserTest method build.
private DetectCodeLocation build(final String resource) throws IOException {
final File file = new File(resource);
final GradleReportParser gradleReportParser = new GradleReportParser(new ExternalIdFactory());
final Optional<DetectCodeLocation> result = gradleReportParser.parseDependencies(file);
if (result.isPresent()) {
return result.get();
} else {
return null;
}
}
use of com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation 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()));
}
use of com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation 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());
}
use of com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation in project hub-detect by blackducksoftware.
the class BazelCodeLocationBuilderTest method test.
@Test
public void test() {
BazelCodeLocationBuilder bdioBuilder = new BazelCodeLocationBuilder(new ExternalIdFactory());
final List<DetectCodeLocation> codeLocations = bdioBuilder.setWorkspaceDir(new File("src/test/resources/bazel/multiLevel")).addDependency(BazelExternalId.fromBazelArtifactString("testGroup:testArtifact:testVersion", ":")).build();
assertEquals(1, codeLocations.size());
assertEquals("src/test/resources/bazel/multiLevel", codeLocations.get(0).getExternalId().path);
assertEquals(1, codeLocations.get(0).getDependencyGraph().getRootDependencies().size());
Dependency dep = codeLocations.get(0).getDependencyGraph().getRootDependencies().iterator().next();
assertEquals("testArtifact", dep.name);
assertEquals("testVersion", dep.version);
assertEquals("testGroup", dep.externalId.group);
}
use of com.blackducksoftware.integration.hub.detect.workflow.codelocation.DetectCodeLocation in project hub-detect by blackducksoftware.
the class NpmCliParser method convertNpmJsonFileToCodeLocation.
NpmParseResult convertNpmJsonFileToCodeLocation(final String sourcePath, final String npmLsOutput) {
final JsonObject npmJson = new JsonParser().parse(npmLsOutput).getAsJsonObject();
final MutableDependencyGraph graph = new MutableMapDependencyGraph();
final JsonElement projectNameElement = npmJson.getAsJsonPrimitive(JSON_NAME);
final JsonElement projectVersionElement = npmJson.getAsJsonPrimitive(JSON_VERSION);
String projectName = null;
String projectVersion = null;
if (projectNameElement != null) {
projectName = projectNameElement.getAsString();
}
if (projectVersionElement != null) {
projectVersion = projectVersionElement.getAsString();
}
populateChildren(graph, null, npmJson.getAsJsonObject(JSON_DEPENDENCIES), true);
final ExternalId externalId = externalIdFactory.createNameVersionExternalId(Forge.NPM, projectName, projectVersion);
final DetectCodeLocation codeLocation = new DetectCodeLocation.Builder(DetectCodeLocationType.NPM, sourcePath, externalId, graph).build();
return new NpmParseResult(projectName, projectVersion, codeLocation);
}
Aggregations