Search in sources :

Example 1 with PackageResolved

use of com.synopsys.integration.detectable.detectables.xcode.model.PackageResolved in project synopsys-detect by blackducksoftware.

the class XcodeSwiftExtractor method extract.

public Extraction extract(File foundPackageResolvedFile, File foundXcodeProjectFile) throws FileNotFoundException {
    FileReader fileReader = new FileReader(foundPackageResolvedFile);
    PackageResolved packageResolved = gson.fromJson(fileReader, PackageResolved.class);
    if (packageResolved == null) {
        // There are no dependencies to extract.
        DependencyGraph dependencyGraph = new MutableMapDependencyGraph();
        CodeLocation emptyCodeLocation = new CodeLocation(dependencyGraph, foundXcodeProjectFile);
        return new Extraction.Builder().success(emptyCodeLocation).build();
    }
    packageResolvedFormatChecker.handleVersionCompatibility(packageResolved, (fileFormatVersion, knownVersions) -> logger.warn(String.format("The format version of Package.resolved (%s) is unknown to Detect, but will attempt to parse anyway. Known format versions are (%s).", fileFormatVersion, StringUtils.join(knownVersions, ", "))));
    DependencyGraph dependencyGraph = packageResolvedTransformer.transform(packageResolved);
    CodeLocation codeLocation = new CodeLocation(dependencyGraph);
    return new Extraction.Builder().success(codeLocation).build();
}
Also used : PackageResolved(com.synopsys.integration.detectable.detectables.xcode.model.PackageResolved) CodeLocation(com.synopsys.integration.detectable.detectable.codelocation.CodeLocation) FileReader(java.io.FileReader) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) MutableMapDependencyGraph(com.synopsys.integration.bdio.graph.MutableMapDependencyGraph) MutableMapDependencyGraph(com.synopsys.integration.bdio.graph.MutableMapDependencyGraph)

Example 2 with PackageResolved

use of com.synopsys.integration.detectable.detectables.xcode.model.PackageResolved in project synopsys-detect by blackducksoftware.

the class PackageResolvedTransformerTest method manyExtensionsTest.

@Test
void manyExtensionsTest() {
    ResolvedPackage rSwiftLibraryPackage = new ResolvedPackage("R.swift.Library", "http://github.com/mac-cain13/R.swift.Library", new PackageState(null, "8998cfe77f4fce79ee6dfab0c88a7d551659d8fb", "5.4.0"));
    PackageResolvedTransformer transformer = new PackageResolvedTransformer(externalIdFactory);
    PackageResolved packageResolved = createPackageResolved(rSwiftLibraryPackage);
    DependencyGraph dependencyGraph = transformer.transform(packageResolved);
    GraphAssert graphAssert = new GraphAssert(Forge.GITHUB, dependencyGraph);
    ExternalId rSwiftLibrary = externalIdFactory.createNameVersionExternalId(Forge.GITHUB, "mac-cain13/R.swift.Library", "5.4.0");
    graphAssert.hasRootDependency(rSwiftLibrary);
    graphAssert.hasRootSize(1);
}
Also used : PackageResolved(com.synopsys.integration.detectable.detectables.xcode.model.PackageResolved) PackageResolvedTransformer(com.synopsys.integration.detectable.detectables.xcode.process.PackageResolvedTransformer) GraphAssert(com.synopsys.integration.detectable.util.graph.GraphAssert) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) PackageState(com.synopsys.integration.detectable.detectables.xcode.model.PackageState) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) ResolvedPackage(com.synopsys.integration.detectable.detectables.xcode.model.ResolvedPackage) Test(org.junit.jupiter.api.Test)

Example 3 with PackageResolved

use of com.synopsys.integration.detectable.detectables.xcode.model.PackageResolved in project synopsys-detect by blackducksoftware.

the class PackageResolvedTransformerTest method noGitExtensionTest.

@Test
void noGitExtensionTest() {
    ResolvedPackage swiftLogPackage = new ResolvedPackage("swift-log", // Won't be malformed for sanity check
    "http://github.com/apple/swift-log", new PackageState(null, "5d66f7ba25daf4f94100e7022febf3c75e37a6c7", "1.4.2"));
    PackageResolvedTransformer transformer = new PackageResolvedTransformer(externalIdFactory);
    PackageResolved packageResolved = createPackageResolved(swiftLogPackage);
    DependencyGraph dependencyGraph = transformer.transform(packageResolved);
    GraphAssert graphAssert = new GraphAssert(Forge.GITHUB, dependencyGraph);
    ExternalId swiftLog = externalIdFactory.createNameVersionExternalId(Forge.GITHUB, "apple/swift-log", "1.4.2");
    graphAssert.hasRootDependency(swiftLog);
    graphAssert.hasRootSize(1);
}
Also used : PackageResolved(com.synopsys.integration.detectable.detectables.xcode.model.PackageResolved) PackageResolvedTransformer(com.synopsys.integration.detectable.detectables.xcode.process.PackageResolvedTransformer) GraphAssert(com.synopsys.integration.detectable.util.graph.GraphAssert) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) PackageState(com.synopsys.integration.detectable.detectables.xcode.model.PackageState) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) ResolvedPackage(com.synopsys.integration.detectable.detectables.xcode.model.ResolvedPackage) Test(org.junit.jupiter.api.Test)

Example 4 with PackageResolved

use of com.synopsys.integration.detectable.detectables.xcode.model.PackageResolved in project synopsys-detect by blackducksoftware.

the class PackageResolvedTransformerTest method malformedUrlTest.

@Test
void malformedUrlTest() {
    ResolvedPackage malformedUrlPackage = new ResolvedPackage("MalformedUrlPackage", "data that isn't a url", new PackageState(null, "revision", "version"));
    PackageResolvedTransformer transformer = new PackageResolvedTransformer(externalIdFactory);
    PackageResolved packageResolved = createPackageResolved(malformedUrlPackage);
    DependencyGraph dependencyGraph = transformer.transform(packageResolved);
    GraphAssert graphAssert = new GraphAssert(Forge.GITHUB, dependencyGraph);
    graphAssert.hasRootSize(0);
}
Also used : PackageResolved(com.synopsys.integration.detectable.detectables.xcode.model.PackageResolved) PackageResolvedTransformer(com.synopsys.integration.detectable.detectables.xcode.process.PackageResolvedTransformer) GraphAssert(com.synopsys.integration.detectable.util.graph.GraphAssert) PackageState(com.synopsys.integration.detectable.detectables.xcode.model.PackageState) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) ResolvedPackage(com.synopsys.integration.detectable.detectables.xcode.model.ResolvedPackage) Test(org.junit.jupiter.api.Test)

Example 5 with PackageResolved

use of com.synopsys.integration.detectable.detectables.xcode.model.PackageResolved in project synopsys-detect by blackducksoftware.

the class PackageResolvedTransformerTest method testHttpWithGit.

@Test
void testHttpWithGit() {
    ResolvedPackage auth0Package = new ResolvedPackage("Auth0", "http://github.com/auth0/Auth0.swift.git", new PackageState(null, "8e8a6b0337a27a3342beb72b5407141fdd4a7860", "1.35.0"));
    PackageResolved packageResolved = createPackageResolved(auth0Package);
    PackageResolvedTransformer transformer = new PackageResolvedTransformer(externalIdFactory);
    DependencyGraph dependencyGraph = transformer.transform(packageResolved);
    GraphAssert graphAssert = new GraphAssert(Forge.GITHUB, dependencyGraph);
    ExternalId auth0 = externalIdFactory.createNameVersionExternalId(Forge.GITHUB, "auth0/Auth0.swift", "1.35.0");
    graphAssert.hasRootDependency(auth0);
    graphAssert.hasRootSize(1);
}
Also used : PackageResolved(com.synopsys.integration.detectable.detectables.xcode.model.PackageResolved) PackageResolvedTransformer(com.synopsys.integration.detectable.detectables.xcode.process.PackageResolvedTransformer) GraphAssert(com.synopsys.integration.detectable.util.graph.GraphAssert) ExternalId(com.synopsys.integration.bdio.model.externalid.ExternalId) PackageState(com.synopsys.integration.detectable.detectables.xcode.model.PackageState) DependencyGraph(com.synopsys.integration.bdio.graph.DependencyGraph) ResolvedPackage(com.synopsys.integration.detectable.detectables.xcode.model.ResolvedPackage) Test(org.junit.jupiter.api.Test)

Aggregations

PackageResolved (com.synopsys.integration.detectable.detectables.xcode.model.PackageResolved)9 DependencyGraph (com.synopsys.integration.bdio.graph.DependencyGraph)6 ResolvedPackage (com.synopsys.integration.detectable.detectables.xcode.model.ResolvedPackage)6 Test (org.junit.jupiter.api.Test)6 PackageState (com.synopsys.integration.detectable.detectables.xcode.model.PackageState)5 PackageResolvedTransformer (com.synopsys.integration.detectable.detectables.xcode.process.PackageResolvedTransformer)5 GraphAssert (com.synopsys.integration.detectable.util.graph.GraphAssert)5 ExternalId (com.synopsys.integration.bdio.model.externalid.ExternalId)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MutableMapDependencyGraph (com.synopsys.integration.bdio.graph.MutableMapDependencyGraph)1 CodeLocation (com.synopsys.integration.detectable.detectable.codelocation.CodeLocation)1 ResolvedObject (com.synopsys.integration.detectable.detectables.xcode.model.ResolvedObject)1 FileReader (java.io.FileReader)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1