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.urlPathEqualTo;
26 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockAAIVfModule;
27 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDBUpdateVfModule;
28 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth;
29 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance;
30 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById;
31 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetPserverByVnfId;
32 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfsByVnfId;
33 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockSetInMaintFlagByVnfId;
34 import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogData;
35 import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
36 import static org.openecomp.mso.bpmn.mock.StubResponsePolicy.MockPolicySkip;
37 import static org.openecomp.mso.bpmn.mock.StubResponseAPPC.MockAppcError;
39 import java.io.IOException;
40 import java.util.HashMap;
42 import java.util.UUID;
44 import org.camunda.bpm.engine.test.Deployment;
45 import org.junit.Ignore;
46 import org.junit.Test;
47 import org.openecomp.mso.bpmn.common.WorkflowTest;
48 import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
49 import org.openecomp.mso.bpmn.mock.FileUtil;
50 import org.openecomp.mso.client.aai.AAIObjectType;
51 import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri;
52 import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory;
55 * Unit test cases for VnfConfigUpdate.bpmn
57 public class VnfConfigUpdateTest extends WorkflowTest {
59 public VnfConfigUpdateTest() throws IOException {
70 @Deployment(resources = {
71 "process/VnfConfigUpdate.bpmn",
72 "subprocess/RollbackVnf.bpmn",
73 "subprocess/CompleteMsoProcess.bpmn",
74 "subprocess/FalloutHandler.bpmn",
75 "subprocess/BuildingBlock/RainyDayHandler.bpmn",
76 "subprocess/BuildingBlock/ManualHandling.bpmn",
77 "subprocess/BuildingBlock/AppCClient.bpmn"
80 public void sunnyDay() throws Exception {
84 System.setProperty("mso.config.path", "src/test/resources");
85 AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "comx9906v");
86 wireMockRule.stubFor(get(
87 urlPathEqualTo("/aai/v11" + path.build()))
90 .withHeader("Content-Type", "application/json")
91 .withBodyFile("AAI/mockObject.json")
95 MockNodeQueryServiceInstanceById("MIS%2F1604%2F0026%2FSW_INTERNET", "GenericFlows/getSIUrlByIdVipr.xml");
96 MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml");
97 //MockGetGenericVnfById_404("testVnfId");
98 MockGetGenericVnfByIdWithDepth("comx9906v", 1, "AAI/AAI_genericVnfsByVnfIdVnfConfig.json");
100 MockDBUpdateVfModule();
101 MockGetPserverByVnfId("comx9906v", "AAI/AAI_pserverByVnfId.json", 200);
102 MockGetGenericVnfsByVnfId("comx9906v", "AAI/AAI_genericVnfsByVnfIdVnfConfig.json", 200);
103 MockSetInMaintFlagByVnfId("comx9906v", "AAI/AAI_genericVnfsByVnfIdVnfConfig.json", 200);
106 mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
108 String businessKey = UUID.randomUUID().toString();
109 String updaetVnfRequest =
110 FileUtil.readResourceFile("__files/InfrastructureFlows/ConfigVnf_VID_request.json");
112 Map<String, Object> variables = setupVariablesSunnyDayVID();
115 TestAsyncResponse asyncResponse = invokeAsyncProcess("VnfConfigUpdate",
116 "v1", businessKey, updaetVnfRequest, variables);
118 WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000);
120 String responseBody = response.getResponse();
121 System.out.println("Workflow (Synch) Response:\n" + responseBody);
123 // TODO add appropriate assertions
125 waitForProcessEnd(businessKey, 1000000);
126 checkVariable(businessKey, "VnfConfigUpdateSuccessIndicator", true);
132 private Map<String, Object> setupVariablesSunnyDayVID() {
133 Map<String, Object> variables = new HashMap<String, Object>();
135 variables.put("requestId", "testRequestId");
136 variables.put("isDebugLogEnabled", "true");
137 variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4");
138 variables.put("vnfId", "comx9906v");
139 variables.put("vnfType", "vSAMP12");
140 variables.put("serviceType", "MOG");