Search in sources :

Example 1 with LinuxDistro

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));
}
Also used : LinuxDistroToForgeMapper(com.synopsys.integration.detectable.detectables.clang.LinuxDistroToForgeMapper) ClangPackageManager(com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManager) 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 2 with LinuxDistro

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());
}
Also used : File(java.io.File) LinuxDistro(com.synopsys.integration.detectable.detectables.clang.linux.LinuxDistro) Test(org.junit.jupiter.api.Test)

Example 3 with LinuxDistro

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);
}
Also used : LinuxDistroToForgeMapper(com.synopsys.integration.detectable.detectables.clang.LinuxDistroToForgeMapper) ForgeChooser(com.synopsys.integration.detectable.detectables.clang.ForgeChooser) LinuxDistro(com.synopsys.integration.detectable.detectables.clang.linux.LinuxDistro)

Example 4 with 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));
}
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 5 with LinuxDistro

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());
}
Also used : File(java.io.File) LinuxDistro(com.synopsys.integration.detectable.detectables.clang.linux.LinuxDistro) Test(org.junit.jupiter.api.Test)

Aggregations

LinuxDistro (com.synopsys.integration.detectable.detectables.clang.linux.LinuxDistro)6 Test (org.junit.jupiter.api.Test)5 ForgeChooser (com.synopsys.integration.detectable.detectables.clang.ForgeChooser)3 LinuxDistroToForgeMapper (com.synopsys.integration.detectable.detectables.clang.LinuxDistroToForgeMapper)3 File (java.io.File)3 Forge (com.synopsys.integration.bdio.model.Forge)2 ClangPackageManager (com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManager)2 ClangPackageManagerInfo (com.synopsys.integration.detectable.detectables.clang.packagemanager.ClangPackageManagerInfo)1