Moti Asayag has uploaded a new change for review.

Change subject: engine: Use postConstruct for initialing command state
......................................................................

engine: Use postConstruct for initialing command state

Change-Id: I4aafdc4f963c85574c8f10691f013dcdadc3e5af
Signed-off-by: Moti Asayag <masa...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommonVmPoolWithVmsCommand.java
M 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddVmPoolWithVmsCommandTest.java
M 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmPoolWithVmsCommandTest.java
3 files changed, 14 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/46/38346/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommonVmPoolWithVmsCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommonVmPoolWithVmsCommand.java
index f2de827..a59ce4d 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommonVmPoolWithVmsCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommonVmPoolWithVmsCommand.java
@@ -75,10 +75,14 @@
 
     public CommonVmPoolWithVmsCommand(T parameters) {
         super(parameters);
+        setVdsGroupId(parameters.getVmPool().getVdsGroupId());
+    }
 
+    @Override
+    protected void postConstruct() {
         Guid templateIdToUse = getParameters().getVmStaticData().getVmtGuid();
         // if set to use latest version, get it from db and use it as template
-        if (parameters.getVmStaticData().isUseLatestVersion()) {
+        if (getParameters().getVmStaticData().isUseLatestVersion()) {
             VmTemplate latest = 
getVmTemplateDAO().getTemplateWithLatestVersionInChain(templateIdToUse);
 
             if (latest != null) {
@@ -100,7 +104,7 @@
         if (diskInfoDestinationMap == null) {
             diskInfoDestinationMap = new HashMap<>();
         }
-        setVdsGroupId(parameters.getVmPool().getVdsGroupId());
+
 
         nameForVmInPoolGenerator = new 
NameForVmInPoolGenerator(getParameters().getVmPool().getName());
     }
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddVmPoolWithVmsCommandTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddVmPoolWithVmsCommandTest.java
index f4a254d..d894e92 100644
--- 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddVmPoolWithVmsCommandTest.java
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/AddVmPoolWithVmsCommandTest.java
@@ -21,12 +21,15 @@
         AddVmPoolWithVmsParameters param =
                 new AddVmPoolWithVmsParameters(vmPools, testVm, VM_COUNT, 
DISK_SIZE);
         param.setStorageDomainId(firstStorageDomainId);
-        return spy(new 
AddVmPoolWithVmsCommand<AddVmPoolWithVmsParameters>(param) {
+        AddVmPoolWithVmsCommand<AddVmPoolWithVmsParameters> command =
+                spy(new 
AddVmPoolWithVmsCommand<AddVmPoolWithVmsParameters>(param) {
             @Override
             protected void initTemplate() {
                 // do nothing - is done here and not with mockito since it's 
called in the ctor
             }
         });
+        command.postConstruct();
+        return command;
     }
 
     @Test
diff --git 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmPoolWithVmsCommandTest.java
 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmPoolWithVmsCommandTest.java
index 1de5b3b..29b11cc 100644
--- 
a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmPoolWithVmsCommandTest.java
+++ 
b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmPoolWithVmsCommandTest.java
@@ -14,12 +14,15 @@
         AddVmPoolWithVmsParameters param = new 
AddVmPoolWithVmsParameters(vmPools, testVm,
                 VM_COUNT, DISK_SIZE);
         param.setStorageDomainId(firstStorageDomainId);
-        return spy(new 
UpdateVmPoolWithVmsCommand<AddVmPoolWithVmsParameters>(param) {
+        UpdateVmPoolWithVmsCommand<AddVmPoolWithVmsParameters> command =
+                spy(new 
UpdateVmPoolWithVmsCommand<AddVmPoolWithVmsParameters>(param) {
             @Override
             protected void initTemplate() {
                 // do nothing - is done here and not with mockito since it's 
called in the ctor
             }
         });
+        command.postConstruct();
+        return command;
     }
 
     @Test


-- 
To view, visit https://gerrit.ovirt.org/38346
To unsubscribe, visit https://gerrit.ovirt.org/settings

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

Reply via email to