Search in sources :

Example 6 with ClangPackageManagerInfo

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

the class ForgeChooserTest method testDistroNotIdentified.

@Test
void testDistroNotIdentified() {
    LinuxDistroToForgeMapper forgeGenerator = Mockito.mock(LinuxDistroToForgeMapper.class);
    LinuxDistro linuxDistro = Mockito.mock(LinuxDistro.class);
    ForgeChooser forgeChooser = new ForgeChooser(forgeGenerator, linuxDistro);
    ClangPackageManager currentPackageManager = Mockito.mock(ClangPackageManager.class);
    Mockito.when(linuxDistro.extractLinuxDistroNameFromEtcDir()).thenReturn(Optional.empty());
    ClangPackageManagerInfo packageManagerInfo = Mockito.mock(ClangPackageManagerInfo.class);
    Mockito.when(currentPackageManager.getPackageManagerInfo()).thenReturn(packageManagerInfo);
    Forge possibleForge1 = Mockito.mock(Forge.class);
    Mockito.when(possibleForge1.getName()).thenReturn("possibleForge1");
    Forge possibleForge2 = Mockito.mock(Forge.class);
    Mockito.when(possibleForge2.getName()).thenReturn("possibleForge2");
    List<Forge> possibleForges = Arrays.asList(possibleForge1, possibleForge2);
    Mockito.when(packageManagerInfo.getPossibleForges()).thenReturn(possibleForges);
    List<Forge> chosenForges = forgeChooser.determineForges(currentPackageManager);
    assertEquals(2, chosenForges.size());
    assertEquals(possibleForge1, chosenForges.get(0));
    assertEquals(possibleForge2, chosenForges.get(1));
}
Also used : LinuxDistroToForgeMapper(com.synopsys.integration.detectable.detectables.clang.LinuxDistroToForgeMapper) ClangPackageManager(com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManager) ClangPackageManagerInfo(com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManagerInfo) Forge(com.synopsys.integration.bdio.model.Forge) ForgeChooser(com.synopsys.integration.detectable.detectables.clang.ForgeChooser) LinuxDistro(com.synopsys.integration.detectable.detectables.clang.linux.LinuxDistro) Test(org.junit.jupiter.api.Test)

Example 7 with ClangPackageManagerInfo

use of com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManagerInfo 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)

Example 8 with ClangPackageManagerInfo

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

the class ClangPackageManagerRunnerTest method testDpkgPkgNotInstalled.

@Test
public void testDpkgPkgNotInstalled() throws ExecutableRunnerException {
    ClangPackageManagerInfoFactory factory = ClangPackageManagerInfoFactory.standardFactory();
    ClangPackageManagerInfo packageManagerInfo = factory.dpkg();
    DpkgPkgDetailsResolver versionResolver = new DpkgPkgDetailsResolver();
    ClangPackageManagerResolver packageResolver = new DpkgPackageManagerResolver(versionResolver);
    String pkgOwnerPattern = "libxt-dev:amd64: %s\n";
    String pkgDetailsPattern = "Package: %s\n" + "Architecture: amd64\n" + "Version: 1:1.1.5-1\n" + "Status: pending\n";
    testNoResultsCase(packageManagerInfo, packageResolver, "libxt-dev", "amd64", pkgOwnerPattern, pkgDetailsPattern);
}
Also used : ClangPackageManagerInfoFactory(com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManagerInfoFactory) ClangPackageManagerInfo(com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManagerInfo) ClangPackageManagerResolver(com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.ClangPackageManagerResolver) DpkgPackageManagerResolver(com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.DpkgPackageManagerResolver) DpkgPkgDetailsResolver(com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.DpkgPkgDetailsResolver) Test(org.junit.jupiter.api.Test)

Example 9 with ClangPackageManagerInfo

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

the class ClangPackageManagerRunnerTest method testDpkgNonPkgOwnedIncludeFile.

@Test
public void testDpkgNonPkgOwnedIncludeFile() throws ExecutableRunnerException {
    ClangPackageManagerInfoFactory factory = ClangPackageManagerInfoFactory.standardFactory();
    ClangPackageManagerInfo packageManagerInfo = factory.dpkg();
    DpkgPkgDetailsResolver versionResolver = new DpkgPkgDetailsResolver();
    ClangPackageManagerResolver packageResolver = new DpkgPackageManagerResolver(versionResolver);
    String pkgOwnerPattern = "dpkg-query: no path found matching pattern %s";
    testNonPkgOwnedIncludeFile(packageManagerInfo, packageResolver, pkgOwnerPattern);
}
Also used : ClangPackageManagerInfoFactory(com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManagerInfoFactory) ClangPackageManagerInfo(com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManagerInfo) ClangPackageManagerResolver(com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.ClangPackageManagerResolver) DpkgPackageManagerResolver(com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.DpkgPackageManagerResolver) DpkgPkgDetailsResolver(com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.DpkgPkgDetailsResolver) Test(org.junit.jupiter.api.Test)

Aggregations

ClangPackageManagerInfo (com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManagerInfo)9 Test (org.junit.jupiter.api.Test)9 ClangPackageManagerInfoFactory (com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManagerInfoFactory)7 ClangPackageManagerResolver (com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.ClangPackageManagerResolver)6 DpkgPackageManagerResolver (com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.DpkgPackageManagerResolver)4 DpkgPkgDetailsResolver (com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.DpkgPkgDetailsResolver)4 Gson (com.google.gson.Gson)2 PackageDetails (com.synopsys.integration.detectable.detectables.clang.packagemanager.PackageDetails)2 ApkArchitectureResolver (com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.ApkArchitectureResolver)2 ApkPackageManagerResolver (com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.ApkPackageManagerResolver)2 RpmPackageManagerResolver (com.synopsys.integration.detectable.detectables.clang.packagemanager.resolver.RpmPackageManagerResolver)2 Forge (com.synopsys.integration.bdio.model.Forge)1 DetectableExecutableRunner (com.synopsys.integration.detectable.detectable.executable.DetectableExecutableRunner)1 ForgeChooser (com.synopsys.integration.detectable.detectables.clang.ForgeChooser)1 LinuxDistroToForgeMapper (com.synopsys.integration.detectable.detectables.clang.LinuxDistroToForgeMapper)1 LinuxDistro (com.synopsys.integration.detectable.detectables.clang.linux.LinuxDistro)1 ClangPackageManager (com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManager)1 File (java.io.File)1