Yair Zaslavsky has uploaded a new change for review.

Change subject: core: Adding some ctors tests.
......................................................................

core: Adding some ctors tests.

Change-Id: Iea6593f19871e241d19bb6265cb48ffe03ea2eb3
Signed-off-by: Yair Zaslavsky <[email protected]>
---
A 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/CommandCtorsTest.java
1 file changed, 43 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/91/29391/1

diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/CommandCtorsTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/CommandCtorsTest.java
new file mode 100644
index 0000000..adb3a0c
--- /dev/null
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/CommandCtorsTest.java
@@ -0,0 +1,43 @@
+package org.ovirt.engine.core.bll;
+
+import static org.junit.Assert.assertTrue;
+import static org.ovirt.engine.core.utils.MockConfigRule.mockConfig;
+
+import java.lang.reflect.Constructor;
+
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.ovirt.engine.core.bll.context.CommandContext;
+import org.ovirt.engine.core.common.action.VdcActionParametersBase;
+import org.ovirt.engine.core.common.action.VdcActionType;
+import org.ovirt.engine.core.common.config.ConfigValues;
+import org.ovirt.engine.core.utils.MockConfigRule;
+
+public class CommandCtorsTest {
+
+    @ClassRule
+    public static MockConfigRule mcr = new MockConfigRule(
+            mockConfig(ConfigValues.GlusterPeerStatusRetries, 2));
+
+    @Test
+    public void testInternalAnnotationCtors() {
+
+        for (VdcActionType commandType : VdcActionType.values()) {
+            if (!commandType.equals(VdcActionType.Unknown)) {
+                Class<CommandBase<? extends VdcActionParametersBase>> 
commandClass = CommandsFactory.getCommandClass(commandType.toString());
+                if (commandClass != null) {
+                    if 
(commandClass.isAnnotationPresent(InternalCommandAttribute.class)) {
+                        boolean foundContextCtor = false;
+                        for (Constructor<?> ctor : 
commandClass.getConstructors()) {
+                          if 
(ctor.getParameterTypes()[ctor.getParameterTypes().length-1].equals(CommandContext.class))
 {
+                              foundContextCtor = true;
+                          }
+                        }
+                        assertTrue("no context ctor for class " + 
commandClass.getSimpleName(), foundContextCtor);
+                    }
+                }
+            }
+        }
+    }
+
+}


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iea6593f19871e241d19bb6265cb48ffe03ea2eb3
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Yair Zaslavsky <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to