Search in sources :

Example 71 with ValidationResult

use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.

the class TransferDiskImageCommandTest method validateCantUploadDiskNotExists.

@Test
public void validateCantUploadDiskNotExists() {
    initializeSuppliedImage();
    doReturn(new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_DISK_NOT_EXIST, "")).when(diskValidator).isDiskExists();
    getCommand().validate();
    ValidateTestUtils.assertValidationMessages("Can't start a transfer for image that doesn't exist.", getCommand(), EngineMessage.ACTION_TYPE_FAILED_DISK_NOT_EXIST);
}
Also used : ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 72 with ValidationResult

use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.

the class AddDiskCommandTest method testValidateFailReadOnlyOnInterface.

@Test
public void testValidateFailReadOnlyOnInterface() {
    command.getParameters().setStorageDomainId(Guid.newGuid());
    mockVm();
    doReturn(true).when(command).isDiskPassPciAndIdeLimit();
    doReturn(new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_INTERFACE_DOES_NOT_SUPPORT_READ_ONLY_ATTR)).when(diskVmElementValidator).isReadOnlyPropertyCompatibleWithInterface();
    ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_INTERFACE_DOES_NOT_SUPPORT_READ_ONLY_ATTR);
}
Also used : ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 73 with ValidationResult

use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.

the class AddDiskCommandTest method testValidateFailsForPassDiscard.

@Test
public void testValidateFailsForPassDiscard() {
    initializeCommand(Guid.newGuid());
    mockVm();
    StoragePool storagePool = new StoragePool();
    storagePool.setCompatibilityVersion(Version.v4_1);
    command.setStoragePool(storagePool);
    command.getParameters().getDiskVmElement().setPassDiscard(true);
    doReturn(new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_PASS_DISCARD_NOT_SUPPORTED_BY_DISK_INTERFACE)).when(diskVmElementValidator).isPassDiscardSupported(any());
    mcr.mockConfigValue(ConfigValues.PassDiscardSupported, command.getStoragePool().getCompatibilityVersion(), true);
    ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_PASS_DISCARD_NOT_SUPPORTED_BY_DISK_INTERFACE);
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Example 74 with ValidationResult

use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.

the class AttachDiskToVmCommandTest method testValidateFailsWhenDiscardIsNotSupported.

@Test
public void testValidateFailsWhenDiscardIsNotSupported() {
    when(diskVmElementValidator.isPassDiscardSupported(any())).thenReturn(new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_PASS_DISCARD_NOT_SUPPORTED_BY_DISK_INTERFACE));
    ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_PASS_DISCARD_NOT_SUPPORTED_BY_DISK_INTERFACE);
}
Also used : ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test)

Example 75 with ValidationResult

use of org.ovirt.engine.core.bll.ValidationResult in project ovirt-engine by oVirt.

the class HotPlugDiskToVmCommandTest method validateBackupStorageDomain.

@Test
public void validateBackupStorageDomain() {
    mockVmStatusUp();
    mockInterfaceList();
    createVirtIODisk();
    initStorageDomain();
    doReturn(new ValidationResult(EngineMessage.ACTION_TYPE_FAILED_VM_DISKS_ON_BACKUP_STORAGE)).when(storageDomainValidator).isNotBackupDomain();
    ValidateTestUtils.runAndAssertValidateFailure(command, EngineMessage.ACTION_TYPE_FAILED_VM_DISKS_ON_BACKUP_STORAGE);
}
Also used : ValidationResult(org.ovirt.engine.core.bll.ValidationResult) Test(org.junit.Test) BaseCommandTest(org.ovirt.engine.core.bll.BaseCommandTest)

Aggregations

ValidationResult (org.ovirt.engine.core.bll.ValidationResult)239 Test (org.junit.Test)132 BaseCommandTest (org.ovirt.engine.core.bll.BaseCommandTest)49 Guid (org.ovirt.engine.core.compat.Guid)40 ArrayList (java.util.ArrayList)31 EngineMessage (org.ovirt.engine.core.common.errors.EngineMessage)31 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)30 Network (org.ovirt.engine.core.common.businessentities.network.Network)21 NetworkAttachment (org.ovirt.engine.core.common.businessentities.network.NetworkAttachment)19 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)16 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)15 CreateOrUpdateBond (org.ovirt.engine.core.common.action.CreateOrUpdateBond)13 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)12 List (java.util.List)11 VM (org.ovirt.engine.core.common.businessentities.VM)11 HashSet (java.util.HashSet)10 FindActiveVmsUsingNetwork (org.ovirt.engine.core.bll.network.FindActiveVmsUsingNetwork)10 GlusterBrickEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity)9 StorageDomainValidator (org.ovirt.engine.core.bll.validator.storage.StorageDomainValidator)7 Disk (org.ovirt.engine.core.common.businessentities.storage.Disk)7