Search in sources :

Example 1 with ApkPackageManagerResolver

use of com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.ApkPackageManagerResolver in project synopsys-detect by blackducksoftware.

the class ClangPackageManagerFactory method createPackageManagers.

public List<ClangPackageManager> createPackageManagers() {
    List<ClangPackageManager> packageManagers = new ArrayList<>();
    packageManagers.add(new ClangPackageManager(packageManagerInfoFactory.apk(), new ApkPackageManagerResolver(new ApkArchitectureResolver())));
    packageManagers.add(new ClangPackageManager(packageManagerInfoFactory.dpkg(), new DpkgPackageManagerResolver(new DpkgPkgDetailsResolver())));
    packageManagers.add(new ClangPackageManager(packageManagerInfoFactory.rpm(), new RpmPackageManagerResolver(new Gson())));
    return packageManagers;
}
Also used : RpmPackageManagerResolver(com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.RpmPackageManagerResolver) ApkArchitectureResolver(com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.ApkArchitectureResolver) ArrayList(java.util.ArrayList) DpkgPackageManagerResolver(com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.DpkgPackageManagerResolver) Gson(com.google.gson.Gson) ApkPackageManagerResolver(com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.ApkPackageManagerResolver) DpkgPkgDetailsResolver(com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.DpkgPkgDetailsResolver)

Example 2 with ApkPackageManagerResolver

use of com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.ApkPackageManagerResolver in project synopsys-detect by blackducksoftware.

the class ClangPackageManagerRunnerTest method testApkNonPkgOwnedIncludeFile.

@Test
public void testApkNonPkgOwnedIncludeFile() throws ExecutableRunnerException {
    ClangPackageManagerInfoFactory factory = ClangPackageManagerInfoFactory.standardFactory();
    ClangPackageManagerInfo packageManagerInfo = factory.apk();
    ApkArchitectureResolver archResolver = new ApkArchitectureResolver();
    ClangPackageManagerResolver packageResolver = new ApkPackageManagerResolver(archResolver);
    String pkgOwnerPattern = "ERROR: %s: Could not find owner package";
    testNonPkgOwnedIncludeFile(packageManagerInfo, packageResolver, pkgOwnerPattern);
}
Also used : ClangPackageManagerInfoFactory(com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManagerInfoFactory) ClangPackageManagerInfo(com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManagerInfo) ApkArchitectureResolver(com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.ApkArchitectureResolver) ClangPackageManagerResolver(com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.ClangPackageManagerResolver) ApkPackageManagerResolver(com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.ApkPackageManagerResolver) Test(org.junit.jupiter.api.Test)

Example 3 with ApkPackageManagerResolver

use of com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.ApkPackageManagerResolver in project synopsys-detect by blackducksoftware.

the class ApkPackageManagerTest method canParsePackages.

@Test
public void canParsePackages() throws ExecutableRunnerException, NotOwnedByAnyPkgException {
    StringBuilder sb = new StringBuilder();
    sb.append("garbage\n");
    sb.append("nonsense\n");
    sb.append("this line has the is owned by substring\n");
    sb.append(" is owned by \n");
    // This is the one valid line; rest should be discarded
    sb.append("/usr/include/stdlib.h is owned by musl-dev-1.1.18-r3\n");
    sb.append("/usr/include/stdlib.h is owned by .musl-dev-1.1.18-r99\n");
    String pkgMgrOwnedByOutput = sb.toString();
    ApkArchitectureResolver architectureResolver = Mockito.mock(ApkArchitectureResolver.class);
    Mockito.when(architectureResolver.resolveArchitecture(Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(Optional.of("x86_64"));
    ApkPackageManagerResolver apkPackageManagerResolver = new ApkPackageManagerResolver(architectureResolver);
    ClangPackageManagerInfo apk = new ClangPackageManagerInfoFactory().apk();
    List<PackageDetails> pkgs = apkPackageManagerResolver.resolvePackages(apk, null, null, pkgMgrOwnedByOutput);
    Assertions.assertEquals(1, pkgs.size());
    Assertions.assertEquals("musl-dev", pkgs.get(0).getPackageName());
    Assertions.assertEquals("1.1.18-r3", pkgs.get(0).getPackageVersion());
    Assertions.assertEquals("x86_64", pkgs.get(0).getPackageArch());
}
Also used : ClangPackageManagerInfoFactory(com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManagerInfoFactory) ClangPackageManagerInfo(com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManagerInfo) ApkArchitectureResolver(com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.ApkArchitectureResolver) ApkPackageManagerResolver(com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.ApkPackageManagerResolver) PackageDetails(com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetails) Test(org.junit.jupiter.api.Test)

Aggregations

ApkArchitectureResolver (com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.ApkArchitectureResolver)3 ApkPackageManagerResolver (com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.ApkPackageManagerResolver)3 ClangPackageManagerInfo (com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManagerInfo)2 ClangPackageManagerInfoFactory (com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManagerInfoFactory)2 Test (org.junit.jupiter.api.Test)2 Gson (com.google.gson.Gson)1 PackageDetails (com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetails)1 ClangPackageManagerResolver (com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.ClangPackageManagerResolver)1 DpkgPackageManagerResolver (com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.DpkgPackageManagerResolver)1 DpkgPkgDetailsResolver (com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.DpkgPkgDetailsResolver)1 RpmPackageManagerResolver (com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.RpmPackageManagerResolver)1 ArrayList (java.util.ArrayList)1