2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.bpmn.common;
23 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority;
24 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVfModuleId;
25 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutVfModuleIdNoResponse;
27 import java.io.IOException;
28 import java.util.HashMap;
30 import java.util.UUID;
32 import org.camunda.bpm.engine.test.Deployment;
33 import org.junit.Assert;
34 import org.junit.Test;
35 import org.openecomp.mso.bpmn.mock.FileUtil;
38 * Unit tests for CreateAAIVfModuleVolumeGroup.bpmn.
40 public class CreateAAIVfModuleVolumeGroupTest extends WorkflowTest {
43 * Test the happy path through the flow.
46 @Deployment(resources = {
47 "subprocess/CreateAAIVfModuleVolumeGroup.bpmn"
49 public void happyPath() throws IOException {
53 String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml");
54 MockGetGenericVnfByIdWithPriority("skask", "lukewarm", 200, "VfModularity/VfModule-lukewarm.xml", 2);
55 MockPutVfModuleIdNoResponse("skask", "PCRF", "lukewarm");
57 String businessKey = UUID.randomUUID().toString();
58 Map<String, Object> variables = new HashMap<String, Object>();
59 variables.put("mso-request-id", "999-99-9999");
60 variables.put("isDebugLogEnabled","true");
61 variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest);
62 invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables);
64 Assert.assertTrue(isProcessEnded(businessKey));
65 String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponse");
66 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponseCode");
67 System.out.println("Subflow response code: " + responseCode);
68 System.out.println("Subflow response: " + response);
69 Assert.assertEquals(200, responseCode.intValue());
75 * Test the case where the GET to AAI returns a 404.
78 @Deployment(resources = {
79 "subprocess/CreateAAIVfModuleVolumeGroup.bpmn"
81 public void badGet() throws IOException {
85 String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml");
86 MockGetVfModuleId("skask", ".*", "VfModularity/VfModule-supercool.xml", 404);
88 String businessKey = UUID.randomUUID().toString();
89 Map<String, Object> variables = new HashMap<String, Object>();
90 variables.put("mso-request-id", "999-99-9999");
91 variables.put("isDebugLogEnabled","true");
92 variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest);
93 invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables);
95 Assert.assertTrue(isProcessEnded(businessKey));
96 String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponse");
97 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponseCode");
98 System.out.println("Subflow response code: " + responseCode);
99 System.out.println("Subflow response: " + response);
100 Assert.assertEquals(404, responseCode.intValue());
106 * Test the case where the GET to AAI is successful, but he subsequent PUT returns 404.
109 @Deployment(resources = {
110 "subprocess/CreateAAIVfModuleVolumeGroup.bpmn"
112 public void badPut() throws IOException {
116 String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml");
117 MockGetVfModuleId("skask", "lukewarm", "VfModularity/VfModule-lukewarm.xml", 200);
119 String businessKey = UUID.randomUUID().toString();
120 Map<String, Object> variables = new HashMap<String, Object>();
121 variables.put("mso-request-id", "999-99-9999");
122 variables.put("isDebugLogEnabled","true");
123 variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest);
124 invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables);
126 Assert.assertTrue(isProcessEnded(businessKey));
127 String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponse");
128 Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponseCode");
129 System.out.println("Subflow response code: " + responseCode);
130 System.out.println("Subflow response: " + response);
131 Assert.assertEquals(404, responseCode.intValue());