2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (c) 2019 Samsung
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.so.bpmn.common;
25 import static org.onap.so.bpmn.mock.StubResponseAAI.MockAAIVfModuleBadPatch;
26 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth;
27 import static org.onap.so.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_404;
28 import static org.onap.so.bpmn.mock.StubResponseAAI.MockPatchGenericVnf;
29 import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutGenericVnf;
30 import static org.onap.so.bpmn.mock.StubResponseAAI.MockPutGenericVnf_Bad;
31 import java.io.IOException;
32 import java.util.HashMap;
34 import java.util.UUID;
35 import org.camunda.bpm.engine.test.Deployment;
36 import org.junit.Assert;
37 import org.junit.Ignore;
38 import org.junit.Test;
39 import org.onap.so.BaseIntegrationTest;
40 import org.onap.so.bpmn.core.WorkflowException;
41 import org.onap.so.bpmn.mock.FileUtil;
42 import org.slf4j.Logger;
43 import org.slf4j.LoggerFactory;
46 * Unit tests for UpdateAAIGenericVnf bpmn.
49 public class UpdateAAIGenericVnfIT extends BaseIntegrationTest {
51 Logger logger = LoggerFactory.getLogger(CreateAAIVfModuleIT.class);
55 * Test the happy path through the flow.
59 public void happyPath() throws IOException {
62 String updateAAIGenericVnfRequest =
63 FileUtil.readResourceFile("__files/VfModularity/UpdateAAIGenericVnfRequest.xml");
64 MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
65 MockPutGenericVnf(wireMockServer, "/skask", 200);
66 MockPatchGenericVnf(wireMockServer, "skask");
68 String businessKey = UUID.randomUUID().toString();
69 Map<String, Object> variables = new HashMap<>();
70 variables.put("mso-request-id", UUID.randomUUID().toString());
71 variables.put("isDebugLogEnabled", "true");
72 variables.put("UpdateAAIGenericVnfRequest", updateAAIGenericVnfRequest);
73 invokeSubProcess("UpdateAAIGenericVnf", businessKey, variables);
75 Assert.assertTrue(isProcessEnded(businessKey));
76 String response = (String) getVariableFromHistory(businessKey, "UAAIGenVnf_updateGenericVnfResponse");
77 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIGenVnf_updateGenericVnfResponseCode");
78 logger.debug("Subflow response code: {}", responseCode);
79 logger.debug("Subflow response: {}", response);
80 Assert.assertEquals(200, responseCode.intValue());
86 * Test the happy path through the flow.
90 public void personaMismatch() throws IOException {
94 String updateAAIGenericVnfRequest =
95 FileUtil.readResourceFile("__files/VfModularity/UpdateAAIGenericVnfRequest.xml");
96 updateAAIGenericVnfRequest = updateAAIGenericVnfRequest.replaceFirst("introvert", "extrovert");
98 MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
100 String businessKey = UUID.randomUUID().toString();
101 Map<String, Object> variables = new HashMap<>();
102 variables.put("mso-request-id", UUID.randomUUID().toString());
103 variables.put("isDebugLogEnabled", "true");
104 variables.put("UpdateAAIGenericVnfRequest", updateAAIGenericVnfRequest);
105 invokeSubProcess("UpdateAAIGenericVnf", businessKey, variables);
107 Assert.assertTrue(isProcessEnded(businessKey));
108 WorkflowException workflowException =
109 (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
110 logger.debug("Workflow Exception: {}", workflowException);
111 Assert.assertNotNull(workflowException);
117 * Test the case where the GET to AAI returns a 404.
121 public void badGet() throws IOException {
125 String updateAAIGenericVnfRequest =
126 FileUtil.readResourceFile("__files/VfModularity/UpdateAAIGenericVnfRequest.xml");
128 MockGetGenericVnfById_404(wireMockServer, "skask[?]depth=1");
130 String businessKey = UUID.randomUUID().toString();
131 Map<String, Object> variables = new HashMap<>();
132 variables.put("mso-request-id", UUID.randomUUID().toString());
133 variables.put("isDebugLogEnabled", "true");
134 variables.put("UpdateAAIGenericVnfRequest", updateAAIGenericVnfRequest);
135 invokeSubProcess("UpdateAAIGenericVnf", businessKey, variables);
137 Assert.assertTrue(isProcessEnded(businessKey));
138 String response = (String) getVariableFromHistory(businessKey, "UAAIGenVnf_getGenericVnfResponse");
139 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIGenVnf_getGenericVnfResponseCode");
140 logger.debug("Subflow response code: {}", responseCode);
141 logger.debug("Subflow response: {}", response);
142 Assert.assertEquals(404, responseCode.intValue());
148 * Test the case where the GET to AAI is successful, but he subsequent PUT returns 404.
152 public void badPatch() throws IOException {
156 String updateAAIGenericVnfRequest =
157 FileUtil.readResourceFile("__files/VfModularity/UpdateAAIGenericVnfRequest.xml");
159 MockGetGenericVnfByIdWithDepth(wireMockServer, "skask", 1, "VfModularity/GenericVnf.xml");
160 MockPutGenericVnf_Bad(wireMockServer, "skask", 404);
161 MockAAIVfModuleBadPatch(wireMockServer, "/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask", 404);
163 String businessKey = UUID.randomUUID().toString();
164 Map<String, Object> variables = new HashMap<>();
165 variables.put("mso-request-id", UUID.randomUUID().toString());
166 variables.put("isDebugLogEnabled", "true");
167 variables.put("UpdateAAIGenericVnfRequest", updateAAIGenericVnfRequest);
168 invokeSubProcess("UpdateAAIGenericVnf", businessKey, variables);
170 Assert.assertTrue(isProcessEnded(businessKey));
171 String response = (String) getVariableFromHistory(businessKey, "UAAIGenVnf_updateGenericVnfResponse");
172 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIGenVnf_updateGenericVnfResponseCode");
173 logger.debug("Subflow response code: {}", responseCode);
174 logger.debug("Subflow response: {}", response);
175 Assert.assertEquals(404, responseCode.intValue());