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/RequestsDbAdapter"))
\r
44 .willReturn(aResponse()
\r
46 .withHeader("Content-Type", "text/xml")
\r
47 .withBody("<DbTag>Notified</DbTag>")));
\r
50 private void executeFlow(String inputRequestFile) throws InterruptedException {
\r
51 String method = getClass().getSimpleName() + "." + new Object() {
\r
52 }.getClass().getEnclosingMethod().getName();
\r
53 System.out.println("STARTED TEST: " + method);
\r
55 //String changeFeatureActivateRequest = FileUtil.readResourceFile("__files/SDN-ETHERNET-INTERNET/ChangeFeatureActivateV1/" + inputRequestFile);
\r
56 Map<String, String> variables = new HashMap<String, String>();
\r
57 variables.put("FalloutHandlerRequest",inputRequestFile);
\r
59 WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "FalloutHandler", variables);
\r
60 waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID());
\r
61 System.out.println("ENDED TEST: " + method);
\r
65 @Deployment(resources = {"subprocess/FalloutHandler.bpmn",
\r
66 "subprocess/GenericNotificationService.bpmn"
\r
68 public void msoFalloutHandlerWithNotificationurl_200() throws Exception{
\r
69 String method = getClass().getSimpleName() + "." + new Object() {
\r
70 }.getClass().getEnclosingMethod().getName();
\r
71 System.out.println("STARTED TEST: " + method);
\r
76 executeFlow(gMsoFalloutHandlerWithNotificationurl());
\r
78 String FH_ResponseCode = BPMNUtil.getVariable(processEngineRule, "FalloutHandler", "FH_ResponseCode");
\r
79 Assert.assertEquals("200", FH_ResponseCode);
\r
80 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "FalloutHandler", "FH_SuccessIndicator"));
\r
83 public String gMsoFalloutHandlerWithNotificationurl() {
\r
84 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
\r
86 + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:ns7=\"http://org.openecomp/mso/request/types/v1\">"
\r
87 + " <ns7:request-information>"
\r
88 + " <ns7:request-id>uCPE1020_STUW105_5002</ns7:request-id>"
\r
89 + " <ns7:request-action>Layer3ServiceActivateRequest</ns7:request-action>"
\r
90 + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
\r
91 + " <ns7:source>OMX</ns7:source>"
\r
92 + " <ns7:notification-url>http://localhost:28090/CCD/StatusNotification</ns7:notification-url>"
\r
93 + " <ns7:order-number>10205000</ns7:order-number>"
\r
94 + " <ns7:order-version>1</ns7:order-version>"
\r
95 + " </ns7:request-information>"
\r
96 + " <sdncadapterworkflow:WorkflowException>"
\r
97 + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
\r
98 + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
\r
99 + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
\r
100 + " </sdncadapterworkflow:WorkflowException>"
\r
101 + "</sdncadapterworkflow:FalloutHandlerRequest>";
\r
111 @Deployment(resources = {"subprocess/FalloutHandler.bpmn"})
\r
112 public void msoFalloutHandlerWithNoNotificationurl() throws Exception{
\r
113 String method = getClass().getSimpleName() + "." + new Object() {
\r
114 }.getClass().getEnclosingMethod().getName();
\r
115 System.out.println("STARTED TEST: " + method);
\r
119 executeFlow(gMsoFalloutHandlerWithNoNotificationurl());
\r
121 String FH_ResponseCode = BPMNUtil.getVariable(processEngineRule, "FalloutHandler", "FH_ResponseCode");
\r
122 Assert.assertEquals("200", FH_ResponseCode);
\r
123 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "FalloutHandler", "FH_SuccessIndicator"));
\r
126 public String gMsoFalloutHandlerWithNoNotificationurl() {
\r
127 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
\r
129 + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:ns7=\"http://org.openecomp/mso/request/types/v1\">"
\r
130 + " <ns7:request-information>"
\r
131 + " <ns7:request-id>uCPE1020_STUW105_5002</ns7:request-id>"
\r
132 + " <ns7:request-action>Layer3ServiceActivateRequest</ns7:request-action>"
\r
133 + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
\r
134 + " <ns7:source>OMX</ns7:source>"
\r
135 + " <ns7:notification-url></ns7:notification-url>"
\r
136 + " <ns7:order-number>10205000</ns7:order-number>"
\r
137 + " <ns7:order-version>1</ns7:order-version>"
\r
138 + " </ns7:request-information>"
\r
139 + " <sdncadapterworkflow:WorkflowException>"
\r
140 + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
\r
141 + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
\r
142 + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
\r
143 + " </sdncadapterworkflow:WorkflowException>"
\r
144 + "</sdncadapterworkflow:FalloutHandlerRequest>";
\r
150 @Deployment(resources = {"subprocess/FalloutHandler.bpmn",
\r
151 "subprocess/GenericNotificationService.bpmn"
\r
153 public void msoFalloutHandlerWithNotificationurlNoRequestId() throws Exception{
\r
154 String method = getClass().getSimpleName() + "." + new Object() {
\r
155 }.getClass().getEnclosingMethod().getName();
\r
156 System.out.println("STARTED TEST: " + method);
\r
160 executeFlow(gMsoFalloutHandlerWithNotificationurlNoRequestId());
\r
162 String FH_ResponseCode = BPMNUtil.getVariable(processEngineRule, "FalloutHandler", "FH_ResponseCode");
\r
163 Assert.assertEquals("200", FH_ResponseCode);
\r
164 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "FalloutHandler", "FH_SuccessIndicator"));
\r
167 public String gMsoFalloutHandlerWithNotificationurlNoRequestId() {
\r
168 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
\r
170 + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:ns7=\"http://org.openecomp/mso/request/types/v1\">"
\r
171 + " <ns7:request-information>"
\r
172 + " <ns7:request-id></ns7:request-id>"
\r
173 + " <ns7:request-action>Layer3ServiceActivateRequest</ns7:request-action>"
\r
174 + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
\r
175 + " <ns7:source>OMX</ns7:source>"
\r
176 + " <ns7:notification-url>www.test.com</ns7:notification-url>"
\r
177 + " <ns7:order-number>10205000</ns7:order-number>"
\r
178 + " <ns7:order-version>1</ns7:order-version>"
\r
179 + " </ns7:request-information>"
\r
180 + " <sdncadapterworkflow:WorkflowException>"
\r
181 + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
\r
182 + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
\r
183 + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
\r
184 + " </sdncadapterworkflow:WorkflowException>"
\r
185 + "</sdncadapterworkflow:FalloutHandlerRequest>";
\r
191 @Deployment(resources = {"subprocess/FalloutHandler.bpmn"})
\r
192 public void msoFalloutHandlerWithNoNotificationurlNoRequestId() throws Exception{
\r
193 String method = getClass().getSimpleName() + "." + new Object() {
\r
194 }.getClass().getEnclosingMethod().getName();
\r
195 System.out.println("STARTED TEST: " + method);
\r
199 executeFlow(gMsoFalloutHandlerWithNoNotificationurlNoRequestId());
\r
201 String FH_ResponseCode = BPMNUtil.getVariable(processEngineRule, "FalloutHandler", "FH_ResponseCode");
\r
202 Assert.assertEquals("200", FH_ResponseCode);
\r
203 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "FalloutHandler", "FH_SuccessIndicator"));
\r
206 public String gMsoFalloutHandlerWithNoNotificationurlNoRequestId() {
\r
207 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
\r
209 + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:ns7=\"http://org.openecomp/mso/request/types/v1\">"
\r
210 + " <ns7:request-information>"
\r
211 + " <ns7:request-id></ns7:request-id>"
\r
212 + " <ns7:request-action>Layer3ServiceActivateRequest</ns7:request-action>"
\r
213 + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
\r
214 + " <ns7:source>OMX</ns7:source>"
\r
215 + " <ns7:notification-url></ns7:notification-url>"
\r
216 + " <ns7:order-number>10205000</ns7:order-number>"
\r
217 + " <ns7:order-version>1</ns7:order-version>"
\r
218 + " </ns7:request-information>"
\r
219 + " <sdncadapterworkflow:WorkflowException>"
\r
220 + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
\r
221 + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
\r
222 + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
\r
223 + " </sdncadapterworkflow:WorkflowException>"
\r
224 + "</sdncadapterworkflow:FalloutHandlerRequest>";
\r