コード例 #1
0
  @Test
  public void isUpdateOperation() throws Exception {
    VmInputs vmInputs = new VmInputs.VmInputsBuilder().withOperation("add").build();
    boolean isUpdate = InputUtils.isUpdateOperation(vmInputs);

    assertFalse(isUpdate);
  }
コード例 #2
0
  @Test
  public void getDiskFileNameString() {
    String testDiskFileNameString =
        InputUtils.getDiskFileNameString("someDataStore", "testVM", "Renamed");

    assertEquals("[someDataStore] testVM/Renamed.vmdk", testDiskFileNameString);
  }
コード例 #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);
  }
コード例 #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");
  }
コード例 #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);
  }
コード例 #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);
  }
コード例 #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);
  }
コード例 #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);
  }
コード例 #9
0
  @Test
  public void getSuccessfullyDefaultDelimiter() {
    String testDelimiter = InputUtils.getDefaultDelimiter("", ",");

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

    assertTrue(isUpdate);
  }
コード例 #15
0
  @Test
  public void isIntFalse() {
    boolean isUpdate = InputUtils.isInt("2147483648");

    assertFalse(isUpdate);
  }