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