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.StubResponseDatabase.mockUpdateRequestDB;
31 import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;
33 import java.io.IOException;
34 import java.util.HashMap;
36 import java.util.UUID;
38 import org.camunda.bpm.engine.test.Deployment;
39 import org.junit.Assert;
40 import org.junit.Test;
41 import org.openecomp.mso.bpmn.common.BPMNUtil;
42 import org.openecomp.mso.bpmn.common.WorkflowTest;
43 import org.openecomp.mso.bpmn.core.RollbackData;
44 import org.openecomp.mso.bpmn.mock.FileUtil;
47 public class DoCreateAllottedResourceBRGRollbackTest extends WorkflowTest {
49 private static final String RbType = "DCARBRG_";
50 private final CallbackSet callbacks = new CallbackSet();
52 public DoCreateAllottedResourceBRGRollbackTest() throws IOException {
53 callbacks.put("deactivate", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyDeactivateCallback.xml"));
54 callbacks.put("delete", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyDeleteCallback.xml"));
55 callbacks.put("unassign", FileUtil.readResourceFile("__files/VCPE/VfModularity/SDNCTopologyUnassignCallback.xml"));
59 @Deployment(resources = {
60 "subprocess/SDNCAdapterV1.bpmn",
61 "subprocess/FalloutHandler.bpmn",
62 "subprocess/DoCreateAllottedResourceBRGRollback.bpmn"})
63 public void testDoCreateAllottedResourceBRGRollback_success() throws Exception {
65 MockGetAllottedResource("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "arId-1", "VCPE/DoCreateAllottedResourceBRGRollback/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("DoCreateAllottedResourceBRGRollback", 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, "DoCreateAllottedResourceBRGRollback", "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");
98 RollbackData rollbackData = new RollbackData();
100 rollbackData.put(RbType, "serviceInstanceId", "MIS%252F1604%252F0026%252FSW_INTERNET");
101 rollbackData.put(RbType, "serviceSubscriptionType", "123456789");
102 rollbackData.put(RbType, "disablerollback", "false");
103 rollbackData.put(RbType, "rollbackAAI", "true");
104 rollbackData.put(RbType, "rollbackSDNCassign", "true");
105 rollbackData.put(RbType, "rollbackSDNCactivate", "true");
106 rollbackData.put(RbType, "rollbackSDNCcreate", "true");
107 rollbackData.put(RbType, "aaiARPath", "http://localhost:28090/aai/v9/business/customers/customer/SDN-ETHERNET-INTERNET/service-subscriptions/service-subscription/123456789/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET/allotted-resources/allotted-resource/arId-1");
109 rollbackData.put(RbType, "sdncActivateRollbackReq", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncActivateRollbackReq.xml"));
110 rollbackData.put(RbType, "sdncCreateRollbackReq", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncCreateRollbackReq.xml"));
111 rollbackData.put(RbType, "sdncAssignRollbackReq", FileUtil.readResourceFile("__files/VCPE/DoCreateAllottedResourceBRGRollback/sdncAssignRollbackReq.xml"));
113 variables.put("rollbackData",rollbackData);