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.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;
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 DoDeleteAllottedResourceBRGTest extends WorkflowTest {
49 private final CallbackSet callbacks = new CallbackSet();
51 public DoDeleteAllottedResourceBRGTest() 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"));
58 @Deployment(resources = {
59 "subprocess/SDNCAdapterV1.bpmn",
60 "subprocess/FalloutHandler.bpmn",
61 "subprocess/DoDeleteAllottedResourceBRG.bpmn"})
62 public void testDoDeleteAllottedResourceBRG_success() throws Exception {
64 MockQueryAllottedResourceById("arId-1", "GenericFlows/getARUrlById.xml");
65 MockGetAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "arId-1", "VCPE/DoDeleteAllottedResourceBRG/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");
69 mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
71 String businessKey = UUID.randomUUID().toString();
72 Map<String, Object> variables = new HashMap<>();
73 setVariablesSuccess(variables, "testRequestId1");
75 invokeSubProcess("DoDeleteAllottedResourceBRG", businessKey, variables);
77 injectSDNCCallbacks(callbacks, "deactivate");
78 injectSDNCCallbacks(callbacks, "delete");
79 injectSDNCCallbacks(callbacks, "unassign");
81 waitForProcessEnd(businessKey, 10000);
83 Assert.assertTrue(isProcessEnded(businessKey));
84 String workflowException = BPMNUtil.getVariable(processEngineRule, "DoDeleteAllottedResourceBRG", "WorkflowException");
85 System.out.println("workflowException:\n" + workflowException);
86 assertEquals(null, workflowException);
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");
96 variables.put("serviceInstanceId", "MIS%252F1604%252F0026%252FSW_INTERNET");
97 variables.put("parentServiceInstanceId","MIS%252F1604%252F0026%252FSW_INTERNET");