|
64 | 64 | import com.cloud.cluster.dao.ManagementServerHostDao; |
65 | 65 | import com.cloud.domain.DomainVO; |
66 | 66 | import com.cloud.domain.dao.DomainDao; |
| 67 | +import com.cloud.event.EventTypes; |
67 | 68 | import com.cloud.exception.InvalidParameterValueException; |
68 | 69 | import com.cloud.exception.PermissionDeniedException; |
69 | 70 | import com.cloud.user.Account; |
@@ -1262,6 +1263,28 @@ public void addWebhookFilterConflictsWithExisting() { |
1262 | 1263 | webhookApiServiceImpl.addWebhookFilter(cmd); |
1263 | 1264 | } |
1264 | 1265 |
|
| 1266 | + @Test(expected = InvalidParameterValueException.class) |
| 1267 | + public void addWebhookFilterSameEventConflictsWithExisting() { |
| 1268 | + AddWebhookFilterCmd cmd = Mockito.mock(AddWebhookFilterCmd.class); |
| 1269 | + WebhookVO webhook = Mockito.mock(WebhookVO.class); |
| 1270 | + WebhookFilterVO filter = Mockito.mock(WebhookFilterVO.class); |
| 1271 | + |
| 1272 | + Mockito.when(webhook.getId()).thenReturn(1L); |
| 1273 | + Mockito.when(filter.getType()).thenReturn(WebhookFilter.Type.EventType); |
| 1274 | + Mockito.when(filter.getMode()).thenReturn(WebhookFilter.Mode.Include); |
| 1275 | + Mockito.when(filter.getMatchType()).thenReturn(WebhookFilter.MatchType.Exact); |
| 1276 | + Mockito.when(filter.getValue()).thenReturn(EventTypes.EVENT_VM_CREATE); |
| 1277 | + Mockito.when(cmd.getId()).thenReturn(1L); |
| 1278 | + Mockito.when(cmd.getType()).thenReturn(WebhookFilter.Type.EventType.name()); |
| 1279 | + Mockito.when(cmd.getMode()).thenReturn(WebhookFilter.Mode.Exclude.name()); |
| 1280 | + Mockito.when(cmd.getMatchType()).thenReturn(WebhookFilter.MatchType.Exact.name()); |
| 1281 | + Mockito.when(cmd.getValue()).thenReturn(EventTypes.EVENT_VM_CREATE); |
| 1282 | + Mockito.when(webhookDao.findById(1L)).thenReturn(webhook); |
| 1283 | + Mockito.when(webhookFilterDao.listByWebhook(1L)).thenReturn(List.of(filter)); |
| 1284 | + |
| 1285 | + webhookApiServiceImpl.addWebhookFilter(cmd); |
| 1286 | + } |
| 1287 | + |
1265 | 1288 | @Test |
1266 | 1289 | public void deleteWebhookFilterDeletesFilterSuccessfully() { |
1267 | 1290 | DeleteWebhookFilterCmd cmd = Mockito.mock(DeleteWebhookFilterCmd.class); |
|
0 commit comments