AT&T 1712 and 1802 release code
[so.git] / bpmn / MSOCommonBPMN / src / test / java / org / openecomp / mso / bpmn / common / DecomposeServiceTest.java
1 /*- 
2  * ============LICENSE_START======================================================= 
3  * ONAP - SO 
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 
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0 
12  * 
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========================================================= 
19  */ 
20
21 package org.openecomp.mso.bpmn.common;
22
23 import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogData;
24 import java.io.IOException;
25 import java.util.HashMap;
26 import java.util.Map;
27 import java.util.UUID;
28
29 import org.camunda.bpm.engine.test.Deployment;
30 import org.junit.Assert;
31 import org.junit.Test;
32 import org.openecomp.mso.bpmn.common.WorkflowTest;
33
34 /**
35  * Unit Test for the DecomposeService Flow
36  *
37  */
38 public class DecomposeServiceTest extends WorkflowTest {
39
40
41         public DecomposeServiceTest() throws IOException {
42
43         }
44
45         @Test
46         @Deployment(resources = {"subprocess/BuildingBlock/DecomposeService.bpmn"})
47         public void testDecomposeService_success() throws Exception{
48                 MockGetServiceResourcesCatalogData("cmw-123-456-789", "1.0", "/getCatalogServiceResourcesDataWithConfig.json");
49
50                 String businessKey = UUID.randomUUID().toString();
51                 Map<String, Object> variables = new HashMap<>();
52                 setVariablesSuccess(variables, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff");
53                 invokeSubProcess("DecomposeService", businessKey, variables);
54
55                 waitForProcessEnd(businessKey, 10000);
56
57                 Assert.assertTrue(isProcessEnded(businessKey));
58
59         }
60         
61         //@Test
62         @Deployment(resources = {"subprocess/BuildingBlock/DecomposeService.bpmn"})
63         public void testDecomposeService_success_partial() throws Exception{
64                 MockGetServiceResourcesCatalogData("cmw-123-456-789", "/getCatalogServiceResourcesDataNoNetwork.json");
65
66
67                 String businessKey = UUID.randomUUID().toString();
68                 Map<String, Object> variables = new HashMap<>();
69                 setVariablesSuccess(variables, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff");
70                 invokeSubProcess("DecomposeService", businessKey, variables);
71
72                 waitForProcessEnd(businessKey, 10000);
73
74                 Assert.assertTrue(isProcessEnded(businessKey));
75
76         }
77
78         private void setVariablesSuccess(Map<String, Object> variables, String requestId, String siId) {
79                 variables.put("isDebugLogEnabled", "true");
80                 variables.put("mso-request-id", requestId);
81                 variables.put("msoRequestId", requestId);
82                 variables.put("serviceInstanceId",siId);
83
84                 String serviceModelInfo = "{ "+ "\"modelType\": \"service\"," +
85                                 "\"modelInvariantUuid\": \"cmw-123-456-789\"," +
86                                 "\"modelVersionId\": \"ab6478e5-ea33-3346-ac12-ab121484a3fe\"," +
87                                 "\"modelName\": \"ServicevSAMP12\"," +
88                                 "\"modelVersion\": \"1.0\"," +
89                                 "}";
90                 variables.put("serviceModelInfo", serviceModelInfo);
91
92         }
93
94 }