2 * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property.
5 * ============LICENSE_START=======================================================
7 * ================================================================================
8 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
9 * ================================================================================
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 * ============LICENSE_END=========================================================
24 package org.openecomp.mso.bpmn.common;
26 import static org.junit.Assert.assertEquals;
27 import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow;
28 import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish;
29 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteServiceInstance;
30 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteServiceInstance_404;
31 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance;
32 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance_404;
33 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance_500;
34 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceSubscription;
36 import java.util.HashMap;
39 import org.camunda.bpm.engine.test.Deployment;
40 import org.junit.Test;
41 import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
46 * Please describe the GenericDeleteServiceTest.java class
49 public class GenericDeleteServiceTest extends WorkflowTest {
51 @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"})
52 public void testGenericDeleteService_success_serviceInstance() throws Exception{
53 MockDeleteServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", "1234");
54 Map<String, String> variables = new HashMap<String, String>();
55 setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234");
56 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables);
57 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());
58 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator");
59 String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator");
60 String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag");
61 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException");
62 assertEquals("true", foundIndicator);
63 assertEquals("true", successIndicator);
64 assertEquals("true", resourceVersionProvidedFlag);
65 assertEquals(null, workflowException);
68 @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"})
69 public void testGenericDeleteService_success_serviceSubscription() throws Exception{
71 MockDeleteServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234", 204);
73 Map<String, String> variables = new HashMap<String, String>();
74 setVariablesSubscription(variables, "", "1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234");
76 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables);
77 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());
79 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator");
80 String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator");
81 String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag");
82 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException");
84 assertEquals("true", foundIndicator);
85 assertEquals("true", successIndicator);
86 assertEquals("true", resourceVersionProvidedFlag);
87 assertEquals(null, workflowException);
92 @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"})
93 public void testGenericDeleteService_success_instanceNoResourceVersion() throws Exception {
94 MockGetServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceSubscription.xml");
95 MockDeleteServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", "1234");
97 Map<String, String> variables = new HashMap<String, String>();
98 setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", null);
100 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables);
101 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());
103 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator");
104 String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator");
105 String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag");
106 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException");
108 assertEquals("true", foundIndicator);
109 assertEquals("true", successIndicator);
110 assertEquals("false", resourceVersionProvidedFlag);
111 assertEquals(null, workflowException);
116 @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"})
117 public void testGenericDeleteService_success_subscriptionNoResourceVersion() throws Exception{
118 MockGetServiceSubscription("1604-MVM-26", "SDN-ETHERNET-INTERNET", "GenericFlows/getServiceSubscription.xml");
119 MockDeleteServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234", 204);
121 Map<String, String> variables = new HashMap<String, String>();
122 setVariablesSubscription(variables, null, "1604-MVM-26", "SDN-ETHERNET-INTERNET", null);
124 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables);
125 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());
127 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator");
128 String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator");
129 String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag");
130 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException");
132 assertEquals("true", foundIndicator);
133 assertEquals("true", successIndicator);
134 assertEquals("false", resourceVersionProvidedFlag);
135 assertEquals(null, workflowException);
140 @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"})
141 public void testGenericDeleteService_success_get404Response() throws Exception{
143 MockGetServiceInstance_404("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET");
145 Map<String, String> variables = new HashMap<String, String>();
146 setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", null);
148 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables);
149 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());
151 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator");
152 String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator");
153 String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag");
154 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException");
156 assertEquals("false", foundIndicator);
157 assertEquals("true", successIndicator);
158 assertEquals("false", resourceVersionProvidedFlag);
159 assertEquals(null, workflowException);
163 @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"})
164 public void testGenericDeleteService_success_subscriptionGetEmpty200() throws Exception{
165 MockGetServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234", 200);
167 Map<String, String> variables = new HashMap<String, String>();
168 setVariablesSubscription(variables, "", "1604-MVM-26", "SDN-ETHERNET-INTERNET", "");
170 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables);
171 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());
173 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator");
174 String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator");
175 String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag");
176 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException");
178 assertEquals("false", foundIndicator);
179 assertEquals("true", successIndicator);
180 assertEquals("false", resourceVersionProvidedFlag);
181 assertEquals(null, workflowException);
186 @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"})
187 public void testGenericDeleteService_success_delete404Response() throws Exception{
189 MockGetServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", "GENDSI_getServiceInstanceResponse.xml");
190 MockDeleteServiceInstance_404("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", "1234");
192 Map<String, String> variables = new HashMap<String, String>();
193 setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234");
195 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables);
196 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());
198 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator");
199 String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator");
200 String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag");
201 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException");
203 assertEquals("false", foundIndicator);
204 assertEquals("true", successIndicator);
205 assertEquals("true", resourceVersionProvidedFlag);
206 assertEquals(null, workflowException);
210 @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"})
211 public void testGenericDeleteService_error_invalidVariables() throws Exception{
213 Map<String, String> variables = new HashMap<String, String>();
214 setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "1234");
216 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables);
217 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());
219 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator");
220 String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator");
221 String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag");
222 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException");
224 String expectedResponse = "WorkflowException[processKey=GenericDeleteService,errorCode=500,errorMessage=Incoming Required Variable is Missing or Null!]";
226 assertEquals("false", foundIndicator);
227 assertEquals("false", successIndicator);
228 assertEquals("true", resourceVersionProvidedFlag);
229 assertEquals(expectedResponse, workflowException);
234 @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"})
235 public void testGenericDeleteService_error_getBadAAIResponse() throws Exception{
237 MockGetServiceInstance_500("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", "aaiFault.xml");
239 Map<String, String> variables = new HashMap<String, String>();
240 setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", null);
242 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables);
243 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());
245 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator");
246 String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator");
247 String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag");
248 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException");
250 String expectedResponse = "WorkflowException[processKey=GenericDeleteService,errorCode=500,errorMessage=<requestError><serviceException><messageId>SVC3002</messageId><text>Error writing output performing %1 on %2 (msg=%3) (ec=%4)</text><variables><variable>PUTcustomer</variable><variable>SubName01</variable><variable>Unexpected error reading/updating database:Adding this property for key [service-instance-id] and value [USSTU2CFCNC0101UJZZ01] violates a uniqueness constraint [service-instance-id]</variable><variable>ERR.5.4.5105</variable></variables></serviceException></requestError>" + "\n" +
253 assertEquals("false", foundIndicator);
254 assertEquals("false", successIndicator);
255 assertEquals("false", resourceVersionProvidedFlag);
256 assertEquals(expectedResponse, workflowException);
260 private void setVariablesInstance(Map<String, String> variables, String siId, String globalCustId, String serviceType, String reVersion) {
261 variables.put("isDebugLogEnabled", "true");
262 variables.put("GENDS_serviceInstanceId", siId);
263 variables.put("GENDS_globalCustomerId",globalCustId);
264 variables.put("GENDS_serviceType", serviceType);
265 variables.put("GENDS_resourceVersion", reVersion);
266 variables.put("GENDS_type", "service-instance");
269 private void setVariablesSubscription(Map<String, String> variables, String siId, String globalCustId, String serviceType, String reVersion) {
270 variables.put("isDebugLogEnabled", "true");
271 variables.put("GENDS_serviceInstanceId", siId);
272 variables.put("GENDS_globalCustomerId",globalCustId);
273 variables.put("GENDS_serviceType", serviceType);
274 variables.put("GENDS_resourceVersion", reVersion);
275 variables.put("GENDS_type", "service-subscription");