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.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetCustomer;
25 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance;
26 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById;
27 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName;
28 import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutServiceInstance;
29 import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
30 import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;
31 import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogData;
33 import java.io.IOException;
34 import java.util.HashMap;
36 import java.util.UUID;
38 import org.camunda.bpm.engine.test.Deployment;
39 import org.junit.Assert;
40 import org.junit.Ignore;
41 import org.junit.Test;
42 import org.openecomp.mso.bpmn.common.BPMNUtil;
43 import org.openecomp.mso.bpmn.common.WorkflowTest;
44 import org.openecomp.mso.bpmn.mock.FileUtil;
47 * Unit test cases for DoCreateServiceInstance.bpmn
49 public class DoCreateServiceInstanceTest extends WorkflowTest {
50 private static final String EOL = "\n";
51 private final CallbackSet callbacks = new CallbackSet();
52 private final String sdncAdapterCallback =
53 "<output xmlns=\"com:att:sdnctl:l3api\">" + EOL +
54 " <svc-request-id>((REQUEST-ID))</svc-request-id>" + EOL +
55 " <ack-final-indicator>Y</ack-final-indicator>" + EOL +
57 private final String input = FileUtil.readResourceFile("__files/CreateServiceInstance/DoCreateServiceInstanceInput.json");
60 public DoCreateServiceInstanceTest() throws IOException {
61 callbacks.put("assign", sdncAdapterCallback);
65 * Sunny day VID scenario.
71 @Deployment(resources = {
72 "subprocess/DoCreateServiceInstance.bpmn",
73 "subprocess/SDNCAdapterV1.bpmn",
74 "subprocess/GenericGetService.bpmn",
75 "subprocess/GenericPutService.bpmn",
76 "subprocess/CompleteMsoProcess.bpmn",
77 "subprocess/DoCreateServiceInstanceRollback.bpmn",
78 "subprocess/FalloutHandler.bpmn" })
79 public void sunnyDay() throws Exception {
84 MockGetCustomer("MCBH-1610", "CreateServiceInstance/createServiceInstance_queryGlobalCustomerId_AAIResponse_Success.xml");
85 MockPutServiceInstance("MCBH-1610", "viprsvc", "RaaTest-si-id", "");
86 MockGetServiceInstance("MCBH-1610", "viprsvc", "RaaTest-si-id", "GenericFlows/getServiceInstance.xml");
87 MockNodeQueryServiceInstanceByName("RAATest-si", "");
89 MockNodeQueryServiceInstanceById("RaaTest-si-id", "");
90 MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getSINoRelations.xml");
91 MockNodeQueryServiceInstanceById("MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getSIUrlById.xml");
95 mockUpdateRequestDB(200, "DBUpdateResponse.xml");
97 MockGetServiceResourcesCatalogData("uuid-miu-svc-011-abcdef","InfrastructureFlows/DoCreateServiceInstance_request.json");
99 String businessKey = UUID.randomUUID().toString();
101 Map<String, Object> variables = new HashMap<>();
102 setupVariables(variables);
103 invokeSubProcess("DoCreateServiceInstance", businessKey, variables);
104 injectSDNCCallbacks(callbacks, "assign");
105 waitForProcessEnd(businessKey, 10000);
106 Assert.assertTrue(isProcessEnded(businessKey));
107 String workflowException = BPMNUtil.getVariable(processEngineRule, "DoCreateServiceInstance", "WorkflowException");
108 System.out.println("workflowException:\n" + workflowException);
109 assertEquals(null, workflowException);
115 private void setupVariables(Map<String, Object> variables) {
116 variables.put("mso-request-id", "RaaDSITest1");
117 variables.put("isDebugLogEnabled", "true");
118 variables.put("msoRequestId", "RaaDSITestRequestId-1");
119 variables.put("serviceInstanceId","RaaTest-si-id");
120 variables.put("serviceModelInfo", "{\"modelType\":\"service\",\"modelInvariantUuid\":\"uuid-miu-svc-011-abcdef\",\"modelVersionUuid\":\"ASDC_TOSCA_UUID\",\"modelName\":\"SIModelName1\",\"modelVersion\":\"2\",\"projectName\":\"proj123\",\"owningEntityId\":\"id123\",\"owningEntityName\":\"name123\"}");
121 variables.put("productFamilyId", "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb");
122 variables.put("globalSubscriberId", "MCBH-1610");
123 variables.put("subscriptionServiceType", "viprsvc");
124 variables.put("instanceName", "RAATest-1");
125 variables.put("serviceInstanceName", "RAT-123");
126 variables.put("sdncVersion", "1611");
127 variables.put("serviceType", "PORT-MIRROR");
128 variables.put("requestJson", input);