aboutsummaryrefslogtreecommitdiffstats
path: root/vnfapi/provider/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'vnfapi/provider/src/test')
-rw-r--r--vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VNFSDNSvcLogicServiceClientTest.java437
-rw-r--r--vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VfModuleTopologyOperationTest.java388
-rw-r--r--vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfApiProviderTest.java70
-rw-r--r--vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfInstanceTopologyOperationTest.java368
-rw-r--r--vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfSdnUtilTest.java41
-rw-r--r--vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfTopologyOperationRPCTest.java174
-rw-r--r--vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfapiProviderTestBase.java1416
-rw-r--r--vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/DataBrokerUtil.java94
-rw-r--r--vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/MDSALUtil.java113
-rw-r--r--vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/PropBuilder.java62
-rw-r--r--vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/VNFSDNSvcLogicServiceClientMockUtil.java130
-rw-r--r--vnfapi/provider/src/test/resources/proplist.properties22
-rw-r--r--vnfapi/provider/src/test/resources/simplelogger.properties23
13 files changed, 0 insertions, 3338 deletions
diff --git a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VNFSDNSvcLogicServiceClientTest.java b/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VNFSDNSvcLogicServiceClientTest.java
deleted file mode 100644
index 8a8dd446..00000000
--- a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VNFSDNSvcLogicServiceClientTest.java
+++ /dev/null
@@ -1,437 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.sdnc.vnfapi;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.mockito.internal.util.reflection.Whitebox;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.preload.data.PreloadDataBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.service.data.ServiceDataBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vf.module.preload.data.VfModulePreloadDataBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vf.module.service.data.VfModuleServiceDataBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.instance.preload.data.VnfInstancePreloadDataBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.instance.service.data.VnfInstanceServiceDataBuilder;
-import org.slf4j.Logger;
-
-import java.util.Properties;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.*;
-
-public class VNFSDNSvcLogicServiceClientTest {
- private static final String MODE = "mode";
- private static final String MODULE = "module";
- private static final String RPC = "rpc";
- private static final String VERSION = "version";
-
- private Logger mockLog = mock(Logger.class);
- private SvcLogicService mockSvcLogic = mock(SvcLogicService.class);
-
- private VNFSDNSvcLogicServiceClient svcClient;
-
- @Before
- public void setUp() throws Exception {
- svcClient = spy(new VNFSDNSvcLogicServiceClient(mockSvcLogic));
-
- Whitebox.setInternalState(svcClient, "logger", mockLog);
- Whitebox.setInternalState(svcClient, "svcLogic", mockSvcLogic);
- }
-
- @Test
- public void testConstructorWithoutSvcLogicBundle() throws Exception {
- VNFSDNSvcLogicServiceClient client = new VNFSDNSvcLogicServiceClient(mockSvcLogic);
- Assert.assertEquals("Should have set mockSvcLogic",
- mockSvcLogic, Whitebox.getInternalState(client, "svcLogic"));
- }
-
- @Test (expected = SvcLogicException.class)
- public void testHasGraphWithException() throws Exception {
- Mockito.doThrow(new SvcLogicException()).when(mockSvcLogic).hasGraph(MODULE, RPC, VERSION, MODE);
- svcClient.hasGraph(MODULE, RPC, VERSION, MODE);
- }
-
- @Test
- public void testHasGraph() throws Exception {
- Mockito.doReturn(true).when(mockSvcLogic).hasGraph(MODULE, RPC, VERSION, MODE);
- Assert.assertTrue("Should return true", svcClient.hasGraph(MODULE, RPC, VERSION, MODE));
- }
-
- // --------- Test cases for ServiceDataBuilder serviceData-----------------
- @Test (expected = SvcLogicException.class)
- public void testExecuteWithServiceDataBuilderWithException() throws Exception {
- ServiceDataBuilder mockBuilder = mock(ServiceDataBuilder.class);
- Mockito.doThrow(new SvcLogicException()).when(mockSvcLogic).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
-
- svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder);
- }
-
- @Test
- public void testExecuteWithServiceDataBuilder() throws Exception {
- ServiceDataBuilder mockBuilder = mock(ServiceDataBuilder.class);
- svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder);
- Mockito.verify(svcClient, times(1)).execute(
- any(String.class), any(String.class), any(String.class), any(String.class),
- any(ServiceDataBuilder.class), any(Properties.class));
- }
-
- @Test (expected = SvcLogicException.class)
- public void testParamExecuteWithServiceDataBuilderWithException() throws Exception {
- ServiceDataBuilder mockBuilder = mock(ServiceDataBuilder.class);
- Mockito.doThrow(new SvcLogicException()).when(mockSvcLogic).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
-
- svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder, new Properties());
- }
-
- @Test
- public void testParamExecuteWithServiceDataBuilderWithExecutorReturnNull() throws Exception {
- ServiceDataBuilder mockBuilder = mock(ServiceDataBuilder.class);
- Properties properties = svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder, new Properties());
- Assert.assertTrue("Should return null", properties == null);
- Mockito.verify(mockSvcLogic, times(1)).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
- }
-
- @Test
- public void testParamExecuteWithServiceDataBuilderWithExecutorReturnFailure() throws Exception {
- ServiceDataBuilder mockBuilder = mock(ServiceDataBuilder.class);
- Properties resultProps = new Properties();
- resultProps.setProperty(VNFSDNSvcLogicServiceClient.SVC_LOGIC_STATUS_KEY,
- VNFSDNSvcLogicServiceClient.FAILURE_RESULT);
- Mockito.doReturn(resultProps).when(mockSvcLogic).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
- Properties properties = svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder, new Properties());
- Assert.assertEquals("Should return resultProps", resultProps, properties);
- }
-
- @Test
- public void testParamExecuteWithServiceDataBuilder() throws Exception {
- Mockito.doReturn(true).when(mockLog).isDebugEnabled();
- ServiceDataBuilder mockBuilder = mock(ServiceDataBuilder.class);
- Properties resultProps = new Properties();
- resultProps.setProperty("my", "testing");
- Mockito.doReturn(resultProps).when(mockSvcLogic).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
- Properties properties = svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder, new Properties());
- Assert.assertEquals("Should still return resultProps", resultProps, properties);
- }
-
- // --------- Test cases for PreloadDataBuilder serviceData-----------------
- @Test (expected = SvcLogicException.class)
- public void testExecuteWithPreloadDataBuilderWithException() throws Exception {
- PreloadDataBuilder mockBuilder = mock(PreloadDataBuilder.class);
- Mockito.doThrow(new SvcLogicException()).when(mockSvcLogic).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
-
- svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder);
- }
-
- @Test
- public void testExecuteWithPreloadDataBuilder() throws Exception {
- PreloadDataBuilder mockBuilder = mock(PreloadDataBuilder.class);
- svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder);
- Mockito.verify(svcClient, times(1)).execute(
- any(String.class), any(String.class), any(String.class), any(String.class),
- any(PreloadDataBuilder .class), any(Properties.class));
- }
-
- @Test (expected = SvcLogicException.class)
- public void testParamExecuteWithPreloadDataBuilderWithException() throws Exception {
- PreloadDataBuilder mockBuilder = mock(PreloadDataBuilder.class);
- Mockito.doThrow(new SvcLogicException()).when(mockSvcLogic).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
-
- svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder, new Properties());
- }
-
- @Test
- public void testParamExecuteWithPreloadDataBuilderWithExecutorReturnNull() throws Exception {
- PreloadDataBuilder mockBuilder = mock(PreloadDataBuilder.class);
- Properties properties = svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder, new Properties());
- Assert.assertTrue("Should return null", properties == null);
- Mockito.verify(mockSvcLogic, times(1)).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
- }
-
- @Test
- public void testParamExecuteWithPreloadDataBuilderWithExecutorReturnFailure() throws Exception {
- PreloadDataBuilder mockBuilder = mock(PreloadDataBuilder.class);
- Properties resultProps = new Properties();
- resultProps.setProperty(VNFSDNSvcLogicServiceClient.SVC_LOGIC_STATUS_KEY,
- VNFSDNSvcLogicServiceClient.FAILURE_RESULT);
- Mockito.doReturn(resultProps).when(mockSvcLogic).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
- Properties properties = svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder, new Properties());
- Assert.assertEquals("Should return resultProps", resultProps, properties);
- }
-
- @Test
- public void testParamExecuteWithPreloadDataBuilder() throws Exception {
- Mockito.doReturn(true).when(mockLog).isDebugEnabled();
- PreloadDataBuilder mockBuilder = mock(PreloadDataBuilder.class);
- Properties resultProps = new Properties();
- resultProps.setProperty("my", "testing");
- Mockito.doReturn(resultProps).when(mockSvcLogic).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
- Properties properties = svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder, new Properties());
- Assert.assertEquals("Should still return resultProps", resultProps, properties);
- }
-
-
- // --------- Test cases for VfModulePreloadDataBuilder serviceData-----------------
- @Test (expected = SvcLogicException.class)
- public void testExecuteWithVfModulePreloadDataBuilderWithException() throws Exception {
- VfModulePreloadDataBuilder mockBuilder = mock(VfModulePreloadDataBuilder.class);
- Mockito.doThrow(new SvcLogicException()).when(mockSvcLogic).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
-
- svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder);
- }
-
- @Test
- public void testExecuteWithVfModulePreloadDataBuilder() throws Exception {
- VfModulePreloadDataBuilder mockBuilder = mock(VfModulePreloadDataBuilder.class);
- svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder);
- Mockito.verify(svcClient, times(1)).execute(
- any(String.class), any(String.class), any(String.class), any(String.class),
- any(VfModulePreloadDataBuilder .class), any(Properties.class));
- }
-
- @Test (expected = SvcLogicException.class)
- public void testParamExecuteWithVfModulePreloadDataBuilderWithException() throws Exception {
- VfModulePreloadDataBuilder mockBuilder = mock(VfModulePreloadDataBuilder.class);
- Mockito.doThrow(new SvcLogicException()).when(mockSvcLogic).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
-
- svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder, new Properties());
- }
-
- @Test
- public void testParamExecuteWithVfModulePreloadDataBuilderWithExecutorReturnNull() throws Exception {
- VfModulePreloadDataBuilder mockBuilder = mock(VfModulePreloadDataBuilder.class);
- Properties properties = svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder, new Properties());
- Assert.assertTrue("Should return null", properties == null);
- Mockito.verify(mockSvcLogic, times(1)).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
- }
-
- @Test
- public void testParamExecuteWithVfModulePreloadDataBuilderWithExecutorReturnFailure() throws Exception {
- VfModulePreloadDataBuilder mockBuilder = mock(VfModulePreloadDataBuilder.class);
- Properties resultProps = new Properties();
- resultProps.setProperty(VNFSDNSvcLogicServiceClient.SVC_LOGIC_STATUS_KEY,
- VNFSDNSvcLogicServiceClient.FAILURE_RESULT);
- Mockito.doReturn(resultProps).when(mockSvcLogic).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
- Properties properties = svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder, new Properties());
- Assert.assertEquals("Should return resultProps", resultProps, properties);
- }
-
- @Test
- public void testParamExecuteWithVfModulePreloadDataBuilder() throws Exception {
- Mockito.doReturn(true).when(mockLog).isDebugEnabled();
- VfModulePreloadDataBuilder mockBuilder = mock(VfModulePreloadDataBuilder.class);
- Properties resultProps = new Properties();
- resultProps.setProperty("my", "testing");
- Mockito.doReturn(resultProps).when(mockSvcLogic).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
- Properties properties = svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder, new Properties());
- Assert.assertEquals("Should still return resultProps", resultProps, properties);
- }
-
- // --------- Test cases for VfModuleServiceDataBuilder serviceData-----------------
- @Test (expected = SvcLogicException.class)
- public void testExecuteWithVfModuleServiceDataBuilderWithException() throws Exception {
- VfModuleServiceDataBuilder mockBuilder = mock(VfModuleServiceDataBuilder.class);
- Mockito.doThrow(new SvcLogicException()).when(mockSvcLogic).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
-
- svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder);
- }
-
- @Test
- public void testExecuteWithVfModuleServiceDataBuilder() throws Exception {
- VfModuleServiceDataBuilder mockBuilder = mock(VfModuleServiceDataBuilder.class);
- svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder);
- Mockito.verify(svcClient, times(1)).execute(
- any(String.class), any(String.class), any(String.class), any(String.class),
- any(VfModuleServiceDataBuilder .class), any(Properties.class));
- }
-
- @Test (expected = SvcLogicException.class)
- public void testParamExecuteWithVfModuleServiceDataBuilderWithException() throws Exception {
- VfModuleServiceDataBuilder mockBuilder = mock(VfModuleServiceDataBuilder.class);
- Mockito.doThrow(new SvcLogicException()).when(mockSvcLogic).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
-
- svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder, new Properties());
- }
-
- @Test
- public void testParamExecuteWithVfModuleServiceDataBuilderWithExecutorReturnNull() throws Exception {
- VfModuleServiceDataBuilder mockBuilder = mock(VfModuleServiceDataBuilder.class);
- Properties properties = svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder, new Properties());
- Assert.assertTrue("Should return null", properties == null);
- Mockito.verify(mockSvcLogic, times(1)).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
- }
-
- @Test
- public void testParamExecuteWithVfModuleServiceDataBuilderWithExecutorReturnFailure() throws Exception {
- VfModuleServiceDataBuilder mockBuilder = mock(VfModuleServiceDataBuilder.class);
- Properties resultProps = new Properties();
- resultProps.setProperty(VNFSDNSvcLogicServiceClient.SVC_LOGIC_STATUS_KEY,
- VNFSDNSvcLogicServiceClient.FAILURE_RESULT);
- Mockito.doReturn(resultProps).when(mockSvcLogic).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
- Properties properties = svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder, new Properties());
- Assert.assertEquals("Should return resultProps", resultProps, properties);
- }
-
- @Test
- public void testParamExecuteWithVfModuleServiceDataBuilder() throws Exception {
- Mockito.doReturn(true).when(mockLog).isDebugEnabled();
- VfModuleServiceDataBuilder mockBuilder = mock(VfModuleServiceDataBuilder.class);
- Properties resultProps = new Properties();
- resultProps.setProperty("my", "testing");
- Mockito.doReturn(resultProps).when(mockSvcLogic).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
- Properties properties = svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder, new Properties());
- Assert.assertEquals("Should still return resultProps", resultProps, properties);
- }
-
- // --------- Test cases for VnfInstancePreloadDataBuilder serviceData-----------------
- @Test (expected = SvcLogicException.class)
- public void testExecuteWithVnfInstancePreloadDataBuilderWithException() throws Exception {
- VnfInstancePreloadDataBuilder mockBuilder = mock(VnfInstancePreloadDataBuilder.class);
- Mockito.doThrow(new SvcLogicException()).when(mockSvcLogic).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
-
- svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder);
- }
-
- @Test
- public void testExecuteWithVnfInstancePreloadDataBuilder() throws Exception {
- VnfInstancePreloadDataBuilder mockBuilder = mock(VnfInstancePreloadDataBuilder.class);
- svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder);
- Mockito.verify(svcClient, times(1)).execute(
- any(String.class), any(String.class), any(String.class), any(String.class),
- any(VnfInstancePreloadDataBuilder .class), any(Properties.class));
- }
-
- @Test (expected = SvcLogicException.class)
- public void testParamExecuteWithVnfInstancePreloadDataBuilderWithException() throws Exception {
- VnfInstancePreloadDataBuilder mockBuilder = mock(VnfInstancePreloadDataBuilder.class);
- Mockito.doThrow(new SvcLogicException()).when(mockSvcLogic).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
-
- svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder, new Properties());
- }
-
- @Test
- public void testParamExecuteWithVnfInstancePreloadDataBuilderWithExecutorReturnNull() throws Exception {
- VnfInstancePreloadDataBuilder mockBuilder = mock(VnfInstancePreloadDataBuilder.class);
- Properties properties = svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder, new Properties());
- Assert.assertTrue("Should return null", properties == null);
- Mockito.verify(mockSvcLogic, times(1)).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
- }
-
- @Test
- public void testParamExecuteWithVnfInstancePreloadDataBuilderWithExecutorReturnFailure() throws Exception {
- VnfInstancePreloadDataBuilder mockBuilder = mock(VnfInstancePreloadDataBuilder.class);
- Properties resultProps = new Properties();
- resultProps.setProperty(VNFSDNSvcLogicServiceClient.SVC_LOGIC_STATUS_KEY,
- VNFSDNSvcLogicServiceClient.FAILURE_RESULT);
- Mockito.doReturn(resultProps).when(mockSvcLogic).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
- Properties properties = svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder, new Properties());
- Assert.assertEquals("Should return resultProps", resultProps, properties);
- }
-
- @Test
- public void testParamExecuteWithVnfInstancePreloadDataBuilder() throws Exception {
- Mockito.doReturn(true).when(mockLog).isDebugEnabled();
- VnfInstancePreloadDataBuilder mockBuilder = mock(VnfInstancePreloadDataBuilder.class);
- Properties resultProps = new Properties();
- resultProps.setProperty("my", "testing");
- Mockito.doReturn(resultProps).when(mockSvcLogic).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
- Properties properties = svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder, new Properties());
- Assert.assertEquals("Should still return resultProps", resultProps, properties);
- }
-
- // --------- Test cases for VnfInstanceServiceDataBuilder serviceData-----------------
- @Test (expected = SvcLogicException.class)
- public void testExecuteWithVnfInstanceServiceDataBuilderWithException() throws Exception {
- VnfInstanceServiceDataBuilder mockBuilder = mock(VnfInstanceServiceDataBuilder.class);
- Mockito.doThrow(new SvcLogicException()).when(mockSvcLogic).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
-
- svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder);
- }
-
- @Test
- public void testExecuteWithVnfInstanceServiceDataBuilder() throws Exception {
- VnfInstanceServiceDataBuilder mockBuilder = mock(VnfInstanceServiceDataBuilder.class);
- svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder);
- Mockito.verify(svcClient, times(1)).execute(
- any(String.class), any(String.class), any(String.class), any(String.class),
- any(VnfInstanceServiceDataBuilder .class), any(Properties.class));
- }
-
- @Test (expected = SvcLogicException.class)
- public void testParamExecuteWithVnfInstanceServiceDataBuilderWithException() throws Exception {
- VnfInstanceServiceDataBuilder mockBuilder = mock(VnfInstanceServiceDataBuilder.class);
- Mockito.doThrow(new SvcLogicException()).when(mockSvcLogic).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
-
- svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder, new Properties());
- }
-
- @Test
- public void testParamExecuteWithVnfInstanceServiceDataBuilderWithExecutorReturnNull() throws Exception {
- VnfInstanceServiceDataBuilder mockBuilder = mock(VnfInstanceServiceDataBuilder.class);
- Properties properties = svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder, new Properties());
- Assert.assertTrue("Should return null", properties == null);
- Mockito.verify(mockSvcLogic, times(1)).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
- }
-
- @Test
- public void testParamExecuteWithVnfInstanceServiceDataBuilderWithExecutorReturnFailure() throws Exception {
- VnfInstanceServiceDataBuilder mockBuilder = mock(VnfInstanceServiceDataBuilder.class);
- Properties resultProps = new Properties();
- resultProps.setProperty(VNFSDNSvcLogicServiceClient.SVC_LOGIC_STATUS_KEY,
- VNFSDNSvcLogicServiceClient.FAILURE_RESULT);
- Mockito.doReturn(resultProps).when(mockSvcLogic).execute(
- any(String.class), any(String.class), any(String.class), any(String.class), any(Properties.class));
- Properties properties = svcClient.execute(MODULE, RPC, VERSION, MODE, mockBuilder, new Properties());
- Assert.assertEquals("Should return resultProps", resultProps, properties);
- }
-
-} \ No newline at end of file
diff --git a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VfModuleTopologyOperationTest.java b/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VfModuleTopologyOperationTest.java
deleted file mode 100644
index beefb2ff..00000000
--- a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VfModuleTopologyOperationTest.java
+++ /dev/null
@@ -1,388 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.sdnc.vnfapi;
-
-import com.google.common.util.concurrent.CheckedFuture;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.mockito.Mockito;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMDataBrokerAdapter;
-import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
-import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTestCustomizer;
-import org.opendaylight.controller.md.sal.binding.test.ConcurrentDataBrokerTestCustomizer;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VfModuleTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VfModuleTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.request.information.RequestInformation;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.request.information.RequestInformation.RequestAction;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.request.information.RequestInformationBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vf.module.request.information.VfModuleRequestInformation;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vf.module.request.information.VfModuleRequestInformationBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vf.module.service.data.VfModuleServiceDataBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VfModuleTopologyOperationInputBuilder;
-
-import java.util.Properties;
-import java.util.concurrent.ExecutionException;
-
-class VfModuleExceptionThrowerConfigurator {
- private boolean shouldThrowExceptionDuringTransactionPut;
-
- public VfModuleExceptionThrowerConfigurator() {
- this.shouldThrowExceptionDuringTransactionPut = true;
- }
-
- public boolean shouldThrowExceptionDuringTransactionPut() {
- return shouldThrowExceptionDuringTransactionPut;
- }
-
- public void setShouldThrowExceptionDuringTransactionPut(boolean shouldThrowExceptionDuringTransactionPut) {
- this.shouldThrowExceptionDuringTransactionPut = shouldThrowExceptionDuringTransactionPut;
- }
-}
-
-class VfModuleDataBrokerErrorMsgConfigurator {
- static public String JAVA_LANG_RUNTIME_EXCEPTION = "java.lang.RuntimeException: ";
- static public String TRANSACTION_WRITE_ERROR = "transaction-write-error";
-}
-
-class VfModuleDataBrokerStab extends BindingDOMDataBrokerAdapter {
- VfModuleExceptionThrowerConfigurator exceptionThrowerConfigurator;
-
- public VfModuleDataBrokerStab(final DOMDataBroker domDataBroker,
- final BindingToNormalizedNodeCodec codec, VfModuleExceptionThrowerConfigurator exceptionThrowerConfigurator) {
- super(domDataBroker, codec);
- this.exceptionThrowerConfigurator = exceptionThrowerConfigurator;
-
- }
-
- @Override
- public WriteTransaction newWriteOnlyTransaction() {
- if (exceptionThrowerConfigurator.shouldThrowExceptionDuringTransactionPut()) {
- return newThrowingExceptionWriteOnlyTransaction();
- }
- return newNotThrowingExceptionWriteOnlyTransaction();
- }
-
- private WriteTransaction newThrowingExceptionWriteOnlyTransaction() {
- WriteTransaction mockWriteTransaction = Mockito.mock(WriteTransaction.class);
- Mockito.doThrow(new RuntimeException(VfModuleDataBrokerErrorMsgConfigurator.TRANSACTION_WRITE_ERROR))
- .when(mockWriteTransaction).put(Mockito.any(), Mockito.any(), Mockito.any());
- return mockWriteTransaction;
- }
-
- private WriteTransaction newNotThrowingExceptionWriteOnlyTransaction() {
- WriteTransaction mockWriteTransaction = Mockito.mock(WriteTransaction.class);
- CheckedFuture<Void, TransactionCommitFailedException> mockCheckedFuture =
- Mockito.mock(CheckedFuture.class);
- Mockito.doNothing().when(mockWriteTransaction).put(Mockito.any(), Mockito.any(), Mockito.any());
- Mockito.doReturn(mockCheckedFuture).when(mockWriteTransaction).submit();
- return mockWriteTransaction;
- }
-}
-
-class VfModuleProviderDataBrokerTestCustomizer extends ConcurrentDataBrokerTestCustomizer {
- VfModuleExceptionThrowerConfigurator exceptionThrowerConfigurator;
-
- public VfModuleProviderDataBrokerTestCustomizer(VfModuleExceptionThrowerConfigurator exceptionThrowerConfigurator) {
- super(false);
- this.exceptionThrowerConfigurator = exceptionThrowerConfigurator;
- }
-
- public DataBroker createDataBroker() {
- return new VfModuleDataBrokerStab(createDOMDataBroker(),
- super.getBindingToNormalized(), this.exceptionThrowerConfigurator);
- }
-}
-
-@RunWith(MockitoJUnitRunner.class)
-public class VfModuleTopologyOperationTest extends VnfApiProviderTest {
- protected static final Logger LOG = LoggerFactory.getLogger(VfModuleTopologyOperationTest.class);
-
- private static final String INVALID_VFMODULEID = "invalid input, null or empty vf-module-id";
- private static final String INVALID_VNFINSTANCEID = "invalid input, null or empty vnf-instance-id";
- private static final String NO_SERVICE_LOGIC = "No service logic active for VNF-API: \'vf-module-topology-operation\'";
- private static final String VF_MODULE_ID = "vfModule1";
- private static final String VNF_INSTANCE_ID = "vnfInstance1";
- private static final String PRELOAD_NAME = "preloadName";
- private static final String PRELOAD_TYPE = "preloadType";
- private static final String ERROR_CODE = "error-code";
-
- private static final String ERROR_MESSAGE = "error-message";
- private static final String ACK_FINAL = "ack-final";
- private static final String SVC_OPERATION = "vf-module-topology-operation";
-
- private VfModuleExceptionThrowerConfigurator exceptionThrowerConfigurator;
-
- @Override
- protected AbstractDataBrokerTestCustomizer createDataBrokerTestCustomizer() {
- this.exceptionThrowerConfigurator = new VfModuleExceptionThrowerConfigurator();
- return new VfModuleProviderDataBrokerTestCustomizer(this.exceptionThrowerConfigurator);
- }
-
- @Before
- public void setUp() throws Exception {
- super.setUp();
- svcClient.setScvOperation(SVC_OPERATION);
- }
-
- @Test
- public void vfModuleTopologyOperationInputIsNull() throws Exception {
- VfModuleTopologyOperationInput input = null;
- checkVfModuleTopologyOperation(input, "403", INVALID_VFMODULEID);
- }
-
- @Test
- public void vfModuleTopologyOperationInput_VfModuleRequestInformationIsNull() throws Exception {
- VfModuleTopologyOperationInputBuilder builder = new VfModuleTopologyOperationInputBuilder();
- builder.setVfModuleRequestInformation(null);
- VfModuleTopologyOperationInput input = builder.build();
- checkVfModuleTopologyOperation(input, "403", INVALID_VFMODULEID);
- }
-
- @Test
- public void vfModuleTopologyOperationInput_getVfModuleRequestInformationVfModuleIdIsNull() throws Exception {
- RequestInformation reqInfo = createRequestInformation(RequestAction.PreloadVfModuleRequest);
- VfModuleRequestInformation vfModuleRequestInformation = createVfModuleRequestInformation(VNF_INSTANCE_ID, null);
- VfModuleTopologyOperationInputBuilder builder = createVfModuleTopologyOperationInputBuilder(vfModuleRequestInformation, reqInfo);
- VfModuleTopologyOperationInput input = builder.build();
- checkVfModuleTopologyOperation(input, "403", INVALID_VFMODULEID);
- }
-
- @Test
- public void vfModuleTopologyOperationInput_VfModuleRequestInformationVfModuleIdIsZero() throws Exception {
- VfModuleTopologyOperationInputBuilder builder = createVfModuleTopologyOperationInputBuilder(createVfModuleRequestInformation(VNF_INSTANCE_ID,""), createRequestInformation(RequestAction.PreloadVfModuleRequest));
- VfModuleTopologyOperationInput input = builder.build();
- checkVfModuleTopologyOperation(input, "403", INVALID_VFMODULEID);
- }
-
- @Test
- public void vfModuleTopologyOperationInput_getVfModuleRequestInformationVnfInstanceIdIsNull() throws Exception {
- RequestInformation reqInfo = createRequestInformation(RequestAction.PreloadVfModuleRequest);
- VfModuleRequestInformation vfModuleRequestInformation = createVfModuleRequestInformation(null, VF_MODULE_ID);
- VfModuleTopologyOperationInputBuilder builder = createVfModuleTopologyOperationInputBuilder(vfModuleRequestInformation, reqInfo);
- VfModuleTopologyOperationInput input = builder.build();
- checkVfModuleTopologyOperation(input, "403", INVALID_VNFINSTANCEID);
- }
-
- @Test
- public void vfModuleTopologyOperationInput_VfModuleRequestInformationVnfInstanceIdIsZero() throws Exception {
- VfModuleTopologyOperationInputBuilder builder = createVfModuleTopologyOperationInputBuilder(createVfModuleRequestInformation("",VF_MODULE_ID), createRequestInformation(RequestAction.PreloadVfModuleRequest));
- VfModuleTopologyOperationInput input = builder.build();
- checkVfModuleTopologyOperation(input, "403", INVALID_VNFINSTANCEID);
- }
-
- @Test
- public void vfModuleTopologyOperationInput_svcLogicClientHasGrapheReturnFalse() throws Exception {
- VfModuleTopologyOperationInputBuilder builder = createVfModuleTopologyOperationInputBuilder(createVfModuleRequestInformation(VNF_INSTANCE_ID, VF_MODULE_ID), createRequestInformation(RequestAction.PreloadVfModuleRequest));
- VfModuleTopologyOperationInput input = builder.build();
- setReturnForSvcLogicServiceClientHasGraph(false);
- checkVfModuleTopologyOperation(input, "503", NO_SERVICE_LOGIC);
- }
-
- @Test
- public void vfModuleTopologyOperationInput_svcLogicClientExecuteThrowsSvcLogicException() throws Exception {
- VfModuleTopologyOperationInputBuilder builder = createVfModuleTopologyOperationInputBuilder(createVfModuleRequestInformation(VNF_INSTANCE_ID, VF_MODULE_ID), createRequestInformation(RequestAction.PreloadVfModuleRequest));
- VfModuleTopologyOperationInput input = builder.build();
- setReturnForSvcLogicServiceClientHasGraph(true);
- setMockVNFSDNSvcLogicServiceClientToThrowException(SvcLogicException.class);
- checkVfModuleTopologyOperation(input, "500", null);
- }
-
- @Test
- public void vfModuleTopologyOperationInput_svcLogicClientExecuteThrowsException() throws Exception {
- VfModuleTopologyOperationInputBuilder builder = createVfModuleTopologyOperationInputBuilder(createVfModuleRequestInformation(VNF_INSTANCE_ID, VF_MODULE_ID), createRequestInformation(RequestAction.PreloadVfModuleRequest));
- VfModuleTopologyOperationInput input = builder.build();
-
- setReturnForSvcLogicServiceClientHasGraph(true);
- setMockVNFSDNSvcLogicServiceClientToThrowException(Exception.class);
- checkVfModuleTopologyOperation(input, "500", null);
- }
-
- @Test
- public void vfModuleTopologyOperationInput_svcLogicClientExecuteReturnsNotNull() throws Exception {
- VfModuleTopologyOperationInputBuilder builder = createVfModuleTopologyOperationInputBuilder(createVfModuleRequestInformation(VNF_INSTANCE_ID, VF_MODULE_ID), createRequestInformation(RequestAction.PreloadVfModuleRequest));
- VfModuleTopologyOperationInput input = builder.build();
-
- Properties properties = prop().set(ERROR_CODE, "500")
- .set(ERROR_MESSAGE, ERROR_MESSAGE)
- .set(ACK_FINAL, "Y")
- .build();
-
- setReturnForSvcLogicServiceClientHasGraph(true);
- setReturnForSvcLogicServiceClientExecute(properties);
- checkVfModuleTopologyOperation(input, "500", ERROR_MESSAGE);
- }
-
- @Test
- public void vfModuleTopologyOperationInput_svcLogicClientExecuteReturnsNull() throws Exception {
- VfModuleTopologyOperationInputBuilder builder = createVfModuleTopologyOperationInputBuilder(createVfModuleRequestInformation(VNF_INSTANCE_ID, VF_MODULE_ID), createRequestInformation(RequestAction.PreloadVfModuleRequest));
- VfModuleTopologyOperationInput input = builder.build();
-
- setReturnForSvcLogicServiceClientHasGraph(true);
- setReturnForSvcLogicServiceClientExecute(null);
- String expectedErrorMsg = VfModuleDataBrokerErrorMsgConfigurator.JAVA_LANG_RUNTIME_EXCEPTION
- + VfModuleDataBrokerErrorMsgConfigurator.TRANSACTION_WRITE_ERROR;
- checkVfModuleTopologyOperation(input, "500", expectedErrorMsg);
- }
-
- @Test
- public void vfModuleTopologyOperationInput_ActivateNoErrorDuringTransactionWriting() throws Exception {
- VfModuleTopologyOperationInputBuilder builder = createVfModuleTopologyOperationInputBuilder(createVfModuleRequestInformation(VNF_INSTANCE_ID, VF_MODULE_ID), createRequestInformation(RequestAction.VfModuleActivateRequest));
- VfModuleTopologyOperationInput input = builder.build();
-
- setReturnForSvcLogicServiceClientHasGraph(true);
- setReturnForSvcLogicServiceClientExecute(null);
- exceptionThrowerConfigurator.setShouldThrowExceptionDuringTransactionPut(false);
- checkVfModuleTopologyOperation(input, "200", null);
- }
-
- @Test
- public void vfModuleTopologyOperationInput_ChangeNoErrorDuringTransactionWriting() throws Exception {
- VfModuleTopologyOperationInputBuilder builder = createVfModuleTopologyOperationInputBuilder(createVfModuleRequestInformation(VNF_INSTANCE_ID, VF_MODULE_ID), createRequestInformation(RequestAction.ChangeVfModuleActivateRequest));
- VfModuleTopologyOperationInput input = builder.build();
-
- setReturnForSvcLogicServiceClientHasGraph(true);
- setReturnForSvcLogicServiceClientExecute(null);
- exceptionThrowerConfigurator.setShouldThrowExceptionDuringTransactionPut(false);
- checkVfModuleTopologyOperation(input, "200", null);
- }
-
- @Test
- public void vfModuleTopologyOperationInput_DisconnectNoErrorDuringTransactionWriting() throws Exception {
- VfModuleTopologyOperationInputBuilder builder = createVfModuleTopologyOperationInputBuilder(createVfModuleRequestInformation(VNF_INSTANCE_ID, VF_MODULE_ID), createRequestInformation(RequestAction.DisconnectVfModuleRequest));
- VfModuleTopologyOperationInput input = builder.build();
-
- setReturnForSvcLogicServiceClientHasGraph(true);
- setReturnForSvcLogicServiceClientExecute(null);
- exceptionThrowerConfigurator.setShouldThrowExceptionDuringTransactionPut(false);
- checkVfModuleTopologyOperation(input, "200", null);
- }
-
- @Test
- public void vfModuleTopologyOperationInput_PreloadNoErrorDuringTransactionWriting() throws Exception {
- VfModuleTopologyOperationInputBuilder builder = createVfModuleTopologyOperationInputBuilder(createVfModuleRequestInformation(VNF_INSTANCE_ID, VF_MODULE_ID), createRequestInformation(RequestAction.PreloadVfModuleRequest));
- VfModuleTopologyOperationInput input = builder.build();
-
- setReturnForSvcLogicServiceClientHasGraph(true);
- setReturnForSvcLogicServiceClientExecute(null);
- exceptionThrowerConfigurator.setShouldThrowExceptionDuringTransactionPut(false);
- checkVfModuleTopologyOperation(input, "200", null);
- }
-
- @Test
- public void vfModuleTopologyOperationInput_DeletePreloadNoErrorDuringTransactionWriting() throws Exception {
- VfModuleTopologyOperationInputBuilder builder = createVfModuleTopologyOperationInputBuilder(createVfModuleRequestInformation(VNF_INSTANCE_ID, VF_MODULE_ID), createRequestInformation(RequestAction.DeletePreloadVfModuleRequest));
- VfModuleTopologyOperationInput input = builder.build();
-
- setReturnForSvcLogicServiceClientHasGraph(true);
- setReturnForSvcLogicServiceClientExecute(null);
- exceptionThrowerConfigurator.setShouldThrowExceptionDuringTransactionPut(false);
- checkVfModuleTopologyOperation(input, "200", null);
- }
- private void checkVfModuleTopologyOperation(VfModuleTopologyOperationInput input,
- String expectedResponseCode, String expectedResponseMessage) throws ExecutionException, InterruptedException {
-
- VfModuleTopologyOperationOutput output = executeVfModuleTopologyOperation(input);
- checkVfModuleTopologyOperationOutput(output, expectedResponseCode, expectedResponseMessage);
- }
-
- private VfModuleTopologyOperationOutput executeVfModuleTopologyOperation(
- VfModuleTopologyOperationInput input) throws ExecutionException, InterruptedException {
- return vnfapiProvider
- .vfModuleTopologyOperation(input)
- .get()
- .getResult();
- }
-
- private void checkVfModuleTopologyOperationOutput(VfModuleTopologyOperationOutput result,
- String expectedResponseCode, String expectedResponseMessage) {
-
- String expectedAckFinalIndicator = "Y";
-
- Assert.assertEquals(expectedResponseCode , result.getResponseCode());
- Assert.assertEquals(expectedResponseMessage, result.getResponseMessage());
- Assert.assertEquals(expectedAckFinalIndicator, result.getAckFinalIndicator());
- }
-
- private void setReturnForSvcLogicServiceClientHasGraph(Boolean returnValue) throws Exception{
- Mockito.when(mockVNFSDNSvcLogicServiceClient
- .hasGraph(Mockito.any(),Mockito.any(), Mockito.any(),Mockito.any()))
- .thenReturn(returnValue);
- }
-
- private void setReturnForSvcLogicServiceClientExecute(Properties properties) throws Exception{
- Mockito.when(mockVNFSDNSvcLogicServiceClient
- .execute(Mockito.any(),
- Mockito.any(),
- Mockito.any(),
- Mockito.any(),
- Mockito.any(VfModuleServiceDataBuilder.class),
- Mockito.any()))
- .thenReturn(properties);
- }
-
- private void setMockVNFSDNSvcLogicServiceClientToThrowException(Class exceptionClass) throws Exception {
- Mockito.when(mockVNFSDNSvcLogicServiceClient
- .execute(Mockito.any(),
- Mockito.any(),
- Mockito.any(),
- Mockito.any(),
- Mockito.any(VfModuleServiceDataBuilder.class),
- Mockito.any()))
- .thenThrow(exceptionClass.asSubclass(Throwable.class));
- }
-
- private VfModuleTopologyOperationInputBuilder createVfModuleTopologyOperationInputBuilder(VfModuleRequestInformation vfModuleRequestInformation, RequestInformation reqInfo) {
- VfModuleTopologyOperationInputBuilder builder = new VfModuleTopologyOperationInputBuilder();
- builder.setVfModuleRequestInformation(vfModuleRequestInformation);
- builder.setRequestInformation(reqInfo);
- return builder;
- }
-
-
-
- private VfModuleRequestInformation createVfModuleRequestInformation(String vnfInstanceId, String vfModuleId) {
- return new VfModuleRequestInformationBuilder()
- .setVnfInstanceId(vnfInstanceId)
- .setVfModuleId(vfModuleId)
- .setVfModuleName(PRELOAD_NAME)
- .setVfModuleModelId(PRELOAD_TYPE)
- .build();
- }
-
- private RequestInformation createRequestInformation(RequestAction action) {
- return new RequestInformationBuilder()
- .setRequestAction(action)
- .build();
- }
-
-
-}
diff --git a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfApiProviderTest.java b/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfApiProviderTest.java
deleted file mode 100644
index 458e6d41..00000000
--- a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfApiProviderTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.sdnc.vnfapi;
-
-import org.junit.Before;
-import org.mockito.Mock;
-import org.onap.sdnc.vnfapi.util.DataBrokerUtil;
-import org.onap.sdnc.vnfapi.util.PropBuilder;
-import org.onap.sdnc.vnfapi.util.VNFSDNSvcLogicServiceClientMockUtil;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-public class VnfApiProviderTest extends AbstractConcurrentDataBrokerTest {
-
- protected VnfApiProvider vnfapiProvider;
- protected DataBroker dataBroker;
- protected @Mock NotificationPublishService mockNotificationPublishService;
- protected @Mock RpcProviderRegistry mockRpcProviderRegistry;
- protected @Mock VNFSDNSvcLogicServiceClient mockVNFSDNSvcLogicServiceClient;
- protected static final Logger LOG = LoggerFactory.getLogger(VnfApiProvider.class);
-
- protected DataBrokerUtil db;
- protected VNFSDNSvcLogicServiceClientMockUtil svcClient;
-
- @Before
- public void setUp() throws Exception {
- svcClient = new VNFSDNSvcLogicServiceClientMockUtil(mockVNFSDNSvcLogicServiceClient);
- dataBroker = getDataBroker();
- db = new DataBrokerUtil(dataBroker);
- try {
- vnfapiProvider = new VnfApiProvider(
- dataBroker,
- mockNotificationPublishService,
- mockRpcProviderRegistry,
- mockVNFSDNSvcLogicServiceClient
- );
- } catch (Exception e) {
- LOG.error("Caught exception on setUp", e);
- throw e;
- }
- }
-
- public static PropBuilder prop(){
- return (new PropBuilder());
- }
- } \ No newline at end of file
diff --git a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfInstanceTopologyOperationTest.java b/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfInstanceTopologyOperationTest.java
deleted file mode 100644
index 230a394e..00000000
--- a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfInstanceTopologyOperationTest.java
+++ /dev/null
@@ -1,368 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.sdnc.vnfapi;
-
-import com.google.common.util.concurrent.CheckedFuture;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.mockito.Mockito;
-import org.onap.ccsdk.sli.core.sli.SvcLogicException;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.binding.impl.BindingDOMDataBrokerAdapter;
-import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec;
-import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTestCustomizer;
-import org.opendaylight.controller.md.sal.binding.test.ConcurrentDataBrokerTestCustomizer;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VnfInstanceTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VnfInstanceTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.request.information.RequestInformation;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.request.information.RequestInformation.RequestAction;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.request.information.RequestInformationBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VnfInstanceTopologyOperationInputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.instance.request.information.VnfInstanceRequestInformation;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.instance.request.information.VnfInstanceRequestInformationBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.instance.service.data.VnfInstanceServiceDataBuilder;
-
-import java.util.Properties;
-import java.util.concurrent.ExecutionException;
-
-class VnfInstanceExceptionThrowerConfigurator {
- private boolean shouldThrowExceptionDuringTransactionPut;
-
- public VnfInstanceExceptionThrowerConfigurator() {
- this.shouldThrowExceptionDuringTransactionPut = true;
- }
-
- public boolean shouldThrowExceptionDuringTransactionPut() {
- return shouldThrowExceptionDuringTransactionPut;
- }
-
- public void setShouldThrowExceptionDuringTransactionPut(boolean shouldThrowExceptionDuringTransactionPut) {
- this.shouldThrowExceptionDuringTransactionPut = shouldThrowExceptionDuringTransactionPut;
- }
-}
-
-class VnfInstanceDataBrokerErrorMsgConfigurator {
- static public String JAVA_LANG_RUNTIME_EXCEPTION = "java.lang.RuntimeException: ";
- static public String TRANSACTION_WRITE_ERROR = "transaction-write-error";
-}
-
-class VnfInstanceDataBrokerStab extends BindingDOMDataBrokerAdapter {
- VnfInstanceExceptionThrowerConfigurator exceptionThrowerConfigurator;
-
- public VnfInstanceDataBrokerStab(final DOMDataBroker domDataBroker,
- final BindingToNormalizedNodeCodec codec, VnfInstanceExceptionThrowerConfigurator exceptionThrowerConfigurator) {
- super(domDataBroker, codec);
- this.exceptionThrowerConfigurator = exceptionThrowerConfigurator;
-
- }
-
- @Override
- public WriteTransaction newWriteOnlyTransaction() {
- if (exceptionThrowerConfigurator.shouldThrowExceptionDuringTransactionPut()) {
- return newThrowingExceptionWriteOnlyTransaction();
- }
- return newNotThrowingExceptionWriteOnlyTransaction();
- }
-
- private WriteTransaction newThrowingExceptionWriteOnlyTransaction() {
- WriteTransaction mockWriteTransaction = Mockito.mock(WriteTransaction.class);
- Mockito.doThrow(new RuntimeException(VnfInstanceDataBrokerErrorMsgConfigurator.TRANSACTION_WRITE_ERROR))
- .when(mockWriteTransaction).put(Mockito.any(), Mockito.any(), Mockito.any());
- return mockWriteTransaction;
- }
-
- private WriteTransaction newNotThrowingExceptionWriteOnlyTransaction() {
- WriteTransaction mockWriteTransaction = Mockito.mock(WriteTransaction.class);
- CheckedFuture<Void, TransactionCommitFailedException> mockCheckedFuture =
- Mockito.mock(CheckedFuture.class);
- Mockito.doNothing().when(mockWriteTransaction).put(Mockito.any(), Mockito.any(), Mockito.any());
- Mockito.doReturn(mockCheckedFuture).when(mockWriteTransaction).submit();
- return mockWriteTransaction;
- }
-}
-
-class VnfInstanceProviderDataBrokerTestCustomizer extends ConcurrentDataBrokerTestCustomizer {
- VnfInstanceExceptionThrowerConfigurator exceptionThrowerConfigurator;
-
- public VnfInstanceProviderDataBrokerTestCustomizer(VnfInstanceExceptionThrowerConfigurator exceptionThrowerConfigurator) {
- super(false);
- this.exceptionThrowerConfigurator = exceptionThrowerConfigurator;
- }
-
- public DataBroker createDataBroker() {
- return new VnfInstanceDataBrokerStab(createDOMDataBroker(),
- super.getBindingToNormalized(), this.exceptionThrowerConfigurator);
- }
-}
-
-@RunWith(MockitoJUnitRunner.class)
-public class VnfInstanceTopologyOperationTest extends VnfApiProviderTest {
- protected static final Logger LOG = LoggerFactory.getLogger(VnfInstanceTopologyOperationTest.class);
-
- private static final String INVALID_INPUT = "invalid input, null or empty vnf-instance-id";
- private static final String NO_SERVICE_LOGIC = "No service logic active for VNF-API: \'vnf-instance-topology-operation\'";
- private static final String VIID = "viid";
- private static final String PRELOAD_NAME = "preloadName";
- private static final String PRELOAD_TYPE = "preloadType";
- private static final String ERROR_CODE = "error-code";
- private static final String ERROR_MESSAGE = "error-message";
- private static final String ACK_FINAL = "ack-final";
- private static final String SVC_OPERATION = "vnf-topology-operation";
-
- private VnfInstanceExceptionThrowerConfigurator exceptionThrowerConfigurator;
-
- @Override
- protected AbstractDataBrokerTestCustomizer createDataBrokerTestCustomizer() {
- this.exceptionThrowerConfigurator = new VnfInstanceExceptionThrowerConfigurator();
- return new VnfInstanceProviderDataBrokerTestCustomizer(this.exceptionThrowerConfigurator);
- }
-
- @Before
- public void setUp() throws Exception {
- super.setUp();
- svcClient.setScvOperation(SVC_OPERATION);
- }
-
- @Test
- public void vnfInstanceTopologyOperationInputIsNull() throws Exception {
- VnfInstanceTopologyOperationInput input = null;
- checkVnfInstanceTopologyOperation(input, "403", INVALID_INPUT);
- }
-
- @Test
- public void vnfInstanceTopologyOperationInput_VnfInstanceRequestInformationIsNull() throws Exception {
- VnfInstanceTopologyOperationInputBuilder builder = new VnfInstanceTopologyOperationInputBuilder();
- builder.setVnfInstanceRequestInformation(null);
- VnfInstanceTopologyOperationInput input = builder.build();
- checkVnfInstanceTopologyOperation(input, "403", INVALID_INPUT);
- }
-
- @Test
- public void vnfInstanceTopologyOperationInput_getVnfInstanceRequestInformationVnfInstanceIdIsNull() throws Exception {
- RequestInformation reqInfo = createRequestInformation(RequestAction.PreloadVnfInstanceRequest);
- VnfInstanceRequestInformation vnfInstanceRequestInformation = createVnfInstanceRequestInformation(null);
- VnfInstanceTopologyOperationInputBuilder builder = createVnfInstanceTopologyOperationInputBuilder(vnfInstanceRequestInformation, reqInfo);
- VnfInstanceTopologyOperationInput input = builder.build();
- checkVnfInstanceTopologyOperation(input, "403", INVALID_INPUT);
- }
-
- @Test
- public void vnfInstanceTopologyOperationInput_VnfInstanceRequestInformationVnfInstanceIdIsZero() throws Exception {
- VnfInstanceTopologyOperationInputBuilder builder = createVnfInstanceTopologyOperationInputBuilder(createVnfInstanceRequestInformation(""), createRequestInformation(RequestAction.PreloadVnfInstanceRequest));
- VnfInstanceTopologyOperationInput input = builder.build();
- checkVnfInstanceTopologyOperation(input, "403", INVALID_INPUT);
- }
-
- @Test
- public void vnfInstanceTopologyOperationInput_svcLogicClientHasGrapheReturnFalse() throws Exception {
- VnfInstanceTopologyOperationInputBuilder builder = createVnfInstanceTopologyOperationInputBuilder(createVnfInstanceRequestInformation(VIID), createRequestInformation(RequestAction.PreloadVnfInstanceRequest));
- VnfInstanceTopologyOperationInput input = builder.build();
- setReturnForSvcLogicServiceClientHasGraph(false);
- checkVnfInstanceTopologyOperation(input, "503", NO_SERVICE_LOGIC);
- }
-
- @Test
- public void vnfInstanceTopologyOperationInput_svcLogicClientExecuteThrowsSvcLogicException() throws Exception {
- VnfInstanceTopologyOperationInputBuilder builder = createVnfInstanceTopologyOperationInputBuilder(createVnfInstanceRequestInformation(VIID), createRequestInformation(RequestAction.PreloadVnfInstanceRequest));
- VnfInstanceTopologyOperationInput input = builder.build();
- setReturnForSvcLogicServiceClientHasGraph(true);
- setMockVNFSDNSvcLogicServiceClientToThrowException(SvcLogicException.class);
- checkVnfInstanceTopologyOperation(input, "500", null);
- }
-
- @Test
- public void vnfInstanceTopologyOperationInput_svcLogicClientExecuteThrowsException() throws Exception {
- VnfInstanceTopologyOperationInputBuilder builder = createVnfInstanceTopologyOperationInputBuilder(createVnfInstanceRequestInformation(VIID), createRequestInformation(RequestAction.PreloadVnfInstanceRequest));
- VnfInstanceTopologyOperationInput input = builder.build();
-
- setReturnForSvcLogicServiceClientHasGraph(true);
- setMockVNFSDNSvcLogicServiceClientToThrowException(Exception.class);
- checkVnfInstanceTopologyOperation(input, "500", null);
- }
-
- @Test
- public void vnfInstanceTopologyOperationInput_svcLogicClientExecuteReturnsNotNull() throws Exception {
- VnfInstanceTopologyOperationInputBuilder builder = createVnfInstanceTopologyOperationInputBuilder(createVnfInstanceRequestInformation(VIID), createRequestInformation(RequestAction.PreloadVnfInstanceRequest));
- VnfInstanceTopologyOperationInput input = builder.build();
-
- Properties properties = prop().set(ERROR_CODE, "500")
- .set(ERROR_MESSAGE, ERROR_MESSAGE)
- .set(ACK_FINAL, "Y")
- .build();
-
- setReturnForSvcLogicServiceClientHasGraph(true);
- setReturnForSvcLogicServiceClientExecute(properties);
- checkVnfInstanceTopologyOperation(input, "500", ERROR_MESSAGE);
- }
-
- @Test
- public void vnfInstanceTopologyOperationInput_svcLogicClientExecuteReturnsNull() throws Exception {
- VnfInstanceTopologyOperationInputBuilder builder = createVnfInstanceTopologyOperationInputBuilder(createVnfInstanceRequestInformation(VIID), createRequestInformation(RequestAction.PreloadVnfInstanceRequest));
- VnfInstanceTopologyOperationInput input = builder.build();
-
- setReturnForSvcLogicServiceClientHasGraph(true);
- setReturnForSvcLogicServiceClientExecute(null);
- String expectedErrorMsg = VnfInstanceDataBrokerErrorMsgConfigurator.JAVA_LANG_RUNTIME_EXCEPTION
- + VnfInstanceDataBrokerErrorMsgConfigurator.TRANSACTION_WRITE_ERROR;
- checkVnfInstanceTopologyOperation(input, "500", expectedErrorMsg);
- }
-
- @Test
- public void vnfInstanceTopologyOperationInput_ActivateNoErrorDuringTransactionWriting() throws Exception {
- VnfInstanceTopologyOperationInputBuilder builder = createVnfInstanceTopologyOperationInputBuilder(createVnfInstanceRequestInformation(VIID), createRequestInformation(RequestAction.VnfInstanceActivateRequest));
- VnfInstanceTopologyOperationInput input = builder.build();
-
- setReturnForSvcLogicServiceClientHasGraph(true);
- setReturnForSvcLogicServiceClientExecute(null);
- exceptionThrowerConfigurator.setShouldThrowExceptionDuringTransactionPut(false);
- checkVnfInstanceTopologyOperation(input, "200", null);
- }
-
- @Test
- public void vnfInstanceTopologyOperationInput_ChangeNoErrorDuringTransactionWriting() throws Exception {
- VnfInstanceTopologyOperationInputBuilder builder = createVnfInstanceTopologyOperationInputBuilder(createVnfInstanceRequestInformation(VIID), createRequestInformation(RequestAction.ChangeVnfInstanceActivateRequest));
- VnfInstanceTopologyOperationInput input = builder.build();
-
- setReturnForSvcLogicServiceClientHasGraph(true);
- setReturnForSvcLogicServiceClientExecute(null);
- exceptionThrowerConfigurator.setShouldThrowExceptionDuringTransactionPut(false);
- checkVnfInstanceTopologyOperation(input, "200", null);
- }
-
- @Test
- public void vnfInstanceTopologyOperationInput_DisconnectNoErrorDuringTransactionWriting() throws Exception {
- VnfInstanceTopologyOperationInputBuilder builder = createVnfInstanceTopologyOperationInputBuilder(createVnfInstanceRequestInformation(VIID), createRequestInformation(RequestAction.DisconnectVnfInstanceRequest));
- VnfInstanceTopologyOperationInput input = builder.build();
-
- setReturnForSvcLogicServiceClientHasGraph(true);
- setReturnForSvcLogicServiceClientExecute(null);
- exceptionThrowerConfigurator.setShouldThrowExceptionDuringTransactionPut(false);
- checkVnfInstanceTopologyOperation(input, "200", null);
- }
-
- @Test
- public void vnfInstanceTopologyOperationInput_PreloadNoErrorDuringTransactionWriting() throws Exception {
- VnfInstanceTopologyOperationInputBuilder builder = createVnfInstanceTopologyOperationInputBuilder(createVnfInstanceRequestInformation(VIID), createRequestInformation(RequestAction.PreloadVnfInstanceRequest));
- VnfInstanceTopologyOperationInput input = builder.build();
-
- setReturnForSvcLogicServiceClientHasGraph(true);
- setReturnForSvcLogicServiceClientExecute(null);
- exceptionThrowerConfigurator.setShouldThrowExceptionDuringTransactionPut(false);
- checkVnfInstanceTopologyOperation(input, "200", null);
- }
-
- @Test
- public void vnfInstanceTopologyOperationInput_DeletePreloadNoErrorDuringTransactionWriting() throws Exception {
- VnfInstanceTopologyOperationInputBuilder builder = createVnfInstanceTopologyOperationInputBuilder(createVnfInstanceRequestInformation(VIID), createRequestInformation(RequestAction.DeletePreloadVnfInstanceRequest));
- VnfInstanceTopologyOperationInput input = builder.build();
-
- setReturnForSvcLogicServiceClientHasGraph(true);
- setReturnForSvcLogicServiceClientExecute(null);
- exceptionThrowerConfigurator.setShouldThrowExceptionDuringTransactionPut(false);
- checkVnfInstanceTopologyOperation(input, "200", null);
- }
- private void checkVnfInstanceTopologyOperation(VnfInstanceTopologyOperationInput input,
- String expectedResponseCode, String expectedResponseMessage) throws ExecutionException, InterruptedException {
-
- VnfInstanceTopologyOperationOutput output = executeVnfInstanceTopologyOperation(input);
- checkVnfInstanceTopologyOperationOutput(output, expectedResponseCode, expectedResponseMessage);
- }
-
- private VnfInstanceTopologyOperationOutput executeVnfInstanceTopologyOperation(
- VnfInstanceTopologyOperationInput input) throws ExecutionException, InterruptedException {
- return vnfapiProvider
- .vnfInstanceTopologyOperation(input)
- .get()
- .getResult();
- }
-
- private void checkVnfInstanceTopologyOperationOutput(VnfInstanceTopologyOperationOutput result,
- String expectedResponseCode, String expectedResponseMessage) {
-
- String expectedAckFinalIndicator = "Y";
-
- Assert.assertEquals(expectedResponseCode , result.getResponseCode());
- Assert.assertEquals(expectedResponseMessage, result.getResponseMessage());
- Assert.assertEquals(expectedAckFinalIndicator, result.getAckFinalIndicator());
- }
-
- private void setReturnForSvcLogicServiceClientHasGraph(Boolean returnValue) throws Exception{
- Mockito.when(mockVNFSDNSvcLogicServiceClient
- .hasGraph(Mockito.any(),Mockito.any(), Mockito.any(),Mockito.any()))
- .thenReturn(returnValue);
- }
-
- private void setReturnForSvcLogicServiceClientExecute(Properties properties) throws Exception{
- Mockito.when(mockVNFSDNSvcLogicServiceClient
- .execute(Mockito.any(),
- Mockito.any(),
- Mockito.any(),
- Mockito.any(),
- Mockito.any(VnfInstanceServiceDataBuilder.class),
- Mockito.any()))
- .thenReturn(properties);
- }
-
- private void setMockVNFSDNSvcLogicServiceClientToThrowException(Class exceptionClass) throws Exception {
- Mockito.when(mockVNFSDNSvcLogicServiceClient
- .execute(Mockito.any(),
- Mockito.any(),
- Mockito.any(),
- Mockito.any(),
- Mockito.any(VnfInstanceServiceDataBuilder.class),
- Mockito.any()))
- .thenThrow(exceptionClass.asSubclass(Throwable.class));
- }
-
- private VnfInstanceTopologyOperationInputBuilder createVnfInstanceTopologyOperationInputBuilder(VnfInstanceRequestInformation vnfInstanceRequestInformation, RequestInformation reqInfo) {
- VnfInstanceTopologyOperationInputBuilder builder = new VnfInstanceTopologyOperationInputBuilder();
- builder.setVnfInstanceRequestInformation(vnfInstanceRequestInformation);
- builder.setRequestInformation(reqInfo);
- return builder;
- }
-
-
-
- private VnfInstanceRequestInformation createVnfInstanceRequestInformation(String vnfInstanceId) {
- return new VnfInstanceRequestInformationBuilder()
- .setVnfInstanceId(vnfInstanceId)
- .setVnfInstanceName(PRELOAD_NAME)
- .setVnfModelId(PRELOAD_TYPE)
- .build();
- }
-
- private RequestInformation createRequestInformation(RequestAction action) {
- return new RequestInformationBuilder()
- .setRequestAction(action)
- .build();
- }
-
-
-}
diff --git a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfSdnUtilTest.java b/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfSdnUtilTest.java
deleted file mode 100644
index 3f486f62..00000000
--- a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfSdnUtilTest.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.sdnc.vnfapi;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.powermock.reflect.Whitebox;
-
-public class VnfSdnUtilTest {
-
- private VnfSdnUtil vnfSdnUtil;
-
- @Before public void setUp() throws Exception {
- vnfSdnUtil = new VnfSdnUtil();
- }
-
- @Test public void loadProperties() throws Exception {
- vnfSdnUtil.loadProperties();
- Object properties = Whitebox.getInternalState(VnfSdnUtil.class, "properties");
- Assert.assertNotNull(properties);
- }
-}
diff --git a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfTopologyOperationRPCTest.java b/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfTopologyOperationRPCTest.java
deleted file mode 100644
index 422a6adb..00000000
--- a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfTopologyOperationRPCTest.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.sdnc.vnfapi;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.sdnc.vnfapi.util.PropBuilder;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VnfTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VnfTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.sdnc.request.header.SdncRequestHeader.SvcAction;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.model.infrastructure.VnfList;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-
-import static org.onap.sdnc.vnfapi.util.MDSALUtil.build;
-import static org.onap.sdnc.vnfapi.util.MDSALUtil.exec;
-import static org.onap.sdnc.vnfapi.util.MDSALUtil.sdncRequestHeader;
-import static org.onap.sdnc.vnfapi.util.MDSALUtil.serviceData;
-import static org.onap.sdnc.vnfapi.util.MDSALUtil.serviceInformation;
-import static org.onap.sdnc.vnfapi.util.MDSALUtil.vnfInformation;
-import static org.onap.sdnc.vnfapi.util.MDSALUtil.vnfList;
-import static org.onap.sdnc.vnfapi.util.MDSALUtil.vnfRequestInformation;
-import static org.onap.sdnc.vnfapi.util.MDSALUtil.vnfTopologyOperationInput;
-import static org.onap.sdnc.vnfapi.util.MDSALUtil.vnfTopologyOperationOutput;
-
-
-/**
- * This class test the VnfTopologyOperation mdsal RPC.
- */
-@RunWith(MockitoJUnitRunner.class)
-public class VnfTopologyOperationRPCTest extends VnfApiProviderTest {
-
-
- final String SVC_OPERATION = "vnf-topology-operation";
-
-
- @Before
- public void setUp() throws Exception {
- super.setUp();
- svcClient.setScvOperation(SVC_OPERATION);
- }
-
-
- /**
- * Verify VnfTopologyOperation RPC executes Delete VNFList entry
- * {@link VnfTopologyOperationOutput} and persisted the expected {@link VnfList} in the {@link DataBroker}
- */
- @Test
- public void testVnfTopologyOperationRPC_Delete_VNFList_Entry_Success() throws Exception {
-
-
- //mock svcClient to perform a successful execution with the expected parameters
- svcClient.mockHasGraph(true);
- PropBuilder svcResultProp = svcClient.createExecuteOKResult();
- svcClient.mockExecute(svcResultProp);
-
- // create the VnfTopologyOperationInput from the template
- VnfTopologyOperationInput vnfTopologyOperationInput = createVTOI();
-
- //persist a vnfList entry in the dataBroker
- persistVnfListBroker(vnfTopologyOperationInput);
-
- //execute the mdsal exec
- VnfTopologyOperationOutput actualVnfTopologyOperationOutput = exec(
- vnfapiProvider::vnfTopologyOperation
- , vnfTopologyOperationInput
- , RpcResult::getResult
- );
-
-
- //verify the returned VnfTopologyOperationOutput
- VnfTopologyOperationOutput expectedVnfTopologyOperationOutput = createExpectedVTOO(svcResultProp,vnfTopologyOperationInput);
- Assert.assertEquals(expectedVnfTopologyOperationOutput,actualVnfTopologyOperationOutput);
-
-
- //verify the persisted VnfList
- VnfList actualVnfList = db.read(vnfTopologyOperationInput.getVnfRequestInformation().getVnfId(), LogicalDatastoreType.CONFIGURATION);
- VnfList expectedVnfList = null;
- Assert.assertEquals(expectedVnfList,actualVnfList);
-
- LOG.debug("done");
- }
-
-
- public VnfTopologyOperationInput createVTOI(){
- return build(vnfTopologyOperationInput()
- .setServiceInformation(
- build(serviceInformation()
- .setServiceId("serviceId: xyz")
- .setServiceInstanceId("serviceInstanceId: xyz")
- .setServiceType("serviceType: xyz")
- .setSubscriberName("subscriberName: xyz")
- )
- )
- .setVnfRequestInformation(
- build(vnfRequestInformation()
- .setVnfId("vnfId: xyz")
- .setVnfName("vnfName: xyz")//defect if missing
- .setVnfType("vnfType: xyz")//defect if missing
-
-
- )
- )
- .setSdncRequestHeader(
- build(sdncRequestHeader()
- .setSvcAction(SvcAction.Delete)
- )
- )
- );
-
- }
-
-
-
- private VnfList persistVnfListBroker(
- VnfTopologyOperationInput vnfTopologyOperationInput
- ) throws Exception{
- VnfList service = build(
- vnfList()
- .setVnfId(vnfTopologyOperationInput.getVnfRequestInformation().getVnfId())
- .setServiceData(
- build(serviceData()
- .setVnfId(vnfTopologyOperationInput.getVnfRequestInformation().getVnfId())
- )
- )
- );
- db.write(true,service, LogicalDatastoreType.CONFIGURATION);
- return service;
- }
-
-
-
-
-
- private VnfTopologyOperationOutput createExpectedVTOO(PropBuilder expectedSvcResultProp,VnfTopologyOperationInput expectedVnfTopologyOperationInput){
- return build(
- vnfTopologyOperationOutput()
- .setSvcRequestId(expectedVnfTopologyOperationInput.getSdncRequestHeader().getSvcRequestId())
- .setResponseCode(expectedSvcResultProp.get(svcClient.errorCode))
- .setAckFinalIndicator(expectedSvcResultProp.get(svcClient.ackFinal))
- .setResponseMessage(expectedSvcResultProp.get(svcClient.errorMessage))
- .setVnfInformation(build(vnfInformation()
- .setVnfId(expectedVnfTopologyOperationInput.getVnfRequestInformation().getVnfId())
- ))
- );
- }
-
-
-
-
-}
diff --git a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfapiProviderTestBase.java b/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfapiProviderTestBase.java
deleted file mode 100644
index 92346047..00000000
--- a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfapiProviderTestBase.java
+++ /dev/null
@@ -1,1416 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.sdnc.vnfapi;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnit;
-import org.mockito.junit.MockitoRule;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.NetworkTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.NetworkTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.PreloadNetworkTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.PreloadNetworkTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.PreloadVfModuleTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.PreloadVfModuleTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.PreloadVfModules;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.PreloadVnfInstanceTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.PreloadVnfInstanceTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.PreloadVnfInstances;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.PreloadVnfTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.PreloadVnfTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.PreloadVnfs;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VNFAPIService;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VfModuleTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VfModuleTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VfModules;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VnfInstanceTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VnfInstanceTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VnfInstances;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VnfTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VnfTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.Vnfs;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.network.request.information.NetworkRequestInformation;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.network.topology.identifier.NetworkTopologyIdentifier;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.network.topology.information.NetworkTopologyInformation;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.preload.data.PreloadData;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.preload.data.PreloadDataBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.preload.model.information.VnfPreloadList;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.preload.vf.module.model.information.VfModulePreloadList;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.preload.vnf.instance.model.information.VnfInstancePreloadList;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.request.information.RequestInformation;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.sdnc.request.header.SdncRequestHeader;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.service.data.ServiceData;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.service.data.ServiceDataBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.service.information.ServiceInformation;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.service.status.ServiceStatus;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.service.status.ServiceStatusBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vf.module.identifiers.VfModuleIdentifiers;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vf.module.model.infrastructure.VfModuleList;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vf.module.preload.data.VfModulePreloadData;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vf.module.preload.data.VfModulePreloadDataBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vf.module.request.information.VfModuleRequestInformation;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vf.module.service.data.VfModuleServiceData;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vf.module.service.data.VfModuleServiceDataBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vf.module.topology.information.VfModuleTopologyInformation;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.instance.identifiers.VnfInstanceIdentifiers;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.instance.model.infrastructure.VnfInstanceList;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.instance.preload.data.VnfInstancePreloadData;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.instance.preload.data.VnfInstancePreloadDataBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.instance.request.information.VnfInstanceRequestInformation;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.instance.service.data.VnfInstanceServiceData;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.instance.service.data.VnfInstanceServiceDataBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.instance.topology.information.VnfInstanceTopologyInformation;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.model.infrastructure.VnfList;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.model.infrastructure.VnfListKey;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.request.information.VnfRequestInformation;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.topology.identifier.VnfTopologyIdentifier;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.topology.information.VnfTopologyInformation;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.powermock.reflect.Whitebox;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-
-public class VnfapiProviderTestBase {
- @Rule public MockitoRule rule = MockitoJUnit.rule();
-
- @Mock private DataBroker dataBroker;
- @Mock private NotificationPublishService notificationPublishService;
- @Mock private RpcProviderRegistry rpcProviderRegistry;
- @Mock private VNFSDNSvcLogicServiceClient vnfsdnSvcLogicServiceClient;
- @Mock private ReadWriteTransaction readWriteTransactionInCreateContainer;
- @Mock private ReadWriteTransaction readWriteTransactionInDataChanged;
- @Mock private CheckedFuture<Void, TransactionCommitFailedException> checkedFuture;
-
- private VnfApiProvider vnfapiProvider;
- private String vfModuleName;
- private String vfModuleModelId;
- private String vnfInstanceId;
- private String vnfInstanceName;
- private String vnfModelId;
- private String svcRequestId;
- private String serviceInstanceId;
- private String vnfName;
- private String vnfType;
- private String vfModuleId;
-
- @Before public void setUp() throws Exception {
- doReturn(readWriteTransactionInCreateContainer).when(dataBroker).newReadWriteTransaction();
- doReturn(checkedFuture).when(readWriteTransactionInCreateContainer).submit();
- // mock readOnlyTransaction
- ReadOnlyTransaction readOnlyTransaction = mock(ReadOnlyTransaction.class);
- doReturn(readOnlyTransaction).when(dataBroker).newReadOnlyTransaction();
- doReturn(checkedFuture).when(readOnlyTransaction).read(any(), any());
- // mock writeTransaction
- WriteTransaction writeTransaction = mock(WriteTransaction.class);
- doReturn(writeTransaction).when(dataBroker).newWriteOnlyTransaction();
- doReturn(checkedFuture).when(writeTransaction).submit();
-
- vnfapiProvider = spy(new VnfApiProvider(dataBroker, notificationPublishService, rpcProviderRegistry,
- vnfsdnSvcLogicServiceClient));
- }
-
- @After public void tearDown() throws Exception {
-
- }
-
- @Test public void close() throws Exception {
- ExecutorService executor = Whitebox.getInternalState(vnfapiProvider, "executor");
- BindingAwareBroker.RpcRegistration<VNFAPIService> vnfapiServiceRpcRegistration =
- mock(BindingAwareBroker.RpcRegistration.class);
- vnfapiProvider.rpcRegistration = vnfapiServiceRpcRegistration;
-
- vnfapiProvider.close();
-
- Assert.assertTrue(executor.isShutdown());
- verify(vnfapiServiceRpcRegistration, times(1)).close();
- }
-
- /**
- * Test Error case:
- * <p>
- * <code>input.getVnfInstanceRequestInformation() == null</code>
- *
- * @throws Exception
- */
- @Test public void vnfInstanceTopologyOperationErrorOne() throws Exception {
- VnfInstanceTopologyOperationInput vnfInstanceTopologyOperationInput =
- mock(VnfInstanceTopologyOperationInput.class);
- doReturn(null).when(vnfInstanceTopologyOperationInput).getVnfInstanceRequestInformation();
-
- Future<RpcResult<VnfInstanceTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.vnfInstanceTopologyOperation(vnfInstanceTopologyOperationInput);
-
- Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals("invalid input, null or empty vnf-instance-id",
- rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Error case:
- * <p>
- * <code>viid == null</code>
- *
- * @throws Exception
- */
- @Test public void vnfInstanceTopologyOperationErrorTwo() throws Exception {
- vnfInstanceId = "";
- vnfInstanceName = "vnf-instance-name";
- vnfModelId = "vnf-model-id";
- VnfInstanceTopologyOperationInput vnfInstanceTopologyOperationInput =
- mock(VnfInstanceTopologyOperationInput.class);
- VnfInstanceRequestInformation vnfInstanceRequestInformation = mock(VnfInstanceRequestInformation.class);
- doReturn(vnfInstanceName).when(vnfInstanceRequestInformation).getVnfInstanceName();
- doReturn(vnfModelId).when(vnfInstanceRequestInformation).getVnfModelId();
- doReturn(vnfInstanceId).when(vnfInstanceRequestInformation).getVnfInstanceId();
- doReturn(vnfInstanceRequestInformation).when(vnfInstanceTopologyOperationInput)
- .getVnfInstanceRequestInformation();
-
- Future<RpcResult<VnfInstanceTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.vnfInstanceTopologyOperation(vnfInstanceTopologyOperationInput);
-
- Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals("invalid input, null or empty vnf-instance-id",
- rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Error case:
- * <p>
- * <code>svcLogicClient.hasGraph("VNF-API",SVC_OPERATION,null,"sync" = false</code>
- *
- * @throws Exception
- */
- @Test public void vnfInstanceTopologyOperationErrorThree() throws Exception {
- vnfInstanceId = "vnf-instance-id";
- vnfInstanceName = "vnf-instance-name";
- vnfModelId = "vnf-model-id";
- svcRequestId = "svc-request-id";
-
- VnfInstanceTopologyOperationInput vnfInstanceTopologyOperationInput =
- mock(VnfInstanceTopologyOperationInput.class);
- VnfInstanceRequestInformation vnfInstanceRequestInformation = mock(VnfInstanceRequestInformation.class);
- doReturn(vnfInstanceId).when(vnfInstanceRequestInformation).getVnfInstanceId();
- doReturn(vnfInstanceName).when(vnfInstanceRequestInformation).getVnfInstanceName();
- doReturn(vnfModelId).when(vnfInstanceRequestInformation).getVnfModelId();
- doReturn(vnfInstanceRequestInformation).when(vnfInstanceTopologyOperationInput)
- .getVnfInstanceRequestInformation();
-
- SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
- doReturn(sdncRequestHeader).when(vnfInstanceTopologyOperationInput).getSdncRequestHeader();
- doReturn(svcRequestId).when(sdncRequestHeader).getSvcRequestId();
-
- Future<RpcResult<VnfInstanceTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.vnfInstanceTopologyOperation(vnfInstanceTopologyOperationInput);
-
- Assert.assertEquals("503", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertTrue(
- rpcResultFuture.get().getResult().getResponseMessage().contains("No service logic active for VNF-API"));
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Success case
- *
- * @throws Exception
- */
- @Test public void vnfInstanceTopologyOperationSuccess() throws Exception {
- vnfInstanceId = "vnf-instance-id";
- vnfInstanceName = "vnf-instance-name";
- vnfModelId = "vnf-model-id";
- svcRequestId = "svc-request-id";
-
- VnfInstanceTopologyOperationInput vnfInstanceTopologyOperationInput =
- mock(VnfInstanceTopologyOperationInput.class);
- VnfInstanceRequestInformation vnfInstanceRequestInformation = mock(VnfInstanceRequestInformation.class);
- doReturn(vnfInstanceId).when(vnfInstanceRequestInformation).getVnfInstanceId();
- doReturn(vnfInstanceName).when(vnfInstanceRequestInformation).getVnfInstanceName();
- doReturn(vnfModelId).when(vnfInstanceRequestInformation).getVnfModelId();
- doReturn(vnfInstanceRequestInformation).when(vnfInstanceTopologyOperationInput)
- .getVnfInstanceRequestInformation();
-
- SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
- doReturn(sdncRequestHeader).when(vnfInstanceTopologyOperationInput).getSdncRequestHeader();
- doReturn(svcRequestId).when(sdncRequestHeader).getSvcRequestId();
- doReturn(SdncRequestHeader.SvcAction.Activate).when(sdncRequestHeader).getSvcAction();
- ReadOnlyTransaction readOnlyTransaction = mock(ReadOnlyTransaction.class);
- doReturn(readOnlyTransaction).when(dataBroker).newReadOnlyTransaction();
- doReturn(checkedFuture).when(readOnlyTransaction).read(any(), any());
- WriteTransaction writeTransaction = mock(WriteTransaction.class);
- doReturn(writeTransaction).when(dataBroker).newWriteOnlyTransaction();
- doReturn(checkedFuture).when(writeTransaction).submit();
- doReturn(true).when(vnfsdnSvcLogicServiceClient).hasGraph(any(), any(), any(), any());
-
- Future<RpcResult<VnfInstanceTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.vnfInstanceTopologyOperation(vnfInstanceTopologyOperationInput);
-
- Assert.assertEquals("200", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals(null, rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Error case:
- * <p>
- * <code>input.getVfModuleTopologyInformation() == null</code>
- *
- * @throws Exception
- */
- @Test public void vfModuleTopologyOperationErrorOne() throws Exception {
- VfModuleTopologyOperationInput vfModuleTopologyOperationInput = mock(VfModuleTopologyOperationInput.class);
- doReturn(null).when(vfModuleTopologyOperationInput).getVfModuleRequestInformation();
- Future<RpcResult<VfModuleTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.vfModuleTopologyOperation(vfModuleTopologyOperationInput);
-
- Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals("invalid input, null or empty vf-module-id",
- rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Error case:
- * <p>
- * <code>vfid = ""</code>
- * And
- * <p>
- * <code>viid = ""</code>
- *
- * @throws Exception
- */
- @Test public void vfModuleTopologyOperationErrorTwo() throws Exception {
- // vifd = ""
- vfModuleName = "vfModuleName";
- vfModuleModelId = "vfModuleModelId";
- vfModuleId = "";
- vnfInstanceId = "";
- VfModuleTopologyOperationInput vfModuleTopologyOperationInput = mock(VfModuleTopologyOperationInput.class);
- VfModuleRequestInformation vfModuleRequestInformation = mock(VfModuleRequestInformation.class);
- doReturn(vfModuleRequestInformation).when(vfModuleTopologyOperationInput).getVfModuleRequestInformation();
- VfModuleIdentifiers vfModuleIdentifiers = mock(VfModuleIdentifiers.class);
- doReturn(vfModuleName).when(vfModuleIdentifiers).getVfModuleName();
- doReturn(vfModuleModelId).when(vfModuleIdentifiers).getVfModuleModelId();
- doReturn(vfModuleId).when(vfModuleRequestInformation).getVfModuleId();
-
- Future<RpcResult<VfModuleTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.vfModuleTopologyOperation(vfModuleTopologyOperationInput);
-
- Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals("invalid input, null or empty vf-module-id",
- rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
-
- // viid = ""
- vfModuleId = "vfModuleId";
- doReturn(vfModuleId).when(vfModuleRequestInformation).getVfModuleId();
- doReturn(vnfInstanceId).when(vfModuleRequestInformation).getVnfInstanceId();
- rpcResultFuture = vnfapiProvider.vfModuleTopologyOperation(vfModuleTopologyOperationInput);
-
- Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals("invalid input, null or empty vnf-instance-id",
- rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Error case:
- * <p>
- * <code>svcLogicClient.hasGraph("VNF-API", SVC_OPERATION, null, "sync") = false</code>
- *
- * @throws Exception
- */
- @Test public void vfModuleTopologyOperationErrorThree() throws Exception {
- // vifd = ""
- vfModuleName = "vfModuleName";
- vfModuleModelId = "vfModuleModelId";
- vfModuleId = "vfModuleId";
- vnfInstanceId = "vnfInstanceId";
- VfModuleTopologyOperationInput vfModuleTopologyOperationInput = mock(VfModuleTopologyOperationInput.class);
- VfModuleRequestInformation vfModuleRequestInformation = mock(VfModuleRequestInformation.class);
- doReturn(vfModuleRequestInformation).when(vfModuleTopologyOperationInput).getVfModuleRequestInformation();
- VfModuleIdentifiers vfModuleIdentifiers = mock(VfModuleIdentifiers.class);
- doReturn(vfModuleName).when(vfModuleIdentifiers).getVfModuleName();
- doReturn(vfModuleModelId).when(vfModuleIdentifiers).getVfModuleModelId();
- doReturn(vfModuleId).when(vfModuleRequestInformation).getVfModuleId();
- doReturn(vnfInstanceId).when(vfModuleRequestInformation).getVnfInstanceId();
- // mock sdncRequestHeader
- SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
- doReturn(sdncRequestHeader).when(vfModuleTopologyOperationInput).getSdncRequestHeader();
- doReturn(svcRequestId).when(sdncRequestHeader).getSvcRequestId();
-
- Future<RpcResult<VfModuleTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.vfModuleTopologyOperation(vfModuleTopologyOperationInput);
-
- Assert.assertEquals("503", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertTrue(
- rpcResultFuture.get().getResult().getResponseMessage().contains("No service logic active for VNF-API"));
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Success case
- *
- * @throws Exception
- */
- @Test public void vfModuleTopologyOperationSuccess() throws Exception {
- vfModuleName = "vfModuleName";
- vfModuleModelId = "vfModuleModelId";
- vfModuleId = "vfModuleId";
- vnfInstanceId = "vnfInstanceId";
- VfModuleTopologyOperationInput vfModuleTopologyOperationInput = mock(VfModuleTopologyOperationInput.class);
- VfModuleRequestInformation vfModuleRequestInformation = mock(VfModuleRequestInformation.class);
- doReturn(vfModuleRequestInformation).when(vfModuleTopologyOperationInput).getVfModuleRequestInformation();
- VfModuleIdentifiers vfModuleIdentifiers = mock(VfModuleIdentifiers.class);
- doReturn(vfModuleName).when(vfModuleIdentifiers).getVfModuleName();
- doReturn(vfModuleModelId).when(vfModuleIdentifiers).getVfModuleModelId();
- doReturn(vfModuleId).when(vfModuleRequestInformation).getVfModuleId();
- doReturn(vnfInstanceId).when(vfModuleRequestInformation).getVnfInstanceId();
- // mock sdncRequestHeader
- SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
- doReturn(sdncRequestHeader).when(vfModuleTopologyOperationInput).getSdncRequestHeader();
- doReturn(svcRequestId).when(sdncRequestHeader).getSvcRequestId();
- doReturn(true).when(vnfsdnSvcLogicServiceClient).hasGraph(any(), any(), any(), any());
-
- Future<RpcResult<VfModuleTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.vfModuleTopologyOperation(vfModuleTopologyOperationInput);
-
- Assert.assertEquals("200", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals(null, rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Error case:
- * <p>
- * <code>input.getServiceInformation() == null</code>
- *
- * @throws Exception
- */
- @Test public void vnfTopologyOperationErrorOne() throws Exception {
- VnfTopologyOperationInput vnfTopologyOperationInput = mock(VnfTopologyOperationInput.class);
- doReturn(null).when(vnfTopologyOperationInput).getServiceInformation();
-
- Future<RpcResult<VnfTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.vnfTopologyOperation(vnfTopologyOperationInput);
-
- Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals("invalid input, null or empty service-instance-id",
- rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Error case:
- * <p>
- * <code>input.getVnfRequestInformation() == null</code>
- *
- * @throws Exception
- */
- @Test public void vnfTopologyOperationErrorTwo() throws Exception {
- serviceInstanceId = "serviceInstanceId";
- VnfTopologyOperationInput vnfTopologyOperationInput = mock(VnfTopologyOperationInput.class);
- ServiceInformation serviceInformation = mock(ServiceInformation.class);
- doReturn(serviceInformation).when(vnfTopologyOperationInput).getServiceInformation();
- doReturn(serviceInstanceId).when(serviceInformation).getServiceInstanceId();
-
- Future<RpcResult<VnfTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.vnfTopologyOperation(vnfTopologyOperationInput);
-
- Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals("invalid input, null or empty vf-module-id",
- rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Error case:
- * <p>
- * <code>svcLogicClient.hasGraph("VNF-API", SVC_OPERATION, null, "sync") == false</code>
- *
- * @throws Exception
- */
- @Test public void vnfTopologyOperationErrorThree() throws Exception {
- serviceInstanceId = "serviceInstanceId";
- String vnfId = "vnfId";
- VnfTopologyOperationInput vnfTopologyOperationInput = mock(VnfTopologyOperationInput.class);
- ServiceInformation serviceInformation = mock(ServiceInformation.class);
- doReturn(serviceInformation).when(vnfTopologyOperationInput).getServiceInformation();
- doReturn(serviceInstanceId).when(serviceInformation).getServiceInstanceId();
-
- VnfRequestInformation vnfRequestInformation = mock(VnfRequestInformation.class);
- doReturn(vnfRequestInformation).when(vnfTopologyOperationInput).getVnfRequestInformation();
- doReturn(vnfId).when(vnfRequestInformation).getVnfId();
-
- Future<RpcResult<VnfTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.vnfTopologyOperation(vnfTopologyOperationInput);
-
- Assert.assertEquals("503", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertTrue(
- rpcResultFuture.get().getResult().getResponseMessage().contains("No service logic active for VNF-API"));
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Success case
- *
- * @throws Exception
- */
- @Test public void vnfTopologyOperationSuccess() throws Exception {
- serviceInstanceId = "serviceInstanceId";
- String vnfId = "vnfId";
- VnfTopologyOperationInput vnfTopologyOperationInput = mock(VnfTopologyOperationInput.class);
- ServiceInformation serviceInformation = mock(ServiceInformation.class);
- doReturn(serviceInformation).when(vnfTopologyOperationInput).getServiceInformation();
- doReturn(serviceInstanceId).when(serviceInformation).getServiceInstanceId();
-
- VnfRequestInformation vnfRequestInformation = mock(VnfRequestInformation.class);
- doReturn(vnfRequestInformation).when(vnfTopologyOperationInput).getVnfRequestInformation();
- doReturn(vnfId).when(vnfRequestInformation).getVnfId();
- doReturn(true).when(vnfsdnSvcLogicServiceClient).hasGraph(any(), any(), any(), any());
-
- Future<RpcResult<VnfTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.vnfTopologyOperation(vnfTopologyOperationInput);
-
- Assert.assertEquals("200", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals(null, rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Error case:
- * <p>
- * <code>input.getServiceInformation() == null</code>
- *
- * @throws Exception
- */
- @Test public void networkTopologyOperationErrorOne() throws Exception {
- VnfTopologyOperationInput vnfTopologyOperationInput = mock(VnfTopologyOperationInput.class);
- doReturn(null).when(vnfTopologyOperationInput).getServiceInformation();
-
- Future<RpcResult<VnfTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.vnfTopologyOperation(vnfTopologyOperationInput);
-
- Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals("invalid input, null or empty service-instance-id",
- rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Error case:
- * <p>
- * <code>input.getNetworkRequestInformation() == null</code>
- *
- * @throws Exception
- */
- @Test public void networkTopologyOperationErrorTwo() throws Exception {
- serviceInstanceId = "serviceInstanceId";
- NetworkTopologyOperationInput networkTopologyOperation = mock(NetworkTopologyOperationInput.class);
- ServiceInformation serviceInformation = mock(ServiceInformation.class);
- doReturn(serviceInstanceId).when(serviceInformation).getServiceInstanceId();
- doReturn(serviceInformation).when(networkTopologyOperation).getServiceInformation();
-
- Future<RpcResult<NetworkTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.networkTopologyOperation(networkTopologyOperation);
-
- Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals("invalid input, null or empty service-instance-id",
- rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Error case:
- * <p>
- * <code>svcLogicClient.hasGraph("VNF-API", SVC_OPERATION, null, "sync") == false</code>
- *
- * @throws Exception
- */
- @Test public void networkTopologyOperationErrorThree() throws Exception {
- serviceInstanceId = "serviceInstanceId";
- NetworkTopologyOperationInput networkTopologyOperationInput = mock(NetworkTopologyOperationInput.class);
- ServiceInformation serviceInformation = mock(ServiceInformation.class);
- doReturn(serviceInstanceId).when(serviceInformation).getServiceInstanceId();
- doReturn(serviceInformation).when(networkTopologyOperationInput).getServiceInformation();
-
- NetworkRequestInformation networkRequestInformation = mock(NetworkRequestInformation.class);
- doReturn(networkRequestInformation).when(networkTopologyOperationInput).getNetworkRequestInformation();
- doReturn("NetworkName").when(networkRequestInformation).getNetworkName();
-
- SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
- doReturn(SdncRequestHeader.SvcAction.Assign).when(sdncRequestHeader).getSvcAction();
- doReturn(sdncRequestHeader).when(networkTopologyOperationInput).getSdncRequestHeader();
-
- Future<RpcResult<NetworkTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.networkTopologyOperation(networkTopologyOperationInput);
-
- Assert.assertEquals("503", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertTrue(
- rpcResultFuture.get().getResult().getResponseMessage().contains("No service logic active for VNF-API"));
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Success case
- *
- * @throws Exception
- */
- @Test public void networkTopologyOperationSuccess() throws Exception {
- serviceInstanceId = "serviceInstanceId";
- NetworkTopologyOperationInput networkTopologyOperationInput = mock(NetworkTopologyOperationInput.class);
- ServiceInformation serviceInformation = mock(ServiceInformation.class);
- doReturn(serviceInstanceId).when(serviceInformation).getServiceInstanceId();
- doReturn(serviceInformation).when(networkTopologyOperationInput).getServiceInformation();
- //mock networkRequestInformation
- NetworkRequestInformation networkRequestInformation = mock(NetworkRequestInformation.class);
- doReturn(networkRequestInformation).when(networkTopologyOperationInput).getNetworkRequestInformation();
- doReturn("NetworkName").when(networkRequestInformation).getNetworkName();
- //mock sdncRequestHeader
- SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
- doReturn(SdncRequestHeader.SvcAction.Assign).when(sdncRequestHeader).getSvcAction();
- doReturn(sdncRequestHeader).when(networkTopologyOperationInput).getSdncRequestHeader();
- doReturn(true).when(vnfsdnSvcLogicServiceClient).hasGraph(any(), any(), any(), any());
-
- Future<RpcResult<NetworkTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.networkTopologyOperation(networkTopologyOperationInput);
-
- Assert.assertEquals("200", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals(null, rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Error case:
- * <p>
- * <code>input.getVnfTopologyInformation() == null</code>
- *
- * @throws Exception
- */
- @Test public void preloadVnfTopologyOperationErrorOne() throws Exception {
- PreloadVnfTopologyOperationInput preloadVnfTopologyOperationInput =
- mock(PreloadVnfTopologyOperationInput.class);
- doReturn(null).when(preloadVnfTopologyOperationInput).getVnfTopologyInformation();
-
- Future<RpcResult<PreloadVnfTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.preloadVnfTopologyOperation(preloadVnfTopologyOperationInput);
-
- Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals("invalid input, null or empty vnf-name or vnf-type",
- rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Error case:
- * <p>
- * <code>preload_name.length() == 0</code>
- * And
- * <code>preload_type.length() == 0</code>
- *
- * @throws Exception
- */
- @Test public void preloadVnfTopologyOperationErrorTwo() throws Exception {
- // preload_name.length() == 0
- vnfName = "";
- vnfType = "vfModuleModelId";
- PreloadVnfTopologyOperationInput preloadVnfTopologyOperationInput =
- mock(PreloadVnfTopologyOperationInput.class);
- doReturn(null).when(preloadVnfTopologyOperationInput).getVnfTopologyInformation();
-
- VnfTopologyInformation vnfTopologyInformation = mock(VnfTopologyInformation.class);
- doReturn(vnfTopologyInformation).when(preloadVnfTopologyOperationInput).getVnfTopologyInformation();
- VnfTopologyIdentifier vnfTopologyIdentifier = mock(VnfTopologyIdentifier.class);
- doReturn(vnfName).when(vnfTopologyIdentifier).getVnfName();
- doReturn(vnfType).when(vnfTopologyIdentifier).getVnfType();
- doReturn(vnfTopologyIdentifier).when(vnfTopologyInformation).getVnfTopologyIdentifier();
-
- Future<RpcResult<PreloadVnfTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.preloadVnfTopologyOperation(preloadVnfTopologyOperationInput);
-
- Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals("invalid input, invalid preload-name",
- rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
-
- // preload_type.length() == 0
- vnfName = "vnfName";
- vnfType = "";
- doReturn(vnfName).when(vnfTopologyIdentifier).getVnfName();
- doReturn(vnfType).when(vnfTopologyIdentifier).getVnfType();
-
- rpcResultFuture = vnfapiProvider.preloadVnfTopologyOperation(preloadVnfTopologyOperationInput);
-
- Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals("invalid input, invalid preload-type",
- rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Error case:
- * <code>svcLogicClient.hasGraph("VNF-API", SVC_OPERATION, null, "sync") = false</code>
- *
- * @throws Exception
- */
- @Test public void preloadVnfTopologyOperationErrorThree() throws Exception {
- // preload_name.length() == 0
- vnfName = "vnfName";
- vnfType = "vfModuleModelId";
- PreloadVnfTopologyOperationInput preloadVnfTopologyOperationInput =
- mock(PreloadVnfTopologyOperationInput.class);
- doReturn(null).when(preloadVnfTopologyOperationInput).getVnfTopologyInformation();
-
- VnfTopologyInformation vnfTopologyInformation = mock(VnfTopologyInformation.class);
- doReturn(vnfTopologyInformation).when(preloadVnfTopologyOperationInput).getVnfTopologyInformation();
- VnfTopologyIdentifier vnfTopologyIdentifier = mock(VnfTopologyIdentifier.class);
- doReturn(vnfName).when(vnfTopologyIdentifier).getVnfName();
- doReturn(vnfType).when(vnfTopologyIdentifier).getVnfType();
- doReturn(vnfTopologyIdentifier).when(vnfTopologyInformation).getVnfTopologyIdentifier();
-
- Future<RpcResult<PreloadVnfTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.preloadVnfTopologyOperation(preloadVnfTopologyOperationInput);
-
- Assert.assertEquals("503", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertTrue(
- rpcResultFuture.get().getResult().getResponseMessage().contains("No service logic active for VNF-API"));
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Success case
- *
- * @throws Exception
- */
- @Test public void preloadVnfTopologyOperationSuccess() throws Exception {
- // preload_name.length() == 0
- vnfName = "vnfName";
- vnfType = "vfModuleModelId";
- PreloadVnfTopologyOperationInput preloadVnfTopologyOperationInput =
- mock(PreloadVnfTopologyOperationInput.class);
- doReturn(null).when(preloadVnfTopologyOperationInput).getVnfTopologyInformation();
-
- VnfTopologyInformation vnfTopologyInformation = mock(VnfTopologyInformation.class);
- doReturn(vnfTopologyInformation).when(preloadVnfTopologyOperationInput).getVnfTopologyInformation();
- VnfTopologyIdentifier vnfTopologyIdentifier = mock(VnfTopologyIdentifier.class);
- doReturn(vnfName).when(vnfTopologyIdentifier).getVnfName();
- doReturn(vnfType).when(vnfTopologyIdentifier).getVnfType();
- doReturn(vnfTopologyIdentifier).when(vnfTopologyInformation).getVnfTopologyIdentifier();
- doReturn(true).when(vnfsdnSvcLogicServiceClient).hasGraph(any(), any(), any(), any());
-
- Future<RpcResult<PreloadVnfTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.preloadVnfTopologyOperation(preloadVnfTopologyOperationInput);
-
- Assert.assertEquals("200", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals(null, rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Error case:
- * <p>
- * <code>input.getVnfInstanceTopologyInformation() == null</code>
- *
- * @throws Exception
- */
- @Test public void preloadVnfInstanceTopologyOperationErrorOne() throws Exception {
- PreloadVnfInstanceTopologyOperationInput preloadVnfInstanceTopologyOperationInput =
- mock(PreloadVnfInstanceTopologyOperationInput.class);
- doReturn(null).when(preloadVnfInstanceTopologyOperationInput).getVnfInstanceTopologyInformation();
- Future<RpcResult<PreloadVnfInstanceTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.preloadVnfInstanceTopologyOperation(preloadVnfInstanceTopologyOperationInput);
-
- Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals("invalid input, null or empty vnf-instance-name or vnf-model-id",
- rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Error case:
- * <p>
- * <code>preload_name = ""</code>
- * And
- * <code>preload_type = ""</code>
- *
- * @throws Exception
- */
- @Test public void preloadVnfInstanceTopologyOperationErrorTwo() throws Exception {
- // preload_type = ""
- vnfInstanceName = "vnfInstanceName";
- vnfModelId = "";
- PreloadVnfInstanceTopologyOperationInput preloadVnfInstanceTopologyOperationInput =
- mock(PreloadVnfInstanceTopologyOperationInput.class);
- VnfInstanceTopologyInformation vnfInstanceTopologyInformation = mock(VnfInstanceTopologyInformation.class);
- doReturn(vnfInstanceTopologyInformation).when(preloadVnfInstanceTopologyOperationInput)
- .getVnfInstanceTopologyInformation();
- VnfInstanceIdentifiers vnfInstanceIdentifiers = mock(VnfInstanceIdentifiers.class);
- doReturn(vnfInstanceName).when(vnfInstanceIdentifiers).getVnfInstanceName();
- doReturn(vnfModelId).when(vnfInstanceIdentifiers).getVnfModelId();
- doReturn(vnfInstanceIdentifiers).when(vnfInstanceTopologyInformation).getVnfInstanceIdentifiers();
-
- Future<RpcResult<PreloadVnfInstanceTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.preloadVnfInstanceTopologyOperation(preloadVnfInstanceTopologyOperationInput);
-
- Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals("invalid input, invalid preload-type",
- rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
-
- //preload_name == ""
- vnfInstanceName = "";
- vnfModelId = "vnfModelId";
- doReturn(vnfInstanceName).when(vnfInstanceIdentifiers).getVnfInstanceName();
- doReturn(vnfModelId).when(vnfInstanceIdentifiers).getVnfModelId();
-
- rpcResultFuture = vnfapiProvider.preloadVnfInstanceTopologyOperation(preloadVnfInstanceTopologyOperationInput);
-
- Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals("invalid input, invalid preload-name",
- rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Error case:
- * <p>
- * <code>svcLogicClient.hasGraph("VNF-API", SVC_OPERATION, null, "sync") = false</code>
- *
- * @throws Exception
- */
- @Test public void preloadVnfInstanceTopologyOperationErrorThree() throws Exception {
- // preload_type = ""
- vnfInstanceName = "vnfInstanceName";
- vnfModelId = "vnfModelId";
- PreloadVnfInstanceTopologyOperationInput preloadVnfInstanceTopologyOperationInput =
- mock(PreloadVnfInstanceTopologyOperationInput.class);
- VnfInstanceTopologyInformation vnfInstanceTopologyInformation = mock(VnfInstanceTopologyInformation.class);
- doReturn(vnfInstanceTopologyInformation).when(preloadVnfInstanceTopologyOperationInput)
- .getVnfInstanceTopologyInformation();
- VnfInstanceIdentifiers vnfInstanceIdentifiers = mock(VnfInstanceIdentifiers.class);
- doReturn(vnfInstanceName).when(vnfInstanceIdentifiers).getVnfInstanceName();
- doReturn(vnfModelId).when(vnfInstanceIdentifiers).getVnfModelId();
- doReturn(vnfInstanceIdentifiers).when(vnfInstanceTopologyInformation).getVnfInstanceIdentifiers();
- SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
- doReturn(sdncRequestHeader).when(preloadVnfInstanceTopologyOperationInput).getSdncRequestHeader();
- doReturn(svcRequestId).when(sdncRequestHeader).getSvcRequestId();
-
- Future<RpcResult<PreloadVnfInstanceTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.preloadVnfInstanceTopologyOperation(preloadVnfInstanceTopologyOperationInput);
-
- Assert.assertEquals("503", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertTrue(
- rpcResultFuture.get().getResult().getResponseMessage().contains("No service logic active for VNF-API"));
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Success case
- *
- * @throws Exception
- */
- @Test public void preloadVnfInstanceTopologyOperationSuccess() throws Exception {
- // preload_type = ""
- vnfInstanceName = "vnfInstanceName";
- vnfModelId = "vnfModelId";
- PreloadVnfInstanceTopologyOperationInput preloadVnfInstanceTopologyOperationInput =
- mock(PreloadVnfInstanceTopologyOperationInput.class);
- VnfInstanceTopologyInformation vnfInstanceTopologyInformation = mock(VnfInstanceTopologyInformation.class);
- doReturn(vnfInstanceTopologyInformation).when(preloadVnfInstanceTopologyOperationInput)
- .getVnfInstanceTopologyInformation();
- VnfInstanceIdentifiers vnfInstanceIdentifiers = mock(VnfInstanceIdentifiers.class);
- doReturn(vnfInstanceName).when(vnfInstanceIdentifiers).getVnfInstanceName();
- doReturn(vnfModelId).when(vnfInstanceIdentifiers).getVnfModelId();
- doReturn(vnfInstanceIdentifiers).when(vnfInstanceTopologyInformation).getVnfInstanceIdentifiers();
- SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
- doReturn(sdncRequestHeader).when(preloadVnfInstanceTopologyOperationInput).getSdncRequestHeader();
- doReturn(svcRequestId).when(sdncRequestHeader).getSvcRequestId();
- doReturn(true).when(vnfsdnSvcLogicServiceClient).hasGraph(any(), any(), any(), any());
-
- Future<RpcResult<PreloadVnfInstanceTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.preloadVnfInstanceTopologyOperation(preloadVnfInstanceTopologyOperationInput);
-
- Assert.assertEquals("200", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals(null, rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Error case:
- * <p>
- * <code>input.getVfModuleTopologyInformation() == null</code>
- *
- * @throws Exception
- */
- @Test public void preloadVfModuleTopologyOperationErrorOne() throws Exception {
- PreloadVfModuleTopologyOperationInput preloadVnfTopologyOperationInput =
- mock(PreloadVfModuleTopologyOperationInput.class);
- doReturn(null).when(preloadVnfTopologyOperationInput).getVfModuleTopologyInformation();
-
- Future<RpcResult<PreloadVfModuleTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.preloadVfModuleTopologyOperation(preloadVnfTopologyOperationInput);
-
- Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals("invalid input, null or empty vf-module-name or vf-module-model-id",
- rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Error case:
- * <p>
- * <code>preload_name = ""</code>
- * And
- * <code>preload_type = ""</code>
- *
- * @throws Exception
- */
- @Test public void preloadVfModuleTopologyOperationErrorTwo() throws Exception {
- // preload_name = ""
- vfModuleName = "";
- vfModuleModelId = "vfModuleModelId";
- PreloadVfModuleTopologyOperationInput preloadVnfTopologyOperationInput =
- mock(PreloadVfModuleTopologyOperationInput.class);
- VfModuleTopologyInformation vfModuleTopologyInformation = mock(VfModuleTopologyInformation.class);
- doReturn(vfModuleTopologyInformation).when(preloadVnfTopologyOperationInput).getVfModuleTopologyInformation();
- VfModuleIdentifiers vfModuleIdentifiers = mock(VfModuleIdentifiers.class);
- doReturn(vfModuleName).when(vfModuleIdentifiers).getVfModuleName();
- doReturn(vfModuleModelId).when(vfModuleIdentifiers).getVfModuleModelId();
- doReturn(vfModuleIdentifiers).when(vfModuleTopologyInformation).getVfModuleIdentifiers();
-
- Future<RpcResult<PreloadVfModuleTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.preloadVfModuleTopologyOperation(preloadVnfTopologyOperationInput);
-
- Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals("invalid input, invalid preload-name",
- rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
-
- // preload_type = ""
- vfModuleName = "vfModuleName";
- vfModuleModelId = "";
- doReturn(vfModuleName).when(vfModuleIdentifiers).getVfModuleName();
- doReturn(vfModuleModelId).when(vfModuleIdentifiers).getVfModuleModelId();
-
- rpcResultFuture = vnfapiProvider.preloadVfModuleTopologyOperation(preloadVnfTopologyOperationInput);
-
- Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals("invalid input, invalid preload-type",
- rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Error case:
- * <p>
- * <code>svcLogicClient.hasGraph("VNF-API", SVC_OPERATION, null, "sync") = false</code>
- *
- * @throws Exception
- */
- @Test public void preloadVfModuleTopologyOperationErrorThree() throws Exception {
- // preload_name = ""
- vfModuleName = "vfModuleName";
- vfModuleModelId = "vfModuleModelId";
- PreloadVfModuleTopologyOperationInput preloadVnfTopologyOperationInput =
- mock(PreloadVfModuleTopologyOperationInput.class);
- VfModuleTopologyInformation vfModuleTopologyInformation = mock(VfModuleTopologyInformation.class);
- doReturn(vfModuleTopologyInformation).when(preloadVnfTopologyOperationInput).getVfModuleTopologyInformation();
- VfModuleIdentifiers vfModuleIdentifiers = mock(VfModuleIdentifiers.class);
- doReturn(vfModuleName).when(vfModuleIdentifiers).getVfModuleName();
- doReturn(vfModuleModelId).when(vfModuleIdentifiers).getVfModuleModelId();
- doReturn(vfModuleIdentifiers).when(vfModuleTopologyInformation).getVfModuleIdentifiers();
- SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
- doReturn(sdncRequestHeader).when(preloadVnfTopologyOperationInput).getSdncRequestHeader();
- doReturn(svcRequestId).when(sdncRequestHeader).getSvcRequestId();
-
- Future<RpcResult<PreloadVfModuleTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.preloadVfModuleTopologyOperation(preloadVnfTopologyOperationInput);
-
- Assert.assertEquals("503", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertTrue(
- rpcResultFuture.get().getResult().getResponseMessage().contains("No service logic active for VNF-API"));
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Success case
- *
- * @throws Exception
- */
- @Test public void preloadVfModuleTopologyOperationSuccess() throws Exception {
- // preload_name = ""
- vfModuleName = "vfModuleName";
- vfModuleModelId = "vfModuleModelId";
- PreloadVfModuleTopologyOperationInput preloadVnfTopologyOperationInput =
- mock(PreloadVfModuleTopologyOperationInput.class);
- VfModuleTopologyInformation vfModuleTopologyInformation = mock(VfModuleTopologyInformation.class);
- doReturn(vfModuleTopologyInformation).when(preloadVnfTopologyOperationInput).getVfModuleTopologyInformation();
- VfModuleIdentifiers vfModuleIdentifiers = mock(VfModuleIdentifiers.class);
- doReturn(vfModuleName).when(vfModuleIdentifiers).getVfModuleName();
- doReturn(vfModuleModelId).when(vfModuleIdentifiers).getVfModuleModelId();
- doReturn(vfModuleIdentifiers).when(vfModuleTopologyInformation).getVfModuleIdentifiers();
- SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
- doReturn(sdncRequestHeader).when(preloadVnfTopologyOperationInput).getSdncRequestHeader();
- doReturn(svcRequestId).when(sdncRequestHeader).getSvcRequestId();
- doReturn(true).when(vnfsdnSvcLogicServiceClient).hasGraph(any(), any(), any(), any());
-
- Future<RpcResult<PreloadVfModuleTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.preloadVfModuleTopologyOperation(preloadVnfTopologyOperationInput);
-
- Assert.assertEquals("200", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals(null, rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Error case:
- * <p>
- * <code>input.getNetworkTopologyInformation() == null</code>
- *
- * @throws Exception
- */
- @Test public void preloadNetworkTopologyOperationErrorOne() throws Exception {
- PreloadNetworkTopologyOperationInput PreloadNetworkTopologyOperationInput =
- mock(PreloadNetworkTopologyOperationInput.class);
- doReturn(null).when(PreloadNetworkTopologyOperationInput).getNetworkTopologyInformation();
-
- Future<RpcResult<PreloadNetworkTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.preloadNetworkTopologyOperation(PreloadNetworkTopologyOperationInput);
-
- Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals("input, null or empty network-name or network-type",
- rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Error case:
- * <p>
- * <code>preload_name == ""</code>
- * ANd
- * <code>preload_type == ""ss</code>
- *
- * @throws Exception
- */
- @Test public void preloadNetworkTopologyOperationErrorTwo() throws Exception {
- String networkName = "";
- String networkType = "NetworkType";
- PreloadNetworkTopologyOperationInput PreloadNetworkTopologyOperationInput =
- mock(PreloadNetworkTopologyOperationInput.class);
- NetworkTopologyInformation networkTopologyInformation = mock(NetworkTopologyInformation.class);
- doReturn(networkTopologyInformation).when(PreloadNetworkTopologyOperationInput).getNetworkTopologyInformation();
- NetworkTopologyIdentifier networkTopologyIdentifier = mock(NetworkTopologyIdentifier.class);
- doReturn(networkTopologyIdentifier).when(networkTopologyInformation).getNetworkTopologyIdentifier();
- doReturn(networkName).when(networkTopologyIdentifier).getNetworkName();
- doReturn(networkType).when(networkTopologyIdentifier).getNetworkType();
-
- Future<RpcResult<PreloadNetworkTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.preloadNetworkTopologyOperation(PreloadNetworkTopologyOperationInput);
-
- Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals("input, invalid preload-name", rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
-
- networkName = "NetworkName";
- networkType = "";
- doReturn(networkName).when(networkTopologyIdentifier).getNetworkName();
- doReturn(networkType).when(networkTopologyIdentifier).getNetworkType();
-
- rpcResultFuture = vnfapiProvider.preloadNetworkTopologyOperation(PreloadNetworkTopologyOperationInput);
-
- Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals("input, invalid preload-type", rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Error case:
- * <p>
- * <code>svcLogicClient.hasGraph("VNF-API",SVC_OPERATION,null,"sync" = false</code>
- *
- * @throws Exception
- */
- @Test public void preloadNetworkTopologyOperationErrorThree() throws Exception {
- String networkName = "NetworkName";
- String networkType = "NetworkType";
- PreloadNetworkTopologyOperationInput PreloadNetworkTopologyOperationInput =
- mock(PreloadNetworkTopologyOperationInput.class);
- NetworkTopologyInformation networkTopologyInformation = mock(NetworkTopologyInformation.class);
- doReturn(networkTopologyInformation).when(PreloadNetworkTopologyOperationInput).getNetworkTopologyInformation();
- NetworkTopologyIdentifier networkTopologyIdentifier = mock(NetworkTopologyIdentifier.class);
- doReturn(networkTopologyIdentifier).when(networkTopologyInformation).getNetworkTopologyIdentifier();
- doReturn(networkName).when(networkTopologyIdentifier).getNetworkName();
- doReturn(networkType).when(networkTopologyIdentifier).getNetworkType();
- SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
- doReturn(sdncRequestHeader).when(PreloadNetworkTopologyOperationInput).getSdncRequestHeader();
- doReturn(svcRequestId).when(sdncRequestHeader).getSvcRequestId();
-
- Future<RpcResult<PreloadNetworkTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.preloadNetworkTopologyOperation(PreloadNetworkTopologyOperationInput);
-
- Assert.assertEquals("503", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertTrue(
- rpcResultFuture.get().getResult().getResponseMessage().contains("No service logic active for VNF-API"));
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Success case
- *
- * @throws Exception
- */
- @Test public void preloadNetworkTopologyOperationErrorFour() throws Exception {
- String networkName = "NetworkName";
- String networkType = "NetworkType";
- PreloadNetworkTopologyOperationInput PreloadNetworkTopologyOperationInput =
- mock(PreloadNetworkTopologyOperationInput.class);
- NetworkTopologyInformation networkTopologyInformation = mock(NetworkTopologyInformation.class);
- doReturn(networkTopologyInformation).when(PreloadNetworkTopologyOperationInput).getNetworkTopologyInformation();
- NetworkTopologyIdentifier networkTopologyIdentifier = mock(NetworkTopologyIdentifier.class);
- doReturn(networkTopologyIdentifier).when(networkTopologyInformation).getNetworkTopologyIdentifier();
- doReturn(networkName).when(networkTopologyIdentifier).getNetworkName();
- doReturn(networkType).when(networkTopologyIdentifier).getNetworkType();
- SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
- doReturn(sdncRequestHeader).when(PreloadNetworkTopologyOperationInput).getSdncRequestHeader();
- doReturn(svcRequestId).when(sdncRequestHeader).getSvcRequestId();
- doReturn(true).when(vnfsdnSvcLogicServiceClient).hasGraph(any(), any(), any(), any());
- doReturn(null).when(dataBroker).newWriteOnlyTransaction();
-
- Future<RpcResult<PreloadNetworkTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.preloadNetworkTopologyOperation(PreloadNetworkTopologyOperationInput);
-
- Assert.assertEquals("500", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals("java.lang.NullPointerException", rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- /**
- * Test Success case
- *
- * @throws Exception
- */
- @Test public void preloadNetworkTopologyOperationSuccess() throws Exception {
- String networkName = "NetworkName";
- String networkType = "NetworkType";
- PreloadNetworkTopologyOperationInput PreloadNetworkTopologyOperationInput =
- mock(PreloadNetworkTopologyOperationInput.class);
- NetworkTopologyInformation networkTopologyInformation = mock(NetworkTopologyInformation.class);
- doReturn(networkTopologyInformation).when(PreloadNetworkTopologyOperationInput).getNetworkTopologyInformation();
- NetworkTopologyIdentifier networkTopologyIdentifier = mock(NetworkTopologyIdentifier.class);
- doReturn(networkTopologyIdentifier).when(networkTopologyInformation).getNetworkTopologyIdentifier();
- doReturn(networkName).when(networkTopologyIdentifier).getNetworkName();
- doReturn(networkType).when(networkTopologyIdentifier).getNetworkType();
- SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
- doReturn(sdncRequestHeader).when(PreloadNetworkTopologyOperationInput).getSdncRequestHeader();
- doReturn(svcRequestId).when(sdncRequestHeader).getSvcRequestId();
- doReturn(true).when(vnfsdnSvcLogicServiceClient).hasGraph(any(), any(), any(), any());
-
- Future<RpcResult<PreloadNetworkTopologyOperationOutput>> rpcResultFuture =
- vnfapiProvider.preloadNetworkTopologyOperation(PreloadNetworkTopologyOperationInput);
-
- Assert.assertEquals("200", rpcResultFuture.get().getResult().getResponseCode());
- Assert.assertEquals(null, rpcResultFuture.get().getResult().getResponseMessage());
- Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
- }
-
- @Test public void getVfModuleServiceData() throws Exception {
- // Three parameters: siid, vfModuleServiceDataBuilder, LogicalDatastoreType
- String ssid = "ssid";
- VfModuleServiceDataBuilder vfModuleServiceDataBuilder = spy(new VfModuleServiceDataBuilder());
- Optional<VfModuleList> optional = mock(Optional.class);
- doReturn(optional).when(checkedFuture).get();
- doReturn(true).when(optional).isPresent();
- VfModuleList vfModuleList = mock(VfModuleList.class);
- doReturn(vfModuleList).when(optional).get();
- VfModuleServiceData vfModuleServiceData = mock(VfModuleServiceData.class);
- doReturn(vfModuleServiceData).when(vfModuleList).getVfModuleServiceData();
- SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
- doReturn(sdncRequestHeader).when(vfModuleServiceData).getSdncRequestHeader();
-
- Whitebox.invokeMethod(vnfapiProvider, "getVfModuleServiceData", ssid, vfModuleServiceDataBuilder,
- LogicalDatastoreType.CONFIGURATION);
-
- Assert.assertEquals(sdncRequestHeader, vfModuleServiceDataBuilder.getSdncRequestHeader());
-
- //With Two parameters: siid, vfModuleServiceDataBuilder
- Whitebox.invokeMethod(vnfapiProvider, "getVfModuleServiceData", ssid, vfModuleServiceDataBuilder);
-
- Assert.assertEquals(sdncRequestHeader, vfModuleServiceDataBuilder.getSdncRequestHeader());
- }
-
- @Test public void getPreloadData() throws Exception {
- // Four parameters:
- // String preload_name, String preload_type, PreloadDataBuilder preloadDataBuilder, LogicalDatastoreType type
- PreloadDataBuilder preloadDataBuilder = spy(new PreloadDataBuilder());
- // mock optional
- Optional<VnfPreloadList> optional = mock(Optional.class);
- doReturn(optional).when(checkedFuture).get();
- doReturn(true).when(optional).isPresent();
-
- VnfPreloadList vnfPreloadList = mock(VnfPreloadList.class);
- doReturn(vnfPreloadList).when(optional).get();
- PreloadData preloadData = mock(PreloadData.class);
- doReturn(preloadData).when(vnfPreloadList).getPreloadData();
-
- VnfTopologyInformation vnfTopologyInformation = mock(VnfTopologyInformation.class);
- doReturn(vnfTopologyInformation).when(preloadData).getVnfTopologyInformation();
-
- Whitebox.invokeMethod(vnfapiProvider, "getPreloadData", "preloadName", "preloadType", preloadDataBuilder,
- LogicalDatastoreType.CONFIGURATION);
-
- Assert.assertEquals(vnfTopologyInformation, preloadDataBuilder.getVnfTopologyInformation());
-
- // Three parameters:
- // String preload_name, String preload_type, PreloadDataBuilder preloadDataBuilder, LogicalDatastoreType type
- Whitebox.invokeMethod(vnfapiProvider, "getPreloadData", "preloadName", "preloadType", preloadDataBuilder);
-
- Assert.assertEquals(vnfTopologyInformation, preloadDataBuilder.getVnfTopologyInformation());
- }
-
- @Test public void getVnfInstancePreloadData() throws Exception {
- // Four parameters:
- // String preload_name, String preload_type, VnfInstancePreloadDataBuilder preloadDataBuilder,
- // LogicalDatastoreType type
- VnfInstancePreloadDataBuilder vnfInstancePreloadDataBuilder = spy(new VnfInstancePreloadDataBuilder());
- // mock optional
- Optional<VnfPreloadList> optional = mock(Optional.class);
- doReturn(optional).when(checkedFuture).get();
- doReturn(true).when(optional).isPresent();
- VnfInstancePreloadList vnfInstancePreloadList = mock(VnfInstancePreloadList.class);
- doReturn(vnfInstancePreloadList).when(optional).get();
- VnfInstancePreloadData vnfInstancePreloadData = mock(VnfInstancePreloadData.class);
- doReturn(vnfInstancePreloadData).when(vnfInstancePreloadList).getVnfInstancePreloadData();
- VnfInstanceTopologyInformation vnfInstanceTopologyInformation = mock(VnfInstanceTopologyInformation.class);
- doReturn(vnfInstanceTopologyInformation).when(vnfInstancePreloadData).getVnfInstanceTopologyInformation();
-
- Whitebox.invokeMethod(vnfapiProvider, "getVnfInstancePreloadData", "preloadName", "preloadType",
- vnfInstancePreloadDataBuilder, LogicalDatastoreType.CONFIGURATION);
-
- Assert.assertEquals(vnfInstanceTopologyInformation,
- vnfInstancePreloadDataBuilder.getVnfInstanceTopologyInformation());
-
- // Three Parameters:
- // String preload_name, String preload_type, VnfInstancePreloadDataBuilder preloadDataBuilder
- Whitebox.invokeMethod(vnfapiProvider, "getVnfInstancePreloadData", "preloadName", "preloadType",
- vnfInstancePreloadDataBuilder);
-
- Assert.assertEquals(vnfInstanceTopologyInformation,
- vnfInstancePreloadDataBuilder.getVnfInstanceTopologyInformation());
- }
-
- @Test public void getVfModulePreloadData() throws Exception {
- // Four Parameters
- // String preload_name, String preload_type, VfModulePreloadDataBuilder preloadDataBuilder,
- // LogicalDatastoreType type
- VfModulePreloadDataBuilder vfModulePreloadDataBuilder = spy(new VfModulePreloadDataBuilder());
- // mock optional
- Optional<VfModulePreloadList> optional = mock(Optional.class);
- doReturn(optional).when(checkedFuture).get();
- doReturn(true).when(optional).isPresent();
- VfModulePreloadList vfModulePreloadList = mock(VfModulePreloadList.class);
- doReturn(vfModulePreloadList).when(optional).get();
- VfModulePreloadData vfModulePreloadData = mock(VfModulePreloadData.class);
- doReturn(vfModulePreloadData).when(vfModulePreloadList).getVfModulePreloadData();
- VfModuleTopologyInformation vfModuleTopologyInformation = mock(VfModuleTopologyInformation.class);
- doReturn(vfModuleTopologyInformation).when(vfModulePreloadData).getVfModuleTopologyInformation();
-
- Whitebox.invokeMethod(vnfapiProvider, "getVfModulePreloadData", "preloadName", "preloadType",
- vfModulePreloadDataBuilder, LogicalDatastoreType.CONFIGURATION);
-
- Assert.assertEquals(vfModuleTopologyInformation, vfModulePreloadDataBuilder.getVfModuleTopologyInformation());
-
- // Three Parameters:
- // String vnf_name, String vnf_type, VfModulePreloadDataBuilder preloadDataBuilder
- Whitebox.invokeMethod(vnfapiProvider, "getVfModulePreloadData", "preloadName", "preloadType",
- vfModulePreloadDataBuilder);
-
- Assert.assertEquals(vfModuleTopologyInformation, vfModulePreloadDataBuilder.getVfModuleTopologyInformation());
- }
-
- /**
- * With ServiceStatusBuilder, RequestInformation
- */
- @Test public void setServiceStatusOne() throws Exception {
- // VNFActivateRequest
- RequestInformation requestInformation = mock(RequestInformation.class);
- ServiceStatusBuilder serviceStatusBuilder = spy(new ServiceStatusBuilder());
- doReturn(RequestInformation.RequestAction.VNFActivateRequest).when(requestInformation).getRequestAction();
- doReturn(RequestInformation.RequestSubAction.SUPP).when(requestInformation).getRequestSubAction();
- Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
- Assert.assertEquals(ServiceStatus.VnfsdnAction.VNFActivateRequest, serviceStatusBuilder.getVnfsdnAction());
-
- //ChangeVNFActivateRequest
- doReturn(RequestInformation.RequestAction.ChangeVNFActivateRequest).when(requestInformation).getRequestAction();
- doReturn(RequestInformation.RequestSubAction.CANCEL).when(requestInformation).getRequestSubAction();
- Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
- Assert
- .assertEquals(ServiceStatus.VnfsdnAction.ChangeVNFActivateRequest, serviceStatusBuilder.getVnfsdnAction());
-
- //DisconnectVNFRequest
- doReturn(RequestInformation.RequestAction.DisconnectVNFRequest).when(requestInformation).getRequestAction();
- Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
- Assert.assertEquals(ServiceStatus.VnfsdnAction.DisconnectVNFRequest, serviceStatusBuilder.getVnfsdnAction());
-
- //PreloadVNFRequest
- doReturn(RequestInformation.RequestAction.PreloadVNFRequest).when(requestInformation).getRequestAction();
- Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
- Assert.assertEquals(ServiceStatus.VnfsdnAction.PreloadVNFRequest, serviceStatusBuilder.getVnfsdnAction());
-
- //DeletePreloadVNFRequest
- doReturn(RequestInformation.RequestAction.DeletePreloadVNFRequest).when(requestInformation).getRequestAction();
- Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
- Assert.assertEquals(ServiceStatus.VnfsdnAction.DeletePreloadVNFRequest, serviceStatusBuilder.getVnfsdnAction());
-
- //VnfInstanceActivateRequest
- doReturn(RequestInformation.RequestAction.VnfInstanceActivateRequest).when(requestInformation)
- .getRequestAction();
- Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
- Assert.assertEquals(ServiceStatus.VnfsdnAction.VnfInstanceActivateRequest,
- serviceStatusBuilder.getVnfsdnAction());
-
- //ChangeVnfInstanceActivateRequest
- doReturn(RequestInformation.RequestAction.ChangeVnfInstanceActivateRequest).when(requestInformation)
- .getRequestAction();
- Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
- Assert.assertEquals(ServiceStatus.VnfsdnAction.ChangeVnfInstanceActivateRequest,
- serviceStatusBuilder.getVnfsdnAction());
-
- //DisconnectVnfInstanceRequest
- doReturn(RequestInformation.RequestAction.DisconnectVnfInstanceRequest).when(requestInformation)
- .getRequestAction();
- Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
- Assert.assertEquals(ServiceStatus.VnfsdnAction.DisconnectVnfInstanceRequest,
- serviceStatusBuilder.getVnfsdnAction());
-
- //PreloadVnfInstanceRequest
- doReturn(RequestInformation.RequestAction.PreloadVnfInstanceRequest).when(requestInformation)
- .getRequestAction();
- Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
- Assert
- .assertEquals(ServiceStatus.VnfsdnAction.PreloadVnfInstanceRequest, serviceStatusBuilder.getVnfsdnAction());
-
- //VfModuleActivateRequest
- doReturn(RequestInformation.RequestAction.VfModuleActivateRequest).when(requestInformation).getRequestAction();
- Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
- Assert.assertEquals(ServiceStatus.VnfsdnAction.VfModuleActivateRequest, serviceStatusBuilder.getVnfsdnAction());
-
- //ChangeVfModuleActivateRequest
- doReturn(RequestInformation.RequestAction.ChangeVfModuleActivateRequest).when(requestInformation)
- .getRequestAction();
- Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
- Assert.assertEquals(ServiceStatus.VnfsdnAction.ChangeVfModuleActivateRequest,
- serviceStatusBuilder.getVnfsdnAction());
-
- //DisconnectVfModuleRequest
- doReturn(RequestInformation.RequestAction.DisconnectVfModuleRequest).when(requestInformation)
- .getRequestAction();
- Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
- Assert
- .assertEquals(ServiceStatus.VnfsdnAction.DisconnectVfModuleRequest, serviceStatusBuilder.getVnfsdnAction());
-
- //PreloadVfModuleRequest
- doReturn(RequestInformation.RequestAction.PreloadVfModuleRequest).when(requestInformation).getRequestAction();
- Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
- Assert.assertEquals(ServiceStatus.VnfsdnAction.PreloadVfModuleRequest, serviceStatusBuilder.getVnfsdnAction());
- }
-
- @Test public void getServiceData() throws Exception {
- ServiceDataBuilder serviceDataBuilder = spy(new ServiceDataBuilder());
- // mock optional
- Optional<VnfList> optional = mock(Optional.class);
- doReturn(optional).when(checkedFuture).get();
- doReturn(true).when(optional).isPresent();
- VnfList vnfList = mock(VnfList.class);
- doReturn(vnfList).when(optional).get();
- ServiceData serviceData = mock(ServiceData.class);
- doReturn(serviceData).when(vnfList).getServiceData();
- SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
- doReturn(sdncRequestHeader).when(serviceData).getSdncRequestHeader();
-
- Whitebox.invokeMethod(vnfapiProvider, "getServiceData", "siid", serviceDataBuilder,
- LogicalDatastoreType.CONFIGURATION);
-
- Assert.assertEquals(sdncRequestHeader, serviceDataBuilder.getSdncRequestHeader());
- }
-
- @Test public void getVnfInstanceServiceData() throws Exception {
- VnfInstanceServiceDataBuilder vnfInstanceServiceDataBuilder = spy(new VnfInstanceServiceDataBuilder());
- // mock optional
- Optional<VnfList> optional = mock(Optional.class);
- doReturn(optional).when(checkedFuture).get();
- doReturn(true).when(optional).isPresent();
- VnfInstanceList vnfInstanceList = mock(VnfInstanceList.class);
- doReturn(vnfInstanceList).when(optional).get();
- VnfInstanceServiceData vnfInstanceServiceData = mock(VnfInstanceServiceData.class);
- doReturn(vnfInstanceServiceData).when(vnfInstanceList).getVnfInstanceServiceData();
- SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
- doReturn(sdncRequestHeader).when(vnfInstanceServiceData).getSdncRequestHeader();
-
- Whitebox.invokeMethod(vnfapiProvider, "getVnfInstanceServiceData", "siid", vnfInstanceServiceDataBuilder,
- LogicalDatastoreType.CONFIGURATION);
-
- Assert.assertEquals(sdncRequestHeader, vnfInstanceServiceDataBuilder.getSdncRequestHeader());
- }
-
- @Test public void DeleteVnfList() throws Exception {
- LogicalDatastoreType configuration = LogicalDatastoreType.CONFIGURATION;
- VnfList vnfList = mock(VnfList.class);
- VnfListKey vnfListKey = mock(VnfListKey.class);
- doReturn(vnfListKey).when(vnfList).key();
- InstanceIdentifier<VnfList> vnfListInstanceIdentifier = mock(InstanceIdentifier.class);
- dataBroker.newWriteOnlyTransaction().put(configuration, vnfListInstanceIdentifier, vnfList);
-
- Whitebox.invokeMethod(vnfapiProvider, "DeleteVnfList", vnfList, configuration);
-
- verify(dataBroker, times(2)).newWriteOnlyTransaction();
- }
-}
diff --git a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/DataBrokerUtil.java b/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/DataBrokerUtil.java
deleted file mode 100644
index 352e9404..00000000
--- a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/DataBrokerUtil.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.sdnc.vnfapi.util;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.Vnfs;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.model.infrastructure.VnfList;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.model.infrastructure.VnfListKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-
-/**
- * This util class provides utility to read and write {@link VnfList} data objects from the {@link DataBroker}
- *
- */
-public class DataBrokerUtil {
-
-
- private final DataBroker dataBroker;
-
- public DataBrokerUtil(DataBroker dataBroker) {
- this.dataBroker = dataBroker;
- }
-
- /** @return VnfList - the VnfList object read from the DataBroker or null if none was found */
- public VnfList read(String VnfListKey, LogicalDatastoreType logicalDatastoreType) throws Exception {
- InstanceIdentifier VnfListInstanceIdentifier = InstanceIdentifier.<Vnfs>builder(Vnfs.class)
- .child(VnfList.class, new VnfListKey(VnfListKey)).build();
- ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
- Optional<VnfList> data = (Optional<VnfList>) readTx.read(logicalDatastoreType, VnfListInstanceIdentifier).get();
- if(!data.isPresent()){
- return null;
- }
- return data.get();
- }
-
-
- /**
- * Write the {@link VnfList} object to the {@link DataBroker}
- * @param isReplace - false specifies the new data is to be merged into existing data, where as true cause the
- * existing data to be replaced.
- * @param VnfList - the {@link VnfList} data object to be presisted in the db.
- * @param logicalDatastoreType - The logicalDatastoreType
- */
- public void write(boolean isReplace,VnfList VnfList, LogicalDatastoreType logicalDatastoreType) throws Exception {
- // Each entry will be identifiable by a unique key, we have to create that
- // identifier
- InstanceIdentifier.InstanceIdentifierBuilder<VnfList> VnfListBuilder = InstanceIdentifier
- .<Vnfs>builder(Vnfs.class).child(VnfList.class, VnfList.key());
- InstanceIdentifier<VnfList> path = VnfListBuilder.build();
-
- WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
- if (!isReplace) {
- tx.merge(logicalDatastoreType, path, VnfList);
- } else {
- tx.put(logicalDatastoreType, path, VnfList);
- }
- CheckedFuture<Void,TransactionCommitFailedException> cf = tx.submit();
- cf.checkedGet();
-
- }
-
-
-
-
-
-
-
-}
diff --git a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/MDSALUtil.java b/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/MDSALUtil.java
deleted file mode 100644
index b28139c7..00000000
--- a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/MDSALUtil.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.sdnc.vnfapi.util;
-
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VnfTopologyOperationInputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VnfTopologyOperationOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.sdnc.request.header.SdncRequestHeaderBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.service.data.ServiceDataBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.service.information.ServiceInformationBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.information.VnfInformationBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.model.infrastructure.VnfListBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.request.information.VnfRequestInformationBuilder;
-import org.opendaylight.yangtools.concepts.Builder;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-
-import java.util.concurrent.Future;
-import java.util.function.Consumer;
-import java.util.function.Function;
-
-
-/**
- * This uill class provides utility to build yang objects using a recursive syntax that resembles the tree structure
- * when defining the same yang object in json format.
- *
- * For Example
- * <pre>
- * {@code
- * import static org.onap.sdnc.northbound.util.MDSALUtil.*;
- * VnfTopologyOperationInput input = build(vnfTopologyOperationInput()
- * .setServiceInformation(
- * build(serviceInformation()
- * .setServiceId("serviceId: xyz")
- * .setServiceInstanceId("serviceInstanceId: xyz")
- * .setServiceType("serviceType: xyz")
- * .setSubscriberName("subscriberName: xyz")
- * )
- * )
- * .setVnfRequestInformation(
- * build(vnfRequestInformation()
- * .setVnfId("vnfId: xyz")
- * .setVnfName("vnfName: xyz")//defect if missing
- * .setVnfType("vnfType: xyz")//defect if missing
- * )
- * )
- * .setSdncRequestHeader(
- * build(sdncRequestHeader()
- * .setSvcAction(SvcAction.Delete)
- * )
- * )
- * );
- * );
- * }
- * </pre>
- */
-public class MDSALUtil {
-
- public static VnfTopologyOperationInputBuilder vnfTopologyOperationInput(){return new VnfTopologyOperationInputBuilder();}
- public static VnfTopologyOperationOutputBuilder vnfTopologyOperationOutput(){return new VnfTopologyOperationOutputBuilder();}
-
- public static ServiceInformationBuilder serviceInformation(){return new ServiceInformationBuilder();}
- public static VnfRequestInformationBuilder vnfRequestInformation(){return new VnfRequestInformationBuilder();}
- public static VnfListBuilder vnfList(){return new VnfListBuilder();}
- public static ServiceDataBuilder serviceData() { return new ServiceDataBuilder();}
- public static SdncRequestHeaderBuilder sdncRequestHeader(){return new SdncRequestHeaderBuilder();}
- public static VnfInformationBuilder vnfInformation(){return new VnfInformationBuilder();}
-
-
- public static <P> P build(Builder<P> b) {
- return b == null? null :b.build();
- }
-
- public static <P,B extends Builder<P>> P build(Function<P,B> builderConstructor,P sourceDataObject){
- if(sourceDataObject == null){
- return null;
- }
- B bp = builderConstructor.apply(sourceDataObject);
- return bp.build();
- }
-
- public static <P,B extends Builder<P>> P build(Function<P,B> builderConstructor,P sourceDataObject,Consumer<B> builder){
- if(sourceDataObject == null){
- return null;
- }
- B bp = builderConstructor.apply(sourceDataObject);
- builder.accept(bp);
- return bp.build();
- }
-
- public static <I,O> O exec(Function<I,Future<RpcResult<O>>> rpc,I rpcParameter,Function<RpcResult<O>,O> rpcResult) throws Exception {
- Future<RpcResult<O>> future = rpc.apply(rpcParameter);
- return rpcResult.apply(future.get());
- }
-
-}
diff --git a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/PropBuilder.java b/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/PropBuilder.java
deleted file mode 100644
index 6ecc94c8..00000000
--- a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/PropBuilder.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.sdnc.vnfapi.util;
-
-import org.opendaylight.yangtools.concepts.Builder;
-
-import java.util.Properties;
-
-/**
- * A Util class that adds method chaining to the {@link #set(String, String)} to reducing the syntax needed to populate
- * {@link Properties}
- */
-public class PropBuilder implements Builder<Properties> {
-
-
- final Properties prop;
-
- public PropBuilder(Properties prop) {
- this.prop = prop;
- }
-
- public PropBuilder() {
- this.prop = new Properties();
- }
-
- public Properties build(){
- return prop;
- }
-
- public PropBuilder set(String key, String value) {
- prop.setProperty(key, value);
- return this;
- }
-
- public String get(String key) {
- return prop.getProperty(key);
- }
-
-
- public static PropBuilder propBuilder(){
- return (new PropBuilder());
- }
-} \ No newline at end of file
diff --git a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/VNFSDNSvcLogicServiceClientMockUtil.java b/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/VNFSDNSvcLogicServiceClientMockUtil.java
deleted file mode 100644
index d4d94ca8..00000000
--- a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/VNFSDNSvcLogicServiceClientMockUtil.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.sdnc.vnfapi.util;
-
-import org.onap.sdnc.vnfapi.VNFSDNSvcLogicServiceClient;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.service.data.ServiceDataBuilder;
-
-import java.util.Properties;
-
-import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.isA;
-import static org.mockito.Mockito.when;
-import static org.onap.sdnc.vnfapi.util.MDSALUtil.build;
-import static org.onap.sdnc.vnfapi.util.PropBuilder.propBuilder;
-
-
-/**
- * VNFSDNSvcLogicServiceClientMockUtil provides a set of util methods for quickly configuring method
- * behaviour on the Mock VNFSDNSvcLogicServiceClient
- */
-public class VNFSDNSvcLogicServiceClientMockUtil {
-
-
- private final String MODULE = "VNF-API";
- private final String MODE = "sync";
- private final String VERSION = null;
- private String scvOperation = null;
-
-
- public final String errorCode = "error-code";
- public final String errorMessage = "error-message";
- public final String ackFinal = "ack-final";
- public final String serviceObjectPath = "service-object-path";
- public final String networkObjectPath = "network-object-path";
- public final String networkId = "networkId";
-
-
- private final VNFSDNSvcLogicServiceClient mockVNFSDNSvcLogicServiceClient;
-
-
-
- public VNFSDNSvcLogicServiceClientMockUtil(VNFSDNSvcLogicServiceClient mockVNFSDNSvcLogicServiceClient) {
- this.mockVNFSDNSvcLogicServiceClient = mockVNFSDNSvcLogicServiceClient;
- }
-
-
- /** @param scvOperation - The scvOperation parameter to use on the {@link VNFSDNSvcLogicServiceClient} methods */
- public void setScvOperation(String scvOperation) {
- this.scvOperation = scvOperation;
- }
-
- /**
- * Configure {@link VNFSDNSvcLogicServiceClient#hasGraph(String, String, String, String)}
- * to return the specified value when when invoked with the parameters
- * {@link #MODULE}, {@link #MODE}, {@link #VERSION} and {@link #scvOperation}
- */
- public void mockHasGraph(Boolean isHasGraph) throws Exception {
- when(
- mockVNFSDNSvcLogicServiceClient
- .hasGraph(
- eq(MODULE),
- eq(scvOperation),
- eq(VERSION),
- eq(MODE)
- )
- )
- .thenReturn(isHasGraph);
- }
-
-
- /**
- * @return
- * PropBuilder - A PropBuilder populated with the expected properties returned from
- * {@link VNFSDNSvcLogicServiceClient#execute(String, String, String, String, ServiceDataBuilder, Properties)}
- */
- public PropBuilder createExecuteOKResult(){
- return propBuilder()
- .set(errorCode,"200")
- .set(errorMessage,"OK")
- .set(ackFinal,"Y")
- .set(serviceObjectPath,"serviceObjectPath: XYZ")
- .set(networkObjectPath,"networkObjectPath: XYZ")
- .set(networkId,"networkId: XYZ");
-
- }
-
-
- /**
- * Configure
- * {@link VNFSDNSvcLogicServiceClient#execute(String, String, String, String, ServiceDataBuilder, Properties)}
- * to return the specified svcResultProp when when invoked with the parameters
- * {@link #MODULE}, {@link #MODE}, {@link #VERSION} and {@link #scvOperation}
- */
- public void mockExecute(PropBuilder svcResultProp) throws Exception{
- when(
- mockVNFSDNSvcLogicServiceClient
- .execute(
- eq(MODULE),
- eq(scvOperation),
- eq(VERSION),
- eq(MODE),
- isA(ServiceDataBuilder.class),
- isA(Properties.class)
- )
- )
- .thenReturn(build(
- svcResultProp
- ));
- }
-
-}
diff --git a/vnfapi/provider/src/test/resources/proplist.properties b/vnfapi/provider/src/test/resources/proplist.properties
deleted file mode 100644
index 556de910..00000000
--- a/vnfapi/provider/src/test/resources/proplist.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# openECOMP : SDN-C
-# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. 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=========================================================
-###
-
-proplist.aptFile = target/properties.apt
diff --git a/vnfapi/provider/src/test/resources/simplelogger.properties b/vnfapi/provider/src/test/resources/simplelogger.properties
deleted file mode 100644
index 14ffcca0..00000000
--- a/vnfapi/provider/src/test/resources/simplelogger.properties
+++ /dev/null
@@ -1,23 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# openECOMP : SDN-C
-# ================================================================================
-# Copyright (C) 2017 AT&T Intellectual Property. 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=========================================================
-###
-
-org.slf4j.simpleLogger.defaultLogLevel=info
-org.slf4j.simplelogger.log.org.onap.sdnc.vnfapi.VnfApiProvider=debug