2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.bpmn.common;
23 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
24 import static com.github.tomakehurst.wiremock.client.WireMock.post;
25 import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
26 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
27 import static org.onap.so.bpmn.common.BPMNUtil.waitForWorkflowToFinish;
29 import java.util.HashMap;
31 import java.util.UUID;
33 import org.junit.Assert;
34 import org.junit.Test;
35 import org.onap.so.BaseIntegrationTest;
36 import org.onap.so.logger.MsoLogger;
39 * Unit test for FalloutHandler.bpmn.
42 public class FalloutHandlerIT extends BaseIntegrationTest {
44 MsoLogger logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL,FalloutHandlerIT.class);
47 private void setupMocks() {
48 stubFor(post(urlEqualTo("/dbadapters/AttRequestsDbAdapter"))
49 .willReturn(aResponse()
51 .withHeader("Content-Type", "text/xml")
52 .withBody("<DbTag>Notified</DbTag>")));
53 stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
54 .willReturn(aResponse()
56 .withHeader("Content-Type", "text/xml")
57 .withBody("<DbTag>Notified</DbTag>")));
60 private String executeFlow(String inputRequestFile) throws InterruptedException {
62 Map<String, Object> variables = new HashMap<>();
63 variables.put("FalloutHandlerRequest",inputRequestFile); variables.put("mso-request-id", UUID.randomUUID().toString());
64 String processId = invokeSubProcess( "FalloutHandler", variables);
65 waitForWorkflowToFinish(processEngine,processId);
71 public void msoFalloutHandlerWithNotificationurl_200() throws Exception{
75 String processId = executeFlow(gMsoFalloutHandlerWithNotificationurl());
77 String FH_ResponseCode = BPMNUtil.getVariable(processEngine, "FalloutHandler", "FH_ResponseCode",processId);
78 Assert.assertEquals("200", FH_ResponseCode);
79 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "FalloutHandler", "FH_SuccessIndicator",processId));
82 public String gMsoFalloutHandlerWithNotificationurl() {
83 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
85 + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns7=\"http://org.onap/so/request/types/v1\">"
86 + " <ns7:request-information>"
87 + " <ns7:request-id>1020_STUW105_5002</ns7:request-id>"
88 + " <ns7:request-action>requestAction</ns7:request-action>"
89 + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
90 + " <ns7:source>source</ns7:source>"
91 + " <ns7:notification-url>http://localhost:28090/CCD/StatusNotification</ns7:notification-url>"
92 + " <ns7:order-number>10205000</ns7:order-number>"
93 + " <ns7:order-version>1</ns7:order-version>"
94 + " </ns7:request-information>"
95 + " <sdncadapterworkflow:WorkflowException>"
96 + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
97 + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
98 + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
99 + " </sdncadapterworkflow:WorkflowException>"
100 + "</sdncadapterworkflow:FalloutHandlerRequest>";
110 public void msoFalloutHandlerWithNoNotificationurl() throws Exception{
115 executeFlow(gMsoFalloutHandlerWithNoNotificationurl());
117 String FH_ResponseCode = BPMNUtil.getVariable(processEngine, "FalloutHandler", "FH_ResponseCode");
118 Assert.assertEquals("200", FH_ResponseCode);
119 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "FalloutHandler", "FH_SuccessIndicator"));
122 public String gMsoFalloutHandlerWithNoNotificationurl() {
123 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
125 + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns7=\"http://org.onap/so/request/types/v1\">"
126 + " <ns7:request-information>"
127 + " <ns7:request-id>1020_STUW105_5002</ns7:request-id>"
128 + " <ns7:request-action>requestAction</ns7:request-action>"
129 + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
130 + " <ns7:source>source</ns7:source>"
131 + " <ns7:notification-url></ns7:notification-url>"
132 + " <ns7:order-number>10205000</ns7:order-number>"
133 + " <ns7:order-version>1</ns7:order-version>"
134 + " </ns7:request-information>"
135 + " <sdncadapterworkflow:WorkflowException>"
136 + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
137 + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
138 + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
139 + " </sdncadapterworkflow:WorkflowException>"
140 + "</sdncadapterworkflow:FalloutHandlerRequest>";
147 public void msoFalloutHandlerWithNotificationurlNoRequestId() throws Exception{
148 String method = getClass().getSimpleName() + "." + new Object() {
149 }.getClass().getEnclosingMethod().getName();
150 logger.debug("STARTED TEST: " + method);
154 executeFlow(gMsoFalloutHandlerWithNotificationurlNoRequestId());
156 String FH_ResponseCode = BPMNUtil.getVariable(processEngine, "FalloutHandler", "FH_ResponseCode");
157 Assert.assertEquals("200", FH_ResponseCode);
158 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "FalloutHandler", "FH_SuccessIndicator"));
161 public String gMsoFalloutHandlerWithNotificationurlNoRequestId() {
162 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
164 + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns7=\"http://org.onap/so/request/types/v1\">"
165 + " <ns7:request-information>"
166 + " <ns7:request-id></ns7:request-id>"
167 + " <ns7:request-action>requestAction</ns7:request-action>"
168 + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
169 + " <ns7:source>source</ns7:source>"
170 + " <ns7:notification-url>www.test.com</ns7:notification-url>"
171 + " <ns7:order-number>10205000</ns7:order-number>"
172 + " <ns7:order-version>1</ns7:order-version>"
173 + " </ns7:request-information>"
174 + " <sdncadapterworkflow:WorkflowException>"
175 + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
176 + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
177 + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
178 + " </sdncadapterworkflow:WorkflowException>"
179 + "</sdncadapterworkflow:FalloutHandlerRequest>";
186 public void msoFalloutHandlerWithNoNotificationurlNoRequestId() throws Exception{
187 String method = getClass().getSimpleName() + "." + new Object() {
188 }.getClass().getEnclosingMethod().getName();
189 logger.debug("STARTED TEST: " + method);
193 executeFlow(gMsoFalloutHandlerWithNoNotificationurlNoRequestId());
195 String FH_ResponseCode = BPMNUtil.getVariable(processEngine, "FalloutHandler", "FH_ResponseCode");
196 Assert.assertEquals("200", FH_ResponseCode);
197 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "FalloutHandler", "FH_SuccessIndicator"));
200 public String gMsoFalloutHandlerWithNoNotificationurlNoRequestId() {
201 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
203 + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns7=\"http://org.onap/so/request/types/v1\">"
204 + " <ns7:request-information>"
205 + " <ns7:request-id></ns7:request-id>"
206 + " <ns7:request-action>requestAction</ns7:request-action>"
207 + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
208 + " <ns7:source>source</ns7:source>"
209 + " <ns7:notification-url></ns7:notification-url>"
210 + " <ns7:order-number>10205000</ns7:order-number>"
211 + " <ns7:order-version>1</ns7:order-version>"
212 + " </ns7:request-information>"
213 + " <sdncadapterworkflow:WorkflowException>"
214 + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
215 + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
216 + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
217 + " </sdncadapterworkflow:WorkflowException>"
218 + "</sdncadapterworkflow:FalloutHandlerRequest>";