470cc2220ddb969236987ce5a37ec36b267c75f2
[so.git] / bpmn / mso-infrastructure-bpmn / src / test / java / org / onap / so / bpmn / common / CompleteMsoProcessIT.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.common.BPMNUtil.waitForWorkflowToFinish;
24 import static org.onap.so.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
25
26 import java.util.HashMap;
27 import java.util.Map;
28 import java.util.UUID;
29
30 import org.junit.Assert;
31 import org.junit.Test;
32 import org.onap.so.BaseIntegrationTest;
33
34 /**
35  * Unit test for CompleteMsoProcess.bpmn.
36  */
37
38 public class CompleteMsoProcessIT extends BaseIntegrationTest {
39         
40         private void executeFlow(String inputRequestFile) throws InterruptedException {
41                 mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
42                 Map<String, Object> variables = new HashMap<>();
43                 variables.put("CompleteMsoProcessRequest",inputRequestFile);
44                 variables.put("mso-request-id", UUID.randomUUID().toString());
45                 String processId = invokeSubProcess( "CompleteMsoProcess", variables);
46                 waitForWorkflowToFinish(processEngine,processId);
47                 logEnd();
48         }       
49         
50         @Test
51         public void msoCompletionRequestWithNotificationUrl_200() throws Exception {
52                 logStart();     
53                 
54                 //Execute Flow
55                 executeFlow(gMsoCompletionRequestWithNotificationurl());
56                 
57                 //Verify Error
58                 String CMSO_ResponseCode = BPMNUtil.getVariable(processEngine, "CompleteMsoProcess", "CMSO_ResponseCode");
59                 Assert.assertEquals("200", CMSO_ResponseCode);
60                 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "CompleteMsoProcess", "CMSO_SuccessIndicator"));
61                 logEnd();
62         }
63
64         @Test
65         public void msoCompletionRequestWithNoNotificationurl() throws Exception {
66                 logStart();     
67                 
68                 //Execute Flow
69                 executeFlow(gMsoCompletionRequestWithNoNotificationurl());
70                 
71                 //Verify Error
72                 String CMSO_ResponseCode = BPMNUtil.getVariable(processEngine, "CompleteMsoProcess", "CMSO_ResponseCode");
73                 Assert.assertEquals("200", CMSO_ResponseCode);  
74                 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "CompleteMsoProcess", "CMSO_SuccessIndicator"));
75                 logEnd();
76         }
77
78         @Test           
79         public void msoCompletionRequestWithNotificationurlNoRequestId() throws Exception {
80                 logStart();     
81                 
82                 //Execute Flow
83                 executeFlow(gMsoCompletionRequestWithNotificationurlNoRequestId());
84                 
85                 //Verify Error
86                 String CMSO_ResponseCode = BPMNUtil.getVariable(processEngine, "CompleteMsoProcess", "CMSO_ResponseCode");
87                 Assert.assertEquals("200", CMSO_ResponseCode);
88                 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "CompleteMsoProcess", "CMSO_SuccessIndicator"));
89                 logEnd();       
90         }
91         
92         @Test           
93         public void msoCompletionRequestWithNoNotificationurlNoRequestId() throws Exception {
94                 logStart();
95                 
96                 //Execute Flow
97                 executeFlow(gMsoCompletionRequestWithNoNotificationurlNoRequestId());
98                 
99                 //Verify Error
100                 String CMSO_ResponseCode = BPMNUtil.getVariable(processEngine, "CompleteMsoProcess", "CMSO_ResponseCode");
101                 Assert.assertEquals("200", CMSO_ResponseCode);
102                 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "CompleteMsoProcess", "CMSO_SuccessIndicator"));
103                 logEnd();
104         }       
105
106         public String gMsoCompletionRequestWithNotificationurl() {              
107                 String xml = ""
108                                 + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://ecomp.openecomp.org.com/mso/workflow/schema/v1\">"
109                                 + "             <ns:request-information>"
110                                 + "                     <ns:request-id>STUW105_5002</ns:request-id>"
111                                 + "                     <ns:request-action>RequestAction</ns:request-action>"                           
112                                 + "                     <ns:request-sub-action>COMPLETE</ns:request-sub-action>"
113                                 + "                     <ns:source>SOURCE</ns:source>"
114                                 + "                     <ns:notification-url>https://t3nap1a1.snt.bst.bls.com:9004/sdncontroller-sdncontroller-inbound-ws-war/sdncontroller-sdncontroller-inbound-ws.wsdl</ns:notification-url>"                                
115                                 + "                     <ns:order-number>10205000</ns:order-number>"                            
116                                 + "                     <ns:order-version>1</ns:order-version>"
117                                 + "             </ns:request-information>"                              
118                                 + "             <sdncadapterworkflow:mso-bpel-name>BPELNAME</sdncadapterworkflow:mso-bpel-name>"
119                                 + "</sdncadapterworkflow:MsoCompletionRequest>";
120                 
121                 return xml;
122         }
123                 
124
125
126         public String gMsoCompletionRequestWithNoNotificationurl() {
127                 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
128                 String xml = ""
129                                 + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://openecomp.org/mso/workflow/schema/v1\">"
130                                 + "             <ns:request-information>"
131                                 + "                     <ns:request-id>STUW105_5002</ns:request-id>"
132                                 + "                     <ns:request-action>RequestAction</ns:request-action>"                           
133                                 + "                     <ns:request-sub-action>COMPLETE</ns:request-sub-action>"
134                                 + "                     <ns:source>SOURCE</ns:source>"
135                                 + "                     <ns:notification-url></ns:notification-url>"                            
136                                 + "                     <ns:order-number>10205000</ns:order-number>"                            
137                                 + "                     <ns:order-version>1</ns:order-version>"
138                                 + "             </ns:request-information>"                              
139                                 + "             <sdncadapterworkflow:mso-bpel-name>BPELNAME</sdncadapterworkflow:mso-bpel-name>"
140                                 + "</sdncadapterworkflow:MsoCompletionRequest>";
141                 
142                 return xml;
143         }
144         
145         public String gMsoCompletionRequestWithNoNotificationurlNoRequestId() {
146                 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
147                 String xml = ""
148                                 + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://openecomp.org/mso/workflow/schema/v1\">"
149                                 + "             <ns:request-information>"
150                                 + "                     <ns:request-id></ns:request-id>"
151                                 + "                     <ns:request-action>RequestAction</ns:request-action>"
152                                 + "                     <ns:request-sub-action>COMPLETE</ns:request-sub-action>"
153                                 + "                     <ns:source>SOURCE</ns:source>"
154                                 + "                     <ns:notification-url></ns:notification-url>"                            
155                                 + "                     <ns:order-number>10205000</ns:order-number>"                            
156                                 + "                     <ns:order-version>1</ns:order-version>"
157                                 + "             </ns:request-information>"                              
158                                 + "             <sdncadapterworkflow:mso-bpel-name>BPELNAME</sdncadapterworkflow:mso-bpel-name>"
159                                 + "</sdncadapterworkflow:MsoCompletionRequest>";
160                 
161                 return xml;
162         }       
163         
164         public String gMsoCompletionRequestWithNotificationurlNoRequestId() {
165                 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
166                 String xml = ""
167                                 + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://openecomp.org/mso/workflow/schema/v1\">"
168                                 + "             <ns:request-information>"
169                                 + "                     <ns:request-id></ns:request-id>"
170                                 + "                     <ns:request-action>RequestAction</ns:request-action>"                           
171                                 + "                     <ns:request-sub-action>COMPLETE</ns:request-sub-action>"
172                                 + "                     <ns:source>SOURCE</ns:source>"
173                                 + "                     <ns:notification-url>https://t3nap1a1.snt.bst.bls.com:9004/sdncontroller-sdncontroller-inbound-ws-war/sdncontroller-sdncontroller-inbound-ws.wsdl</ns:notification-url>"                                
174                                 + "                     <ns:order-number>10205000</ns:order-number>"                            
175                                 + "                     <ns:order-version>1</ns:order-version>"
176                                 + "             </ns:request-information>"                              
177                                 + "             <sdncadapterworkflow:mso-bpel-name>BPELNAME</sdncadapterworkflow:mso-bpel-name>"
178                                 + "</sdncadapterworkflow:MsoCompletionRequest>";
179                 
180                 return xml;
181         }       
182 }
183