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;
29 import java.util.HashMap;
31 import java.util.UUID;
32 import org.junit.Assert;
33 import org.junit.Test;
34 import org.onap.so.BaseIntegrationTest;
35 import org.slf4j.Logger;
36 import org.slf4j.LoggerFactory;
39 * Unit test for FalloutHandler.bpmn.
42 public class FalloutHandlerIT extends BaseIntegrationTest {
44 Logger logger = LoggerFactory.getLogger(FalloutHandlerIT.class);
47 private void setupMocks() {
48 wireMockServer.stubFor(post(urlEqualTo("/dbadapters/AttRequestsDbAdapter")).willReturn(aResponse()
49 .withStatus(200).withHeader("Content-Type", "text/xml").withBody("<DbTag>Notified</DbTag>")));
50 wireMockServer.stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter")).willReturn(aResponse().withStatus(200)
51 .withHeader("Content-Type", "text/xml").withBody("<DbTag>Notified</DbTag>")));
54 private String executeFlow(String inputRequestFile) throws InterruptedException {
56 Map<String, Object> variables = new HashMap<>();
57 variables.put("FalloutHandlerRequest", inputRequestFile);
58 variables.put("mso-request-id", UUID.randomUUID().toString());
59 String processId = invokeSubProcess("FalloutHandler", variables);
60 waitForWorkflowToFinish(processEngine, processId);
66 public void msoFalloutHandlerWithNotificationurl_200() throws Exception {
70 String processId = executeFlow(gMsoFalloutHandlerWithNotificationurl());
72 String FH_ResponseCode = BPMNUtil.getVariable(processEngine, "FalloutHandler", "FH_ResponseCode", processId);
73 Assert.assertEquals("200", FH_ResponseCode);
75 (boolean) BPMNUtil.getRawVariable(processEngine, "FalloutHandler", "FH_SuccessIndicator", processId));
78 public String gMsoFalloutHandlerWithNotificationurl() {
79 // Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
81 + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns7=\"http://org.onap/so/request/types/v1\">"
82 + " <ns7:request-information>" + " <ns7:request-id>1020_STUW105_5002</ns7:request-id>"
83 + " <ns7:request-action>requestAction</ns7:request-action>"
84 + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
85 + " <ns7:source>source</ns7:source>"
86 + " <ns7:notification-url>http://localhost:28090/CCD/StatusNotification</ns7:notification-url>"
87 + " <ns7:order-number>10205000</ns7:order-number>"
88 + " <ns7:order-version>1</ns7:order-version>" + " </ns7:request-information>"
89 + " <sdncadapterworkflow:WorkflowException>"
90 + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
91 + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
92 + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
93 + " </sdncadapterworkflow:WorkflowException>" + "</sdncadapterworkflow:FalloutHandlerRequest>";
102 public void msoFalloutHandlerWithNoNotificationurl() throws Exception {
107 executeFlow(gMsoFalloutHandlerWithNoNotificationurl());
109 String FH_ResponseCode = BPMNUtil.getVariable(processEngine, "FalloutHandler", "FH_ResponseCode");
110 Assert.assertEquals("200", FH_ResponseCode);
111 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "FalloutHandler", "FH_SuccessIndicator"));
114 public String gMsoFalloutHandlerWithNoNotificationurl() {
115 // Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
117 + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns7=\"http://org.onap/so/request/types/v1\">"
118 + " <ns7:request-information>" + " <ns7:request-id>1020_STUW105_5002</ns7:request-id>"
119 + " <ns7:request-action>requestAction</ns7:request-action>"
120 + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
121 + " <ns7:source>source</ns7:source>" + " <ns7:notification-url></ns7:notification-url>"
122 + " <ns7:order-number>10205000</ns7:order-number>"
123 + " <ns7:order-version>1</ns7:order-version>" + " </ns7:request-information>"
124 + " <sdncadapterworkflow:WorkflowException>"
125 + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
126 + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
127 + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
128 + " </sdncadapterworkflow:WorkflowException>" + "</sdncadapterworkflow:FalloutHandlerRequest>";
135 public void msoFalloutHandlerWithNotificationurlNoRequestId() throws Exception {
136 String method = getClass().getSimpleName() + "." + new Object() {}.getClass().getEnclosingMethod().getName();
137 logger.debug("STARTED TEST: {}", method);
141 executeFlow(gMsoFalloutHandlerWithNotificationurlNoRequestId());
143 String FH_ResponseCode = BPMNUtil.getVariable(processEngine, "FalloutHandler", "FH_ResponseCode");
144 Assert.assertEquals("200", FH_ResponseCode);
145 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "FalloutHandler", "FH_SuccessIndicator"));
148 public String gMsoFalloutHandlerWithNotificationurlNoRequestId() {
149 // Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
151 + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns7=\"http://org.onap/so/request/types/v1\">"
152 + " <ns7:request-information>" + " <ns7:request-id></ns7:request-id>"
153 + " <ns7:request-action>requestAction</ns7:request-action>"
154 + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
155 + " <ns7:source>source</ns7:source>"
156 + " <ns7:notification-url>www.test.com</ns7:notification-url>"
157 + " <ns7:order-number>10205000</ns7:order-number>"
158 + " <ns7:order-version>1</ns7:order-version>" + " </ns7:request-information>"
159 + " <sdncadapterworkflow:WorkflowException>"
160 + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
161 + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
162 + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
163 + " </sdncadapterworkflow:WorkflowException>" + "</sdncadapterworkflow:FalloutHandlerRequest>";
170 public void msoFalloutHandlerWithNoNotificationurlNoRequestId() throws Exception {
171 String method = getClass().getSimpleName() + "." + new Object() {}.getClass().getEnclosingMethod().getName();
172 logger.debug("STARTED TEST: {}", method);
176 executeFlow(gMsoFalloutHandlerWithNoNotificationurlNoRequestId());
178 String FH_ResponseCode = BPMNUtil.getVariable(processEngine, "FalloutHandler", "FH_ResponseCode");
179 Assert.assertEquals("200", FH_ResponseCode);
180 Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngine, "FalloutHandler", "FH_SuccessIndicator"));
183 public String gMsoFalloutHandlerWithNoNotificationurlNoRequestId() {
184 // Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
186 + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.onap/so/workflow/schema/v1\" xmlns:ns7=\"http://org.onap/so/request/types/v1\">"
187 + " <ns7:request-information>" + " <ns7:request-id></ns7:request-id>"
188 + " <ns7:request-action>requestAction</ns7:request-action>"
189 + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
190 + " <ns7:source>source</ns7:source>" + " <ns7:notification-url></ns7:notification-url>"
191 + " <ns7:order-number>10205000</ns7:order-number>"
192 + " <ns7:order-version>1</ns7:order-version>" + " </ns7:request-information>"
193 + " <sdncadapterworkflow:WorkflowException>"
194 + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
195 + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
196 + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
197 + " </sdncadapterworkflow:WorkflowException>" + "</sdncadapterworkflow:FalloutHandlerRequest>";