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;
29 import java.io.IOException;
30 import java.util.HashMap;
32 import java.util.UUID;
34 import org.junit.Assert;
35 import org.junit.Ignore;
36 import org.junit.Test;
37 import org.onap.so.BaseIntegrationTest;
38 import org.onap.so.bpmn.mock.FileUtil;
39 import org.slf4j.Logger;
40 import org.slf4j.LoggerFactory;
43 * Unit tests for SDNCAdapterRestV2.bpmn.
45 * This version of SDNCAdapterRest allows for interim notifications to be sent for
46 * any non-final response received from SDNC.
49 public class SDNCAdapterRestV2IT extends BaseIntegrationTest {
51 private final CallbackSet callbacks = new CallbackSet();
53 Logger logger = LoggerFactory.getLogger(SDNCAdapterRestV2IT.class);
57 * Constructor. Insert callbacks.
61 public SDNCAdapterRestV2IT() throws IOException {
62 String sdncCallbackFinal = FileUtil.readResourceFile("__files/SDNCAdapterRestCallbackFinal.json");
63 String sdncCallbackNonFinal = FileUtil.readResourceFile("__files/SDNCAdapterRestCallbackNonFinal.json");
64 callbacks.put("nonfinal", sdncCallbackNonFinal);
65 callbacks.put("final", sdncCallbackFinal);
69 * Test the success path through the subflow.
73 public void success() throws IOException {
77 String businessKey = UUID.randomUUID().toString();
78 Map<String, Object> variables = new HashMap<String, Object>();
79 variables.put("mso-request-id", "a4383a52-b9de-4bc4-bedf-02f3f9466535");
80 variables.put("mso-service-instance-id", "fd8bcdbb-b799-43ce-a7ff-ed8f2965a3b5");
81 variables.put("isDebugLogEnabled", "true");
82 variables.put("SDNCREST_Request",
83 FileUtil.readResourceFile("__files/SDNCAdapterRestV2Request.json"));
84 variables.put("SDNCREST_InterimNotification1",
85 FileUtil.readResourceFile("__files/SDNCInterimNotification1.json"));
87 invokeSubProcess("SDNCAdapterRestV2", businessKey, variables);
89 injectSDNCRestCallbacks(callbacks, "nonfinal");
91 // First non-final response will have done a notification
92 Object interimNotification = getVariableFromHistory(businessKey, "SDNCREST_interimNotification");
93 Assert.assertNotNull(interimNotification);
95 injectSDNCRestCallbacks(callbacks, "nonfinal");
97 // Second non-final response will not have done a notification
98 interimNotification = getVariableFromHistory(businessKey, "SDNCREST_interimNotification");
99 Assert.assertNull(interimNotification);
101 injectSDNCRestCallbacks(callbacks, "final");
103 interimNotification = this.getVariableFromHistory(businessKey, "SDNCREST_interimNotification");
104 Assert.assertNull(interimNotification);
106 waitForProcessEnd(businessKey, 10000);
108 Assert.assertTrue(isProcessEnded(businessKey));
114 * Defines WireMock stubs needed by these tests.
116 private void mocks() {
117 wireMockServer.stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc"))
118 .willReturn(aResponse()
120 .withHeader("Content-Type", "application/json")));