2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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.bpmn.vcpe;
23 import static org.junit.Assert.*;
24 import static org.onap.so.bpmn.common.BPMNUtil.waitForWorkflowToFinish;
25 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetAllottedResource;
26 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetServiceInstance;
27 import static org.onap.so.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById;
28 import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchAllottedResource;
29 import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutAllottedResource;
30 import static org.onap.so.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
31 import static org.onap.so.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;
33 import java.util.HashMap;
36 import org.junit.Test;
37 import org.onap.so.bpmn.common.BPMNUtil;
38 import org.onap.so.bpmn.mock.FileUtil;
41 public class DoCreateAllottedResourceBRGIT extends AbstractTestBase {
43 private static final String PROCNAME = "DoCreateAllottedResourceBRG";
44 private final CallbackSet callbacks = new CallbackSet();
46 public DoCreateAllottedResourceBRGIT() {
47 callbacks.put("assign", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyAssignCallback.xml"));
48 callbacks.put("create", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyCreateCallback.xml"));
49 callbacks.put("activate", FileUtil.readResourceFile("__files/VfModularity/SDNCTopologyActivateCallback.xml"));
50 callbacks.put("query", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRG/SDNCTopologyQueryCallback.xml"));
54 public void testDoCreateAllottedResourceBRG_Success() throws InterruptedException {
57 // TODO: use INST instead of DEC_INST
59 * should be INST instead of DEC_INST, but AAI utilities appear to
60 * have a bug in that they don't URL-encode the SI id before using
63 MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
64 MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
66 MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
67 MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
68 MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
69 MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
70 mockSDNCAdapter(wireMockServer, 200);
71 mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
73 Map<String, Object> variables = new HashMap<>();
74 setVariablesSuccess(variables,"testRequestId123");
76 String processId = invokeSubProcess(PROCNAME, variables);
78 injectSDNCCallbacks(callbacks, "assign");
79 injectSDNCCallbacks(callbacks, "create");
80 injectSDNCCallbacks(callbacks, "activate");
81 injectSDNCCallbacks(callbacks, "query");
83 waitForWorkflowToFinish(processEngine,processId);
85 assertTrue(isProcessEndedByProcessInstanceId(processId));
86 String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
87 assertNull(workflowException);
89 assertEquals("namefromrequest", BPMNUtil.getVariable(processEngine, PROCNAME, "allotedResourceName",processId));
94 public void testDoCreateAllottedResourceBRG_NoSI() throws Exception{
96 // TODO: use INST instead of DEC_INST
98 * should be INST instead of DEC_INST, but AAI utilities appear to
99 * have a bug in that they don't URL-encode the SI id before using
102 MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getNotFound.xml");
103 MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
105 MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
106 MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
107 MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
108 MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
109 mockSDNCAdapter(wireMockServer, 200);
110 mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
112 Map<String, Object> variables = new HashMap<>();
113 setVariablesSuccess(variables,"testRequestId124");
115 String processId = invokeSubProcess(PROCNAME, variables);
117 waitForWorkflowToFinish(processEngine,processId);
119 assertTrue(isProcessEndedByProcessInstanceId(processId));
120 String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
121 assertNotNull(workflowException);
123 assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "allotedResourceName",processId));
128 public void testDoCreateAllottedResourceBRG_ActiveAr() throws Exception{
130 // TODO: use INST instead of DEC_INST
132 * should be INST instead of DEC_INST, but AAI utilities appear to
133 * have a bug in that they don't URL-encode the SI id before using
136 MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
137 MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
139 MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "VCPE/DoCreateAllottedResourceBRG/getSIandAR.xml");
140 MockGetAllottedResource(wireMockServer, CUST, SVC, INST, ARID, "VCPE/DoCreateAllottedResourceBRG/getArBrg2.xml");
141 MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
142 MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
143 MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
144 mockSDNCAdapter(wireMockServer, 200);
145 mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
147 Map<String, Object> variables = new HashMap<>();
148 setVariablesSuccess(variables,"testRequestId125");
150 variables.put("failExists", "false");
152 String processId = invokeSubProcess(PROCNAME, variables);
156 injectSDNCCallbacks(callbacks, "query");
158 waitForWorkflowToFinish(processEngine,processId);
160 assertTrue(isProcessEndedByProcessInstanceId(processId));
161 String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
162 assertNull( workflowException);
164 assertEquals("namefromrequest", BPMNUtil.getVariable(processEngine, PROCNAME, "allotedResourceName",processId));
169 public void testDoCreateAllottedResourceBRG_NoParentSI() throws Exception{
171 // TODO: use INST instead of DEC_INST
173 * should be INST instead of DEC_INST, but AAI utilities appear to
174 * have a bug in that they don't URL-encode the SI id before using
177 MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
178 MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getNotFound.xml");
180 MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
181 MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
182 MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
183 MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
184 mockSDNCAdapter(wireMockServer, 200);
185 mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
187 Map<String, Object> variables = new HashMap<>();
188 setVariablesSuccess(variables,"testRequestId126");
190 String processId = invokeSubProcess(PROCNAME, variables);
192 waitForWorkflowToFinish(processEngine,processId);
194 assertTrue(isProcessEndedByProcessInstanceId(processId));
195 String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
196 assertNotNull(workflowException);
198 assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "allotedResourceName",processId));
203 public void testDoCreateAllottedResourceBRG_SubProcessError() throws Exception{
205 // TODO: use INST instead of DEC_INST
207 * should be INST instead of DEC_INST, but AAI utilities appear to
208 * have a bug in that they don't URL-encode the SI id before using
211 MockNodeQueryServiceInstanceById(wireMockServer, DEC_INST, "GenericFlows/getSIUrlById.xml");
212 MockNodeQueryServiceInstanceById(wireMockServer, DEC_PARENT_INST, "GenericFlows/getParentSIUrlById.xml");
214 MockGetServiceInstance(wireMockServer, CUST, SVC, INST, "GenericFlows/getServiceInstance.xml");
215 MockGetServiceInstance(wireMockServer, CUST, SVC, PARENT_INST, "GenericFlows/getParentServiceInstance.xml");
216 MockPutAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
217 MockPatchAllottedResource(wireMockServer, CUST, SVC, PARENT_INST, ARID);
218 mockSDNCAdapter(wireMockServer, 404);
219 mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml");
221 Map<String, Object> variables = new HashMap<>();
222 setVariablesSuccess(variables,"testRequestId127");
224 String processId = invokeSubProcess(PROCNAME, variables);
226 waitForWorkflowToFinish(processEngine,processId);
228 assertTrue(isProcessEndedByProcessInstanceId(processId));
229 String workflowException = BPMNUtil.getVariable(processEngine, PROCNAME, VAR_WFEX,processId);
230 assertNotNull(workflowException);
232 assertNull(BPMNUtil.getVariable(processEngine, PROCNAME, "allotedResourceName",processId));
236 private void setVariablesSuccess(Map<String, Object> variables, String requestId) {
237 variables.put("isDebugLogEnabled", "true");
238 variables.put("failExists", "true");
239 variables.put("disableRollback", "true");
240 variables.put("msoRequestId", requestId);
241 variables.put("mso-request-id", "requestId");
242 variables.put("sourceNetworkId", "snId");
243 variables.put("sourceNetworkRole", "snRole");
244 variables.put("allottedResourceRole", "txc");
245 variables.put("allottedResourceType", "BRG");
246 variables.put("allottedResourceId", ARID);
247 variables.put("vni", "BRG");
248 variables.put("vgmuxBearerIP", "bearerip");
249 variables.put("brgWanMacAddress", "wanmac");
251 variables.put("serviceInstanceId", DEC_INST);
252 variables.put("parentServiceInstanceId", DEC_PARENT_INST);
254 variables.put("serviceChainServiceInstanceId", "scsiId");
256 String arModelInfo = "{ "+ "\"modelType\": \"allotted-resource\"," +
257 "\"modelInvariantUuid\": \"ff5256d2-5a33-55df-13ab-12abad84e7ff\"," +
258 "\"modelUuid\": \"fe6478e5-ea33-3346-ac12-ab121484a3fe\"," +
259 "\"modelName\": \"vSAMP12\"," +
260 "\"modelVersion\": \"1.0\"," +
261 "\"modelCustomizationUuid\": \"MODEL-ID-1234\"," +
263 variables.put("allottedResourceModelInfo", arModelInfo);