2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 Samsung 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=========================================================
20 package org.onap.so.bpmn.infrastructure.workflow.service;
22 import static org.mockito.Mockito.doReturn;
24 import org.junit.Assert;
25 import org.junit.Test;
26 import org.junit.runner.RunWith;
27 import org.mockito.Mock;
28 import org.mockito.Spy;
29 import org.mockito.junit.MockitoJUnitRunner;
30 import org.onap.so.bpmn.core.domain.ServiceDecomposition;
32 @RunWith(MockitoJUnitRunner.class)
33 public class ServicePluginFactoryTest {
36 ServiceDecomposition serviceDecomposition;
39 ServicePluginFactory servicePluginFactory;
41 String uuiRequest = "{"
43 + " \"name\":\"ONAP_223531\","
44 + " \"description\":\"ONAP_1546\","
45 + " \"serviceInvariantUuid\":\"4a09419a-c9fd-4a53-b1bd-b49603169ca1\","
46 + " \"serviceUuid\":\"1bd0eae6-2dcc-4461-9ae6-56d641f369d6\","
47 + " \"globalSubscriberId\":\"test_custormer\","
48 + " \"serviceType\":\"example-service-type\","
50 + " \"locationConstraints\":["
54 + " \"resourceName\":\"vEPC_ONAP01\","
55 + " \"resourceInvariantUuid\":\"36ebe421-283a-4ee8-92f1-d09e7c44b911\","
56 + " \"resourceUuid\":\"27a0e235-b67a-4ea4-a0cf-25761afed111\","
57 + " \"resourceCustomizationUuid\":\"47a0e235-b67a-4ea4-a0cf-25761afed231\","
59 + " \"locationConstraints\":["
61 + " \"vnfProfileId\":\"b244d433-8c9c-49ad-9c70-8e34b8dc8328\","
62 + " \"locationConstraints\":{"
63 + " \"vimId\":\"vmware_vio\""
67 + " \"vnfProfileId\":\"8a9f7c48-21ce-41b7-95b8-a8ac61ccb1ff\","
68 + " \"locationConstraints\":{"
69 + " \"vimId\":\"core-dc_RegionOne\""
75 + " \"requestInputs\":{"
76 + " \"sdncontroller\":\"\""
81 + " \"resourceName\":\"VL OVERLAYTUNNEL\","
82 + " \"resourceInvariantUuid\":\"184494cf-472f-436f-82e2-d83dddde21cb\","
83 + " \"resourceUuid\":\"95bc3e59-c9c5-458f-ad6e-78874ab4b3cc\","
84 + " \"resourceCustomizationUuid\":\"27a0e235-b67a-4ea4-a0cf-25761afed232\","
86 + " \"locationConstraints\":["
90 + " \"requestInputs\":{"
95 + " \"requestInputs\":{"
96 + " \"vlunderlayvpn0_name\":\"l3connect\","
97 + " \"vlunderlayvpn0_site1_id\":\"IP-WAN-Controller-1\","
98 + " \"vlunderlayvpn0_site2_id\":\"SPTNController\","
99 + " \"vlunderlayvpn0_site1_networkName\":\"network1,network2\","
100 + " \"vlunderlayvpn0_site2_networkName\":\"network3,network4\","
101 + " \"vlunderlayvpn0_site1_routerId\":\"a8098c1a-f86e-11da-bd1a-00112444be1a\","
102 + " \"vlunderlayvpn0_site2_routerId\":\"a8098c1a-f86e-11da-bd1a-00112444be1e\","
103 + " \"vlunderlayvpn0_site2_importRT1\":\"200:1,200:2\","
104 + " \"vlunderlayvpn0_site1_exportRT1\":\"300:1,300:2\","
105 + " \"vlunderlayvpn0_site2_exportRT1\":\"400:1,400:2\","
106 + " \"vlunderlayvpn0_site1_vni\":\"2000\","
107 + " \"vlunderlayvpn0_site2_vni\":\"3000\","
108 + " \"vlunderlayvpn0_tunnelType\":\"L3-DCI\","
109 + " \"CallSource\":\"NOT-ExternalAPI\","
110 + " \"sotnconnectivity\":\"\""
118 public void doProcessSiteLocation_isNeedProcessSite() {
119 String result = servicePluginFactory.doProcessSiteLocation(serviceDecomposition, uuiRequest);
120 Assert.assertEquals(result, uuiRequest);
124 public void doProcessSiteLocation_uuiObjectNull() {
125 String faultyJsonInput = "site_address,sotncondition_clientsignal";
126 String result = servicePluginFactory.doProcessSiteLocation(
127 serviceDecomposition, faultyJsonInput);
128 Assert.assertEquals(result, faultyJsonInput);
132 public void doProcessSiteLocation_isSiteLocationLocal() {
133 String jsonWithOnlyNeededValues = "{\"site_address\":\"\",\"sotncondition_clientsignal\":\"\"}";
134 String result = servicePluginFactory.doProcessSiteLocation(
135 serviceDecomposition, jsonWithOnlyNeededValues);
136 Assert.assertEquals(result, jsonWithOnlyNeededValues);
141 public void doTPResourcesAllocation_Success() {
142 doReturn(null).when(servicePluginFactory).getTPsfromAAI();
143 String result = servicePluginFactory.doTPResourcesAllocation(null, uuiRequest);
144 Assert.assertNotEquals(result, uuiRequest);
148 public void doTPResourcesAllocation_uuiObjectNull() {
149 String faultyJsonInput = "site_address,sotncondition_clientsignal";
150 String result = servicePluginFactory.doTPResourcesAllocation(null, faultyJsonInput);
151 Assert.assertEquals(result, faultyJsonInput);
155 public void doTPResourcesAllocation_isNeedAllocateCrossTPResources() {
156 //doReturn(null).when(servicePluginFactory).getTPsfromAAI();
157 String jsonWithOnlyNeededValues = "{\"site_address\":\"\",\"sotncondition_clientsignal\":\"\"}";
158 String result = servicePluginFactory.doTPResourcesAllocation(null, jsonWithOnlyNeededValues);
159 Assert.assertEquals(result, jsonWithOnlyNeededValues);
163 public void preProcessService_isSOTN() {
164 String invalidJsonWithOnlyNeededValues = "\"clientSignal\":\"\",\"vpnType\":\"\"}";
165 String result = servicePluginFactory.preProcessService(null, invalidJsonWithOnlyNeededValues);
166 Assert.assertEquals(result, invalidJsonWithOnlyNeededValues);
170 public void preProcessService() {
171 String result = servicePluginFactory.preProcessService(null, uuiRequest);
172 Assert.assertEquals(result, uuiRequest);
176 public void doServiceHoming() {
177 String result = servicePluginFactory.doServiceHoming(null, uuiRequest);
178 Assert.assertEquals(result, uuiRequest);
182 public void doServiceHoming_isSOTN() {
183 String invalidJsonWithOnlyNeededValues = "\"clientSignal\":\"\",\"vpnType\":\"\"}";
184 String result = servicePluginFactory.doServiceHoming(null, invalidJsonWithOnlyNeededValues);
185 Assert.assertEquals(result, invalidJsonWithOnlyNeededValues);