Search in sources :

Example 1 with ForgeChooser

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

use of com.synopsys.integration.detectable.detectables.clang.ForgeChooser 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 3 with ForgeChooser

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

Aggregations

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