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;
23 import org.junit.Assert;
24 import org.junit.Test;
25 import org.junit.runner.RunWith;
26 import org.mockito.Mock;
27 import org.mockito.Spy;
28 import org.mockito.junit.MockitoJUnitRunner;
29 import org.onap.so.bpmn.core.domain.ServiceDecomposition;
31 @RunWith(MockitoJUnitRunner.class)
32 public class ServicePluginFactoryTest {
35 ServiceDecomposition serviceDecomposition;
38 ServicePluginFactory servicePluginFactory;
40 String uuiRequest = "{" + " \"service\":{" + " \"name\":\"ONAP_223531\","
41 + " \"description\":\"ONAP_1546\","
42 + " \"serviceInvariantUuid\":\"4a09419a-c9fd-4a53-b1bd-b49603169ca1\","
43 + " \"serviceUuid\":\"1bd0eae6-2dcc-4461-9ae6-56d641f369d6\","
44 + " \"globalSubscriberId\":\"test_custormer\"," + " \"serviceType\":\"example-service-type\","
45 + " \"parameters\":{" + " \"locationConstraints\":[" + " ],"
46 + " \"resources\":[" + " {"
47 + " \"resourceName\":\"vEPC_ONAP01\","
48 + " \"resourceInvariantUuid\":\"36ebe421-283a-4ee8-92f1-d09e7c44b911\","
49 + " \"resourceUuid\":\"27a0e235-b67a-4ea4-a0cf-25761afed111\","
50 + " \"resourceCustomizationUuid\":\"47a0e235-b67a-4ea4-a0cf-25761afed231\","
51 + " \"parameters\":{" + " \"locationConstraints\":["
53 + " \"vnfProfileId\":\"b244d433-8c9c-49ad-9c70-8e34b8dc8328\","
54 + " \"locationConstraints\":{"
55 + " \"vimId\":\"vmware_vio\"" + " }"
57 + " \"vnfProfileId\":\"8a9f7c48-21ce-41b7-95b8-a8ac61ccb1ff\","
58 + " \"locationConstraints\":{"
59 + " \"vimId\":\"core-dc_RegionOne\""
61 + " \"resources\":[" + " ],"
62 + " \"requestInputs\":{" + " \"sdncontroller\":\"\""
63 + " }" + " }" + " }," + " {"
64 + " \"resourceName\":\"VL OVERLAYTUNNEL\","
65 + " \"resourceInvariantUuid\":\"184494cf-472f-436f-82e2-d83dddde21cb\","
66 + " \"resourceUuid\":\"95bc3e59-c9c5-458f-ad6e-78874ab4b3cc\","
67 + " \"resourceCustomizationUuid\":\"27a0e235-b67a-4ea4-a0cf-25761afed232\","
68 + " \"parameters\":{" + " \"locationConstraints\":["
69 + " ]," + " \"resources\":[" + " ],"
70 + " \"requestInputs\":{" + " }" + " }"
71 + " }" + " ]," + " \"requestInputs\":{"
72 + " \"vlunderlayvpn0_name\":\"l3connect\","
73 + " \"vlunderlayvpn0_site1_id\":\"IP-WAN-Controller-1\","
74 + " \"vlunderlayvpn0_site2_id\":\"SPTNController\","
75 + " \"vlunderlayvpn0_site1_networkName\":\"network1,network2\","
76 + " \"vlunderlayvpn0_site2_networkName\":\"network3,network4\","
77 + " \"vlunderlayvpn0_site1_routerId\":\"a8098c1a-f86e-11da-bd1a-00112444be1a\","
78 + " \"vlunderlayvpn0_site2_routerId\":\"a8098c1a-f86e-11da-bd1a-00112444be1e\","
79 + " \"vlunderlayvpn0_site2_importRT1\":\"200:1,200:2\","
80 + " \"vlunderlayvpn0_site1_exportRT1\":\"300:1,300:2\","
81 + " \"vlunderlayvpn0_site2_exportRT1\":\"400:1,400:2\","
82 + " \"vlunderlayvpn0_site1_vni\":\"2000\","
83 + " \"vlunderlayvpn0_site2_vni\":\"3000\","
84 + " \"vlunderlayvpn0_tunnelType\":\"L3-DCI\","
85 + " \"CallSource\":\"NOT-ExternalAPI\"," + " \"sotnconnectivity\":\"\""
86 + " }" + " }" + " }" + "}";
90 public void doProcessSiteLocation_isNeedProcessSite() {
91 String result = servicePluginFactory.doProcessSiteLocation(serviceDecomposition, uuiRequest);
92 Assert.assertEquals(result, uuiRequest);
96 public void doProcessSiteLocation_uuiObjectNull() {
97 String faultyJsonInput = "site_address,sotncondition_clientsignal";
98 String result = servicePluginFactory.doProcessSiteLocation(serviceDecomposition, faultyJsonInput);
99 Assert.assertEquals(result, faultyJsonInput);
103 public void doProcessSiteLocation_isSiteLocationLocal() {
104 String jsonWithOnlyNeededValues = "{\"site_address\":\"\",\"sotncondition_clientsignal\":\"\"}";
105 String result = servicePluginFactory.doProcessSiteLocation(serviceDecomposition, jsonWithOnlyNeededValues);
106 Assert.assertEquals(result, jsonWithOnlyNeededValues);
111 public void doTPResourcesAllocation_Success() {
112 doReturn(null).when(servicePluginFactory).getTPsfromAAI();
113 String result = servicePluginFactory.doTPResourcesAllocation(null, uuiRequest);
114 Assert.assertNotEquals(result, uuiRequest);
118 public void doTPResourcesAllocation_uuiObjectNull() {
119 String faultyJsonInput = "site_address,sotncondition_clientsignal";
120 String result = servicePluginFactory.doTPResourcesAllocation(null, faultyJsonInput);
121 Assert.assertEquals(result, faultyJsonInput);
125 public void doTPResourcesAllocation_isNeedAllocateCrossTPResources() {
126 // doReturn(null).when(servicePluginFactory).getTPsfromAAI();
127 String jsonWithOnlyNeededValues = "{\"site_address\":\"\",\"sotncondition_clientsignal\":\"\"}";
128 String result = servicePluginFactory.doTPResourcesAllocation(null, jsonWithOnlyNeededValues);
129 Assert.assertEquals(result, jsonWithOnlyNeededValues);
133 public void preProcessService_isSOTN() {
134 String invalidJsonWithOnlyNeededValues = "\"clientSignal\":\"\",\"vpnType\":\"\"}";
135 String result = servicePluginFactory.preProcessService(null, invalidJsonWithOnlyNeededValues);
136 Assert.assertEquals(result, invalidJsonWithOnlyNeededValues);
140 public void preProcessService() {
141 String result = servicePluginFactory.preProcessService(null, uuiRequest);
142 Assert.assertEquals(result, uuiRequest);
146 public void doServiceHoming() {
147 String result = servicePluginFactory.doServiceHoming(null, uuiRequest);
148 Assert.assertEquals(result, uuiRequest);
152 public void doServiceHoming_isSOTN() {
153 String invalidJsonWithOnlyNeededValues = "\"clientSignal\":\"\",\"vpnType\":\"\"}";
154 String result = servicePluginFactory.doServiceHoming(null, invalidJsonWithOnlyNeededValues);
155 Assert.assertEquals(result, invalidJsonWithOnlyNeededValues);