use of com.synopsys.integration.detectable.detectables.clang.linux.LinuxDistro in project synopsys-detect by blackducksoftware.
the class ForgeChooserTest method testDistroIdentified.
@Test
void testDistroIdentified() {
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.of("ubuntu"));
Forge createdForge = Mockito.mock(Forge.class);
Mockito.when(forgeGenerator.createPreferredAliasNamespaceForge("ubuntu")).thenReturn(createdForge);
List<Forge> chosenForges = forgeChooser.determineForges(currentPackageManager);
assertEquals(1, chosenForges.size());
assertEquals(createdForge, chosenForges.get(0));
}
use of com.synopsys.integration.detectable.detectables.clang.linux.LinuxDistro in project synopsys-detect by blackducksoftware.
the class LinuxDistroTest method testFedora.
@Test
void testFedora() throws IOException {
File etcDir = Files.createTempDirectory("linuxDistroTest").toFile();
File osReleaseFile = new File(etcDir, "redhat-release");
FileUtils.write(osReleaseFile, "Fedora-something", StandardCharsets.UTF_8);
LinuxDistro linuxDistro = new LinuxDistro();
Optional<String> extractedLinuxDistroName = linuxDistro.extractLinuxDistroNameFromEtcDir(etcDir);
assertTrue(extractedLinuxDistroName.isPresent());
assertEquals("fedora", extractedLinuxDistroName.get());
}
use of com.synopsys.integration.detectable.detectables.clang.linux.LinuxDistro in project synopsys-detect by blackducksoftware.
the class DetectableFactory method forgeChooser.
private ForgeChooser forgeChooser() {
LinuxDistroToForgeMapper forgeGenerator = new LinuxDistroToForgeMapper();
LinuxDistro linuxDistro = new LinuxDistro();
return new ForgeChooser(forgeGenerator, linuxDistro);
}
use of com.synopsys.integration.detectable.detectables.clang.linux.LinuxDistro 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.linux.LinuxDistro in project synopsys-detect by blackducksoftware.
the class LinuxDistroTest method testUbuntu.
@Test
void testUbuntu() throws IOException {
File etcDir = Files.createTempDirectory("linuxDistroTest").toFile();
File osReleaseFile = new File(etcDir, "os-release");
FileUtils.write(osReleaseFile, "ID=ubuntu", StandardCharsets.UTF_8);
LinuxDistro linuxDistro = new LinuxDistro();
Optional<String> extractedLinuxDistroName = linuxDistro.extractLinuxDistroNameFromEtcDir(etcDir);
assertTrue(extractedLinuxDistroName.isPresent());
assertEquals("ubuntu", extractedLinuxDistroName.get());
}
Aggregations