Update POM to inherit from oparent
[so.git] / bpmn / MSOInfrastructureBPMN / src / test / java / org / openecomp / mso / bpmn / vcpe / DoDeleteAllottedResourceTXCTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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=========================================================
19  */
20
21 /*
22  * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property.
23  */
24 package org.openecomp.mso.bpmn.vcpe;
25
26 import static org.junit.Assert.assertEquals;
27 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteAllottedResource;
28 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetAllottedResource;
29 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchAllottedResource;
30 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockQueryAllottedResourceById;
31 import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
32 import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;
33
34 import java.io.IOException;
35 import java.util.HashMap;
36 import java.util.Map;
37 import java.util.UUID;
38
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;
45
46
47 public class DoDeleteAllottedResourceTXCTest extends WorkflowTest {
48
49         private final CallbackSet callbacks = new CallbackSet();
50         
51         public DoDeleteAllottedResourceTXCTest() throws IOException {
52                 callbacks.put("deactivate", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyDeactivateCallback.xml"));
53                 callbacks.put("delete", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyDeleteCallback.xml"));
54                 callbacks.put("unassign", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyUnassignCallback.xml"));
55         }
56         
57         @Test
58         @Deployment(resources = {
59                         "subprocess/SDNCAdapterV1.bpmn",
60                         "subprocess/FalloutHandler.bpmn",
61                         "subprocess/DoDeleteAllottedResourceTXC.bpmn"})
62         public void testDoDeleteAllottedResourceTXC_success() throws Exception {
63                 
64                 MockQueryAllottedResourceById("arId-1", "GenericFlows/getARUrlById.xml");
65                 MockGetAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "arId-1", "VCPE/DoDeleteAllottedResourceTXC/arGetById.xml");
66                 MockPatchAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "arId-1");
67                 MockDeleteAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "arId-1", "1490627351232");
68                 mockSDNCAdapter(200);
69                 mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
70                 
71                 String businessKey = UUID.randomUUID().toString();
72                 Map<String, Object> variables = new HashMap<>();
73                 setVariablesSuccess(variables, "testRequestId1");
74                 
75                 invokeSubProcess("DoDeleteAllottedResourceTXC", businessKey, variables);
76                 
77                 injectSDNCCallbacks(callbacks, "deactivate");
78                 injectSDNCCallbacks(callbacks, "delete");
79                 injectSDNCCallbacks(callbacks, "unassign");
80
81                 waitForProcessEnd(businessKey, 10000);
82                 
83                 Assert.assertTrue(isProcessEnded(businessKey));
84                 String workflowException = BPMNUtil.getVariable(processEngineRule, "DoDeleteAllottedResourceTXC", "WorkflowException");
85                 System.out.println("workflowException:\n" + workflowException);
86                 assertEquals(null, workflowException);
87         }
88
89         private void setVariablesSuccess(Map<String, Object> variables, String requestId) {
90                 variables.put("isDebugLogEnabled", "true");
91                 variables.put("failNotFound", "true");
92                 variables.put("msoRequestId", requestId);
93                 variables.put("mso-request-id", "requestId");
94                 variables.put("allottedResourceId", "arId-1");
95                 
96                 variables.put("serviceInstanceId", "MIS%252F1604%252F0026%252FSW_INTERNET");
97                 variables.put("parentServiceInstanceId","MIS%252F1604%252F0026%252FSW_INTERNET");
98         }
99
100 }