|
16 | 16 | // under the License. |
17 | 17 | package org.apache.cloudstack.internallbvmmgr; |
18 | 18 |
|
| 19 | +import static org.mockito.ArgumentMatchers.anyBoolean; |
| 20 | +import static org.mockito.ArgumentMatchers.anyLong; |
| 21 | +import static org.mockito.ArgumentMatchers.anyString; |
19 | 22 | import static org.mockito.ArgumentMatchers.nullable; |
20 | 23 |
|
21 | 24 | import java.lang.reflect.Field; |
|
24 | 27 |
|
25 | 28 | import javax.inject.Inject; |
26 | 29 |
|
| 30 | +import com.cloud.event.ActionEventUtils; |
27 | 31 | import org.apache.cloudstack.context.CallContext; |
| 32 | +import org.apache.cloudstack.framework.config.dao.ConfigurationDao; |
28 | 33 | import org.apache.cloudstack.network.lb.InternalLoadBalancerVMService; |
29 | 34 | import org.junit.After; |
30 | 35 | import org.junit.Before; |
31 | 36 | import org.junit.Test; |
32 | 37 | import org.junit.runner.RunWith; |
| 38 | +import org.mockito.BDDMockito; |
33 | 39 | import org.mockito.Matchers; |
| 40 | +import org.mockito.MockedStatic; |
34 | 41 | import org.mockito.Mockito; |
35 | 42 | import org.springframework.test.context.ContextConfiguration; |
36 | 43 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
@@ -82,6 +89,8 @@ public class InternalLBVMServiceTest extends TestCase { |
82 | 89 | @Inject |
83 | 90 | AccountDao _accountDao; |
84 | 91 |
|
| 92 | + private MockedStatic<ActionEventUtils> actionEventUtilsMocked; |
| 93 | + |
85 | 94 | long validVmId = 1L; |
86 | 95 | long nonExistingVmId = 2L; |
87 | 96 | long nonInternalLbVmId = 3L; |
@@ -120,11 +129,16 @@ public void setUp() { |
120 | 129 | Mockito.when(_domainRouterDao.findById(validVmId)).thenReturn(validVm); |
121 | 130 | Mockito.when(_domainRouterDao.findById(nonExistingVmId)).thenReturn(null); |
122 | 131 | Mockito.when(_domainRouterDao.findById(nonInternalLbVmId)).thenReturn(nonInternalLbVm); |
| 132 | + |
| 133 | + actionEventUtilsMocked = Mockito.mockStatic(ActionEventUtils.class); |
| 134 | + BDDMockito.given(ActionEventUtils.onStartedActionEvent(anyLong(), anyLong(), anyString(), anyString(), anyLong(), anyString(), anyBoolean(), anyLong())) |
| 135 | + .willReturn(1L); |
123 | 136 | } |
124 | 137 |
|
125 | 138 | @Override |
126 | 139 | @After |
127 | 140 | public void tearDown() { |
| 141 | + actionEventUtilsMocked.close(); |
128 | 142 | CallContext.unregister(); |
129 | 143 | } |
130 | 144 |
|
|
0 commit comments