test: fix test failures in ActionEventInterceptorTest (#8938)

* test: fix test failures in ActionEventInterceptorTest

```
Error:  Failures:
Error:    ActionEventInterceptorTest.testInterceptComplete:247
Error:    ActionEventInterceptorTest.testInterceptException:261
Error:    ActionEventInterceptorTest.testInterceptStartAsync:234 expected:<Starting VM[.  Id: 0 Name: null]> but was:<Starting VM[]>
```

* Update 8938: move CallContext.unregister as well
This commit is contained in:
Wei Zhou 2024-04-19 15:10:38 +02:00 committed by GitHub
parent e1922da249
commit 8ff2c018cc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 2 deletions

View File

@ -172,6 +172,7 @@ public class ActionEventInterceptorTest {
account.setId(ACCOUNT_ID);
user = new UserVO(1, "testuser", "password", "firstname", "lastName", "email", "timezone",
UUID.randomUUID().toString(), User.Source.UNKNOWN);
CallContext.register(user, account);
Mockito.when(accountDao.findById(ACCOUNT_ID)).thenReturn(account);
}
@ -197,6 +198,8 @@ public class ActionEventInterceptorTest {
utils.init();
CallContext.unregister();
componentContextMocked.close();
}
@ -265,7 +268,6 @@ public class ActionEventInterceptorTest {
@Test
public void testInterceptExceptionResource() throws NoSuchMethodException {
CallContext.register(user, account);
Long resourceId = 1L;
ApiCommandResourceType resourceType = ApiCommandResourceType.VirtualMachine;
CallContext.current().setEventResourceId(resourceId);
@ -282,7 +284,6 @@ public class ActionEventInterceptorTest {
Assert.assertEquals(eventVO.getState(), com.cloud.event.Event.State.Completed);
Assert.assertEquals(eventVO.getResourceId(), resourceId);
Assert.assertEquals(eventVO.getResourceType(), resourceType.toString());
CallContext.unregister();
}
@Test