[MSO-8] Update the maven dependency
[so.git] / bpmn / MSOCommonBPMN / src / test / java / org / openecomp / mso / bpmn / common / CompleteMsoProcessTest.java
1 /*- 
2  * ============LICENSE_START======================================================= 
3  * OPENECOMP - MSO 
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.common.BPMNUtil.executeWorkFlow;
24 import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish;
25 import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
26
27 import java.util.HashMap;
28 import java.util.Map;
29
30 import org.camunda.bpm.engine.test.Deployment;
31 import org.junit.Assert;
32 import org.junit.Ignore;
33 import org.junit.Test;
34 import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
35
36 /**
37  * Unit test for CompleteMsoProcess.bpmn.
38  */
39 public class CompleteMsoProcessTest extends WorkflowTest {
40         
41         private void executeFlow(String inputRequestFile) throws InterruptedException {
42                 mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
43                 
44                 //String changeFeatureActivateRequest = FileUtil.readResourceFile("__files/SDN-ETHERNET-INTERNET/ChangeFeatureActivateV1/" + inputRequestFile);
45                 Map<String, String> variables = new HashMap<String, String>();          
46                 variables.put("CompleteMsoProcessRequest",inputRequestFile);
47                 
48                 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "CompleteMsoProcess", variables);
49                 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());
50                 logEnd();
51         }       
52         
53         @Test           
54         @Deployment(resources = {"subprocess/CompleteMsoProcess.bpmn"})
55         public void msoCompletionRequestWithNotificationurl_200() throws Exception {
56                 logStart();     
57                 
58                 //Execute Flow
59                 executeFlow(gMsoCompletionRequestWithNotificationurl());
60                 
61                 //Verify Error
62                 String CMSO_ResponseCode = BPMNUtil.getVariable(processEngineRule, "CompleteMsoProcess", "CMSO_ResponseCode");
63                 Assert.assertEquals("200", CMSO_ResponseCode);
64                 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "CompleteMsoProcess", "CMSO_SuccessIndicator"));
65                 logEnd();
66         }
67         
68         @Test           
69         @Ignore // BROKEN TEST
70         @Deployment(resources = {"subprocess/CompleteMsoProcess.bpmn"})
71         public void msoCompletionRequestWithNotificationurl_500() throws Exception {
72                 logStart();
73                 
74                 //Execute Flow
75                 executeFlow(gMsoCompletionRequestWithNotificationurl());
76                 
77                 //Verify Error
78                 String CMSO_ResponseCode = BPMNUtil.getVariable(processEngineRule, "CompleteMsoProcess", "CMSO_ResponseCode");
79                 Assert.assertEquals("500", CMSO_ResponseCode);
80                 Assert.assertFalse((boolean) BPMNUtil.getRawVariable(processEngineRule, "CompleteMsoProcess", "CMSO_SuccessIndicator"));
81                 logEnd();
82         }       
83
84         @Test           
85         @Deployment(resources = {"subprocess/CompleteMsoProcess.bpmn"})
86         public void msoCompletionRequestWithNoNotificationurl() throws Exception {
87                 logStart();     
88                 
89                 //Execute Flow
90                 executeFlow(gMsoCompletionRequestWithNoNotificationurl());
91                 
92                 //Verify Error
93                 String CMSO_ResponseCode = BPMNUtil.getVariable(processEngineRule, "CompleteMsoProcess", "CMSO_ResponseCode");
94                 Assert.assertEquals("200", CMSO_ResponseCode);  
95                 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "CompleteMsoProcess", "CMSO_SuccessIndicator"));
96                 logEnd();
97         }
98
99         @Test           
100         @Deployment(resources = {"subprocess/CompleteMsoProcess.bpmn"})
101         public void msoCompletionRequestWithNotificationurlNoRequestId() throws Exception {
102                 logStart();     
103                 
104                 //Execute Flow
105                 executeFlow(gMsoCompletionRequestWithNotificationurlNoRequestId());
106                 
107                 //Verify Error
108                 String CMSO_ResponseCode = BPMNUtil.getVariable(processEngineRule, "CompleteMsoProcess", "CMSO_ResponseCode");
109                 Assert.assertEquals("200", CMSO_ResponseCode);
110                 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "CompleteMsoProcess", "CMSO_SuccessIndicator"));
111                 logEnd();       
112         }
113         
114         @Test           
115         @Deployment(resources = {"subprocess/CompleteMsoProcess.bpmn"})
116         public void msoCompletionRequestWithNoNotificationurlNoRequestId() throws Exception {
117                 logStart();
118                 
119                 //Execute Flow
120                 executeFlow(gMsoCompletionRequestWithNoNotificationurlNoRequestId());
121                 
122                 //Verify Error
123                 String CMSO_ResponseCode = BPMNUtil.getVariable(processEngineRule, "CompleteMsoProcess", "CMSO_ResponseCode");
124                 Assert.assertEquals("200", CMSO_ResponseCode);
125                 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "CompleteMsoProcess", "CMSO_SuccessIndicator"));
126                 logEnd();
127         }       
128
129         public String gMsoCompletionRequestWithNotificationurl() {
130                 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
131                 String xml = ""
132                                 + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://ecomp.openecomp.org.com/mso/workflow/schema/v1\">"
133                                 + "             <ns:request-information>"
134                                 + "                     <ns:request-id>uCPE1020_STUW105_5002</ns:request-id>"
135                                 + "                     <ns:request-action>Layer3ServiceActivateRequest</ns:request-action>"                            
136                                 + "                     <ns:request-sub-action>COMPLETE</ns:request-sub-action>"
137                                 + "                     <ns:source>OMX</ns:source>"
138                                 + "                     <ns:notification-url>https://t3nap1a1.snt.bst.bls.com:9004/sdncontroller-sdncontroller-inbound-ws-war/sdncontroller-sdncontroller-inbound-ws.wsdl</ns:notification-url>"                                
139                                 + "                     <ns:order-number>10205000</ns:order-number>"                            
140                                 + "                     <ns:order-version>1</ns:order-version>"
141                                 + "             </ns:request-information>"                              
142                                 + "             <sdncadapterworkflow:mso-bpel-name>UCPELayer3ServiceActivateV1</sdncadapterworkflow:mso-bpel-name>"
143                                 + "</sdncadapterworkflow:MsoCompletionRequest>";
144                 
145                 return xml;
146         }
147                 
148
149
150         public String gMsoCompletionRequestWithNoNotificationurl() {
151                 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
152                 String xml = ""
153                                 + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://openecomp.org/mso/workflow/schema/v1\">"
154                                 + "             <ns:request-information>"
155                                 + "                     <ns:request-id>uCPE1020_STUW105_5002</ns:request-id>"
156                                 + "                     <ns:request-action>Layer3ServiceActivateRequest</ns:request-action>"                            
157                                 + "                     <ns:request-sub-action>COMPLETE</ns:request-sub-action>"
158                                 + "                     <ns:source>OMX</ns:source>"
159                                 + "                     <ns:notification-url></ns:notification-url>"                            
160                                 + "                     <ns:order-number>10205000</ns:order-number>"                            
161                                 + "                     <ns:order-version>1</ns:order-version>"
162                                 + "             </ns:request-information>"                              
163                                 + "             <sdncadapterworkflow:mso-bpel-name>UCPELayer3ServiceActivateV1</sdncadapterworkflow:mso-bpel-name>"
164                                 + "</sdncadapterworkflow:MsoCompletionRequest>";
165                 
166                 return xml;
167         }
168         
169         public String gMsoCompletionRequestWithNoNotificationurlNoRequestId() {
170                 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
171                 String xml = ""
172                                 + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://openecomp.org/mso/workflow/schema/v1\">"
173                                 + "             <ns:request-information>"
174                                 + "                     <ns:request-id></ns:request-id>"
175                                 + "                     <ns:request-action>Layer3ServiceActivateRequest</ns:request-action>"
176                                 + "                     <ns:request-sub-action>COMPLETE</ns:request-sub-action>"
177                                 + "                     <ns:source>OMX</ns:source>"
178                                 + "                     <ns:notification-url></ns:notification-url>"                            
179                                 + "                     <ns:order-number>10205000</ns:order-number>"                            
180                                 + "                     <ns:order-version>1</ns:order-version>"
181                                 + "             </ns:request-information>"                              
182                                 + "             <sdncadapterworkflow:mso-bpel-name>UCPELayer3ServiceActivateV1</sdncadapterworkflow:mso-bpel-name>"
183                                 + "</sdncadapterworkflow:MsoCompletionRequest>";
184                 
185                 return xml;
186         }       
187         
188         public String gMsoCompletionRequestWithNotificationurlNoRequestId() {
189                 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
190                 String xml = ""
191                                 + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://openecomp.org/mso/workflow/schema/v1\">"
192                                 + "             <ns:request-information>"
193                                 + "                     <ns:request-id></ns:request-id>"
194                                 + "                     <ns:request-action>Layer3ServiceActivateRequest</ns:request-action>"                            
195                                 + "                     <ns:request-sub-action>COMPLETE</ns:request-sub-action>"
196                                 + "                     <ns:source>OMX</ns:source>"
197                                 + "                     <ns:notification-url>https://t3nap1a1.snt.bst.bls.com:9004/sdncontroller-sdncontroller-inbound-ws-war/sdncontroller-sdncontroller-inbound-ws.wsdl</ns:notification-url>"                                
198                                 + "                     <ns:order-number>10205000</ns:order-number>"                            
199                                 + "                     <ns:order-version>1</ns:order-version>"
200                                 + "             </ns:request-information>"                              
201                                 + "             <sdncadapterworkflow:mso-bpel-name>UCPELayer3ServiceActivateV1</sdncadapterworkflow:mso-bpel-name>"
202                                 + "</sdncadapterworkflow:MsoCompletionRequest>";
203                 
204                 return xml;
205         }       
206 }
207