37814999ba55b7e9e7ebba7d9d05d9bdb7036a80
[so.git] /
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 package org.openecomp.mso.bpmn.infrastructure;
22
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;
29
30 import java.io.IOException;
31 import java.util.HashMap;
32 import java.util.Map;
33 import java.util.UUID;
34
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;
40
41 /**
42  * Unit test cases for DoDeleteServiceInstance.bpmn
43  */
44 public class DoDeleteServiceInstanceTest extends WorkflowTest {
45
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 +
52                         "</output>" + EOL;
53                 
54         public DoDeleteServiceInstanceTest() throws IOException {
55                 callbacks.put("deactivate", sdncAdapterCallback);
56                 callbacks.put("delete", sdncAdapterCallback);
57         }
58                 
59         /**
60          * Sunny day VID scenario.
61          *
62          * @throws Exception
63          */
64         //@Ignore // File not found - unable to run the test.  Also, Stubs need updating..
65         @Test
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 {
74
75                 logStart();
76
77                 //AAI
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");
81                 //SDNC
82                 mockSDNCAdapter(200);
83                 //DB
84                 mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
85                 String businessKey = UUID.randomUUID().toString();
86
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);
97
98                 logEnd();
99         }
100
101         // Success Scenario
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");
107         }
108 }