use of com.synopsys.integration.detectable.detectables.nuget.model.NugetInspection in project synopsys-detect by blackducksoftware.
the class NugetInspectorParser method createCodeLocation.
public NugetParseResult createCodeLocation(String dependencyFileText) {
NugetInspection nugetInspection = gson.fromJson(dependencyFileText, NugetInspection.class);
List<CodeLocation> codeLocations = new ArrayList<>();
String projectName = "";
String projectVersion = "";
for (NugetContainer it : nugetInspection.containers) {
Optional<NugetParseResult> possibleParseResult = createDetectCodeLocationFromNugetContainer(it);
if (possibleParseResult.isPresent()) {
NugetParseResult result = possibleParseResult.get();
if (StringUtils.isNotBlank(result.getProjectName())) {
projectName = result.getProjectName();
projectVersion = result.getProjectVersion();
}
codeLocations.addAll(result.getCodeLocations());
}
}
return new NugetParseResult(projectName, projectVersion, codeLocations);
}
use of com.synopsys.integration.detectable.detectables.nuget.model.NugetInspection in project synopsys-detect by blackducksoftware.
the class NugetParserTest method handlesNullContainer.
@Test
public void handlesNullContainer() {
NugetInspection result = new NugetInspection();
result.containers.add(null);
String resultText = gson.toJson(result);
NugetInspectorParser parser = new NugetInspectorParser(gson, new ExternalIdFactory());
NugetParseResult parsed = parser.createCodeLocation(resultText);
Assertions.assertEquals(0, parsed.getCodeLocations().size());
}
use of com.synopsys.integration.detectable.detectables.nuget.model.NugetInspection in project synopsys-detect by blackducksoftware.
the class NugetParserTest method handlesNullChild.
@Test
public void handlesNullChild() {
NugetInspection result = new NugetInspection();
NugetContainer container = new NugetContainer();
container.type = NugetContainerType.SOLUTION;
container.children = new ArrayList<>();
container.children.add(null);
result.containers.add(container);
String resultText = gson.toJson(result);
NugetInspectorParser parser = new NugetInspectorParser(gson, new ExternalIdFactory());
NugetParseResult parsed = parser.createCodeLocation(resultText);
Assertions.assertEquals(0, parsed.getCodeLocations().size());
}
Aggregations