From 8ff2c018cc5b3fc69bcd8756695d04b384e46ab8 Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Fri, 19 Apr 2024 15:10:38 +0200 Subject: [PATCH] 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: but was: ``` * Update 8938: move CallContext.unregister as well --- .../java/com/cloud/event/ActionEventInterceptorTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/src/test/java/com/cloud/event/ActionEventInterceptorTest.java b/server/src/test/java/com/cloud/event/ActionEventInterceptorTest.java index 9211ce167591..109cb585d8e5 100644 --- a/server/src/test/java/com/cloud/event/ActionEventInterceptorTest.java +++ b/server/src/test/java/com/cloud/event/ActionEventInterceptorTest.java @@ -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); } @@ -197,6 +198,8 @@ public void teardown() { utils.init(); + CallContext.unregister(); + componentContextMocked.close(); } @@ -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); @@ -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