Skip to content

Commit 39c0706

Browse files
Update XenServer610WrapperTest.java (#8139)
* Update XenServer610WrapperTest.java * Apply suggestions from code review Co-authored-by: Rohit Yadav <[email protected]> --------- Co-authored-by: Rohit Yadav <[email protected]>
1 parent ec3d0f5 commit 39c0706

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

plugins/hypervisors/xenserver/src/test/java/com/cloud/hypervisor/xenserver/resource/wrapper/xenbase/XenServer610WrapperTest.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ public void testMigrateWithStorageSendCommand() {
259259
final Connection conn = Mockito.mock(Connection.class);
260260
final VirtualMachineTO vmSpec = Mockito.mock(VirtualMachineTO.class);
261261

262-
final VolumeTO volume1 = Mockito.mock(VolumeTO.class);
263-
final VolumeTO volume2 = Mockito.mock(VolumeTO.class);
262+
final VolumeTO volume1 = MockVolumeTO(path);
263+
final VolumeTO volume2 = MockVolumeTO(path);
264264

265265
final SR sr1 = Mockito.mock(SR.class);
266266
final SR sr2 = Mockito.mock(SR.class);
@@ -295,9 +295,6 @@ public void testMigrateWithStorageSendCommand() {
295295
when(xenServer610Resource.getConnection()).thenReturn(conn);
296296
when(vmSpec.getName()).thenReturn(vmName);
297297

298-
when(volume1.getPath()).thenReturn(path);
299-
when(volume2.getPath()).thenReturn(path);
300-
301298
when(nic1.getMac()).thenReturn(mac);
302299
when(nic2.getMac()).thenReturn(mac);
303300

@@ -369,8 +366,8 @@ public void testMigrateWithStorageSendCommandNetException() {
369366
final Connection conn = Mockito.mock(Connection.class);
370367
final VirtualMachineTO vmSpec = Mockito.mock(VirtualMachineTO.class);
371368

372-
final VolumeTO volume1 = Mockito.mock(VolumeTO.class);
373-
final VolumeTO volume2 = Mockito.mock(VolumeTO.class);
369+
final VolumeTO volume1 = MockVolumeTO(path);
370+
final VolumeTO volume2 = MockVolumeTO(path);
374371

375372
final SR sr1 = Mockito.mock(SR.class);
376373
final SR sr2 = Mockito.mock(SR.class);
@@ -399,9 +396,6 @@ public void testMigrateWithStorageSendCommandNetException() {
399396
when(xenServer610Resource.getConnection()).thenReturn(conn);
400397
when(vmSpec.getName()).thenReturn(vmName);
401398

402-
when(volume1.getPath()).thenReturn(path);
403-
when(volume2.getPath()).thenReturn(path);
404-
405399
when(xenServer610Resource.getVDIbyUuid(conn, volume1.getPath())).thenReturn(vdi1);
406400
when(xenServer610Resource.getVDIbyUuid(conn, volume2.getPath())).thenReturn(vdi2);
407401

@@ -481,4 +475,10 @@ public void testXenServer610MigrateVolumeCommandWrapper() {
481475

482476
assertFalse(answer.getResult());
483477
}
478+
479+
VolumeTO MockVolumeTO(String path){
480+
VolumeTO vol = Mockito.mock(VolumeTO.class);
481+
when(vol.getPath()).thenReturn(path);
482+
return vol;
483+
}
484484
}

0 commit comments

Comments
 (0)