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.infrastructure;
26 import static org.junit.Assert.assertEquals;
27 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteGenericVnf;
28 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth;
29 import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
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 * Please describe the DeleteVnfInfra.java class
45 public class DoDeleteVnfTest extends WorkflowTest {
49 @Deployment(resources = {"subprocess/GenericGetVnf.bpmn", "subprocess/GenericDeleteVnf.bpmn", "subprocess/DoDeleteVnf.bpmn"})
50 public void testDoDeleteVnf_success() throws Exception{
52 MockGetGenericVnfByIdWithDepth("testVnfId123", 1, "GenericFlows/getGenericVnfByNameResponse.xml");
53 MockDeleteGenericVnf("testVnfId123", "testReVer123");
54 mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
56 String businessKey = UUID.randomUUID().toString();
57 Map<String, Object> variables = new HashMap<String, Object>();
58 setVariables(variables);
59 invokeSubProcess("DoDeleteVnf", businessKey, variables);
60 // Disabled until SDNC support is there
61 // injectSDNCCallbacks(callbacks, "assign");
62 // injectSDNCCallbacks(callbacks, "activate");
64 waitForProcessEnd(businessKey, 10000);
66 Assert.assertTrue(isProcessEnded(businessKey));
67 String found = BPMNUtil.getVariable(processEngineRule, "DoDeleteVnf", "GENGV_FoundIndicator") ;
68 String inUse = BPMNUtil.getVariable(processEngineRule, "DoDeleteVnf", "DoDVNF_vnfInUse");
69 String workflowException = BPMNUtil.getVariable(processEngineRule, "DoDeleteVnf", "WorkflowException");
71 assertEquals("true", found);
72 assertEquals("false", inUse);
73 assertEquals(null, workflowException);
77 @Deployment(resources = {"subprocess/GenericGetVnf.bpmn", "subprocess/GenericDeleteVnf.bpmn", "subprocess/DoDeleteVnf.bpmn"})
78 public void testDeleteVnfInfra_success_vnfNotFound() throws Exception{
80 MockDeleteGenericVnf("testVnfId123", "testReVer123", 404);
81 mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
83 String businessKey = UUID.randomUUID().toString();
84 Map<String, Object> variables = new HashMap<String, Object>();
85 setVariables(variables);
87 invokeSubProcess("DoDeleteVnf", businessKey, variables);
88 // Disabled until SDNC support is there
89 // injectSDNCCallbacks(callbacks, "assign");
90 // injectSDNCCallbacks(callbacks, "activate");
92 waitForProcessEnd(businessKey, 10000);
94 Assert.assertTrue(isProcessEnded(businessKey));
95 String found = BPMNUtil.getVariable(processEngineRule, "DoDeleteVnf", "GENGV_FoundIndicator") ;
96 String inUse = BPMNUtil.getVariable(processEngineRule, "DoDeleteVnf", "DoDVNF_vnfInUse");
97 String workflowException = BPMNUtil.getVariable(processEngineRule, "DoDeleteVnf", "WorkflowException");
99 assertEquals("false", found);
100 assertEquals("false", inUse);
101 assertEquals(null, workflowException);
105 @Deployment(resources = {"subprocess/GenericGetVnf.bpmn", "subprocess/GenericDeleteVnf.bpmn", "subprocess/DoDeleteVnf.bpmn"})
106 public void testDeleteVnfInfra_error_vnfInUse() throws Exception{
108 MockGetGenericVnfByIdWithDepth("testVnfId123", 1, "GenericFlows/getGenericVnfResponse_hasRelationships.xml");
109 MockDeleteGenericVnf("testVnfId123", "testReVer123");
110 mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
112 String businessKey = UUID.randomUUID().toString();
113 Map<String, Object> variables = new HashMap<String, Object>();
114 setVariables(variables);
116 invokeSubProcess("DoDeleteVnf", businessKey, variables);
117 // Disabled until SDNC support is there
118 // injectSDNCCallbacks(callbacks, "assign");
119 // injectSDNCCallbacks(callbacks, "activate");
121 waitForProcessEnd(businessKey, 10000);
123 Assert.assertTrue(isProcessEnded(businessKey));
125 String found = BPMNUtil.getVariable(processEngineRule, "DoDeleteVnf", "GENGV_FoundIndicator") ;
126 String inUse = BPMNUtil.getVariable(processEngineRule, "DoDeleteVnf", "DoDVNF_vnfInUse");
127 String workflowException = BPMNUtil.getVariable(processEngineRule, "DoDeleteVnf", "WorkflowException");
128 String exWfex = "WorkflowException[processKey=DoDeleteVnf,errorCode=5000,errorMessage=Can't Delete Generic Vnf. Generic Vnf is still in use.]";
130 assertEquals("true", found);
131 assertEquals("true", inUse);
132 assertEquals(exWfex, workflowException);
135 private void setVariables(Map<String, Object> variables) {
136 variables.put("mso-request-id", "123");
137 variables.put("isDebugLogEnabled", "true");
138 variables.put("vnfId","testVnfId123");