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));
}
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());
}
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);
}
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);
}
Aggregations