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.StubResponseDatabase.MockGetServiceResourcesCatalogData;
39 import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
40 import static org.openecomp.mso.bpmn.mock.StubResponsePolicy.MockPolicySkip;
41 import static org.openecomp.mso.bpmn.mock.StubResponseAPPC.MockAppcError;
43 import java.io.IOException;
44 import java.util.HashMap;
46 import java.util.UUID;
48 import org.camunda.bpm.engine.test.Deployment;
49 import org.junit.Assert;
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 RollbackVnf.bpmn
62 public class RollbackVnfTest extends WorkflowTest {
64 public RollbackVnfTest() throws IOException {
76 @Deployment(resources = {
77 "subprocess/RollbackVnf.bpmn",
78 "subprocess/BuildingBlock/AppCClient.bpmn"
81 public void sunnyDay() throws Exception {
84 System.setProperty("mso.config.path", "src/test/resources");
85 AAIResourceUri path = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, "skask");
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 MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml");
98 MockGetGenericVnfsByVnfId("skask", "AAI/AAI_genericVnfsByVnfId.json", 200);
99 MockSetInMaintFlagByVnfId("skask", "AAI/AAI_genericVnfsByVnfId.json", 200);
102 String businessKey = UUID.randomUUID().toString();
103 Map<String, Object> variables = setupVariablesSunnyDayVID();
105 invokeSubProcess("RollbackVnf", businessKey, variables);
107 // TODO add appropriate assertions
109 waitForProcessEnd(businessKey, 10000);
110 Assert.assertTrue(isProcessEnded(businessKey));
111 // assertVariables("true", "true", "false", "true", "Success", null);
117 private Map<String, Object> setupVariablesSunnyDayVID() {
118 Map<String, Object> variables = new HashMap<String, Object>();
120 variables.put("msoRequestId", "testRequestId");
121 variables.put("isDebugLogEnabled", "true");
122 variables.put("vnfId", "skask");
123 variables.put("rollbackVnfStop", true);
124 variables.put("rollbackVnfLock", true);
125 variables.put("rollbackQuiesceTraffic", false);
126 variables.put("rollbackSetClosedLoopDisabledFlag", true);
127 variables.put("rollbackSetVnfInMaintenanceFlag", true);
128 variables.put("errorCode", "1005");