bc3bdd2d4633826a8f7242c035a3f83bad026a7d
[so.git] /
1 /*
2  * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property.
3  */
4 package org.openecomp.mso.bpmn.vcpe;
5
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;
13
14 import java.io.IOException;
15 import java.util.HashMap;
16 import java.util.Map;
17 import java.util.UUID;
18
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;
25
26
27 public class DoCreateAllottedResourceBRGTest extends WorkflowTest {
28
29         private final CallbackSet callbacks = new CallbackSet();
30
31         public DoCreateAllottedResourceBRGTest() 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/DoCreateAllottedResourceBRG/SDNCTopologyQueryCallback.xml"));
36         }
37         
38         @Test
39         @Deployment(resources = {
40                         "subprocess/GenericGetService.bpmn", 
41                         "subprocess/SDNCAdapterV1.bpmn", 
42                         "subprocess/FalloutHandler.bpmn",
43                         "subprocess/DoCreateAllottedResourceBRG.bpmn",
44                         "subprocess/DoCreateAllottedResourceBRGRollback.bpmn"})
45         public void testDoCreateAllottedResourceBRG_success() throws Exception{
46
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");
53                 mockSDNCAdapter(200);
54                 mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
55
56                 String businessKey = UUID.randomUUID().toString();
57                 Map<String, Object> variables = new HashMap<>();
58                 setVariablesSuccess(variables, "testRequestId123");
59                 
60                 invokeSubProcess("DoCreateAllottedResourceBRG", businessKey, variables);
61                 
62                 injectSDNCCallbacks(callbacks, "assign");
63                 injectSDNCCallbacks(callbacks, "create");
64                 injectSDNCCallbacks(callbacks, "activate");
65                 injectSDNCCallbacks(callbacks, "query");
66
67                 waitForProcessEnd(businessKey, 10000);
68                 
69                 Assert.assertTrue(isProcessEnded(businessKey));
70                 String allotedResourceName = BPMNUtil.getVariable(processEngineRule, "DoCreateAllottedResourceBRG", "allotedResourceName");
71                 String workflowException = BPMNUtil.getVariable(processEngineRule, "DoCreateAllottedResourceBRG", "WorkflowException");
72                 assertEquals("namefromrequest", allotedResourceName);
73                 assertEquals(null, workflowException);
74         }
75
76         private void setVariablesSuccess(Map<String, Object> variables, String requestId) {
77                 // TODO: need all of these?
78                 variables.put("isDebugLogEnabled", "true");
79                 variables.put("failExists", "true");
80                 variables.put("disableRollback", "true");
81                 variables.put("msoRequestId", requestId);
82                 variables.put("mso-request-id", "requestId");
83                 variables.put("sourceNetworkId", "snId");
84                 variables.put("sourceNetworkRole", "snRole");
85                 variables.put("allottedResourceRole", "txc");
86                 variables.put("allottedResourceType", "BRG");
87                 variables.put("allottedResourceId", "arId-1");
88                 variables.put("vni", "BRG");
89                 variables.put("vgmuxBearerIP", "bearerip");
90                 variables.put("brgWanMacAddress", "wanmac");
91                 variables.put("junitSleepMs", "5");
92                 
93                 variables.put("serviceInstanceId", "MIS%252F1604%252F0026%252FSW_INTERNET");
94                 variables.put("parentServiceInstanceId","MIS%252F1604%252F0027%252FSW_INTERNET");
95                 variables.put("serviceChainServiceInstanceId", "scsiId");
96                 
97                 String arModelInfo = "{ "+ "\"modelType\": \"allotted-resource\"," +
98                                 "\"modelInvariantUuid\": \"ff5256d2-5a33-55df-13ab-12abad84e7ff\"," +
99                                 "\"modelUuid\": \"fe6478e5-ea33-3346-ac12-ab121484a3fe\"," +
100                                 "\"modelName\": \"vSAMP12\"," +
101                                 "\"modelVersion\": \"1.0\"," +
102                                 "\"modelCustomizationUuid\": \"MODEL-ID-1234\"," +
103                                 "}";
104                 variables.put("allottedResourceModelInfo", arModelInfo);
105         }
106
107 }