Amit Aviram has uploaded a new change for review. Change subject: core: New tests for AddVmTemplateCommand ......................................................................
core: New tests for AddVmTemplateCommand While making a new template based on a VM, providing the template's allocated disks' alias as an empty string is now disabled. The user should not be able to create a template with disks that have an empty alias. This patch adds tests to AddVmTemplateCommandTest to verify that this will be disabled at the backend level. Change-Id: I614239c750096b1c3585e0e56bc0d77d328e4c8f Bug-Url: https://bugzilla.redhat.com/1110304 Signed-off-by: Amit Aviram <aavi...@redhat.com> --- M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddVmTemplateCommandTest.java 1 file changed, 29 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/55/34555/1 diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddVmTemplateCommandTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddVmTemplateCommandTest.java index 61acd10..5585ab4 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddVmTemplateCommandTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddVmTemplateCommandTest.java @@ -12,7 +12,9 @@ import java.util.ArrayList; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.junit.Before; import org.junit.ClassRule; @@ -24,6 +26,7 @@ import org.ovirt.engine.core.bll.validator.MultipleStorageDomainsValidator; import org.ovirt.engine.core.common.action.AddVmTemplateParameters; import org.ovirt.engine.core.common.businessentities.ArchitectureType; +import org.ovirt.engine.core.common.businessentities.Disk; import org.ovirt.engine.core.common.businessentities.DiskImage; import org.ovirt.engine.core.common.businessentities.StoragePool; import org.ovirt.engine.core.common.businessentities.StoragePoolStatus; @@ -165,6 +168,32 @@ assertFalse("Pattern-based name should not be supported for Template", cmd.validateInputs()); } + @Test + public void testEmptyDiskAlias() { + Map<Guid, Disk> diskInfoDestinationMap = new HashMap(); + vm.setDiskMap(diskInfoDestinationMap); + DiskImage disk1 = new DiskImage(); + DiskImage disk2 = new DiskImage(); + disk1.setDiskAlias(""); + disk2.setDiskAlias(""); + + // 1 disk + diskInfoDestinationMap.put(Guid.newGuid(), disk1); + assertFalse(cmd.isDisksAliasNotEmpty()); + + // 2 or more disks + diskInfoDestinationMap.put(Guid.newGuid(), disk2); + assertFalse(cmd.isDisksAliasNotEmpty()); + + // one of many has empty disk alias. + disk1.setDiskAlias("alias"); + assertFalse(cmd.isDisksAliasNotEmpty()); + + disk1.setDiskAlias(""); + disk2.setDiskAlias("alias"); + assertFalse(cmd.isDisksAliasNotEmpty()); + } + private void setupForStorageTests() { doReturn(true).when(cmd).validateVmNotDuringSnapshot(); vm.setStatus(VMStatus.Down); -- To view, visit http://gerrit.ovirt.org/34555 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I614239c750096b1c3585e0e56bc0d77d328e4c8f Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Amit Aviram <aavi...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches