Allon Mureinik has uploaded a new change for review.

Change subject: core: Introducing VdcActionUtilsTest
......................................................................

core: Introducing VdcActionUtilsTest

Introducing a new test suite for VdcActionUtils before refactoring.

Change-Id: I87bd69a56814ee6613b4b8fb522e97aaf1aef6fe
Signed-off-by: Allon Mureinik <amure...@redhat.com>
---
A 
backend/manager/modules/common/src/test/java/org/ovirt/engine/core/common/VdcActionUtilsTest.java
1 file changed, 81 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/47/18847/1

diff --git 
a/backend/manager/modules/common/src/test/java/org/ovirt/engine/core/common/VdcActionUtilsTest.java
 
b/backend/manager/modules/common/src/test/java/org/ovirt/engine/core/common/VdcActionUtilsTest.java
new file mode 100644
index 0000000..e4aba70
--- /dev/null
+++ 
b/backend/manager/modules/common/src/test/java/org/ovirt/engine/core/common/VdcActionUtilsTest.java
@@ -0,0 +1,81 @@
+package org.ovirt.engine.core.common;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.runners.Parameterized.Parameters;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.ovirt.engine.core.common.action.VdcActionType;
+import org.ovirt.engine.core.common.businessentities.StorageDomain;
+import org.ovirt.engine.core.common.businessentities.StorageDomainStatus;
+import org.ovirt.engine.core.common.businessentities.StoragePool;
+import org.ovirt.engine.core.common.businessentities.VDS;
+import org.ovirt.engine.core.common.businessentities.VDSStatus;
+import org.ovirt.engine.core.common.businessentities.VM;
+import org.ovirt.engine.core.common.businessentities.VMStatus;
+
+/**
+ * A test case for the {@link VdcActionUtils} class.
+ */
+@RunWith(Parameterized.class)
+public class VdcActionUtilsTest {
+
+    @Parameters
+    public static Collection<Object[]> data() {
+        VM upVm = new VM();
+        upVm.setStatus(VMStatus.Up);
+
+        VM downVm = new VM();
+        downVm.setStatus(VMStatus.Down);
+
+        VDS upVds = new VDS();
+        upVds.setStatus(VDSStatus.Up);
+
+        VDS downVds = new VDS();
+        downVds.setStatus(VDSStatus.Down);
+
+        StorageDomain upStorageDomain = new StorageDomain();
+        upStorageDomain.setStatus(StorageDomainStatus.Active);
+
+        StorageDomain downStorageDomain = new StorageDomain();
+        downStorageDomain.setStatus(StorageDomainStatus.InActive);
+
+        return Arrays.asList(new Object[][] {
+                { upVm, VdcActionType.MigrateVm, true },
+                { downVm, VdcActionType.MigrateVm, false },
+                { upVds, VdcActionType.RefreshHostCapabilities, true },
+                { downVds, VdcActionType.RefreshHostCapabilities, false },
+                { upStorageDomain, VdcActionType.DeactivateStorageDomain, true 
},
+                { downStorageDomain, VdcActionType.DeactivateStorageDomain, 
false },
+                { new StoragePool(), VdcActionType.UpdateStoragePool, true }
+        });
+    }
+
+    public VdcActionUtilsTest(Object toTest, VdcActionType action, boolean 
result) {
+        this.toTest = toTest;
+        this.action = action;
+        this.result = result;
+    }
+
+    /** The object to test. */
+    private Object toTest;
+
+    /** The action to test */
+    private VdcActionType action;
+
+    /**
+     * The expected result.
+     */
+    private boolean result;
+
+    @Test
+    public void canExecute() {
+        assertEquals(result, 
VdcActionUtils.CanExecute(Collections.singletonList(toTest), toTest.getClass(), 
action));
+    }
+
+}


-- 
To view, visit http://gerrit.ovirt.org/18847
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I87bd69a56814ee6613b4b8fb522e97aaf1aef6fe
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Allon Mureinik <amure...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to