コード例 #1
0
  @Test
  public void testUpdateOvfDiskNotSupported() {
    DiskImage updatedDisk = createDiskImage();
    updatedDisk.setReadOnly(true);
    updatedDisk.setDiskInterface(DiskInterface.IDE);

    DiskImage diskFromDB = createDiskImage();
    diskFromDB.setReadOnly(false);
    diskFromDB.setDiskInterface(DiskInterface.IDE);
    diskFromDB.setContentType(DiskContentType.OVF_STORE);

    when(diskDao.get(diskImageGuid)).thenReturn(diskFromDB);

    initializeCommand(new UpdateVmDiskParameters(vmId, diskImageGuid, updatedDisk));

    when(diskValidator.isDiskUsedAsOvfStore()).thenCallRealMethod();

    CanDoActionTestUtils.runAndAssertCanDoActionFailure(
        command, EngineMessage.ACTION_TYPE_FAILED_OVF_DISK_NOT_SUPPORTED);
  }
コード例 #2
0
  private void canDoActionUpdateDescription(VMStatus status) {
    DiskImage disk = createDiskImage();
    disk.setReadOnly(false);
    when(diskDao.get(diskImageGuid)).thenReturn(disk);
    UpdateVmDiskParameters parameters = createParameters();
    parameters.getDiskInfo().setReadOnly(false);
    disk.setDescription(RandomUtils.instance().nextString(10));
    initializeCommand(parameters, Collections.singletonList(createVm(status)));

    CanDoActionTestUtils.runAndAssertCanDoActionSuccess(command);
  }