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 org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNotNull;
25 import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow;
26 import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish;
27 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetCustomer;
28 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance;
29 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById;
30 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName;
31 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutServiceInstance;
32 import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogData;
33 import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
34 import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;
36 import java.io.IOException;
37 import java.util.HashMap;
39 import java.util.UUID;
41 import org.camunda.bpm.engine.test.Deployment;
42 import org.junit.Ignore;
43 import org.junit.Test;
44 import org.openecomp.mso.bpmn.common.BPMNUtil;
45 import org.openecomp.mso.bpmn.common.WorkflowTest;
46 import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
47 import org.openecomp.mso.bpmn.mock.FileUtil;
50 * Unit test cases for CreateGenericALaCarteServiceInstance.bpmn
52 public class CreateGenericALaCarteServiceInstanceTest extends WorkflowTest {
54 private final CallbackSet callbacks = new CallbackSet();
56 public CreateGenericALaCarteServiceInstanceTest() throws IOException {
57 callbacks.put("assign", FileUtil.readResourceFile("__files/VfModularity/SDNCSITopologyAssignCallback.xml"));
61 * Sunny day VID scenario.
65 //@Ignore // File not found - unable to run the test. Also, Stubs need updating..
68 @Deployment(resources = {
69 "process/CreateGenericALaCarteServiceInstance.bpmn",
70 "subprocess/BuildingBlock/DecomposeService.bpmn",
71 "subprocess/DoCreateServiceInstance.bpmn",
72 "subprocess/DoCreateServiceInstanceRollback.bpmn",
73 "subprocess/SDNCAdapterV1.bpmn",
74 "subprocess/GenericPutService.bpmn",
75 "subprocess/GenericGetService.bpmn",
76 "subprocess/CompleteMsoProcess.bpmn",
77 "subprocess/FalloutHandler.bpmn" })
78 public void sunnyDayAlaCarte() throws Exception {
83 MockGetCustomer("MCBH-1610", "CreateServiceInstance/createServiceInstance_queryGlobalCustomerId_AAIResponse_Success.xml");
84 MockPutServiceInstance("MCBH-1610", "viprsvc", "RaaTest-1-id", "");
85 MockGetServiceInstance("MCBH-1610", "viprsvc", "RaaTest-1-id", "GenericFlows/getServiceInstance.xml");
86 MockNodeQueryServiceInstanceByName("RAATest-1", null);
87 MockNodeQueryServiceInstanceById("RaaTest-1-id", null);
91 MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef","2","/VIPR/getCatalogServiceResourcesData.json");
92 mockUpdateRequestDB(200, "DBUpdateResponse.xml");
93 MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef","InfrastructureFlows/DoCreateServiceInstance_request.json");
96 String businessKey = UUID.randomUUID().toString();
98 //String createVfModuleRequest = FileUtil.readResourceFile("__files/SIRequest.json");
100 Map<String, String> variables = setupVariables();
101 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "CreateGenericALaCarteServiceInstance", variables);
102 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());
104 String workflowResp = BPMNUtil.getVariable(processEngineRule, "CreateGenericALaCarteServiceInstance", "WorkflowResponse");
105 //assertNotNull(workflowResp);
106 System.out.println("Workflow (Synch) Response:\n" + workflowResp);
107 String workflowException = BPMNUtil.getVariable(processEngineRule, "CreateGenericALaCarteServiceInstance", "WorkflowException");
108 String completionReq = BPMNUtil.getVariable(processEngineRule, "CreateGenericALaCarteServiceInstance", "completionRequest");
109 System.out.println("completionReq:\n" + completionReq);
110 System.out.println("workflowException:\n" + workflowException);
111 assertNotNull(completionReq);
112 assertEquals(null, workflowException);
115 //injectSDNCCallbacks(callbacks, "assign");
121 private Map<String, String> setupVariables() {
122 Map<String, String> variables = new HashMap<>();
123 variables.put("isDebugLogEnabled", "true");
124 variables.put("bpmnRequest", getRequest());
125 variables.put("mso-request-id", "RaaCSIRequestId-1");
126 variables.put("serviceInstanceId","RaaTest-1-id");
127 variables.put("sdncVersion", "1802");
128 variables.put("serviceInstanceName", "some-junk-name");
132 public String getRequest() {
133 String request = "{\"requestDetails\":{\"project\": {\"projectName\": \"projectName\"},\"owningEntity\": {\"owningEntityId\": \"randomStrings\",\"owningEntityName\": \"randomStrings\"},\"modelInfo\":{\"modelType\":\"service\",\"modelInvariantUuid\":\"uuid-miu-svc-011-abcdef\",\"modelVersionUuid\":\"ASDC_TOSCA_UUID\",\"modelName\":\"SIModelName1\",\"modelVersion\":\"2\"},\"subscriberInfo\":{\"globalSubscriberId\":\"MCBH-1610\",\"subscriberName\":\"Kaneohe\"},\"requestInfo\":{\"instanceName\":\"RAATest-1\",\"source\":\"VID\",\"suppressRollback\":\"true\",\"productFamilyId\":\"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\"},\"cloudConfiguration\":{\"lcpCloudRegionId\":\"mdt1\",\"tenantId\":\"8b1df54faa3b49078e3416e21370a3ba\"},\"requestParameters\":{\"subscriptionServiceType\":\"viprsvc\",\"aLaCarte\":\"false\",\"userParams\":[]}}}";