Search in sources :

Example 1 with ProjectInspectorParser

use of com.synopsys.integration.detectable.detectables.projectinspector.ProjectInspectorParser in project synopsys-detect by blackducksoftware.

the class NugetProjectInspectorParseTest method checkParse.

@Test
void checkParse() {
    String inspectorOutput = FunctionalTestFiles.asString("/nuget/project_inspector/ConsoleApp.json");
    List<CodeLocation> codeLocations = new ProjectInspectorParser(new Gson(), new ExternalIdFactory()).parse(inspectorOutput);
    Assertions.assertEquals(2, codeLocations.size());
    Assertions.assertEquals(new File("C:\\Users\\jordanp\\source\\repos\\ConsoleApp3\\ConsoleApp1\\ConsoleApp1.csproj"), codeLocations.get(0).getSourcePath().orElse(null));
    Assertions.assertEquals(new File("C:\\Users\\jordanp\\source\\repos\\ConsoleApp3\\ConsoleApp3\\ConsoleApp3.csproj"), codeLocations.get(1).getSourcePath().orElse(null));
    NameVersionGraphAssert consoleApp1 = new NameVersionGraphAssert(Forge.NUGET, codeLocations.get(0).getDependencyGraph());
    consoleApp1.hasDependency("DocumentFormat.OpenXml", "2.13.0");
    NameVersionGraphAssert consoleApp3 = new NameVersionGraphAssert(Forge.NUGET, codeLocations.get(1).getDependencyGraph());
    consoleApp3.hasDependency("Newtonsoft.Json.Bson", "1.0.2");
    consoleApp3.hasDependency("Serilog", "2.10.0");
    consoleApp3.hasParentChildRelationship("Newtonsoft.Json.Bson", "1.0.2", "Newtonsoft.Json", "12.0.1");
}
Also used : CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) ExternalIdFactory(com.synopsys.integration.bdio.model.externalid.ExternalIdFactory) Gson(com.google.gson.Gson) NameVersionGraphAssert(com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert) ProjectInspectorParser(com.synopsys.integration.detectable.detectables.projectinspector.ProjectInspectorParser) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

Gson (com.google.gson.Gson)1 ExternalIdFactory (com.synopsys.integration.bdio.model.externalid.ExternalIdFactory)1 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)1 ProjectInspectorParser (com.synopsys.integration.detectable.detectables.projectinspector.ProjectInspectorParser)1 NameVersionGraphAssert (com.synopsys.integration.detectable.util.graph.NameVersionGraphAssert)1 File (java.io.File)1 Test (org.junit.jupiter.api.Test)1