2 * ============LICENSE_START=======================================================
\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
11 * http://www.apache.org/licenses/LICENSE-2.0
\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
21 package org.openecomp.mso.bpmn.common;
\r
23 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
\r
24 import static com.github.tomakehurst.wiremock.client.WireMock.post;
\r
25 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
\r
26 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
\r
27 import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow;
\r
28 import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish;
\r
30 import java.util.HashMap;
\r
31 import java.util.Map;
\r
33 import org.camunda.bpm.engine.test.Deployment;
\r
34 import org.junit.Assert;
\r
35 import org.junit.Test;
\r
36 import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
\r
39 * Unit test for FalloutHandler.bpmn.
\r
41 public class FalloutHandlerTest extends WorkflowTest {
\r
42 private void setupMocks() {
\r
43 stubFor(post(urlEqualTo("/dbadapters/MsoRequestsDbAdapter"))
\r
44 .willReturn(aResponse()
\r
46 .withHeader("Content-Type", "text/xml")
\r
47 .withBody("<DbTag>Notified</DbTag>")));
\r
48 stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
\r
49 .willReturn(aResponse()
\r
51 .withHeader("Content-Type", "text/xml")
\r
52 .withBody("<DbTag>Notified</DbTag>")));
\r
55 private void executeFlow(String inputRequestFile) throws InterruptedException {
\r
56 String method = getClass().getSimpleName() + "." + new Object() {
\r
57 }.getClass().getEnclosingMethod().getName();
\r
58 System.out.println("STARTED TEST: " + method);
\r
60 //String changeFeatureActivateRequest = FileUtil.readResourceFile("__files/SDN-ETHERNET-INTERNET/ChangeFeatureActivateV1/" + inputRequestFile);
\r
61 Map<String, String> variables = new HashMap<String, String>();
\r
62 variables.put("FalloutHandlerRequest",inputRequestFile);
\r
64 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "FalloutHandler", variables);
\r
65 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());
\r
66 System.out.println("ENDED TEST: " + method);
\r
70 @Deployment(resources = {"subprocess/FalloutHandler.bpmn",
\r
71 "subprocess/GenericNotificationService.bpmn"
\r
73 public void msoFalloutHandlerWithNotificationurl_200() throws Exception{
\r
74 String method = getClass().getSimpleName() + "." + new Object() {
\r
75 }.getClass().getEnclosingMethod().getName();
\r
76 System.out.println("STARTED TEST: " + method);
\r
81 executeFlow(gMsoFalloutHandlerWithNotificationurl());
\r
83 String FH_ResponseCode = BPMNUtil.getVariable(processEngineRule, "FalloutHandler", "FH_ResponseCode");
\r
84 Assert.assertEquals("200", FH_ResponseCode);
\r
85 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "FalloutHandler", "FH_SuccessIndicator"));
\r
88 public String gMsoFalloutHandlerWithNotificationurl() {
\r
89 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
\r
91 + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:ns7=\"http://org.openecomp/mso/request/types/v1\">"
\r
92 + " <ns7:request-information>"
\r
93 + " <ns7:request-id>uCPE1020_STUW105_5002</ns7:request-id>"
\r
94 + " <ns7:request-action>Layer3ServiceActivateRequest</ns7:request-action>"
\r
95 + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
\r
96 + " <ns7:source>OMX</ns7:source>"
\r
97 + " <ns7:notification-url>http://localhost:28090/CCD/StatusNotification</ns7:notification-url>"
\r
98 + " <ns7:order-number>10205000</ns7:order-number>"
\r
99 + " <ns7:order-version>1</ns7:order-version>"
\r
100 + " </ns7:request-information>"
\r
101 + " <sdncadapterworkflow:WorkflowException>"
\r
102 + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
\r
103 + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
\r
104 + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
\r
105 + " </sdncadapterworkflow:WorkflowException>"
\r
106 + "</sdncadapterworkflow:FalloutHandlerRequest>";
\r
116 @Deployment(resources = {"subprocess/FalloutHandler.bpmn"})
\r
117 public void msoFalloutHandlerWithNoNotificationurl() throws Exception{
\r
118 String method = getClass().getSimpleName() + "." + new Object() {
\r
119 }.getClass().getEnclosingMethod().getName();
\r
120 System.out.println("STARTED TEST: " + method);
\r
124 executeFlow(gMsoFalloutHandlerWithNoNotificationurl());
\r
126 String FH_ResponseCode = BPMNUtil.getVariable(processEngineRule, "FalloutHandler", "FH_ResponseCode");
\r
127 Assert.assertEquals("200", FH_ResponseCode);
\r
128 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "FalloutHandler", "FH_SuccessIndicator"));
\r
131 public String gMsoFalloutHandlerWithNoNotificationurl() {
\r
132 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
\r
134 + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:ns7=\"http://org.openecomp/mso/request/types/v1\">"
\r
135 + " <ns7:request-information>"
\r
136 + " <ns7:request-id>uCPE1020_STUW105_5002</ns7:request-id>"
\r
137 + " <ns7:request-action>Layer3ServiceActivateRequest</ns7:request-action>"
\r
138 + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
\r
139 + " <ns7:source>OMX</ns7:source>"
\r
140 + " <ns7:notification-url></ns7:notification-url>"
\r
141 + " <ns7:order-number>10205000</ns7:order-number>"
\r
142 + " <ns7:order-version>1</ns7:order-version>"
\r
143 + " </ns7:request-information>"
\r
144 + " <sdncadapterworkflow:WorkflowException>"
\r
145 + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
\r
146 + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
\r
147 + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
\r
148 + " </sdncadapterworkflow:WorkflowException>"
\r
149 + "</sdncadapterworkflow:FalloutHandlerRequest>";
\r
155 @Deployment(resources = {"subprocess/FalloutHandler.bpmn",
\r
156 "subprocess/GenericNotificationService.bpmn"
\r
158 public void msoFalloutHandlerWithNotificationurlNoRequestId() throws Exception{
\r
159 String method = getClass().getSimpleName() + "." + new Object() {
\r
160 }.getClass().getEnclosingMethod().getName();
\r
161 System.out.println("STARTED TEST: " + method);
\r
165 executeFlow(gMsoFalloutHandlerWithNotificationurlNoRequestId());
\r
167 String FH_ResponseCode = BPMNUtil.getVariable(processEngineRule, "FalloutHandler", "FH_ResponseCode");
\r
168 Assert.assertEquals("200", FH_ResponseCode);
\r
169 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "FalloutHandler", "FH_SuccessIndicator"));
\r
172 public String gMsoFalloutHandlerWithNotificationurlNoRequestId() {
\r
173 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
\r
175 + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:ns7=\"http://org.openecomp/mso/request/types/v1\">"
\r
176 + " <ns7:request-information>"
\r
177 + " <ns7:request-id></ns7:request-id>"
\r
178 + " <ns7:request-action>Layer3ServiceActivateRequest</ns7:request-action>"
\r
179 + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
\r
180 + " <ns7:source>OMX</ns7:source>"
\r
181 + " <ns7:notification-url>www.test.com</ns7:notification-url>"
\r
182 + " <ns7:order-number>10205000</ns7:order-number>"
\r
183 + " <ns7:order-version>1</ns7:order-version>"
\r
184 + " </ns7:request-information>"
\r
185 + " <sdncadapterworkflow:WorkflowException>"
\r
186 + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
\r
187 + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
\r
188 + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
\r
189 + " </sdncadapterworkflow:WorkflowException>"
\r
190 + "</sdncadapterworkflow:FalloutHandlerRequest>";
\r
196 @Deployment(resources = {"subprocess/FalloutHandler.bpmn"})
\r
197 public void msoFalloutHandlerWithNoNotificationurlNoRequestId() throws Exception{
\r
198 String method = getClass().getSimpleName() + "." + new Object() {
\r
199 }.getClass().getEnclosingMethod().getName();
\r
200 System.out.println("STARTED TEST: " + method);
\r
204 executeFlow(gMsoFalloutHandlerWithNoNotificationurlNoRequestId());
\r
206 String FH_ResponseCode = BPMNUtil.getVariable(processEngineRule, "FalloutHandler", "FH_ResponseCode");
\r
207 Assert.assertEquals("200", FH_ResponseCode);
\r
208 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "FalloutHandler", "FH_SuccessIndicator"));
\r
211 public String gMsoFalloutHandlerWithNoNotificationurlNoRequestId() {
\r
212 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
\r
214 + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:ns7=\"http://org.openecomp/mso/request/types/v1\">"
\r
215 + " <ns7:request-information>"
\r
216 + " <ns7:request-id></ns7:request-id>"
\r
217 + " <ns7:request-action>Layer3ServiceActivateRequest</ns7:request-action>"
\r
218 + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
\r
219 + " <ns7:source>OMX</ns7:source>"
\r
220 + " <ns7:notification-url></ns7:notification-url>"
\r
221 + " <ns7:order-number>10205000</ns7:order-number>"
\r
222 + " <ns7:order-version>1</ns7:order-version>"
\r
223 + " </ns7:request-information>"
\r
224 + " <sdncadapterworkflow:WorkflowException>"
\r
225 + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
\r
226 + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
\r
227 + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
\r
228 + " </sdncadapterworkflow:WorkflowException>"
\r
229 + "</sdncadapterworkflow:FalloutHandlerRequest>";
\r