Change the header to SO
[so.git] / bpmn / MSOCommonBPMN / src / test / java / org / openecomp / mso / bpmn / common / CompleteMsoProcessTest.java
1 /*- \r
2  * ============LICENSE_START======================================================= \r
3  * ONAP - SO \r
4  * ================================================================================ \r
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. \r
6  * ================================================================================ \r
7  * Licensed under the Apache License, Version 2.0 (the "License"); \r
8  * you may not use this file except in compliance with the License. \r
9  * You may obtain a copy of the License at \r
10  * \r
11  *      http://www.apache.org/licenses/LICENSE-2.0 \r
12  * \r
13  * Unless required by applicable law or agreed to in writing, software \r
14  * distributed under the License is distributed on an "AS IS" BASIS, \r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \r
16  * See the License for the specific language governing permissions and \r
17  * limitations under the License. \r
18  * ============LICENSE_END========================================================= \r
19  */ \r
20 \r
21 package org.openecomp.mso.bpmn.common;\r
22 \r
23 import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow;\r
24 import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish;\r
25 import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;\r
26 \r
27 import java.util.HashMap;\r
28 import java.util.Map;\r
29 \r
30 import org.camunda.bpm.engine.test.Deployment;\r
31 import org.junit.Assert;\r
32 import org.junit.Ignore;\r
33 import org.junit.Test;\r
34 import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;\r
35 \r
36 /**\r
37  * Unit test for CompleteMsoProcess.bpmn.\r
38  */\r
39 public class CompleteMsoProcessTest extends WorkflowTest {\r
40         \r
41         private void executeFlow(String inputRequestFile) throws InterruptedException {\r
42                 mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");\r
43                 \r
44                 //String changeFeatureActivateRequest = FileUtil.readResourceFile("__files/SDN-ETHERNET-INTERNET/ChangeFeatureActivateV1/" + inputRequestFile);\r
45                 Map<String, String> variables = new HashMap<String, String>();          \r
46                 variables.put("CompleteMsoProcessRequest",inputRequestFile);\r
47                 \r
48                 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "CompleteMsoProcess", variables);\r
49                 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());\r
50                 logEnd();\r
51         }       \r
52         \r
53         @Test           \r
54         @Deployment(resources = {"subprocess/CompleteMsoProcess.bpmn",\r
55                         "subprocess/GenericNotificationService.bpmn"\r
56                         })\r
57         public void msoCompletionRequestWithNotificationurl_200() throws Exception {\r
58                 logStart();     \r
59                 \r
60                 //Execute Flow\r
61                 executeFlow(gMsoCompletionRequestWithNotificationurl());\r
62                 \r
63                 //Verify Error\r
64                 String CMSO_ResponseCode = BPMNUtil.getVariable(processEngineRule, "CompleteMsoProcess", "CMSO_ResponseCode");\r
65                 Assert.assertEquals("200", CMSO_ResponseCode);\r
66                 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "CompleteMsoProcess", "CMSO_SuccessIndicator"));\r
67                 logEnd();\r
68         }\r
69         \r
70         @Test           \r
71         @Ignore // BROKEN TEST\r
72         @Deployment(resources = {"subprocess/CompleteMsoProcess.bpmn",\r
73                         "subprocess/GenericNotificationService.bpmn"\r
74                         })\r
75         public void msoCompletionRequestWithNotificationurl_500() throws Exception {\r
76                 logStart();\r
77                 \r
78                 //Execute Flow\r
79                 executeFlow(gMsoCompletionRequestWithNotificationurl());\r
80                 \r
81                 //Verify Error\r
82                 String CMSO_ResponseCode = BPMNUtil.getVariable(processEngineRule, "CompleteMsoProcess", "CMSO_ResponseCode");\r
83                 Assert.assertEquals("500", CMSO_ResponseCode);\r
84                 Assert.assertFalse((boolean) BPMNUtil.getRawVariable(processEngineRule, "CompleteMsoProcess", "CMSO_SuccessIndicator"));\r
85                 logEnd();\r
86         }       \r
87 \r
88         @Test           \r
89         @Deployment(resources = {"subprocess/CompleteMsoProcess.bpmn",\r
90                         "subprocess/GenericNotificationService.bpmn"\r
91                         })\r
92         public void msoCompletionRequestWithNoNotificationurl() throws Exception {\r
93                 logStart();     \r
94                 \r
95                 //Execute Flow\r
96                 executeFlow(gMsoCompletionRequestWithNoNotificationurl());\r
97                 \r
98                 //Verify Error\r
99                 String CMSO_ResponseCode = BPMNUtil.getVariable(processEngineRule, "CompleteMsoProcess", "CMSO_ResponseCode");\r
100                 Assert.assertEquals("200", CMSO_ResponseCode);  \r
101                 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "CompleteMsoProcess", "CMSO_SuccessIndicator"));\r
102                 logEnd();\r
103         }\r
104 \r
105         @Test           \r
106         @Deployment(resources = {"subprocess/CompleteMsoProcess.bpmn",\r
107                         "subprocess/GenericNotificationService.bpmn"\r
108                         })\r
109         public void msoCompletionRequestWithNotificationurlNoRequestId() throws Exception {\r
110                 logStart();     \r
111                 \r
112                 //Execute Flow\r
113                 executeFlow(gMsoCompletionRequestWithNotificationurlNoRequestId());\r
114                 \r
115                 //Verify Error\r
116                 String CMSO_ResponseCode = BPMNUtil.getVariable(processEngineRule, "CompleteMsoProcess", "CMSO_ResponseCode");\r
117                 Assert.assertEquals("200", CMSO_ResponseCode);\r
118                 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "CompleteMsoProcess", "CMSO_SuccessIndicator"));\r
119                 logEnd();       \r
120         }\r
121         \r
122         @Test           \r
123         @Deployment(resources = {"subprocess/CompleteMsoProcess.bpmn",\r
124                         "subprocess/GenericNotificationService.bpmn"\r
125                         })\r
126         public void msoCompletionRequestWithNoNotificationurlNoRequestId() throws Exception {\r
127                 logStart();\r
128                 \r
129                 //Execute Flow\r
130                 executeFlow(gMsoCompletionRequestWithNoNotificationurlNoRequestId());\r
131                 \r
132                 //Verify Error\r
133                 String CMSO_ResponseCode = BPMNUtil.getVariable(processEngineRule, "CompleteMsoProcess", "CMSO_ResponseCode");\r
134                 Assert.assertEquals("200", CMSO_ResponseCode);\r
135                 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "CompleteMsoProcess", "CMSO_SuccessIndicator"));\r
136                 logEnd();\r
137         }       \r
138 \r
139         public String gMsoCompletionRequestWithNotificationurl() {\r
140                 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS\r
141                 String xml = ""\r
142                                 + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://ecomp.openecomp.org.com/mso/workflow/schema/v1\">"\r
143                                 + "             <ns:request-information>"\r
144                                 + "                     <ns:request-id>uCPE1020_STUW105_5002</ns:request-id>"\r
145                                 + "                     <ns:request-action>Layer3ServiceActivateRequest</ns:request-action>"                            \r
146                                 + "                     <ns:request-sub-action>COMPLETE</ns:request-sub-action>"\r
147                                 + "                     <ns:source>OMX</ns:source>"\r
148                                 + "                     <ns:notification-url>https://t3nap1a1.snt.bst.bls.com:9004/sdncontroller-sdncontroller-inbound-ws-war/sdncontroller-sdncontroller-inbound-ws.wsdl</ns:notification-url>"                                \r
149                                 + "                     <ns:order-number>10205000</ns:order-number>"                            \r
150                                 + "                     <ns:order-version>1</ns:order-version>"\r
151                                 + "             </ns:request-information>"                              \r
152                                 + "             <sdncadapterworkflow:mso-bpel-name>UCPELayer3ServiceActivateV1</sdncadapterworkflow:mso-bpel-name>"\r
153                                 + "</sdncadapterworkflow:MsoCompletionRequest>";\r
154                 \r
155                 return xml;\r
156         }\r
157                 \r
158 \r
159 \r
160         public String gMsoCompletionRequestWithNoNotificationurl() {\r
161                 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS\r
162                 String xml = ""\r
163                                 + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://openecomp.org/mso/workflow/schema/v1\">"\r
164                                 + "             <ns:request-information>"\r
165                                 + "                     <ns:request-id>uCPE1020_STUW105_5002</ns:request-id>"\r
166                                 + "                     <ns:request-action>Layer3ServiceActivateRequest</ns:request-action>"                            \r
167                                 + "                     <ns:request-sub-action>COMPLETE</ns:request-sub-action>"\r
168                                 + "                     <ns:source>OMX</ns:source>"\r
169                                 + "                     <ns:notification-url></ns:notification-url>"                            \r
170                                 + "                     <ns:order-number>10205000</ns:order-number>"                            \r
171                                 + "                     <ns:order-version>1</ns:order-version>"\r
172                                 + "             </ns:request-information>"                              \r
173                                 + "             <sdncadapterworkflow:mso-bpel-name>UCPELayer3ServiceActivateV1</sdncadapterworkflow:mso-bpel-name>"\r
174                                 + "</sdncadapterworkflow:MsoCompletionRequest>";\r
175                 \r
176                 return xml;\r
177         }\r
178         \r
179         public String gMsoCompletionRequestWithNoNotificationurlNoRequestId() {\r
180                 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS\r
181                 String xml = ""\r
182                                 + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://openecomp.org/mso/workflow/schema/v1\">"\r
183                                 + "             <ns:request-information>"\r
184                                 + "                     <ns:request-id></ns:request-id>"\r
185                                 + "                     <ns:request-action>Layer3ServiceActivateRequest</ns:request-action>"\r
186                                 + "                     <ns:request-sub-action>COMPLETE</ns:request-sub-action>"\r
187                                 + "                     <ns:source>OMX</ns:source>"\r
188                                 + "                     <ns:notification-url></ns:notification-url>"                            \r
189                                 + "                     <ns:order-number>10205000</ns:order-number>"                            \r
190                                 + "                     <ns:order-version>1</ns:order-version>"\r
191                                 + "             </ns:request-information>"                              \r
192                                 + "             <sdncadapterworkflow:mso-bpel-name>UCPELayer3ServiceActivateV1</sdncadapterworkflow:mso-bpel-name>"\r
193                                 + "</sdncadapterworkflow:MsoCompletionRequest>";\r
194                 \r
195                 return xml;\r
196         }       \r
197         \r
198         public String gMsoCompletionRequestWithNotificationurlNoRequestId() {\r
199                 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS\r
200                 String xml = ""\r
201                                 + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://openecomp.org/mso/workflow/schema/v1\">"\r
202                                 + "             <ns:request-information>"\r
203                                 + "                     <ns:request-id></ns:request-id>"\r
204                                 + "                     <ns:request-action>Layer3ServiceActivateRequest</ns:request-action>"                            \r
205                                 + "                     <ns:request-sub-action>COMPLETE</ns:request-sub-action>"\r
206                                 + "                     <ns:source>OMX</ns:source>"\r
207                                 + "                     <ns:notification-url>https://t3nap1a1.snt.bst.bls.com:9004/sdncontroller-sdncontroller-inbound-ws-war/sdncontroller-sdncontroller-inbound-ws.wsdl</ns:notification-url>"                                \r
208                                 + "                     <ns:order-number>10205000</ns:order-number>"                            \r
209                                 + "                     <ns:order-version>1</ns:order-version>"\r
210                                 + "             </ns:request-information>"                              \r
211                                 + "             <sdncadapterworkflow:mso-bpel-name>UCPELayer3ServiceActivateV1</sdncadapterworkflow:mso-bpel-name>"\r
212                                 + "</sdncadapterworkflow:MsoCompletionRequest>";\r
213                 \r
214                 return xml;\r
215         }       \r
216 }\r
217 \r