Ejemplo n.º 1
0
  @Test
  public void isUpdateOperation() throws Exception {
    VmInputs vmInputs = new VmInputs.VmInputsBuilder().withOperation("add").build();
    boolean isUpdate = InputUtils.isUpdateOperation(vmInputs);

    assertFalse(isUpdate);
  }
Ejemplo n.º 2
0
  @Test
  public void getDiskFileNameString() {
    String testDiskFileNameString =
        InputUtils.getDiskFileNameString("someDataStore", "testVM", "Renamed");

    assertEquals("[someDataStore] testVM/Renamed.vmdk", testDiskFileNameString);
  }
Ejemplo n.º 3
0
  @Test
  public void getLongInputException() throws RuntimeException {
    exception.expect(RuntimeException.class);
    exception.expectMessage("The input value must be a long number.");

    InputUtils.getLongInput("Still doesn't work in this way", 0);
  }
Ejemplo n.º 4
0
  @Test
  public void checkValidOperation() throws Exception {
    exception.expect(RuntimeException.class);
    exception.expectMessage(
        "Invalid operation specified for disk device. The disk device can be only added or removed.");

    VmInputs vmInputs =
        new VmInputs.VmInputsBuilder().withDevice("disk").withOperation("update").build();
    InputUtils.checkValidOperation(vmInputs, "disk");
  }
Ejemplo n.º 5
0
  @Test
  public void validateDiskInputsRemove() throws Exception {
    exception.expect(RuntimeException.class);
    exception.expectMessage("The [] is not a valid disk label.");

    VmInputs vmInputs =
        new VmInputs.VmInputsBuilder()
            .withVirtualMachineName("testVM")
            .withOperation("remove")
            .withDevice("disk")
            .withUpdateValue("")
            .build();
    InputUtils.validateDiskInputs(vmInputs);
  }
Ejemplo n.º 6
0
  @Test
  public void getUrlStringSuccess() throws Exception {
    HttpInputs httpInputs =
        new HttpInputs.HttpInputsBuilder()
            .withHost("vc6.subdomain.example.com")
            .withPort("443")
            .withProtocol("")
            .withUsername("")
            .withPassword("")
            .withTrustEveryone("false")
            .build();
    String testUrl = InputUtils.getUrlString(httpInputs);

    assertEquals("https://vc6.subdomain.example.com:443/sdk", testUrl);
  }
Ejemplo n.º 7
0
  @Test
  public void validateDiskInputsAdd() throws Exception {
    exception.expect(RuntimeException.class);
    exception.expectMessage("The disk size must be positive long.");

    VmInputs vmInputs =
        new VmInputs.VmInputsBuilder()
            .withVirtualMachineName("testVM")
            .withOperation("add")
            .withDevice("disk")
            .withLongVmDiskSize("0")
            .withDiskMode("persistent")
            .build();
    InputUtils.validateDiskInputs(vmInputs);
  }
Ejemplo n.º 8
0
  @Test
  public void getUrlStringException() throws Exception {
    exception.expect(Exception.class);
    exception.expectMessage(
        "Unsupported protocol value: [myProtocol]. Valid values are: https, http.");

    HttpInputs httpInputs =
        new HttpInputs.HttpInputsBuilder()
            .withHost("")
            .withPort("8080")
            .withProtocol("myProtocol")
            .withUsername("")
            .withPassword("")
            .withTrustEveryone("true")
            .build();
    InputUtils.getUrlString(httpInputs);
  }
Ejemplo n.º 9
0
  @Test
  public void getSuccessfullyDefaultDelimiter() {
    String testDelimiter = InputUtils.getDefaultDelimiter("", ",");

    assertEquals(",", testDelimiter);
  }
Ejemplo n.º 10
0
 @Test
 public void getLongInputDefault() {
   long testLong = InputUtils.getLongInput("", 1024L);
   assertEquals(1024L, testLong);
 }
Ejemplo n.º 11
0
 @Test
 public void getLongInput() {
   long testLong = InputUtils.getLongInput("4096", 1024L);
   assertEquals(4096L, testLong);
 }
Ejemplo n.º 12
0
 @Test
 public void getIntInputDefault() {
   int testInt = InputUtils.getIntInput("", 1024);
   assertEquals(1024, testInt);
 }
Ejemplo n.º 13
0
 @Test
 public void getIntInput() {
   int testInt = InputUtils.getIntInput("4096", 1024);
   assertEquals(4096, testInt);
 }
Ejemplo n.º 14
0
  @Test
  public void isIntTrue() {
    boolean isUpdate = InputUtils.isInt("2147483647");

    assertTrue(isUpdate);
  }
Ejemplo n.º 15
0
  @Test
  public void isIntFalse() {
    boolean isUpdate = InputUtils.isInt("2147483648");

    assertFalse(isUpdate);
  }