2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.client.sdnc.mapper;
23 import java.util.HashMap;
24 import java.util.List;
26 import org.junit.Assert;
27 import org.junit.Test;
28 import org.onap.so.bpmn.common.data.TestDataSetup;
29 import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
30 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
31 import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
32 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
33 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceProxy;
34 import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet;
35 import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink;
36 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
37 import org.onap.so.client.sdnc.beans.SDNCSvcAction;
39 import org.onap.sdnc.apps.client.model.GenericResourceApiGcTopologyOperationInformation;
42 public class GCTopologyOperationRequestMapperTest extends TestDataSetup{
44 private GCTopologyOperationRequestMapper genObjMapper = new GCTopologyOperationRequestMapper();
47 public void deactivateOrUnassignVnrReqMapperTest() {
48 RequestContext requestContext = new RequestContext();
49 requestContext.setMsoRequestId("MsoRequestId");
50 ServiceInstance serviceInstance = new ServiceInstance();
51 serviceInstance.setServiceInstanceId("ServiceInstanceId");
52 Configuration Configuration = new Configuration();
53 Configuration.setConfigurationId("ConfigurationId");
54 GenericResourceApiGcTopologyOperationInformation genericInfo = genObjMapper.deactivateOrUnassignVnrReqMapper
55 (SDNCSvcAction.UNASSIGN, serviceInstance, requestContext, Configuration);
57 Assert.assertNotNull(genericInfo);
58 Assert.assertNotNull(genericInfo.getSdncRequestHeader().getSvcRequestId());
63 private VpnBondingLink getVpnBondingLink() {
64 VpnBondingLink vpnBondingLink = new VpnBondingLink();
65 Configuration vrfConfiguration = getVRFConfiguration();
66 vpnBondingLink.setVrfConfiguration(vrfConfiguration);
67 Configuration vnrConfiguration = getVNRConfiguration();
68 vpnBondingLink.setVnrConfiguration(vnrConfiguration);
69 vpnBondingLink.setTransportServiceProxy(buildServiceProxy(buildServiceInstance(buildGenericVnf())));
70 return vpnBondingLink;
73 private RequestContext getRequestContext() {
74 RequestContext requestContext = new RequestContext();
75 requestContext.setMsoRequestId("MsoRequestId");
76 HashMap<String, String> userParams = getUserParams();
77 requestContext.setUserParams(userParams);
78 return requestContext;
81 private HashMap<String, String> getUserParams() {
82 HashMap<String,String> userParams = new HashMap<>();
83 userParams.put("lppCustomerId","lppCustomerId");
87 private ServiceProxy buildServiceProxy(ServiceInstance serviceInstance) {
88 ServiceProxy serviceProxy = new ServiceProxy();
89 serviceProxy.setServiceInstance(serviceInstance);
93 private Configuration getVRFConfiguration() {
94 Configuration vrfConfiguration = new Configuration();
95 vrfConfiguration.setConfigurationId("ConfigurationId");
96 vrfConfiguration.setConfigurationName("ConfigurationName");
97 vrfConfiguration.setConfigurationSubType("ConfigurationSubType");
98 vrfConfiguration.setConfigurationType("VRF-ENTRY");
99 return vrfConfiguration;
102 public Configuration getVNRConfiguration() {
103 Configuration vnrConfiguration = new Configuration();
104 vnrConfiguration.setConfigurationId("ConfigurationId");
105 vnrConfiguration.setConfigurationName("ConfigurationName");
106 vnrConfiguration.setConfigurationSubType("ConfigurationSubType");
107 vnrConfiguration.setConfigurationType("VNRConfiguration");
108 L3Network l3Network = getL3Network();
109 vnrConfiguration.setNetwork(l3Network);
110 return vnrConfiguration;
113 public L3Network getL3Network() {
114 L3Network l3Network = new L3Network();
115 l3Network.setNetworkId("l3NetworkId");
116 Subnet ipv4subnet = getSubnet("ipv4CidrMask", "ipv4NetworkStartAddress", "IPV4");
117 Subnet ipv6subnet = getSubnet("ipv6CidrMask", "ipv6NetworkStartAddress", "IPV6");
118 l3Network.getSubnets().add(ipv4subnet);
119 l3Network.getSubnets().add(ipv6subnet);
123 private Subnet getSubnet(String ipv4CidrMask, String ipv4NetworkStartAddress, String ipv4) {
124 Subnet ipv4subnet = new Subnet();
125 ipv4subnet.setCidrMask(ipv4CidrMask);
126 ipv4subnet.setNetworkStartAddress(ipv4NetworkStartAddress);
127 ipv4subnet.setIpVersion(ipv4);
131 private ServiceInstance buildServiceInstance(GenericVnf vnf) {
132 ServiceInstance serviceInstance = new ServiceInstance();
133 serviceInstance.setServiceInstanceId("ServiceInstanceId");
134 List<GenericVnf> vnfs = serviceInstance.getVnfs();
136 return serviceInstance;