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