7acaf449e33cbfa972c593edf23930a37a39e16a
[so.git] / bpmn / mso-infrastructure-bpmn / src / test / java / org / onap / so / bpmn / common / DecomposeServiceIT.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.onap.so.bpmn.common;
22
23 import static org.onap.so.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.Ignore;
32 import org.junit.Test;
33 import org.onap.so.BaseIntegrationTest;
34
35 /**
36  * Unit Test for the DecomposeService Flow
37  *
38  */
39
40 public class DecomposeServiceIT extends BaseIntegrationTest {
41
42
43         public DecomposeServiceIT() throws IOException {
44
45         }
46
47         @Test   
48         public void testDecomposeService_success() throws Exception{
49                 MockGetServiceResourcesCatalogData("cmw-123-456-789", "1.0", "/getCatalogServiceResourcesDataWithConfig.json");
50
51                 String businessKey = UUID.randomUUID().toString();
52                 Map<String, Object> variables = new HashMap<>();
53                 setVariablesSuccess(variables, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff");
54                 invokeSubProcess("DecomposeService", businessKey, variables);
55
56                 waitForProcessEnd(businessKey, 10000);
57
58                 Assert.assertTrue(isProcessEnded(businessKey));
59
60         }
61         
62         //@Test
63         @Test
64         public void testDecomposeService_success_partial() throws Exception{
65                 MockGetServiceResourcesCatalogData("cmw-123-456-789", "1.0", "/getCatalogServiceResourcesDataNoNetwork.json");
66
67
68                 String businessKey = UUID.randomUUID().toString();
69                 Map<String, Object> variables = new HashMap<>();
70                 setVariablesSuccess(variables, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff");
71                 invokeSubProcess("DecomposeService", businessKey, variables);
72
73                 waitForProcessEnd(businessKey, 10000);
74
75                 Assert.assertTrue(isProcessEnded(businessKey));
76
77         }
78
79         private void setVariablesSuccess(Map<String, Object> variables, String requestId, String siId) {
80                 variables.put("isDebugLogEnabled", "true");
81                 variables.put("mso-request-id", requestId);
82                 variables.put("msoRequestId", requestId);
83                 variables.put("serviceInstanceId",siId);
84
85                 String serviceModelInfo = "{ "+ "\"modelType\": \"service\"," +
86                                 "\"modelInvariantUuid\": \"cmw-123-456-789\"," +
87                                 "\"modelVersionId\": \"ab6478e5-ea33-3346-ac12-ab121484a3fe\"," +
88                                 "\"modelName\": \"ServicevSAMP12\"," +
89                                 "\"modelVersion\": \"1.0\"," +
90                                 "}";
91                 variables.put("serviceModelInfo", serviceModelInfo);
92
93         }
94
95 }