@Before public void setUp() { mockVds(); mockVmDevice(false); doReturn(snapshotsValidator).when(command).getSnapshotsValidator(); doReturn(ValidationResult.VALID).when(snapshotsValidator).vmNotDuringSnapshot(any(Guid.class)); doReturn(ValidationResult.VALID).when(snapshotsValidator).vmNotInPreview(any(Guid.class)); doReturn(storageDomainValidator) .when(command) .getStorageDomainValidator(any(StorageDomain.class)); doReturn(ValidationResult.VALID).when(storageDomainValidator).isDomainExistAndActive(); doReturn(new ArrayList<>()).when(diskVmElementDao).getAllForVm(vmId); doReturn(diskValidator).when(command).getDiskValidator(disk); doReturn(diskVmElementValidator) .when(command) .getDiskVmElementValidator(any(Disk.class), any(DiskVmElement.class)); doReturn(ValidationResult.VALID).when(diskValidator).isDiskExists(); doReturn(ValidationResult.VALID).when(diskValidator).isDiskAttachedToVm(vm); when(osRepository.getDiskHotpluggableInterfaces(any(Integer.class), any(Version.class))) .thenReturn(new HashSet<>(DISK_HOTPLUGGABLE_INTERFACES)); SimpleDependencyInjector.getInstance().bind(VmDeviceUtils.class, vmDeviceUtils); }
@Test public void validateFailedGuestOsIsNotSupported() { mockInterfaceList(); VM vm = mockVmStatusUp(); vm.setVmOs(15); // rhel3x64 createVirtIODisk(); when(osRepository.getOsName(15)).thenReturn("RHEL3x64"); when(osRepository.getDiskHotpluggableInterfaces(any(Integer.class), any(Version.class))) .thenReturn(Collections.emptySet()); ValidateTestUtils.runAndAssertValidateFailure( command, EngineMessage.ACTION_TYPE_FAILED_GUEST_OS_VERSION_IS_NOT_SUPPORTED); }