Search in sources :

Example 1 with GradleReportParser

use of com.synopsys.integration.detectable.detectables.gradle.inspection.parse.GradleReportParser 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);
}
Also used : GradleReportTransformer(com.synopsys.integration.detectable.detectables.gradle.inspection.parse.GradleReportTransformer) CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) GradleReportParser(com.synopsys.integration.detectable.detectables.gradle.inspection.parse.GradleReportParser) GsonBuilder(com.google.gson.GsonBuilder) GradleReport(com.synopsys.integration.detectable.detectables.gradle.inspection.model.GradleReport) Test(org.junit.jupiter.api.Test) UnitTest(com.synopsys.integration.detectable.annotations.UnitTest)

Example 2 with GradleReportParser

use of com.synopsys.integration.detectable.detectables.gradle.inspection.parse.GradleReportParser in project synopsys-detect by blackducksoftware.

the class GradleReportParserFunctionalTest method buildCodeLocation.

private Optional<CodeLocation> buildCodeLocation(String resource, boolean includeUnresolvedConfigurations) {
    File file = FunctionalTestFiles.asFile(resource);
    GradleReportParser gradleReportParser = new GradleReportParser();
    EnumListFilter<GradleConfigurationType> enumListFilter = EnumListFilter.excludeNone();
    if (!includeUnresolvedConfigurations) {
        enumListFilter = EnumListFilter.fromExcluded(GradleConfigurationType.UNRESOLVED);
    }
    GradleReportTransformer gradleReportTransformer = new GradleReportTransformer(enumListFilter);
    return gradleReportParser.parseReport(file).map(gradleReportTransformer::transform);
}
Also used : GradleConfigurationType(com.synopsys.integration.detectable.detectables.gradle.inspection.GradleConfigurationType) GradleReportTransformer(com.synopsys.integration.detectable.detectables.gradle.inspection.parse.GradleReportTransformer) GradleReportParser(com.synopsys.integration.detectable.detectables.gradle.inspection.parse.GradleReportParser) File(java.io.File)

Aggregations

GradleReportParser (com.synopsys.integration.detectable.detectables.gradle.inspection.parse.GradleReportParser)2 GradleReportTransformer (com.synopsys.integration.detectable.detectables.gradle.inspection.parse.GradleReportTransformer)2 GsonBuilder (com.google.gson.GsonBuilder)1 UnitTest (com.synopsys.integration.detectable.annotations.UnitTest)1 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)1 GradleConfigurationType (com.synopsys.integration.detectable.detectables.gradle.inspection.GradleConfigurationType)1 GradleReport (com.synopsys.integration.detectable.detectables.gradle.inspection.model.GradleReport)1 File (java.io.File)1 Test (org.junit.jupiter.api.Test)1