You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2023/11/03 11:48:57 UTC

(cloudstack) branch main updated: Update XenServer610WrapperTest.java (#8139)

This is an automated email from the ASF dual-hosted git repository.

rohit pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/main by this push:
     new 39c0706f1f5 Update XenServer610WrapperTest.java (#8139)
39c0706f1f5 is described below

commit 39c0706f1f5114f6c64bbbcdc2d7a38fbd0318d5
Author: gzhao9 <74...@users.noreply.github.com>
AuthorDate: Fri Nov 3 07:48:48 2023 -0400

    Update XenServer610WrapperTest.java (#8139)
    
    * Update XenServer610WrapperTest.java
    
    * Apply suggestions from code review
    
    Co-authored-by: Rohit Yadav <ro...@gmail.com>
    
    ---------
    
    Co-authored-by: Rohit Yadav <ro...@gmail.com>
---
 .../wrapper/xenbase/XenServer610WrapperTest.java     | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/plugins/hypervisors/xenserver/src/test/java/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/XenServer610WrapperTest.java b/plugins/hypervisors/xenserver/src/test/java/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/XenServer610WrapperTest.java
index 73d2ca6d333..4b2dd1ac3ec 100644
--- a/plugins/hypervisors/xenserver/src/test/java/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/XenServer610WrapperTest.java
+++ b/plugins/hypervisors/xenserver/src/test/java/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/XenServer610WrapperTest.java
@@ -259,8 +259,8 @@ public class XenServer610WrapperTest {
         final Connection conn = Mockito.mock(Connection.class);
         final VirtualMachineTO vmSpec = Mockito.mock(VirtualMachineTO.class);
 
-        final VolumeTO volume1 = Mockito.mock(VolumeTO.class);
-        final VolumeTO volume2 = Mockito.mock(VolumeTO.class);
+        final VolumeTO volume1 = MockVolumeTO(path);
+        final VolumeTO volume2 = MockVolumeTO(path);
 
         final SR sr1 = Mockito.mock(SR.class);
         final SR sr2 = Mockito.mock(SR.class);
@@ -295,9 +295,6 @@ public class XenServer610WrapperTest {
         when(xenServer610Resource.getConnection()).thenReturn(conn);
         when(vmSpec.getName()).thenReturn(vmName);
 
-        when(volume1.getPath()).thenReturn(path);
-        when(volume2.getPath()).thenReturn(path);
-
         when(nic1.getMac()).thenReturn(mac);
         when(nic2.getMac()).thenReturn(mac);
 
@@ -369,8 +366,8 @@ public class XenServer610WrapperTest {
         final Connection conn = Mockito.mock(Connection.class);
         final VirtualMachineTO vmSpec = Mockito.mock(VirtualMachineTO.class);
 
-        final VolumeTO volume1 = Mockito.mock(VolumeTO.class);
-        final VolumeTO volume2 = Mockito.mock(VolumeTO.class);
+        final VolumeTO volume1 = MockVolumeTO(path);
+        final VolumeTO volume2 = MockVolumeTO(path);
 
         final SR sr1 = Mockito.mock(SR.class);
         final SR sr2 = Mockito.mock(SR.class);
@@ -399,9 +396,6 @@ public class XenServer610WrapperTest {
         when(xenServer610Resource.getConnection()).thenReturn(conn);
         when(vmSpec.getName()).thenReturn(vmName);
 
-        when(volume1.getPath()).thenReturn(path);
-        when(volume2.getPath()).thenReturn(path);
-
         when(xenServer610Resource.getVDIbyUuid(conn, volume1.getPath())).thenReturn(vdi1);
         when(xenServer610Resource.getVDIbyUuid(conn, volume2.getPath())).thenReturn(vdi2);
 
@@ -481,4 +475,10 @@ public class XenServer610WrapperTest {
 
         assertFalse(answer.getResult());
     }
+
+    VolumeTO MockVolumeTO(String path){
+        VolumeTO vol = Mockito.mock(VolumeTO.class);
+        when(vol.getPath()).thenReturn(path);
+        return vol;
+    }
 }