2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (c) 2019 Samsung
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.so.bpmn.common;
25 import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
26 import static com.github.tomakehurst.wiremock.client.WireMock.post;
27 import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
28 import static org.onap.so.bpmn.common.BPMNUtil.waitForWorkflowToFinish;
30 import java.util.HashMap;
32 import java.util.UUID;
34 import org.junit.Assert;
35 import org.junit.Test;
36 import org.onap.so.BaseIntegrationTest;
37 import org.slf4j.Logger;
38 import org.slf4j.LoggerFactory;
41 * Unit test for FalloutHandler.bpmn.
44 public class FalloutHandlerIT extends BaseIntegrationTest {
46 Logger logger = LoggerFactory.getLogger(FalloutHandlerIT.class);
49 private void setupMocks() {
50 wireMockServer.stubFor(post(urlEqualTo("/dbadapters/AttRequestsDbAdapter"))
51 .willReturn(aResponse()
53 .withHeader("Content-Type", "text/xml")
54 .withBody("<DbTag>Notified</DbTag>")));
55 wireMockServer.stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
56 .willReturn(aResponse()
58 .withHeader("Content-Type", "text/xml")
59 .withBody("<DbTag>Notified</DbTag>")));
62 private String executeFlow(String inputRequestFile) throws InterruptedException {
64 Map<String, Object> variables = new HashMap<>();
65 variables.put("FalloutHandlerRequest",inputRequestFile); variables.put("mso-request-id", UUID.randomUUID().toString());
66 String processId = invokeSubProcess( "FalloutHandler", variables);
67 waitForWorkflowToFinish(processEngine,processId);
73 public void msoFalloutHandlerWithNotificationurl_200() throws Exception{
77 String processId = executeFlow(gMsoFalloutHandlerWithNotificationurl());
79 String FH_ResponseCode = BPMNUtil.getVariable(processEngine, "FalloutHandler", "FH_ResponseCode",processId);
80 Assert.assertEquals("200", FH_ResponseCode);
81 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "FalloutHandler", "FH_SuccessIndicator",processId));
84 public String gMsoFalloutHandlerWithNotificationurl() {
85 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
87 + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns7=\"http://org.onap/so/request/types/v1\">"
88 + " <ns7:request-information>"
89 + " <ns7:request-id>1020_STUW105_5002</ns7:request-id>"
90 + " <ns7:request-action>requestAction</ns7:request-action>"
91 + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
92 + " <ns7:source>source</ns7:source>"
93 + " <ns7:notification-url>http://localhost:28090/CCD/StatusNotification</ns7:notification-url>"
94 + " <ns7:order-number>10205000</ns7:order-number>"
95 + " <ns7:order-version>1</ns7:order-version>"
96 + " </ns7:request-information>"
97 + " <sdncadapterworkflow:WorkflowException>"
98 + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
99 + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
100 + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
101 + " </sdncadapterworkflow:WorkflowException>"
102 + "</sdncadapterworkflow:FalloutHandlerRequest>";
112 public void msoFalloutHandlerWithNoNotificationurl() throws Exception{
117 executeFlow(gMsoFalloutHandlerWithNoNotificationurl());
119 String FH_ResponseCode = BPMNUtil.getVariable(processEngine, "FalloutHandler", "FH_ResponseCode");
120 Assert.assertEquals("200", FH_ResponseCode);
121 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "FalloutHandler", "FH_SuccessIndicator"));
124 public String gMsoFalloutHandlerWithNoNotificationurl() {
125 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
127 + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns7=\"http://org.onap/so/request/types/v1\">"
128 + " <ns7:request-information>"
129 + " <ns7:request-id>1020_STUW105_5002</ns7:request-id>"
130 + " <ns7:request-action>requestAction</ns7:request-action>"
131 + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
132 + " <ns7:source>source</ns7:source>"
133 + " <ns7:notification-url></ns7:notification-url>"
134 + " <ns7:order-number>10205000</ns7:order-number>"
135 + " <ns7:order-version>1</ns7:order-version>"
136 + " </ns7:request-information>"
137 + " <sdncadapterworkflow:WorkflowException>"
138 + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
139 + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
140 + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
141 + " </sdncadapterworkflow:WorkflowException>"
142 + "</sdncadapterworkflow:FalloutHandlerRequest>";
149 public void msoFalloutHandlerWithNotificationurlNoRequestId() throws Exception{
150 String method = getClass().getSimpleName() + "." + new Object() {
151 }.getClass().getEnclosingMethod().getName();
152 logger.debug("STARTED TEST: {}", method);
156 executeFlow(gMsoFalloutHandlerWithNotificationurlNoRequestId());
158 String FH_ResponseCode = BPMNUtil.getVariable(processEngine, "FalloutHandler", "FH_ResponseCode");
159 Assert.assertEquals("200", FH_ResponseCode);
160 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "FalloutHandler", "FH_SuccessIndicator"));
163 public String gMsoFalloutHandlerWithNotificationurlNoRequestId() {
164 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
166 + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns7=\"http://org.onap/so/request/types/v1\">"
167 + " <ns7:request-information>"
168 + " <ns7:request-id></ns7:request-id>"
169 + " <ns7:request-action>requestAction</ns7:request-action>"
170 + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
171 + " <ns7:source>source</ns7:source>"
172 + " <ns7:notification-url>www.test.com</ns7:notification-url>"
173 + " <ns7:order-number>10205000</ns7:order-number>"
174 + " <ns7:order-version>1</ns7:order-version>"
175 + " </ns7:request-information>"
176 + " <sdncadapterworkflow:WorkflowException>"
177 + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
178 + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
179 + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
180 + " </sdncadapterworkflow:WorkflowException>"
181 + "</sdncadapterworkflow:FalloutHandlerRequest>";
188 public void msoFalloutHandlerWithNoNotificationurlNoRequestId() throws Exception{
189 String method = getClass().getSimpleName() + "." + new Object() {
190 }.getClass().getEnclosingMethod().getName();
191 logger.debug("STARTED TEST: {}", method);
195 executeFlow(gMsoFalloutHandlerWithNoNotificationurlNoRequestId());
197 String FH_ResponseCode = BPMNUtil.getVariable(processEngine, "FalloutHandler", "FH_ResponseCode");
198 Assert.assertEquals("200", FH_ResponseCode);
199 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "FalloutHandler", "FH_SuccessIndicator"));
202 public String gMsoFalloutHandlerWithNoNotificationurlNoRequestId() {
203 //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
205 + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns7=\"http://org.onap/so/request/types/v1\">"
206 + " <ns7:request-information>"
207 + " <ns7:request-id></ns7:request-id>"
208 + " <ns7:request-action>requestAction</ns7:request-action>"
209 + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
210 + " <ns7:source>source</ns7:source>"
211 + " <ns7:notification-url></ns7:notification-url>"
212 + " <ns7:order-number>10205000</ns7:order-number>"
213 + " <ns7:order-version>1</ns7:order-version>"
214 + " </ns7:request-information>"
215 + " <sdncadapterworkflow:WorkflowException>"
216 + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
217 + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
218 + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
219 + " </sdncadapterworkflow:WorkflowException>"
220 + "</sdncadapterworkflow:FalloutHandlerRequest>";