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 java.util.ArrayList;
22 import org.junit.Test;
23 import org.junit.runner.RunWith;
24 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.NokiaSvnfmApplication;
25 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.AAIExternalSystemInfoProvider;
26 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.onap.direct.notification.AAINotificationProcessor;
27 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.util.SystemFunctions;
28 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.ReportedAffectedConnectionPoints;
29 import org.onap.vfc.nfvo.driver.vnfm.svnfm.nokia.vnfm.notification.ReportedAffectedCp;
30 import org.onap.vnfmdriver.model.VimInfo;
31 import org.springframework.beans.factory.annotation.Autowired;
32 import org.springframework.boot.test.context.SpringBootTest;
33 import org.springframework.test.context.ActiveProfiles;
34 import org.springframework.test.context.junit4.SpringRunner;
36 import static java.util.Optional.of;
38 @RunWith(value = SpringRunner.class)
39 @SpringBootTest(classes = NokiaSvnfmApplication.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
40 @ActiveProfiles("direct")
41 public class CTDirectReal {
43 private AAIExternalSystemInfoProvider externalSystemInfoProvider;
45 private AAINotificationProcessor notificationProcessor;
48 * The following is not a real test, but only start the driver locally.
49 * It takes parameters from application-real.properties
52 public void testBasicWorkflow() throws Exception {
53 SystemFunctions.systemFunctions().sleep(10000000 * 1000L);
55 VimInfo nokia_regionOne = externalSystemInfoProvider.getVimInfo("Nokia_RegionOne");
57 VnfLifecycleChangeNotification recievedNot = new VnfLifecycleChangeNotification();
58 recievedNot.setVnfInstanceId("CBAM-d8deb02a7a51449dba576ac9eabb55b8");
59 ReportedAffectedConnectionPoints affectedConnectionPoints = new ReportedAffectedConnectionPoints();
60 recievedNot.setAffectedVirtualLinks(new ArrayList<>());
61 AffectedVirtualLink link = new AffectedVirtualLink();
62 recievedNot.getAffectedVirtualLinks().add(link);
64 link.setChangeType(ChangeType.REMOVED);
65 link.setVirtualLinkDescId("vldId1");
66 link.setResource(new ResourceHandle());
67 link.getResource().setResourceId("netProviderId1");
68 link.getResource().setAdditionalData(additionalData("name", "networkName"));
69 recievedNot.setAffectedVnfcs(new ArrayList<>());
70 AffectedVnfc vnfc = new AffectedVnfc();
71 vnfc.setId("myVnfcId1");
72 vnfc.setChangeType(ChangeType.ADDED);
73 vnfc.setVduId("myVduId");
74 vnfc.setStorageResourceIds(new ArrayList<>());
75 vnfc.setComputeResource(new ResourceHandle());
76 vnfc.getComputeResource().setResourceId("serverProvId1");
77 JsonObject additionalData = additionalData("name", "serverName");
78 additionalData.addProperty("tenantId", "de8fd0d1d5874503a47b920c10f4322a");
79 vnfc.getComputeResource().setAdditionalData(additionalData);
80 recievedNot.getAffectedVnfcs().add(vnfc);
81 ReportedAffectedCp addedCp = new ReportedAffectedCp();
82 addedCp.setCpId("cpId");
83 addedCp.setIpAddress("1.2.3.4");
84 addedCp.setMacAddress("a:b:c:d:e:f");
85 addedCp.setNetworkProviderId("netProviderId1");
86 addedCp.setServerProviderId("serverProvId1");
87 addedCp.setProviderId("portId");
88 addedCp.setTenantId("de8fd0d1d5874503a47b920c10f4322a");
89 addedCp.setCpdId("cpdId");
90 affectedConnectionPoints.getPost().add(addedCp);
91 notificationProcessor.processNotification(recievedNot, null, of(affectedConnectionPoints), "Nokia_RegionOne", "vnfmId");
94 JsonObject additionalData(String key, String value) {
95 JsonObject jsonObject = new JsonObject();
96 jsonObject.addProperty(key, value);