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=========================================================
22 * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property.
24 package org.openecomp.mso.bpmn.vcpe;
26 import static org.junit.Assert.assertEquals;
27 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance;
28 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById;
29 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchAllottedResource;
30 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutAllottedResource;
31 import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
32 import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;
34 import java.io.IOException;
35 import java.util.HashMap;
37 import java.util.UUID;
39 import org.camunda.bpm.engine.test.Deployment;
40 import org.junit.Assert;
41 import org.junit.Test;
42 import org.openecomp.mso.bpmn.common.BPMNUtil;
43 import org.openecomp.mso.bpmn.common.WorkflowTest;
44 import org.openecomp.mso.bpmn.mock.FileUtil;
47 public class DoCreateAllottedResourceTXCTest extends WorkflowTest {
49 private final CallbackSet callbacks = new CallbackSet();
51 public DoCreateAllottedResourceTXCTest() throws IOException {
52 callbacks.put("assign", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyAssignCallback.xml"));
53 callbacks.put("create", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyCreateCallback.xml"));
54 callbacks.put("activate", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyActivateCallback.xml"));
55 callbacks.put("query", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceTXC/SDNCTopologyQueryCallback.xml"));
59 @Deployment(resources = {
60 "subprocess/GenericGetService.bpmn",
61 "subprocess/SDNCAdapterV1.bpmn",
62 "subprocess/FalloutHandler.bpmn",
63 "subprocess/DoCreateAllottedResourceTXC.bpmn",
64 "subprocess/DoCreateAllottedResourceTXCRollback.bpmn"})
65 public void testDoCreateAllottedResourceTXC_success() throws Exception{
67 MockNodeQueryServiceInstanceById("MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getSIUrlById.xml");
68 MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml");
69 MockNodeQueryServiceInstanceById("MIS%252F1604%252F0027%252FSW_INTERNET", "GenericFlows/getParentSIUrlById.xml");
70 MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0027%252FSW_INTERNET", "GenericFlows/getParentServiceInstance.xml");
71 MockPutAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0027%252FSW_INTERNET", "arId-1");
72 MockPatchAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0027%252FSW_INTERNET", "arId-1");
74 mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
76 String businessKey = UUID.randomUUID().toString();
77 Map<String, Object> variables = new HashMap<String, Object>();
78 setVariablesSuccess(variables, "testRequestId123");
80 invokeSubProcess("DoCreateAllottedResourceTXC", businessKey, variables);
82 injectSDNCCallbacks(callbacks, "assign");
83 injectSDNCCallbacks(callbacks, "create");
84 injectSDNCCallbacks(callbacks, "activate");
85 injectSDNCCallbacks(callbacks, "query");
87 waitForProcessEnd(businessKey, 10000);
89 Assert.assertTrue(isProcessEnded(businessKey));
90 String workflowException = BPMNUtil.getVariable(processEngineRule, "DoCreateAllottedResourceTXC", "WorkflowException");
91 System.out.println("workflowException:\n" + workflowException);
92 assertEquals(null, workflowException);
96 private void setVariablesSuccess(Map<String, Object> variables, String requestId) {
97 variables.put("isDebugLogEnabled", "true");
98 variables.put("failExists", "true");
99 variables.put("disableRollback", "true");
100 variables.put("msoRequestId", requestId);
101 variables.put("mso-request-id", "requestId");
102 variables.put("sourceNetworkId", "snId");
103 variables.put("sourceNetworkRole", "snRole");
104 variables.put("allottedResourceRole", "txc");
105 variables.put("allottedResourceType", "TunnelXConn");
106 variables.put("allottedResourceId", "arId-1");
107 variables.put("brgWanMacAddress", "wanmac");
108 variables.put("junitSleepMs", "5");
110 variables.put("serviceInstanceId", "MIS%252F1604%252F0026%252FSW_INTERNET");
111 variables.put("parentServiceInstanceId","MIS%252F1604%252F0027%252FSW_INTERNET");
112 variables.put("serviceChainServiceInstanceId", "scsiId");
114 String arModelInfo = "{ "+ "\"modelType\": \"allotted-resource\"," +
115 "\"modelInvariantUuid\": \"ff5256d2-5a33-55df-13ab-12abad84e7ff\"," +
116 "\"modelUuid\": \"fe6478e5-ea33-3346-ac12-ab121484a3fe\"," +
117 "\"modelName\": \"vSAMP12\"," +
118 "\"modelVersion\": \"1.0\"," +
119 "\"modelCustomizationUuid\": \"MODEL-ID-1234\"," +
121 variables.put("allottedResourceModelInfo", arModelInfo);