Exemple #1
0
 public Builder fromOperatingSystem(OperatingSystem in) {
   return family(in.getFamily())
       .name(in.getName())
       .version(in.getVersion())
       .arch(in.getArch())
       .description(in.getDescription())
       .is64Bit(in.is64Bit());
 }
  @Test
  public void testTryStackNatty() {

    String name = "natty-server-cloudimg-amd64";

    Image imageToConvert = Image.builder().id("id-" + name).name(name).build();

    OperatingSystem convertedOs = converterForUbuntu.apply(imageToConvert);

    assertEquals(convertedOs.getName(), imageToConvert.getName());
    assertEquals(convertedOs.getFamily(), OsFamily.UBUNTU);
    assertEquals(convertedOs.getDescription(), imageToConvert.getName());
    assertEquals(convertedOs.getVersion(), "11.04");
    assertEquals(convertedOs.getArch(), null);
    assertTrue(convertedOs.is64Bit());
  }
  @Test(dataProvider = "getOsFamilyValues")
  public void testOsFamilyValues(OsFamily family) {

    Image imageToConvert = Image.builder().id("id-" + family.name()).name(family.name()).build();

    ImageToOperatingSystem converter =
        new ImageToOperatingSystem(new HashMap<OsFamily, Map<String, String>>());

    OperatingSystem convertedOs = converter.apply(imageToConvert);

    assertEquals(convertedOs.getName(), imageToConvert.getName());
    assertEquals(convertedOs.getFamily(), family);
    assertEquals(convertedOs.getDescription(), imageToConvert.getName());
    assertEquals(convertedOs.getVersion(), null);
    assertEquals(convertedOs.getArch(), null);
    assertTrue(convertedOs.is64Bit());
  }
  @Test
  public void testOEL() {
    String name = "Oracle EL";

    Image imageToConvert = Image.builder().id("id-" + name).name(name).build();

    ImageToOperatingSystem converter =
        new ImageToOperatingSystem(new HashMap<OsFamily, Map<String, String>>());

    OperatingSystem convertedOs = converter.apply(imageToConvert);

    assertEquals(convertedOs.getName(), imageToConvert.getName());
    assertEquals(convertedOs.getFamily(), OsFamily.OEL);
    assertEquals(convertedOs.getDescription(), imageToConvert.getName());
    assertEquals(convertedOs.getVersion(), null);
    assertEquals(convertedOs.getArch(), null);
    assertTrue(convertedOs.is64Bit());
  }
  @Test
  public void testWindows98x86() {
    String name = "Windows 98 x86";

    Image imageToConvert = Image.builder().id("id-" + name).name(name).build();

    Map<OsFamily, Map<String, String>> osFamilyMap = new HashMap<OsFamily, Map<String, String>>();
    osFamilyMap.put(OsFamily.WINDOWS, ImmutableMap.of("98", "98"));

    ImageToOperatingSystem converter = new ImageToOperatingSystem(osFamilyMap);

    OperatingSystem convertedOs = converter.apply(imageToConvert);

    assertEquals(convertedOs.getName(), imageToConvert.getName());
    assertEquals(convertedOs.getFamily(), OsFamily.WINDOWS);
    assertEquals(convertedOs.getDescription(), imageToConvert.getName());
    assertEquals(convertedOs.getVersion(), "98");
    assertEquals(convertedOs.getArch(), null);
    assertFalse(convertedOs.is64Bit());
  }