@@ -221,6 +221,9 @@ public class UserVmManagerImplTest {
221221 @ Mock
222222 UserDataManager userDataManager ;
223223
224+ @ Mock
225+ VirtualMachineProfile virtualMachineProfile ;
226+
224227 private static final long vmId = 1l ;
225228 private static final long zoneId = 2L ;
226229 private static final long accountId = 3L ;
@@ -248,6 +251,8 @@ public void beforeTest() {
248251 customParameters .put (VmDetailConstants .ROOT_DISK_SIZE , "123" );
249252 lenient ().doNothing ().when (resourceLimitMgr ).incrementResourceCount (anyLong (), any (Resource .ResourceType .class ));
250253 lenient ().doNothing ().when (resourceLimitMgr ).decrementResourceCount (anyLong (), any (Resource .ResourceType .class ), anyLong ());
254+
255+ Mockito .when (virtualMachineProfile .getId ()).thenReturn (vmId );
251256 }
252257
253258 @ After
@@ -564,11 +569,7 @@ public void verifyIfHypervisorSupportRootdiskSizeOverrideTest() {
564569 int expectedExceptionCounter = hypervisorTypeArray .length - 5 ;
565570
566571 for (int i = 0 ; i < hypervisorTypeArray .length ; i ++) {
567- if (Hypervisor .HypervisorType .KVM == hypervisorTypeArray [i ]
568- || Hypervisor .HypervisorType .XenServer == hypervisorTypeArray [i ]
569- || Hypervisor .HypervisorType .VMware == hypervisorTypeArray [i ]
570- || Hypervisor .HypervisorType .Custom == hypervisorTypeArray [i ]
571- || Hypervisor .HypervisorType .Simulator == hypervisorTypeArray [i ]) {
572+ if (UserVmManagerImpl .ROOT_DISK_SIZE_OVERRIDE_SUPPORTING_HYPERVISORS .contains (hypervisorTypeArray [i ])) {
572573 userVmManagerImpl .verifyIfHypervisorSupportsRootdiskSizeOverride (hypervisorTypeArray [i ]);
573574 } else {
574575 try {
@@ -1042,4 +1043,21 @@ public void testChooseVmMigrationDestinationUsingVolumePoolMapValid() {
10421043 Pair <VMInstanceVO , Host > pair = mockObjectsForChooseVmMigrationDestinationUsingVolumePoolMapTest (false , destinationHost );
10431044 Assert .assertEquals (destinationHost , userVmManagerImpl .chooseVmMigrationDestinationUsingVolumePoolMap (pair .first (), pair .second (), null ));
10441045 }
1046+
1047+ @ Test
1048+ public void testUpdateVncPasswordIfItHasChanged () {
1049+ String vncPassword = "12345678" ;
1050+ userVmManagerImpl .updateVncPasswordIfItHasChanged (vncPassword , vncPassword , virtualMachineProfile );
1051+ Mockito .verify (userVmDao , Mockito .never ()).update (vmId , userVmVoMock );
1052+ }
1053+
1054+ @ Test
1055+ public void testUpdateVncPasswordIfItHasChangedNewPassword () {
1056+ String vncPassword = "12345678" ;
1057+ String newPassword = "87654321" ;
1058+ Mockito .when (userVmVoMock .getId ()).thenReturn (vmId );
1059+ userVmManagerImpl .updateVncPasswordIfItHasChanged (vncPassword , newPassword , virtualMachineProfile );
1060+ Mockito .verify (userVmDao ).findById (vmId );
1061+ Mockito .verify (userVmDao ).update (vmId , userVmVoMock );
1062+ }
10451063}
0 commit comments