/*- * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= */ package org.onap.so.bpmn.common; import static org.onap.so.bpmn.common.BPMNUtil.waitForWorkflowToFinish; import static org.onap.so.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; import java.util.HashMap; import java.util.Map; import java.util.UUID; import org.junit.Assert; import org.junit.Test; import org.onap.so.BaseIntegrationTest; /** * Unit test for CompleteMsoProcess.bpmn. */ public class CompleteMsoProcessIT extends BaseIntegrationTest { private void executeFlow(String inputRequestFile) throws InterruptedException { mockUpdateRequestDB(wireMockServer, 200, "Database/DBUpdateResponse.xml"); Map variables = new HashMap<>(); variables.put("CompleteMsoProcessRequest", inputRequestFile); variables.put("mso-request-id", UUID.randomUUID().toString()); String processId = invokeSubProcess("CompleteMsoProcess", variables); waitForWorkflowToFinish(processEngine, processId); logEnd(); } @Test public void msoCompletionRequestWithNotificationUrl_200() throws Exception { logStart(); // Execute Flow executeFlow(gMsoCompletionRequestWithNotificationurl()); // Verify Error String CMSO_ResponseCode = BPMNUtil.getVariable(processEngine, "CompleteMsoProcess", "CMSO_ResponseCode"); Assert.assertEquals("200", CMSO_ResponseCode); Assert.assertTrue( (boolean) BPMNUtil.getRawVariable(processEngine, "CompleteMsoProcess", "CMSO_SuccessIndicator")); logEnd(); } @Test public void msoCompletionRequestWithNoNotificationurl() throws Exception { logStart(); // Execute Flow executeFlow(gMsoCompletionRequestWithNoNotificationurl()); // Verify Error String CMSO_ResponseCode = BPMNUtil.getVariable(processEngine, "CompleteMsoProcess", "CMSO_ResponseCode"); Assert.assertEquals("200", CMSO_ResponseCode); Assert.assertTrue( (boolean) BPMNUtil.getRawVariable(processEngine, "CompleteMsoProcess", "CMSO_SuccessIndicator")); logEnd(); } @Test public void msoCompletionRequestWithNotificationurlNoRequestId() throws Exception { logStart(); // Execute Flow executeFlow(gMsoCompletionRequestWithNotificationurlNoRequestId()); // Verify Error String CMSO_ResponseCode = BPMNUtil.getVariable(processEngine, "CompleteMsoProcess", "CMSO_ResponseCode"); Assert.assertEquals("200", CMSO_ResponseCode); Assert.assertTrue( (boolean) BPMNUtil.getRawVariable(processEngine, "CompleteMsoProcess", "CMSO_SuccessIndicator")); logEnd(); } @Test public void msoCompletionRequestWithNoNotificationurlNoRequestId() throws Exception { logStart(); // Execute Flow executeFlow(gMsoCompletionRequestWithNoNotificationurlNoRequestId()); // Verify Error String CMSO_ResponseCode = BPMNUtil.getVariable(processEngine, "CompleteMsoProcess", "CMSO_ResponseCode"); Assert.assertEquals("200", CMSO_ResponseCode); Assert.assertTrue( (boolean) BPMNUtil.getRawVariable(processEngine, "CompleteMsoProcess", "CMSO_SuccessIndicator")); logEnd(); } public String gMsoCompletionRequestWithNotificationurl() { String xml = "" + "" + " " + " STUW105_5002" + " RequestAction" + " COMPLETE" + " SOURCE" + " https://t3nap1a1.snt.bst.bls.com:9004/sdncontroller-sdncontroller-inbound-ws-war/sdncontroller-sdncontroller-inbound-ws.wsdl" + " 10205000" + " 1" + " " + " BPELNAME" + ""; return xml; } public String gMsoCompletionRequestWithNoNotificationurl() { // Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS String xml = "" + "" + " " + " STUW105_5002" + " RequestAction" + " COMPLETE" + " SOURCE" + " " + " 10205000" + " 1" + " " + " BPELNAME" + ""; return xml; } public String gMsoCompletionRequestWithNoNotificationurlNoRequestId() { // Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS String xml = "" + "" + " " + " " + " RequestAction" + " COMPLETE" + " SOURCE" + " " + " 10205000" + " 1" + " " + " BPELNAME" + ""; return xml; } public String gMsoCompletionRequestWithNotificationurlNoRequestId() { // Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS String xml = "" + "" + " " + " " + " RequestAction" + " COMPLETE" + " SOURCE" + " https://t3nap1a1.snt.bst.bls.com:9004/sdncontroller-sdncontroller-inbound-ws-war/sdncontroller-sdncontroller-inbound-ws.wsdl" + " 10205000" + " 1" + " " + " BPELNAME" + ""; return xml; } }