diff options
author | Piotr Borelowski <p.borelowski@partner.samsung.com> | 2020-03-27 14:41:15 +0100 |
---|---|---|
committer | Piotr Borelowski <p.borelowski@partner.samsung.com> | 2020-04-16 11:53:43 +0000 |
commit | a09cd217971f6fb97c263cb8414eb67a2d90767b (patch) | |
tree | bb0c4f16fae384764a43e22c10b936013b8a02da /adapters/mso-ve-vnfm-adapter/src/test/java/org | |
parent | 3b7b6db5947744294c9dada101ee5f095d8c3f37 (diff) |
Notification and Subscription filters
Ve-Vnfm (SOL002) Adapter project
- checking if VNF Id is registered in AAI
- checking if list from ESR is not null
- sending the filter in subscription
Issue-ID: SO-2574
Signed-off-by: Piotr Borelowski <p.borelowski@partner.samsung.com>
Change-Id: Iad2c5d9bc2921221fcf0304db73baee6bbaa0c77
Diffstat (limited to 'adapters/mso-ve-vnfm-adapter/src/test/java/org')
2 files changed, 88 insertions, 2 deletions
diff --git a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/controller/NotificationControllerTest.java b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/controller/NotificationControllerTest.java index 974e6ec544..56c53a72e8 100644 --- a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/controller/NotificationControllerTest.java +++ b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/controller/NotificationControllerTest.java @@ -21,7 +21,6 @@ package org.onap.so.adapters.vevnfm.controller; import static org.junit.Assert.assertEquals; -import static org.springframework.test.web.client.ExpectedCount.once; import static org.springframework.test.web.client.match.MockRestRequestMatchers.anything; import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; import org.junit.Before; @@ -77,7 +76,7 @@ public class NotificationControllerTest { final MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(notification) .contentType(MediaType.APPLICATION_JSON).content(MINIMAL_JSON_CONTENT); - mockRestServer.expect(once(), anything()).andRespond(withSuccess()); + mockRestServer.expect(anything()).andRespond(withSuccess()); // when final MvcResult mvcResult = mvc.perform(request).andReturn(); diff --git a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/VnfAaiCheckerTest.java b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/VnfAaiCheckerTest.java new file mode 100644 index 0000000000..84705d10ce --- /dev/null +++ b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/VnfAaiCheckerTest.java @@ -0,0 +1,87 @@ +/*- + * ============LICENSE_START======================================================= + * SO + * ================================================================================ + * Copyright (C) 2020 Samsung. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.adapters.vevnfm.service; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.when; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.so.adapters.vevnfm.aai.AaiConnection; +import org.onap.so.adapters.vevnfm.constant.VnfNotificationFilterType; + +@RunWith(MockitoJUnitRunner.class) +public class VnfAaiCheckerTest { + + private static final String VNF_ID = "t5h78w"; + + @Mock + private AaiConnection aaiConnection; + + @InjectMocks + private VnfAaiChecker checker; + + @Test + public void testAll() { + // when + final boolean response = checker.vnfCheck(VnfNotificationFilterType.ALL, VNF_ID); + + // then + assertTrue(response); + } + + @Test + public void testAaiCheckedPresent() { + // given + when(aaiConnection.checkGenericVnfId(eq(VNF_ID))).thenReturn(true); + + // when + final boolean response = checker.vnfCheck(VnfNotificationFilterType.AAI_CHECKED, VNF_ID); + + // then + assertTrue(response); + } + + @Test + public void testAaiCheckedAbsent() { + // given + when(aaiConnection.checkGenericVnfId(eq(VNF_ID))).thenReturn(false); + + // when + final boolean response = checker.vnfCheck(VnfNotificationFilterType.AAI_CHECKED, VNF_ID); + + // then + assertFalse(response); + } + + @Test + public void testNone() { + // when + final boolean response = checker.vnfCheck(VnfNotificationFilterType.NONE, VNF_ID); + + // then + assertFalse(response); + } +} |