8989import org .apache .cloudstack .engine .subsystem .api .storage .VolumeDataFactory ;
9090import org .apache .cloudstack .engine .subsystem .api .storage .VolumeInfo ;
9191import org .apache .cloudstack .framework .config .ConfigKey ;
92+ import org .apache .cloudstack .framework .jobs .impl .AsyncJobVO ;
9293import org .apache .cloudstack .storage .datastore .db .PrimaryDataStoreDao ;
9394import org .apache .cloudstack .storage .datastore .db .StoragePoolVO ;
9495import org .apache .cloudstack .storage .template .VnfTemplateManager ;
@@ -1823,35 +1824,35 @@ public void checkExpungeVMPermissionTestAccountIsNotAdminConfigFalseThrowsPermis
18231824 Mockito .doReturn (false ).when (accountManager ).isAdmin (Mockito .anyLong ());
18241825 Mockito .doReturn (false ).when (userVmManagerImpl ).getConfigAllowUserExpungeRecoverVm (Mockito .anyLong ());
18251826
1826- Assert .assertThrows (PermissionDeniedException .class , () -> userVmManagerImpl .checkExpungeVmPermission (accountMock ));
1827+ Assert .assertThrows (PermissionDeniedException .class , () -> userVmManagerImpl .checkExpungeVmPermission (accountMock , null ));
18271828 }
18281829 @ Test
18291830 public void checkExpungeVmPermissionTestAccountIsNotAdminConfigTrueNoApiAccessThrowsPermissionDeniedException () {
18301831 Mockito .doReturn (false ).when (accountManager ).isAdmin (Mockito .anyLong ());
18311832 Mockito .doReturn (true ).when (userVmManagerImpl ).getConfigAllowUserExpungeRecoverVm (Mockito .anyLong ());
1832- doThrow (PermissionDeniedException .class ).when (accountManager ).checkApiAccess (accountMock , "expungeVirtualMachine" );
1833+ doThrow (PermissionDeniedException .class ).when (accountManager ).checkApiAccess (accountMock , "expungeVirtualMachine" , null );
18331834
1834- Assert .assertThrows (PermissionDeniedException .class , () -> userVmManagerImpl .checkExpungeVmPermission (accountMock ));
1835+ Assert .assertThrows (PermissionDeniedException .class , () -> userVmManagerImpl .checkExpungeVmPermission (accountMock , null ));
18351836 }
18361837 @ Test
18371838 public void checkExpungeVmPermissionTestAccountIsNotAdminConfigTrueHasApiAccessReturnNothing () {
18381839 Mockito .doReturn (false ).when (accountManager ).isAdmin (Mockito .anyLong ());
18391840 Mockito .doReturn (true ).when (userVmManagerImpl ).getConfigAllowUserExpungeRecoverVm (Mockito .anyLong ());
18401841
1841- userVmManagerImpl .checkExpungeVmPermission (accountMock );
1842+ userVmManagerImpl .checkExpungeVmPermission (accountMock , null );
18421843 }
18431844 @ Test
18441845 public void checkExpungeVmPermissionTestAccountIsAdminNoApiAccessThrowsPermissionDeniedException () {
18451846 Mockito .doReturn (true ).when (accountManager ).isAdmin (Mockito .anyLong ());
1846- doThrow (PermissionDeniedException .class ).when (accountManager ).checkApiAccess (accountMock , "expungeVirtualMachine" );
1847+ doThrow (PermissionDeniedException .class ).when (accountManager ).checkApiAccess (accountMock , "expungeVirtualMachine" , null );
18471848
1848- Assert .assertThrows (PermissionDeniedException .class , () -> userVmManagerImpl .checkExpungeVmPermission (accountMock ));
1849+ Assert .assertThrows (PermissionDeniedException .class , () -> userVmManagerImpl .checkExpungeVmPermission (accountMock , null ));
18491850 }
18501851 @ Test
18511852 public void checkExpungeVmPermissionTestAccountIsAdminHasApiAccessReturnNothing () {
18521853 Mockito .doReturn (true ).when (accountManager ).isAdmin (Mockito .anyLong ());
18531854
1854- userVmManagerImpl .checkExpungeVmPermission (accountMock );
1855+ userVmManagerImpl .checkExpungeVmPermission (accountMock , null );
18551856 }
18561857
18571858 @ Test
@@ -3661,7 +3662,7 @@ public void testDestroyVm() throws ResourceUnavailableException {
36613662 when (callingAccount .getId ()).thenReturn (accountId );
36623663 when (callContext .getCallingAccount ()).thenReturn (callingAccount );
36633664 when (accountManager .isAdmin (callingAccount .getId ())).thenReturn (true );
3664- doNothing ().when (accountManager ).checkApiAccess (callingAccount , BaseCmd .getCommandNameByClass (ExpungeVMCmd .class ));
3665+ doNothing ().when (accountManager ).checkApiAccess (callingAccount , BaseCmd .getCommandNameByClass (ExpungeVMCmd .class ), null );
36653666 try (MockedStatic <CallContext > mockedCallContext = mockStatic (CallContext .class )) {
36663667 mockedCallContext .when (CallContext ::current ).thenReturn (callContext );
36673668 mockedCallContext .when (() -> CallContext .register (callContext , ApiCommandResourceType .Volume )).thenReturn (callContext );
@@ -3671,6 +3672,9 @@ public void testDestroyVm() throws ResourceUnavailableException {
36713672 when (cmd .getExpunge ()).thenReturn (expunge );
36723673 List <Long > volumeIds = List .of (volumeId );
36733674 when (cmd .getVolumeIds ()).thenReturn (volumeIds );
3675+ AsyncJobVO asyncJobMock = mock (AsyncJobVO .class );
3676+ when (cmd .getJob ()).thenReturn (asyncJobMock );
3677+ when (asyncJobMock .getCmdInfo ()).thenReturn ("{}" );
36743678
36753679 UserVmVO vm = mock (UserVmVO .class );
36763680 when (vm .getId ()).thenReturn (vmId );
0 commit comments