2 * Copyright 2016-2017, Nokia Corporation
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.ct;
19 import com.google.gson.JsonObject;
20 import com.nokia.cbam.lcm.v32.model.*;
21 import org.junit.Test;
22 import org.junit.runner.RunWith;
23 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.NokiaSvnfmApplication;
24 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
25 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification.AAINotificationProcessor;
26 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions;
27 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.ReportedAffectedConnectionPoints;
28 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.ReportedAffectedCp;
29 import org.onap.vnfmdriver.model.VimInfo;
30 import org.springframework.beans.factory.annotation.Autowired;
31 import org.springframework.boot.test.context.SpringBootTest;
32 import org.springframework.test.context.ActiveProfiles;
33 import org.springframework.test.context.junit4.SpringRunner;
35 import java.util.ArrayList;
37 import static java.util.Optional.of;
39 @RunWith(value = SpringRunner.class)
40 @SpringBootTest(classes = NokiaSvnfmApplication.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
41 @ActiveProfiles("direct")
42 public class CTDirectReal {
44 private AAIExternalSystemInfoProvider externalSystemInfoProvider;
46 private AAINotificationProcessor notificationProcessor;
49 * The following is not a real test, but only start the driver locally.
50 * It takes parameters from application-real.properties
53 public void testBasicWorkflow() throws Exception {
54 VimInfo nokia_regionOne = externalSystemInfoProvider.getVimInfo("Nokia_RegionOne");
56 VnfLifecycleChangeNotification recievedNot = new VnfLifecycleChangeNotification();
57 recievedNot.setVnfInstanceId("CBAM-d8deb02a7a51449dba576ac9eabb55b8");
58 ReportedAffectedConnectionPoints affectedConnectionPoints = new ReportedAffectedConnectionPoints();
59 recievedNot.setAffectedVirtualLinks(new ArrayList<>());
60 AffectedVirtualLink link = new AffectedVirtualLink();
61 recievedNot.getAffectedVirtualLinks().add(link);
63 link.setChangeType(ChangeType.REMOVED);
64 link.setVirtualLinkDescId("vldId1");
65 link.setResource(new ResourceHandle());
66 link.getResource().setResourceId("netProviderId1");
67 link.getResource().setAdditionalData(additionalData("name", "networkName"));
68 recievedNot.setAffectedVnfcs(new ArrayList<>());
69 AffectedVnfc vnfc = new AffectedVnfc();
70 vnfc.setId("myVnfcId1");
71 vnfc.setChangeType(ChangeType.ADDED);
72 vnfc.setVduId("myVduId");
73 vnfc.setStorageResourceIds(new ArrayList<>());
74 vnfc.setComputeResource(new ResourceHandle());
75 vnfc.getComputeResource().setResourceId("serverProvId1");
76 JsonObject additionalData = additionalData("name", "serverName");
77 additionalData.addProperty("tenantId", "de8fd0d1d5874503a47b920c10f4322a");
78 vnfc.getComputeResource().setAdditionalData(additionalData);
79 recievedNot.getAffectedVnfcs().add(vnfc);
80 ReportedAffectedCp addedCp = new ReportedAffectedCp();
81 addedCp.setCpId("cpId");
82 addedCp.setIpAddress("1.2.3.4");
83 addedCp.setMacAddress("a:b:c:d:e:f");
84 addedCp.setNetworkProviderId("netProviderId1");
85 addedCp.setServerProviderId("serverProvId1");
86 addedCp.setProviderId("portId");
87 addedCp.setTenantId("de8fd0d1d5874503a47b920c10f4322a");
88 addedCp.setCpdId("cpdId");
89 affectedConnectionPoints.getPost().add(addedCp);
90 notificationProcessor.processNotification(recievedNot, null, of(affectedConnectionPoints), "Nokia_RegionOne");
91 SystemFunctions.systemFunctions().sleep(10000000 * 1000L);
94 JsonObject additionalData(String key, String value) {
95 JsonObject jsonObject = new JsonObject();
96 jsonObject.addProperty(key, value);