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;
24 import static org.junit.Assert.assertEquals;
25 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockAAIVfModule;
26 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDBUpdateVfModule;
27 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth;
28 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfsByVnfId;
29 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetPserverByVnfId;
30 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance;
31 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById;
32 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchGenericVnf;
33 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchVfModuleId;
34 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf;
35 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockSetInMaintFlagByVnfId;
36 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockVNFAdapterRestVfModule;
37 import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogData;
38 import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
39 import static org.openecomp.mso.bpmn.mock.StubResponsePolicy.MockPolicySkip;
40 import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;
41 import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockVNFPut;
43 //import static org.junit.Assert.assertEquals;
44 //import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow;
45 //import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish;
46 //import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById;
48 import java.util.HashMap;
50 import java.util.UUID;
52 import org.camunda.bpm.engine.test.Deployment;
53 import org.junit.Assert;
54 import org.junit.Ignore;
55 import org.junit.Test;
57 import org.openecomp.mso.bpmn.common.WorkflowTest;
58 import org.onap.appc.client.lcm.model.Action;
60 //import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
62 public class AppCClientTest extends WorkflowTest{
67 @Deployment(resources = {"subprocess/BuildingBlock/AppCClient.bpmn"})
68 public void test() throws Exception{
72 MockNodeQueryServiceInstanceById("MIS%2F1604%2F0026%2FSW_INTERNET", "GenericFlows/getSIUrlByIdVipr.xml");
73 MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml");
74 //MockGetGenericVnfById_404("testVnfId");
75 MockGetServiceResourcesCatalogData("995256d2-5a33-55df-13ab-12abad84e7ff", "1.0", "VIPR/getCatalogServiceResourcesDataForUpdateVnfInfra.json");
76 MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml");
77 MockPutGenericVnf(".*");
79 MockPatchGenericVnf("skask");
80 MockPatchVfModuleId("skask", ".*");
81 mockSDNCAdapter("VfModularity/StandardSDNCSynchResponse.xml");
82 mockVNFPut("skask", "/supercool", 202);
83 mockVNFPut("skask", "/lukewarm", 202);
84 MockVNFAdapterRestVfModule();
85 MockDBUpdateVfModule();
86 MockGetPserverByVnfId("skask", "AAI/AAI_pserverByVnfId.json", 200);
87 MockGetGenericVnfsByVnfId("skask", "AAI/AAI_genericVnfsByVnfId.json", 200);
88 MockSetInMaintFlagByVnfId("skask", 200);
90 mockSDNCAdapter("VfModularity/StandardSDNCSynchResponse.xml");
91 mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
93 Map<String, Object> variables = new HashMap<String, Object>();
94 variables = setVariablesInstance();
95 String businessKey = UUID.randomUUID().toString();
96 invokeSubProcess("AppCClient", businessKey, variables);
97 waitForProcessEnd(businessKey, 10000);
98 Assert.assertTrue(isProcessEnded(businessKey));
99 String workflowException = BPMNUtil.getVariable(processEngineRule, "AppCClient", "WorkflowException");
100 System.out.println("workflowException:\n" + workflowException);
101 assertEquals(null, workflowException);
106 private Map<String, Object> setVariablesInstance(){
107 Map<String,Object> variables = new HashMap<String, Object>();
108 variables.put("isDebugLogEnabled", "true");
109 variables.put("mso-request-id", "RaaACCTest1");
110 variables.put("msoRequestId", "RaaACCTestRequestId-1");
111 variables.put("requestId", "testRequestId");
112 variables.put("vnfId", "skask");
113 variables.put("action", Action.Stop);
114 variables.put("healthCheckIndex", 0);
115 variables.put("payload", "{\"existing-software-version\":\"3.1\",\"new-software-version\":\"3.2\"}");
116 //variables.put("payload", "{\"vm-id\": \"<VM-ID>\", \"identy-url\":\"<IDENTITY-URL>\", \"tenant-id\": \"<TENANT-ID>\"}, \"Hello\":\"Whats up\"" );