Skip to content

Commit

Permalink
test: fix test failures in ActionEventInterceptorTest (#8938)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
weizhouapache authored Apr 19, 2024
1 parent e1922da commit 8ff2c01
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ public EventVO answer(InvocationOnMock invocation) throws Throwable {
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);
}
Expand All @@ -197,6 +198,8 @@ public void teardown() {

utils.init();

CallContext.unregister();

componentContextMocked.close();
}

Expand Down Expand Up @@ -265,7 +268,6 @@ public void testInterceptException() throws NoSuchMethodException {

@Test
public void testInterceptExceptionResource() throws NoSuchMethodException {
CallContext.register(user, account);
Long resourceId = 1L;
ApiCommandResourceType resourceType = ApiCommandResourceType.VirtualMachine;
CallContext.current().setEventResourceId(resourceId);
Expand All @@ -282,7 +284,6 @@ public void testInterceptExceptionResource() throws NoSuchMethodException {
Assert.assertEquals(eventVO.getState(), com.cloud.event.Event.State.Completed);
Assert.assertEquals(eventVO.getResourceId(), resourceId);
Assert.assertEquals(eventVO.getResourceType(), resourceType.toString());
CallContext.unregister();
}

@Test
Expand Down

0 comments on commit 8ff2c01

Please sign in to comment.