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.onap.so.bpmn.common;
26 import static org.junit.Assert.assertEquals;
27 import static org.junit.Assert.assertNotNull;
28 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVceByNameWithDepth;
29 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth;
30 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_500;
31 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfByNameWithDepth;
32 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetVceById;
34 import java.util.HashMap;
36 import java.util.UUID;
38 import org.junit.Test;
39 import org.onap.so.BaseIntegrationTest;
42 * Please describe the GenericGetVnfTest.java class
46 public class GenericGetVnfIT extends BaseIntegrationTest {
50 public void testGenericGetVnf_success_genericVnf() throws Exception{
51 MockGetGenericVnfByIdWithDepth("testVnfId123", 1, "GenericFlows/getGenericVnfByNameResponse.xml");
53 Map<String, Object> variables = new HashMap<>();
54 setVariables(variables, "testVnfId123", "testVnfName123", "generic-vnf");
56 String processId = invokeSubProcess( "GenericGetVnf", variables);
59 String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_SuccessIndicator",processId);
60 String found = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_FoundIndicator",processId);
61 String vnf = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_vnf",processId);
62 String byName = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_getVnfByName",processId);
63 String response = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowResponse",processId);
64 String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowException",processId);
66 assertEquals("true", successIndicator);
67 assertEquals("true", found);
68 assertEquals("false", byName);
69 assertNotNull(response);
71 assertEquals(null, workflowException);
77 public void testGenericGetVnf_success_vce() throws Exception{
78 MockGetVceById("testVnfId123[?]depth=1", "GenericFlows/getVceResponse.xml");
80 Map<String, Object> variables = new HashMap<>();
81 setVariables(variables, "testVnfId123", "testVnfName123", "vce");
83 String processId = invokeSubProcess( "GenericGetVnf", variables);
86 String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_SuccessIndicator",processId);
87 String found = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_FoundIndicator",processId);
88 String vnf = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_vnf",processId);
89 String byName = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_getVnfByName",processId);
90 String response = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowResponse",processId);
91 String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowException",processId);
93 assertEquals("true", successIndicator);
94 assertEquals("true", found);
95 assertEquals("false", byName);
96 assertNotNull(response);
98 assertEquals(null, workflowException);
104 public void testGenericGetVnf_success_genericVnfByName() throws Exception{
105 MockGetGenericVnfByNameWithDepth("testVnfName123", 1, "GenericFlows/getGenericVnfResponse.xml");
107 Map<String, Object> variables = new HashMap<>();
108 setVariables(variables, "", "testVnfName123", "generic-vnf");
110 String processId = invokeSubProcess( "GenericGetVnf", variables);
113 String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_SuccessIndicator",processId);
114 String found = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_FoundIndicator",processId);
115 String vnf = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_vnf",processId);
116 String byName = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_getVnfByName",processId);
117 String response = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowResponse",processId);
118 String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowException",processId);
120 assertEquals("true", successIndicator);
121 assertEquals("true", found);
122 assertEquals("true", byName);
123 assertNotNull(response);
125 assertEquals(null, workflowException);
131 public void testGenericGetVnf_success_vceByName() throws Exception{
132 MockGetGenericVceByNameWithDepth("testVnfName123", 1, "GenericFlows/getVceByNameResponse.xml");
134 Map<String, Object> variables = new HashMap<>();
135 setVariables(variables, null, "testVnfName123", "vce");
137 String processId = invokeSubProcess( "GenericGetVnf", variables);
140 String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_SuccessIndicator",processId);
141 String found = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_FoundIndicator",processId);
142 String vnf = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_vnf",processId);
143 String byName = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_getVnfByName",processId);
144 String response = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowResponse",processId);
145 String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowException",processId);
147 assertEquals("true", successIndicator);
148 assertEquals("true", found);
149 assertEquals("true", byName);
150 assertNotNull(response);
152 assertEquals(null, workflowException);
159 public void testGenericGetVnf_error_genericVnf500() throws Exception{
161 MockGetGenericVnfById_500("testVnfId123_500");
163 Map<String, Object> variables = new HashMap<>();
164 setVariables(variables, "testVnfId123_500", "testVnfId123_500", "generic-vnf");
166 String processId = invokeSubProcess( "GenericGetVnf", variables);
169 String successIndicator = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_SuccessIndicator",processId);
170 String found = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_FoundIndicator",processId);
171 String workflowException = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "WorkflowException",processId);
172 String byName = BPMNUtil.getVariable(processEngine, "GenericGetVnf", "GENGV_getVnfByName",processId);
174 String expectedWorkflowException = "WorkflowException[processKey=GenericGetVnf,errorCode=500,errorMessage=Received a bad response from AAI,workStep=*]";
176 assertEquals("false", successIndicator);
177 assertEquals("false", found);
178 assertEquals("false", byName);
180 assertEquals(expectedWorkflowException, workflowException);
183 private void setVariables(Map<String, Object> variables, String vnfId, String vnfName, String type) {
184 variables.put("isDebugLogEnabled", "true");
185 variables.put("GENGV_vnfId", vnfId);
186 variables.put("GENGV_vnfName",vnfName);
187 variables.put("GENGV_type", type);
188 variables.put("mso-request-id", UUID.randomUUID().toString());