2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
21 package org.openecomp.mso.bpmn.infrastructure;
\r
23 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
\r
24 import static com.github.tomakehurst.wiremock.client.WireMock.containing;
\r
25 import static com.github.tomakehurst.wiremock.client.WireMock.delete;
\r
26 import static com.github.tomakehurst.wiremock.client.WireMock.post;
\r
27 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
\r
28 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
\r
29 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
\r
30 import static org.openecomp.mso.bpmn.common.DeleteAAIVfModuleTest.MockAAIDeleteVfModule;
\r
31 import static org.openecomp.mso.bpmn.common.DeleteAAIVfModuleTest.MockAAIGenericVnfSearch;
\r
33 import java.io.IOException;
\r
34 import java.util.HashMap;
\r
35 import java.util.Map;
\r
36 import java.util.UUID;
\r
38 import org.camunda.bpm.engine.test.Deployment;
\r
39 import org.junit.Test;
\r
40 import org.openecomp.mso.bpmn.common.WorkflowTest;
\r
41 import org.openecomp.mso.bpmn.core.WorkflowException;
\r
43 public class DoDeleteVfModuleFromVnfTest extends WorkflowTest {
\r
44 private final CallbackSet callbacks = new CallbackSet();
\r
46 private static final String EOL = "\n";
\r
48 private final String vnfAdapterDeleteCallback =
\r
49 "<deleteVfModuleResponse>" + EOL +
\r
50 " <vnfId>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnfId>" + EOL +
\r
51 " <vfModuleId>973ed047-d251-4fb9-bf1a-65b8949e0a73</vfModuleId>" + EOL +
\r
52 " <vfModuleDeleted>true</vfModuleDeleted>" + EOL +
\r
53 " <messageId>{{MESSAGE-ID}}</messageId>" + EOL +
\r
54 "</deleteVfModuleResponse>" + EOL;
\r
56 private final String vnfAdapterDeleteCallbackFail =
\r
57 "<vfModuleException>" + EOL +
\r
58 " <message>Error processing request to VNF-Async. Not Found.</message>" + EOL +
\r
59 " <category>INTERNAL</category>" + EOL +
\r
60 " <rolledBack>false</rolledBack>" + EOL +
\r
61 " <messageId>{{MESSAGE-ID}}</messageId>" + EOL +
\r
62 "</vfModuleException>" + EOL;
\r
64 private final String sdncAdapterDeleteCallback =
\r
65 "<output xmlns=\"com:att:sdnctl:l3api\">" + EOL +
\r
66 " <svc-request-id>{{REQUEST-ID}}</svc-request-id>" + EOL +
\r
67 " <ack-final-indicator>Y</ack-final-indicator>" + EOL +
\r
70 public DoDeleteVfModuleFromVnfTest() throws IOException {
\r
71 callbacks.put("deactivate", sdncAdapterDeleteCallback);
\r
72 callbacks.put("unassign", sdncAdapterDeleteCallback);
\r
73 callbacks.put("vnfDelete", vnfAdapterDeleteCallback);
\r
74 callbacks.put("vnfDeleteFail", vnfAdapterDeleteCallbackFail);
\r
77 private final String wfeString = "WorkflowException";
\r
80 @Deployment(resources = {
\r
81 "subprocess/DoDeleteVfModuleFromVnf.bpmn",
\r
82 "subprocess/SDNCAdapterV1.bpmn",
\r
83 "subprocess/VnfAdapterRestV1.bpmn",
\r
84 "subprocess/DeleteAAIVfModule.bpmn"
\r
86 public void TestDoDeleteVfModuleFromVnfSuccess() {
\r
87 // delete the Base Module and Generic Vnf
\r
88 // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c721, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a73
\r
90 "<vnf-request xmlns=\"http://org.openecomp/mso/infra/vnf-request/v1\">" + EOL +
\r
91 " <request-info>" + EOL +
\r
92 " <action>DELETE_VF_MODULE</action>" + EOL +
\r
93 " <source>PORTAL</source>" + EOL +
\r
94 " </request-info>" + EOL +
\r
95 " <vnf-inputs>" + EOL +
\r
96 " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL +
\r
97 " <vnf-name>STMTN5MMSC21</vnf-name>" + EOL +
\r
98 " <vnf-type>asc_heat-int</vnf-type>" + EOL +
\r
99 " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL +
\r
100 " <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL +
\r
101 " <service-id>00000000-0000-0000-0000-000000000000</service-id>" + EOL +
\r
102 " <service-type>SDN-ETHERNET-INTERNET</service-type>" + EOL +
\r
103 " <tenant-id>fba1bd1e195a404cacb9ce17a9b2b421</tenant-id>" + EOL +
\r
104 " <orchestration-status>pending-delete</orchestration-status>" + EOL +
\r
105 " <aic-cloud-region>RDM2WAGPLCP</aic-cloud-region>" + EOL +
\r
106 " </vnf-inputs>" + EOL +
\r
107 " <vnf-params xmlns:tns=\"http://org.openecomp/mso/infra/vnf-request/v1\"/>" + EOL +
\r
108 "</vnf-request>" + EOL;
\r
110 MockDoDeleteVfModule_SDNCSuccess();
\r
111 MockDoDeleteVfModule_DeleteVNFSuccess();
\r
112 MockAAIGenericVnfSearch();
\r
113 MockAAIDeleteVfModule();
\r
115 String businessKey = UUID.randomUUID().toString();
\r
116 Map<String, Object> variables = new HashMap<>();
\r
117 variables.put("isDebugLogEnabled","true");
\r
118 variables.put("mso-request-id", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
\r
119 variables.put("msoRequestId", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
\r
120 variables.put("serviceInstanceId", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
\r
121 variables.put("vnfId", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
\r
122 variables.put("vfModuleId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
\r
123 variables.put("lcpCloudRegionId", "RDM2WAGPLCP");
\r
124 variables.put("tenantId", "fba1bd1e195a404cacb9ce17a9b2b421");
\r
125 variables.put("sdncVersion", "1707");
\r
127 invokeSubProcess("DoDeleteVfModuleFromVnf", businessKey, variables);
\r
129 injectSDNCCallbacks(callbacks, "deactivate");
\r
130 injectVNFRestCallbacks(callbacks, "vnfDelete");
\r
131 //waitForRunningProcessCount("vnfAdapterDeleteV1", 0, 120000);
\r
132 injectSDNCCallbacks(callbacks, "unassign");
\r
134 waitForProcessEnd(businessKey, 10000);
\r
135 WorkflowException wfe = (WorkflowException) getVariableFromHistory(businessKey, wfeString);
\r
136 checkVariable(businessKey, wfeString, null);
\r
138 System.out.println("TestDoDeleteVfModuleSuccess: ErrorCode=" + wfe.getErrorCode() +
\r
139 ", ErrorMessage=" + wfe.getErrorMessage());
\r
145 // start of mocks used locally and by other VF Module unit tests
\r
149 public static void MockDoDeleteVfModule_SDNCSuccess() {
\r
150 stubFor(post(urlEqualTo("/SDNCAdapter"))
\r
151 .withRequestBody(containing("SvcAction>deactivate"))
\r
152 .willReturn(aResponse()
\r
154 .withHeader("Content-Type", "text/xml")
\r
155 .withBodyFile("DeleteGenericVNFV1/sdncAdapterResponse.xml")));
\r
156 stubFor(post(urlEqualTo("/SDNCAdapter"))
\r
157 .withRequestBody(containing("SvcAction>unassign"))
\r
158 .willReturn(aResponse()
\r
160 .withHeader("Content-Type", "text/xml")
\r
161 .withBodyFile("DeleteGenericVNFV1/sdncAdapterResponse.xml")));
\r
165 public static void MockDoDeleteVfModule_DeleteVNFSuccess() {
\r
166 stubFor(delete(urlMatching("/vnfs/v1/vnfs/.*/vf-modules/.*"))
\r
167 .willReturn(aResponse()
\r
169 .withHeader("Content-Type", "application/xml")));
\r
170 stubFor(delete(urlMatching("/vnfs/v1/volume-groups/78987"))
\r
171 .willReturn(aResponse()
\r
173 .withHeader("Content-Type", "application/xml")));
\r