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.infrastructure;
23 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
24 import static com.github.tomakehurst.wiremock.client.WireMock.get;
25 import static com.github.tomakehurst.wiremock.client.WireMock.put;
26 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
27 import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
28 import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
29 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockAAIVfModule;
30 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDBUpdateVfModule;
31 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth;
32 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority;
33 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance;
34 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById;
35 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetPserverByVnfId;
36 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfsByVnfId;
37 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockSetInMaintFlagByVnfId;
38 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetDefaultCloudRegionByCloudRegionId;
39 import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogData;
40 import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
41 import static org.openecomp.mso.bpmn.mock.StubResponsePolicy.MockPolicySkip;
42 import static org.openecomp.mso.bpmn.mock.StubResponseAPPC.MockAppcError;
44 import java.io.IOException;
45 import java.util.HashMap;
47 import java.util.UUID;
49 import org.camunda.bpm.engine.test.Deployment;
50 import org.junit.Ignore;
51 import org.junit.Test;
52 import org.openecomp.mso.bpmn.common.WorkflowTest;
53 import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
54 import org.openecomp.mso.bpmn.mock.FileUtil;
55 import org.openecomp.mso.client.aai.AAIObjectType;
56 import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri;
57 import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory;
60 * Unit test cases for VnfInPlaceUpdate.bpmn
62 public class VnfInPlaceUpdateTest extends WorkflowTest {
64 public VnfInPlaceUpdateTest() throws IOException {
76 @Deployment(resources = {
77 "process/VnfInPlaceUpdate.bpmn",
78 "subprocess/CompleteMsoProcess.bpmn",
79 "subprocess/FalloutHandler.bpmn",
80 "subprocess/BuildingBlock/RainyDayHandler.bpmn",
81 "subprocess/BuildingBlock/ManualHandling.bpmn",
82 "subprocess/BuildingBlock/AppCClient.bpmn"
85 public void sunnyDay() throws Exception {
88 System.setProperty("mso.config.path", "src/test/resources");
89 AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "skask");
90 wireMockRule.stubFor(get(
91 urlPathEqualTo("/aai/v11" + path.build()))
94 .withHeader("Content-Type", "application/json")
95 .withBodyFile("AAI/mockObject.json")
100 //AAIResourceUri path1 = AAIUriFactory.createResourceUri(AAIObjectType.CUSTOM_QUERY).queryParam("format", "RESOURCE");
101 //wireMockRule.stubFor(put(
102 // urlMatching("/aai/v10/query/pservers-fromVnf"))
105 // .withHeader("Content-Type", "application/json")
106 // .withBodyFile("AAI/AAI_pserversByVnfId.json")
107 // .withStatus(200)));
109 MockNodeQueryServiceInstanceById("MIS%2F1604%2F0026%2FSW_INTERNET", "GenericFlows/getSIUrlByIdVipr.xml");
110 MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml");
111 //MockGetGenericVnfById_404("testVnfId");
112 MockGetGenericVnfByIdWithDepth("skask", 1, "AAI/AAI_genericVnfsByVnfId.json");
114 MockDBUpdateVfModule();
115 MockGetPserverByVnfId("skask", "AAI/AAI_pserverByVnfId.json", 200);
116 MockSetInMaintFlagByVnfId("skask", "AAI/AAI_genericVnfsByVnfId.json", 200);
117 MockGetGenericVnfsByVnfId("skask", "AAI/AAI_genericVnfsByVnfId.json", 200);
118 MockGetDefaultCloudRegionByCloudRegionId("mdt1", "AAI/AAI_defaultCloudRegionByCloudRegionId.json", 200);
121 mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
123 String businessKey = UUID.randomUUID().toString();
124 String updaetVnfRequest =
125 FileUtil.readResourceFile("__files/InfrastructureFlows/VnfInPlaceUpdate_VID_request.json");
127 Map<String, Object> variables = setupVariablesSunnyDayVID();
130 TestAsyncResponse asyncResponse = invokeAsyncProcess("VnfInPlaceUpdate",
131 "v1", businessKey, updaetVnfRequest, variables);
133 WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 100000);
135 String responseBody = response.getResponse();
136 System.out.println("Workflow (Synch) Response:\n" + responseBody);
138 // TODO add appropriate assertions
140 waitForProcessEnd(businessKey, 100000);
141 checkVariable(businessKey, "VnfInPlaceUpdateSuccessIndicator", true);
147 private Map<String, Object> setupVariablesSunnyDayVID() {
148 Map<String, Object> variables = new HashMap<String, Object>();
150 variables.put("requestId", "testRequestId");
151 variables.put("isDebugLogEnabled", "true");
152 variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4");
153 variables.put("vnfId", "skask");