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=========================================================
21 package org.openecomp.mso.bpmn.infrastructure;
23 import static org.junit.Assert.assertEquals;
24 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteServiceInstance;
25 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance;
26 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById;
27 import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
28 import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;
30 import java.io.IOException;
31 import java.util.HashMap;
33 import java.util.UUID;
35 import org.camunda.bpm.engine.test.Deployment;
36 import org.junit.Assert;
37 import org.junit.Test;
38 import org.openecomp.mso.bpmn.common.BPMNUtil;
39 import org.openecomp.mso.bpmn.common.WorkflowTest;
42 * Unit test cases for DoDeleteServiceInstance.bpmn
44 public class DoDeleteServiceInstanceTest extends WorkflowTest {
46 private final CallbackSet callbacks = new CallbackSet();
47 private static final String EOL = "\n";
48 private final String sdncAdapterCallback =
49 "<output xmlns=\"com:att:sdnctl:l3api\">" + EOL +
50 " <svc-request-id>((REQUEST-ID))</svc-request-id>" + EOL +
51 " <ack-final-indicator>Y</ack-final-indicator>" + EOL +
54 public DoDeleteServiceInstanceTest() throws IOException {
55 callbacks.put("deactivate", sdncAdapterCallback);
56 callbacks.put("delete", sdncAdapterCallback);
60 * Sunny day VID scenario.
64 //@Ignore // File not found - unable to run the test. Also, Stubs need updating..
66 @Deployment(resources = {
67 "subprocess/DoDeleteServiceInstance.bpmn",
68 "subprocess/SDNCAdapterV1.bpmn",
69 "subprocess/GenericDeleteService.bpmn",
70 "subprocess/GenericGetService.bpmn",
71 "subprocess/CompleteMsoProcess.bpmn",
72 "subprocess/FalloutHandler.bpmn" })
73 public void sunnyDay() throws Exception {
78 MockDeleteServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "", 204);
79 MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getSINoRelations.xml");
80 MockNodeQueryServiceInstanceById("MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getSIUrlById.xml");
84 mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
85 String businessKey = UUID.randomUUID().toString();
87 Map<String, Object> variables = new HashMap<>();
88 setupVariables(variables);
89 invokeSubProcess("DoDeleteServiceInstance", businessKey, variables);
90 injectSDNCCallbacks(callbacks, "deactivate");
91 injectSDNCCallbacks(callbacks, "delete");
92 waitForProcessEnd(businessKey, 10000);
93 Assert.assertTrue(isProcessEnded(businessKey));
94 String workflowException = BPMNUtil.getVariable(processEngineRule, "DoDeleteServiceInstance", "WorkflowException");
95 System.out.println("workflowException:\n" + workflowException);
96 assertEquals(null, workflowException);
102 private void setupVariables(Map<String, Object> variables) {
103 variables.put("isDebugLogEnabled", "true");
104 variables.put("msoRequestId", "RaaDDSIRequestId-1");
105 variables.put("mso-request-id", "RaaDDSIRequestId-1");
106 variables.put("serviceInstanceId","MIS%252F1604%252F0026%252FSW_INTERNET");