Tal Nisan 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, 48 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/74/35074/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..4283ba9 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; @@ -165,6 +167,52 @@ assertFalse("Pattern-based name should not be supported for Template", cmd.validateInputs()); } + + @Test + public void testOneEmptyDiskAlias() { + Map<Guid, DiskImage> diskInfoDestinationMap = new HashMap<>(); + DiskImage disk1 = new DiskImage(); + disk1.setDiskAlias(""); + + diskInfoDestinationMap.put(Guid.newGuid(), disk1); + cmd.diskInfoDestinationMap = diskInfoDestinationMap; + assertFalse(cmd.isDisksAliasNotEmpty()); + } + + @Test + public void testOneOfManyEmptyDiskAlias() { + Map<Guid, DiskImage> diskInfoDestinationMap = new HashMap<>(); + DiskImage disk1 = new DiskImage(); + DiskImage disk2 = new DiskImage(); + + disk1.setDiskAlias(""); + disk2.setDiskAlias("disk"); + + diskInfoDestinationMap.put(Guid.newGuid(), disk1); + diskInfoDestinationMap.put(Guid.newGuid(), disk2); + cmd.diskInfoDestinationMap = diskInfoDestinationMap; + assertFalse(cmd.isDisksAliasNotEmpty()); + } + + + @Test + public void testDiskAliasNotEmpty() { + Map<Guid, DiskImage> diskInfoDestinationMap = new HashMap<>(); + + DiskImage disk1 = new DiskImage(); + DiskImage disk2 = new DiskImage(); + + disk1.setDiskAlias("disk"); + disk2.setDiskAlias("disk"); + + diskInfoDestinationMap.put(Guid.newGuid(), disk1); + diskInfoDestinationMap.put(Guid.newGuid(), disk2); + cmd.diskInfoDestinationMap = diskInfoDestinationMap; + + assertTrue(cmd.isDisksAliasNotEmpty()); + } + + private void setupForStorageTests() { doReturn(true).when(cmd).validateVmNotDuringSnapshot(); vm.setStatus(VMStatus.Down); -- To view, visit http://gerrit.ovirt.org/35074 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I614239c750096b1c3585e0e56bc0d77d328e4c8f Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5 Gerrit-Owner: Tal Nisan <tni...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches