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.junit.Assert.assertNotNull;
28 import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow;
29 import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish;
30 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth;
31 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_500;
32 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByNameWithDepth;
33 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVceByNameWithDepth;
34 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVceById;
36 import java.util.HashMap;
39 import org.camunda.bpm.engine.test.Deployment;
40 import org.junit.Ignore;
41 import org.junit.Test;
42 import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
45 * Please describe the GenericGetVnfTest.java class
48 public class GenericGetVnfTest extends WorkflowTest {
51 @Deployment(resources = {"subprocess/GenericGetVnf.bpmn"})
52 public void testGenericGetVnf_success_genericVnf() throws Exception{
53 MockGetGenericVnfByIdWithDepth("testVnfId123", 1, "GenericFlows/getGenericVnfByNameResponse.xml");
55 Map<String, String> variables = new HashMap<String, String>();
56 setVariables(variables, "testVnfId123", "testVnfName123", "generic-vnf");
58 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetVnf", variables);
59 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());
61 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_SuccessIndicator");
62 String found = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_FoundIndicator");
63 String vnf = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_vnf");
64 String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_getVnfByName");
65 String response = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowResponse");
66 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowException");
68 assertEquals("true", successIndicator);
69 assertEquals("true", found);
70 assertEquals("false", byName);
71 assertNotNull(response);
73 assertEquals(null, workflowException);
78 @Deployment(resources = {"subprocess/GenericGetVnf.bpmn"})
79 public void testGenericGetVnf_success_vce() throws Exception{
80 MockGetVceById("testVnfId123[?]depth=1", "GenericFlows/getVceResponse.xml");
82 Map<String, String> variables = new HashMap<String, String>();
83 setVariables(variables, "testVnfId123", "testVnfName123", "vce");
85 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetVnf", variables);
86 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());
88 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_SuccessIndicator");
89 String found = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_FoundIndicator");
90 String vnf = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_vnf");
91 String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_getVnfByName");
92 String response = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowResponse");
93 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowException");
95 assertEquals("true", successIndicator);
96 assertEquals("true", found);
97 assertEquals("false", byName);
98 assertNotNull(response);
100 assertEquals(null, workflowException);
105 @Deployment(resources = {"subprocess/GenericGetVnf.bpmn"})
106 public void testGenericGetVnf_success_genericVnfByName() throws Exception{
107 MockGetGenericVnfByNameWithDepth("testVnfName123", 1, "GenericFlows/getGenericVnfResponse.xml");
109 Map<String, String> variables = new HashMap<String, String>();
110 setVariables(variables, "", "testVnfName123", "generic-vnf");
112 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetVnf", variables);
113 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());
115 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_SuccessIndicator");
116 String found = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_FoundIndicator");
117 String vnf = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_vnf");
118 String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_getVnfByName");
119 String response = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowResponse");
120 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowException");
122 assertEquals("true", successIndicator);
123 assertEquals("true", found);
124 assertEquals("true", byName);
125 assertNotNull(response);
127 assertEquals(null, workflowException);
132 @Deployment(resources = {"subprocess/GenericGetVnf.bpmn"})
133 public void testGenericGetVnf_success_vceByName() throws Exception{
134 MockGetGenericVceByNameWithDepth("testVnfName123", 1, "GenericFlows/getVceByNameResponse.xml");
136 Map<String, String> variables = new HashMap<String, String>();
137 setVariables(variables, null, "testVnfName123", "vce");
139 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetVnf", variables);
140 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());
142 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_SuccessIndicator");
143 String found = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_FoundIndicator");
144 String vnf = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_vnf");
145 String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_getVnfByName");
146 String response = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowResponse");
147 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowException");
149 assertEquals("true", successIndicator);
150 assertEquals("true", found);
151 assertEquals("true", byName);
152 assertNotNull(response);
154 assertEquals(null, workflowException);
159 @Ignore // BROKEN TEST (previously ignored)
160 @Deployment(resources = {"subprocess/GenericGetVnf.bpmn"})
161 public void testGenericGetVnf_error_genericVnf500() throws Exception{
163 MockGetGenericVnfById_500("testVnfId123");
165 Map<String, String> variables = new HashMap<String, String>();
166 setVariables(variables, "testVnfId123", "testVnfName123", "generic-vnf");
168 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetVnf", variables);
169 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());
171 String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_SuccessIndicator");
172 String found = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_FoundIndicator");
173 String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowException");
174 String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_getVnfByName");
176 String expectedWorkflowException = "WorkflowException[processKey=GenericGetVnf,errorCode=500,errorMessage=Incoming VnfId and VnfName are null. VnfId or VnfName is required!]";
178 assertEquals("false", successIndicator);
179 assertEquals("false", found);
180 assertEquals("false", byName);
182 assertEquals(expectedWorkflowException, workflowException);
185 private void setVariables(Map<String, String> variables, String vnfId, String vnfName, String type) {
186 variables.put("isDebugLogEnabled", "true");
187 variables.put("GENGV_vnfId", vnfId);
188 variables.put("GENGV_vnfName",vnfName);
189 variables.put("GENGV_type", type);