diff options
Diffstat (limited to 'adapters/mso-ve-vnfm-adapter/src/test')
7 files changed, 0 insertions, 567 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 deleted file mode 100644 index 27def126ef..0000000000 --- a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/controller/NotificationControllerTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SO - * ================================================================================ - * Copyright (C) 2019 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.controller; - -import static org.junit.Assert.assertEquals; -import static org.springframework.test.web.client.match.MockRestRequestMatchers.anything; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.so.adapters.vevnfm.configuration.ConfigProperties; -import org.onap.so.adapters.vevnfm.configuration.StartupConfiguration; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.mock.web.MockHttpServletResponse; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.client.MockRestServiceServer; -import org.springframework.test.web.servlet.MockMvc; -import org.springframework.test.web.servlet.MvcResult; -import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; -import org.springframework.test.web.servlet.setup.MockMvcBuilders; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.context.WebApplicationContext; - -@SpringBootTest -@RunWith(SpringRunner.class) -@ActiveProfiles(StartupConfiguration.TEST_PROFILE) -public class NotificationControllerTest { - - private static final String MINIMAL_JSON_CONTENT = "{}"; - private static final int ZERO = 0; - - @Autowired - private ConfigProperties configProperties; - - @Autowired - private WebApplicationContext webApplicationContext; - - @Autowired - private RestTemplate restTemplate; - - private String notification; - private MockMvc mvc; - private MockRestServiceServer mockRestServer; - - @Before - public void init() { - notification = configProperties.getVnfmNotification(); - mvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build(); - mockRestServer = MockRestServiceServer.bindTo(restTemplate).build(); - } - - @Test - public void testReceiveNotification() throws Exception { - // given - final MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(notification) - .contentType(MediaType.APPLICATION_JSON).content(MINIMAL_JSON_CONTENT); - - mockRestServer.expect(anything()).andRespond(withSuccess()); - - // when - final MvcResult mvcResult = mvc.perform(request).andReturn(); - - // then - final MockHttpServletResponse response = mvcResult.getResponse(); - assertEquals(HttpStatus.OK.value(), response.getStatus()); - assertEquals(ZERO, response.getContentLength()); - mockRestServer.verify(); - } -} diff --git a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/provider/AuthorizationHeadersProviderTest.java b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/provider/AuthorizationHeadersProviderTest.java deleted file mode 100644 index f9ae427086..0000000000 --- a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/provider/AuthorizationHeadersProviderTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/*- - * ============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.provider; - -import static org.junit.Assert.*; -import static org.onap.so.configuration.rest.BasicHttpHeadersProvider.AUTHORIZATION_HEADER; -import org.junit.Test; -import org.springframework.http.HttpHeaders; - -public class AuthorizationHeadersProviderTest { - - private static final String AUTHORIZATION_EXAMPLE = "authorization"; - private static final String BLANK_EXAMPLE = "\t\n"; - private static final String EMPTY = ""; - - private final AuthorizationHeadersProvider provider = new AuthorizationHeadersProvider(); - - @Test - public void testSuccessValidAuthorizationAndRemoval() { - final HttpHeaders headers = provider.getHttpHeaders(); - final int size = headers.size(); - - provider.addAuthorization(AUTHORIZATION_EXAMPLE); - assertEquals(size + 1, headers.size()); - assertTrue(headers.containsKey(AUTHORIZATION_HEADER)); - - provider.removeAuthorization(); - assertEquals(size, headers.size()); - assertFalse(headers.containsKey(AUTHORIZATION_HEADER)); - } - - @Test - public void testBlankAuthorization() { - final HttpHeaders headers = provider.getHttpHeaders(); - final int size = headers.size(); - - provider.addAuthorization(BLANK_EXAMPLE); - assertEquals(size, headers.size()); - } - - @Test - public void testEmptyAuthorization() { - final HttpHeaders headers = provider.getHttpHeaders(); - final int size = headers.size(); - - provider.addAuthorization(EMPTY); - assertEquals(size, headers.size()); - } - - @Test - public void testNullAuthorization() { - final HttpHeaders headers = provider.getHttpHeaders(); - final int size = headers.size(); - - provider.addAuthorization(null); - assertEquals(size, headers.size()); - } - - @Test - public void testRemoveAuthorization() { - final HttpHeaders headers = provider.getHttpHeaders(); - final int size = headers.size(); - - provider.removeAuthorization(); - provider.removeAuthorization(); - assertEquals(size, headers.size()); - } -} diff --git a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/StartupServiceTest.java b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/StartupServiceTest.java deleted file mode 100644 index 5d5ffa6555..0000000000 --- a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/StartupServiceTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============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.assertEquals; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import java.util.Collections; -import java.util.List; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import org.onap.aai.domain.yang.EsrSystemInfo; -import org.onap.so.adapters.vevnfm.aai.AaiConnection; -import org.onap.so.adapters.vevnfm.configuration.ConfigProperties; - -@RunWith(MockitoJUnitRunner.class) -public class StartupServiceTest { - - private static final String URL = "rt"; - private static final String ENDPOINT = "localhost"; - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Mock - private ConfigProperties configProperties; - - @Mock - private AaiConnection aaiConnection; - - @InjectMocks - private StartupService startupService; - - @Test - public void testSuccess() throws Exception { - // given - final EsrSystemInfo info = new EsrSystemInfo(); - info.setServiceUrl(URL); - final List<EsrSystemInfo> infos = Collections.singletonList(info); - - when(aaiConnection.receiveVnfm()).thenReturn(infos); - - // when - final List<EsrSystemInfo> systemInfo = startupService.receiveVnfm(); - - // then - verify(aaiConnection).receiveVnfm(); - assertEquals(infos, systemInfo); - } -} diff --git a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/SubscribeSenderTest.java b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/SubscribeSenderTest.java deleted file mode 100644 index 02d664e206..0000000000 --- a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/SubscribeSenderTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * ============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.assertEquals; -import static org.onap.so.adapters.vevnfm.service.SubscribeSender.SLASH; -import static org.springframework.http.HttpHeaders.CONTENT_TYPE; -import static org.springframework.test.web.client.ExpectedCount.once; -import static org.springframework.test.web.client.match.MockRestRequestMatchers.*; -import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import org.hamcrest.CoreMatchers; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.aai.domain.yang.EsrSystemInfo; -import org.onap.so.adapters.vevnfm.configuration.ConfigProperties; -import org.onap.so.adapters.vevnfm.configuration.StartupConfiguration; -import org.onap.so.adapters.vevnfm.exception.VeVnfmException; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.client.MockRestServiceServer; -import org.springframework.web.client.RestTemplate; - -@SpringBootTest -@RunWith(SpringRunner.class) -@ActiveProfiles(StartupConfiguration.TEST_PROFILE) -public class SubscribeSenderTest { - - private static final String URL = "lh"; - private static final String ID = "1a2s3d4f"; - private static final String JSON = "{\"id\":\"" + ID + "\"}"; - - private static final Gson GSON; - - static { - final GsonBuilder builder = new GsonBuilder(); - builder.serializeNulls(); - GSON = builder.create(); - } - - @Autowired - private ConfigProperties configProperties; - - @Autowired - private SubscribeSender sender; - - @Autowired - private RestTemplate restTemplate; - - private String vnfmSubscription; - private MockRestServiceServer mockRestServer; - - @Before - public void init() { - vnfmSubscription = configProperties.getVnfmSubscription(); - mockRestServer = MockRestServiceServer.bindTo(restTemplate).build(); - } - - @Test - public void testSuccess() throws VeVnfmException { - // given - final EsrSystemInfo info = new EsrSystemInfo(); - info.setServiceUrl(URL); - final LccnSubscriptionRequest request = new LccnSubscriptionRequest(); - - mockRestServer.expect(once(), requestTo(SLASH + info.getServiceUrl() + vnfmSubscription)) - .andExpect(header(CONTENT_TYPE, CoreMatchers.containsString(MediaType.APPLICATION_JSON_VALUE))) - .andExpect(method(HttpMethod.POST)).andExpect(content().json(GSON.toJson(request))) - .andRespond(withStatus(HttpStatus.CREATED).body(JSON).contentType(MediaType.APPLICATION_JSON)); - - // when - final String id = sender.send(info, request); - - // then - mockRestServer.verify(); - assertEquals(ID, id); - } -} diff --git a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/SubscriptionSchedulerTest.java b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/SubscriptionSchedulerTest.java deleted file mode 100644 index d3da7c86ec..0000000000 --- a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/SubscriptionSchedulerTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============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.assertNull; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import java.util.Collections; -import java.util.List; -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.aai.domain.yang.EsrSystemInfo; - -@RunWith(MockitoJUnitRunner.class) -public class SubscriptionSchedulerTest { - - private static final String URL = "url"; - private static final String ID = "id044"; - - @Mock - private SubscriberService subscriberService; - - @InjectMocks - private SubscriptionScheduler subscriptionScheduler; - - @Test - public void testFullScenario() throws Exception { - // given - final EsrSystemInfo info = new EsrSystemInfo(); - info.setServiceUrl(URL); - final List<EsrSystemInfo> infos = Collections.singletonList(info); - - when(subscriberService.subscribe(eq(info))).thenReturn(ID); - when(subscriberService.checkSubscription(eq(info), eq(ID))).thenReturn(false); - - // when - subscriptionScheduler.setInfos(infos); - subscriptionScheduler.subscribeTask(); - subscriptionScheduler.checkSubscribeTask(); - - // then - verify(subscriberService).subscribe(info); - verify(subscriberService).checkSubscription(info, ID); - - assertNull(subscriptionScheduler.getEsrIds().get(0).getId()); - } -} 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 deleted file mode 100644 index da5992ee42..0000000000 --- a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/VnfAaiCheckerTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/*- - * ============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.NotificationVnfFilterType; - -@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(NotificationVnfFilterType.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(NotificationVnfFilterType.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(NotificationVnfFilterType.AAI_CHECKED, VNF_ID); - - // then - assertFalse(response); - } - - @Test - public void testNone() { - // when - final boolean response = checker.vnfCheck(NotificationVnfFilterType.NONE, VNF_ID); - - // then - assertFalse(response); - } -} diff --git a/adapters/mso-ve-vnfm-adapter/src/test/resources/application.yaml b/adapters/mso-ve-vnfm-adapter/src/test/resources/application.yaml deleted file mode 100644 index 2c7f67e459..0000000000 --- a/adapters/mso-ve-vnfm-adapter/src/test/resources/application.yaml +++ /dev/null @@ -1,56 +0,0 @@ -# -# Copyright © 2019, 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. - -server: - port: 9098 - -vevnfmadapter: - vnf-filter-json: '{notificationTypes:[VnfLcmOperationOccurrenceNotification],operationStates:[COMPLETED]}' - endpoint: http://so-ve-vnfm-adapter.onap:9098 - -mso: - key: 07a7159d3bf51a0e53be7a8f89699be7 - -aai: - endpoint: https://aai.onap:30233 - auth: 75C4483F9C05E2C33A8602635FA532397EC44AB667A2B64DED4FEE08DD932F2E3C1FEE - -vnfm: - default-endpoint: https://so-vnfm-simulator.onap:9093 - subscription: /vnflcm/v1/subscriptions - notification: /lcm/v1/vnf/instances/notifications - -notification: - vnf-filter-type: ALL - -dmaap: - endpoint: http://message-router.onap:30227 - topic: /events/unauthenticated.DCAE_CL_OUTPUT - closed-loop: - control: - name: ClosedLoopControlName - version: 1.0.2 - -spring: - security: - usercredentials: - - username: admin - openpass: a4b3c2d1 - password: '$2a$10$vU.mWyNTsikAxXIA5c269ewCpAbYTiyMS0m1N.kn4F2CSGEnrKN7K' - role: USER - http: - converters: - preferred-json-mapper: gson |