diff options
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/test/java/org/openecomp')
90 files changed, 0 insertions, 15260 deletions
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/appc/payload/PayloadClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/appc/payload/PayloadClientTest.java deleted file mode 100644 index 95af260ac6..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/appc/payload/PayloadClientTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 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.openecomp.mso.bpmn.appc.payload;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Optional;
-
-import org.json.JSONObject;
-import org.junit.Test;
-
-public class PayloadClientTest {
-
- @Test
- public void upgradeFormatTest() throws Exception {
- String payloadResult = "{\"configuration-parameters\":{\"vnf_name\":\"vnfName1\",\"existing-software-version\":\"existingVersion\",\"new-software-version\":\"newVersion\"}}";
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("existing-software-version", "existingVersion");
- jsonObject.put("new-software-version", "newVersion");
- Optional<String> payload = Optional.of(jsonObject.toString());
- Optional<String> payloadClient = PayloadClient.upgradeFormat(payload, "vnfName1");
- assertEquals(payloadResult, payloadClient.get());
- }
-
- @Test
- public void resumeTrafficFormatTest() throws Exception {
- String payloadResult = "{\"configuration-parameters\":{\"vnf_name\":\"vnfName1\"}}";
- Optional<String> payloadClient = PayloadClient.resumeTrafficFormat("vnfName1");
- assertEquals(payloadResult, payloadClient.get());
- }
-
- @Test
- public void quiesceTrafficFormatTest() throws Exception {
- String payloadResult = "{\"configuration-parameters\":{\"vnf_name\":\"vnfName1\",\"operations_timeout\":\"operationTimeout\"}}";
- JSONObject jsonObject = new JSONObject();
- jsonObject.put("operations-timeout", "operationTimeout");
- Optional<String> payload = Optional.of(jsonObject.toString());
- Optional<String> payloadClient = PayloadClient.quiesceTrafficFormat(payload, "vnfName1");
- assertEquals(payloadResult, payloadClient.get());
- }
-
- @Test
- public void startStopFormatTest() throws Exception {
- String payloadResult = "{\" AICIdentity \":\"aicIdentity1\"}";
- Optional<String> payloadClient = PayloadClient.startStopFormat("aicIdentity1");
- assertEquals(payloadResult, payloadClient.get());
- }
-
- @Test
- public void healthCheckFormatTest() throws Exception {
- String payloadResult = "{\"request-parameters\":{\"vnf-name\":\"vnfName1\"},\"configuration-parameters\":{\"vnf_name\":\"vnfName1\"}}";
- Optional<String> payloadClient = PayloadClient.healthCheckFormat("vnfName1", "vnfHostIpAddress1");
- assertEquals(payloadResult, payloadClient.get());
- }
-
- @Test
- public void snapshotFormatTest() throws Exception {
- String payloadResult = "{\"vm-id\":\"vmId1\",\"identity-url\":\"identityUrl1\"}";
- Optional<String> payloadClient = PayloadClient.snapshotFormat("vmId1", "identityUrl1");
- assertEquals(payloadResult, payloadClient.get());
- }
-
-}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/AppCClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/AppCClientTest.java deleted file mode 100644 index 8561b030eb..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/AppCClientTest.java +++ /dev/null @@ -1,119 +0,0 @@ -/*- - * ============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.openecomp.mso.bpmn.common; - - -import static org.junit.Assert.assertEquals; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockAAIVfModule; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDBUpdateVfModule; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfsByVnfId; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetPserverByVnfId; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchGenericVnf; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchVfModuleId; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockSetInMaintFlagByVnfId; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockVNFAdapterRestVfModule; -import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogData; -import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; -import static org.openecomp.mso.bpmn.mock.StubResponsePolicy.MockPolicySkip; -import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; -import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockVNFPut; - -//import static org.junit.Assert.assertEquals; -//import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow; -//import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish; -//import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.camunda.bpm.engine.test.Deployment; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; - -import org.openecomp.mso.bpmn.common.WorkflowTest; -import org.onap.appc.client.lcm.model.Action; - -//import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; - -public class AppCClientTest extends WorkflowTest{ - - - @Test - @Ignore // 1802 merge - @Deployment(resources = {"subprocess/BuildingBlock/AppCClient.bpmn"}) - public void test() throws Exception{ - - logStart(); - - MockNodeQueryServiceInstanceById("MIS%2F1604%2F0026%2FSW_INTERNET", "GenericFlows/getSIUrlByIdVipr.xml"); - MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml"); - //MockGetGenericVnfById_404("testVnfId"); - MockGetServiceResourcesCatalogData("995256d2-5a33-55df-13ab-12abad84e7ff", "1.0", "VIPR/getCatalogServiceResourcesDataForUpdateVnfInfra.json"); - MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml"); - MockPutGenericVnf(".*"); - MockAAIVfModule(); - MockPatchGenericVnf("skask"); - MockPatchVfModuleId("skask", ".*"); - mockSDNCAdapter("VfModularity/StandardSDNCSynchResponse.xml"); - mockVNFPut("skask", "/supercool", 202); - mockVNFPut("skask", "/lukewarm", 202); - MockVNFAdapterRestVfModule(); - MockDBUpdateVfModule(); - MockGetPserverByVnfId("skask", "AAI/AAI_pserverByVnfId.json", 200); - MockGetGenericVnfsByVnfId("skask", "AAI/AAI_genericVnfsByVnfId.json", 200); - MockSetInMaintFlagByVnfId("skask", 200); - MockPolicySkip(); - mockSDNCAdapter("VfModularity/StandardSDNCSynchResponse.xml"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - - Map<String, Object> variables = new HashMap<String, Object>(); - variables = setVariablesInstance(); - String businessKey = UUID.randomUUID().toString(); - invokeSubProcess("AppCClient", businessKey, variables); - waitForProcessEnd(businessKey, 10000); - Assert.assertTrue(isProcessEnded(businessKey)); - String workflowException = BPMNUtil.getVariable(processEngineRule, "AppCClient", "WorkflowException"); - System.out.println("workflowException:\n" + workflowException); - assertEquals(null, workflowException); - logEnd(); - } - - - private Map<String, Object> setVariablesInstance(){ - Map<String,Object> variables = new HashMap<String, Object>(); - variables.put("isDebugLogEnabled", "true"); - variables.put("mso-request-id", "RaaACCTest1"); - variables.put("msoRequestId", "RaaACCTestRequestId-1"); - variables.put("requestId", "testRequestId"); - variables.put("vnfId", "skask"); - variables.put("action", Action.Stop); - variables.put("healthCheckIndex", 0); - variables.put("payload", "{\"existing-software-version\":\"3.1\",\"new-software-version\":\"3.2\"}"); - //variables.put("payload", "{\"vm-id\": \"<VM-ID>\", \"identy-url\":\"<IDENTITY-URL>\", \"tenant-id\": \"<TENANT-ID>\"}, \"Hello\":\"Whats up\"" ); - return variables; - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BPMNUtil.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BPMNUtil.java deleted file mode 100644 index 0bb5186a17..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BPMNUtil.java +++ /dev/null @@ -1,248 +0,0 @@ -/*-
- * ============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.openecomp.mso.bpmn.common;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.spy;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.ws.rs.core.Response;
-
-import org.camunda.bpm.engine.ProcessEngineServices;
-import org.camunda.bpm.engine.history.HistoricProcessInstance;
-import org.camunda.bpm.engine.history.HistoricVariableInstance;
-import org.camunda.bpm.engine.variable.impl.VariableMapImpl;
-import org.jboss.resteasy.spi.AsynchronousResponse;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-import org.openecomp.mso.bpmn.common.workflow.service.WorkflowAsyncResource;
-import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResource;
-import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
-
-/**
- * Set of utility methods used for Unit testing
- *
- */
-public class BPMNUtil {
-
- public static String getVariable(ProcessEngineServices processEngineServices, String processDefinitionID, String name) {
- String pID = getProcessInstanceId(processEngineServices,
- processDefinitionID);
- assertProcessInstanceFinished(processEngineServices, pID);
- HistoricVariableInstance responseData = processEngineServices.getHistoryService()
- .createHistoricVariableInstanceQuery().processInstanceId(pID)
- .variableName(name)
- .singleResult();
-
- if (responseData != null) {
- return (responseData.getValue() != null ? responseData.getValue().toString(): null);
- }
- return null;
- }
-
- @SuppressWarnings("unchecked")
- public static <T> T getRawVariable(ProcessEngineServices processEngineServices, String processDefinitionID, String name) {
- String pID = getProcessInstanceId(processEngineServices,
- processDefinitionID);
- assertProcessInstanceFinished(processEngineServices, pID);
- Object responseData = processEngineServices.getHistoryService()
- .createHistoricVariableInstanceQuery().processInstanceId(pID)
- .variableName(name)
- .singleResult()
- .getValue();
- return (T) responseData;
- }
-
-
- public static void assertAnyProcessInstanceFinished(ProcessEngineServices processEngineServices, String processDefinitionID) {
- String pID = getProcessInstanceId(processEngineServices,
- processDefinitionID);
- assertNotNull(pID);
- assertTrue(processEngineServices.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(pID).finished().count() > 0);
- }
-
- public static void assertNoProcessInstance(ProcessEngineServices processEngineServices, String processDefinitionID) {
- assertNull(getProcessInstanceId(processEngineServices, processDefinitionID));
- }
-
- public static void assertProcessInstanceFinished(ProcessEngineServices processEngineServices, String pid) {
- assertEquals(1, processEngineServices.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(pid).finished().count());
- }
-
- public static void assertProcessInstanceNotFinished(ProcessEngineServices processEngineServices, String processDefinitionID) {
- String pID = getProcessInstanceId(processEngineServices,
- processDefinitionID);
- assertEquals(0, processEngineServices.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(pID).finished().count());
- }
-
- private static String getProcessInstanceId(
- ProcessEngineServices processEngineServices, String processDefinitionID) {
- List<HistoricProcessInstance> historyList = processEngineServices.getHistoryService().createHistoricProcessInstanceQuery().list();
- String pID = null;
- for (HistoricProcessInstance hInstance: historyList) {
- if (hInstance.getProcessDefinitionKey().equals(processDefinitionID)) {
- pID = hInstance.getId();
- break;
- }
- }
- return pID;
- }
-
- public static boolean isProcessInstanceFinished(ProcessEngineServices processEngineServices, String pid) {
- return processEngineServices.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(pid).finished().count() == 1 ? true: false;
- }
-
-
- private static void buildVariable(String key, String value, Map<String,Object> variableValueType) {
- Map<String, Object> host = new HashMap<>();
- host.put("value", value);
- host.put("type", "String");
- variableValueType.put(key, host);
- }
-
- public static WorkflowResponse executeWorkFlow(ProcessEngineServices processEngineServices, String processKey, Map<String,String> variables) {
- WorkflowResource workflowResource = new WorkflowResource();
- VariableMapImpl variableMap = new VariableMapImpl();
-
- Map<String, Object> variableValueType = new HashMap<>();
- for (String key : variables.keySet()) {
- buildVariable(key, variables.get(key), variableValueType);
- }
- buildVariable("mso-service-request-timeout","600", variableValueType);
- variableMap.put("variables", variableValueType);
-
- workflowResource.setProcessEngineServices4junit(processEngineServices);
- Response response = workflowResource.startProcessInstanceByKey(
- processKey, variableMap);
- WorkflowResponse workflowResponse = (WorkflowResponse) response.getEntity();
- return workflowResponse;
- }
-
- //Check the runtime service to see whether the process is completed
- public static void waitForWorkflowToFinish(ProcessEngineServices processEngineServices, String pid) throws InterruptedException {
- // Don't wait forever
- long waitTime = 120000;
- long endTime = System.currentTimeMillis() + waitTime;
-
- while (true) {
- if (processEngineServices.getRuntimeService().createProcessInstanceQuery().processInstanceId(pid).singleResult() == null) {
- break;
- }
-
- if (System.currentTimeMillis() >= endTime) {
- fail("Process " + pid + " did not finish in " + waitTime + "ms");
- }
-
- Thread.sleep(200);
- }
- }
-
- /**
- * Executes the Asynchronous workflow in synchronous fashion and returns the WorkflowResponse object
- * @param processEngineServices
- * @param processKey
- * @param variables
- * @return
- * @throws InterruptedException
- */
- public static WorkflowResponse executeAsyncWorkflow(ProcessEngineServices processEngineServices, String processKey, Map<String,String> variables) throws InterruptedException {
- ProcessThread pthread = new ProcessThread(processKey, processEngineServices, variables);
- pthread.start();
- BPMNUtil.assertProcessInstanceNotFinished(processEngineServices, processKey);
- String pid = getProcessInstanceId(processEngineServices, processKey);
- //Caution: If there is a problem with workflow, this may wait for ever
- while (true) {
- pid = getProcessInstanceId(processEngineServices, processKey);
- if (!isProcessInstanceFinished(processEngineServices,pid)) {
- Thread.sleep(200);
- } else{
- break;
- }
- }
- //need to retrieve for second time ?
- pid = getProcessInstanceId(processEngineServices, processKey);
- waitForWorkflowToFinish(processEngineServices, pid);
- return pthread.workflowResponse;
- }
-
- /**
- * Execute workflow using async resource
- * @param processEngineServices
- * @param processKey
- * @param asyncResponse
- * @param variables
- */
- private static void executeAsyncFlow(ProcessEngineServices processEngineServices, String processKey, AsynchronousResponse asyncResponse, Map<String,String> variables) {
- WorkflowAsyncResource workflowResource = new WorkflowAsyncResource();
- VariableMapImpl variableMap = new VariableMapImpl();
-
- Map<String, Object> variableValueType = new HashMap<>();
- for (String key : variables.keySet()) {
- buildVariable(key, variables.get(key), variableValueType);
- }
- buildVariable("mso-service-request-timeout","600", variableValueType);
- variableMap.put("variables", variableValueType);
-
- workflowResource.setProcessEngineServices4junit(processEngineServices);
- workflowResource.startProcessInstanceByKey(asyncResponse, processKey, variableMap);
- }
-
- /**
- * Helper class which executes workflow in a thread
- *
- */
- static class ProcessThread extends Thread {
-
- public WorkflowResponse workflowResponse = null;
- public String processKey;
- public AsynchronousResponse asyncResponse = spy(AsynchronousResponse.class);
- public boolean started;
- public ProcessEngineServices processEngineServices;
- public Map<String,String> variables;
-
- public ProcessThread(String processKey, ProcessEngineServices processEngineServices, Map<String,String> variables) {
- this.processKey = processKey;
- this.processEngineServices = processEngineServices;
- this.variables = variables;
- }
-
- public void run() {
- started = true;
- doAnswer(new Answer<Void>() {
- public Void answer(InvocationOnMock invocation) {
- Response response = (Response) invocation.getArguments()[0];
- workflowResponse = (WorkflowResponse) response.getEntity();
- return null;
- }
- }).when(asyncResponse).setResponse(any(Response.class));
- executeAsyncFlow(processEngineServices, processKey, asyncResponse, variables);
- }
- }
-}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BeansTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BeansTest.java deleted file mode 100644 index 358ebfa13c..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/BeansTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * ============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.openecomp.mso.bpmn.common; - -import org.junit.Test; - -import com.openpojo.validation.Validator; -import com.openpojo.validation.ValidatorBuilder; -import com.openpojo.validation.rule.impl.GetterMustExistRule; -import com.openpojo.validation.rule.impl.SetterMustExistRule; -import com.openpojo.validation.test.impl.GetterTester; -import com.openpojo.validation.test.impl.SetterTester; -import com.openpojo.reflection.PojoClass; -import com.openpojo.reflection.PojoClassFilter; -import com.openpojo.reflection.filters.FilterEnum; -import com.openpojo.reflection.filters.FilterNonConcrete; -import com.openpojo.reflection.filters.FilterPackageInfo; -import org.openecomp.mso.openpojo.rules.HasToStringRule; -import org.openecomp.mso.openpojo.rules.ToStringTester; - -public class BeansTest { - - - private PojoClassFilter filterTestClasses = new FilterTestClasses(); - - private PojoClassFilter enumFilter = new FilterEnum(); - - - @Test - public void pojoStructure() { - test("org.openecomp.mso.bpmn.appc.payload.beans"); - test("org.openecomp.mso.client.sdnc.beans"); - } - - private void test(String pojoPackage) { - Validator validator = ValidatorBuilder.create() - .with(new GetterMustExistRule()) - .with(new SetterMustExistRule()) - - .with(new SetterTester()) - .with(new GetterTester()) - - .with(new SetterTester()) - .with(new GetterTester()) - .with(new ToStringTester()) - - .build(); - - - validator.validate(pojoPackage, new FilterPackageInfo(), filterTestClasses,enumFilter,new FilterNonConcrete()); - } - private static class FilterTestClasses implements PojoClassFilter { - public boolean include(PojoClass pojoClass) { - return !pojoClass.getSourcePath().contains("/test-classes/"); - } - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CompleteMsoProcessTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CompleteMsoProcessTest.java deleted file mode 100644 index bf69223b52..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CompleteMsoProcessTest.java +++ /dev/null @@ -1,217 +0,0 @@ -/*-
- * ============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.openecomp.mso.bpmn.common;
-
-import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow;
-import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish;
-import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.camunda.bpm.engine.test.Deployment;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
-
-/**
- * Unit test for CompleteMsoProcess.bpmn.
- */
-public class CompleteMsoProcessTest extends WorkflowTest {
-
- private void executeFlow(String inputRequestFile) throws InterruptedException {
- mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml");
-
- //String changeFeatureActivateRequest = FileUtil.readResourceFile("__files/SDN-ETHERNET-INTERNET/ChangeFeatureActivateV1/" + inputRequestFile);
- Map<String, String> variables = new HashMap<>();
- variables.put("CompleteMsoProcessRequest",inputRequestFile);
-
- WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "CompleteMsoProcess", variables);
- waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId());
- logEnd();
- }
-
- @Test
- @Deployment(resources = {"subprocess/CompleteMsoProcess.bpmn",
- "subprocess/GenericNotificationService.bpmn"
- })
- public void msoCompletionRequestWithNotificationurl_200() throws Exception {
- logStart();
-
- //Execute Flow
- executeFlow(gMsoCompletionRequestWithNotificationurl());
-
- //Verify Error
- String CMSO_ResponseCode = BPMNUtil.getVariable(processEngineRule, "CompleteMsoProcess", "CMSO_ResponseCode");
- Assert.assertEquals("200", CMSO_ResponseCode);
- Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "CompleteMsoProcess", "CMSO_SuccessIndicator"));
- logEnd();
- }
-
- @Test
- @Ignore // BROKEN TEST
- @Deployment(resources = {"subprocess/CompleteMsoProcess.bpmn",
- "subprocess/GenericNotificationService.bpmn"
- })
- public void msoCompletionRequestWithNotificationurl_500() throws Exception {
- logStart();
-
- //Execute Flow
- executeFlow(gMsoCompletionRequestWithNotificationurl());
-
- //Verify Error
- String CMSO_ResponseCode = BPMNUtil.getVariable(processEngineRule, "CompleteMsoProcess", "CMSO_ResponseCode");
- Assert.assertEquals("500", CMSO_ResponseCode);
- Assert.assertFalse((boolean) BPMNUtil.getRawVariable(processEngineRule, "CompleteMsoProcess", "CMSO_SuccessIndicator"));
- logEnd();
- }
-
- @Test
- @Deployment(resources = {"subprocess/CompleteMsoProcess.bpmn",
- "subprocess/GenericNotificationService.bpmn"
- })
- public void msoCompletionRequestWithNoNotificationurl() throws Exception {
- logStart();
-
- //Execute Flow
- executeFlow(gMsoCompletionRequestWithNoNotificationurl());
-
- //Verify Error
- String CMSO_ResponseCode = BPMNUtil.getVariable(processEngineRule, "CompleteMsoProcess", "CMSO_ResponseCode");
- Assert.assertEquals("200", CMSO_ResponseCode);
- Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "CompleteMsoProcess", "CMSO_SuccessIndicator"));
- logEnd();
- }
-
- @Test
- @Deployment(resources = {"subprocess/CompleteMsoProcess.bpmn",
- "subprocess/GenericNotificationService.bpmn"
- })
- public void msoCompletionRequestWithNotificationurlNoRequestId() throws Exception {
- logStart();
-
- //Execute Flow
- executeFlow(gMsoCompletionRequestWithNotificationurlNoRequestId());
-
- //Verify Error
- String CMSO_ResponseCode = BPMNUtil.getVariable(processEngineRule, "CompleteMsoProcess", "CMSO_ResponseCode");
- Assert.assertEquals("200", CMSO_ResponseCode);
- Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "CompleteMsoProcess", "CMSO_SuccessIndicator"));
- logEnd();
- }
-
- @Test
- @Deployment(resources = {"subprocess/CompleteMsoProcess.bpmn",
- "subprocess/GenericNotificationService.bpmn"
- })
- public void msoCompletionRequestWithNoNotificationurlNoRequestId() throws Exception {
- logStart();
-
- //Execute Flow
- executeFlow(gMsoCompletionRequestWithNoNotificationurlNoRequestId());
-
- //Verify Error
- String CMSO_ResponseCode = BPMNUtil.getVariable(processEngineRule, "CompleteMsoProcess", "CMSO_ResponseCode");
- Assert.assertEquals("200", CMSO_ResponseCode);
- Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "CompleteMsoProcess", "CMSO_SuccessIndicator"));
- logEnd();
- }
-
- public String gMsoCompletionRequestWithNotificationurl() {
- //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
- String xml = ""
- + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://ecomp.openecomp.org.com/mso/workflow/schema/v1\">"
- + " <ns:request-information>"
- + " <ns:request-id>uCPE1020_STUW105_5002</ns:request-id>"
- + " <ns:request-action>Layer3ServiceActivateRequest</ns:request-action>"
- + " <ns:request-sub-action>COMPLETE</ns:request-sub-action>"
- + " <ns:source>OMX</ns:source>"
- + " <ns:notification-url>https://t3nap1a1.snt.bst.bls.com:9004/sdncontroller-sdncontroller-inbound-ws-war/sdncontroller-sdncontroller-inbound-ws.wsdl</ns:notification-url>"
- + " <ns:order-number>10205000</ns:order-number>"
- + " <ns:order-version>1</ns:order-version>"
- + " </ns:request-information>"
- + " <sdncadapterworkflow:mso-bpel-name>UCPELayer3ServiceActivateV1</sdncadapterworkflow:mso-bpel-name>"
- + "</sdncadapterworkflow:MsoCompletionRequest>";
-
- return xml;
- }
-
-
-
- public String gMsoCompletionRequestWithNoNotificationurl() {
- //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
- String xml = ""
- + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://openecomp.org/mso/workflow/schema/v1\">"
- + " <ns:request-information>"
- + " <ns:request-id>uCPE1020_STUW105_5002</ns:request-id>"
- + " <ns:request-action>Layer3ServiceActivateRequest</ns:request-action>"
- + " <ns:request-sub-action>COMPLETE</ns:request-sub-action>"
- + " <ns:source>OMX</ns:source>"
- + " <ns:notification-url></ns:notification-url>"
- + " <ns:order-number>10205000</ns:order-number>"
- + " <ns:order-version>1</ns:order-version>"
- + " </ns:request-information>"
- + " <sdncadapterworkflow:mso-bpel-name>UCPELayer3ServiceActivateV1</sdncadapterworkflow:mso-bpel-name>"
- + "</sdncadapterworkflow:MsoCompletionRequest>";
-
- return xml;
- }
-
- public String gMsoCompletionRequestWithNoNotificationurlNoRequestId() {
- //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
- String xml = ""
- + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://openecomp.org/mso/workflow/schema/v1\">"
- + " <ns:request-information>"
- + " <ns:request-id></ns:request-id>"
- + " <ns:request-action>Layer3ServiceActivateRequest</ns:request-action>"
- + " <ns:request-sub-action>COMPLETE</ns:request-sub-action>"
- + " <ns:source>OMX</ns:source>"
- + " <ns:notification-url></ns:notification-url>"
- + " <ns:order-number>10205000</ns:order-number>"
- + " <ns:order-version>1</ns:order-version>"
- + " </ns:request-information>"
- + " <sdncadapterworkflow:mso-bpel-name>UCPELayer3ServiceActivateV1</sdncadapterworkflow:mso-bpel-name>"
- + "</sdncadapterworkflow:MsoCompletionRequest>";
-
- return xml;
- }
-
- public String gMsoCompletionRequestWithNotificationurlNoRequestId() {
- //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
- String xml = ""
- + "<sdncadapterworkflow:MsoCompletionRequest xmlns:ns=\"http://openecomp.org/mso/request/types/v1\" xmlns:sdncadapterworkflow=\"http://openecomp.org/mso/workflow/schema/v1\">"
- + " <ns:request-information>"
- + " <ns:request-id></ns:request-id>"
- + " <ns:request-action>Layer3ServiceActivateRequest</ns:request-action>"
- + " <ns:request-sub-action>COMPLETE</ns:request-sub-action>"
- + " <ns:source>OMX</ns:source>"
- + " <ns:notification-url>https://t3nap1a1.snt.bst.bls.com:9004/sdncontroller-sdncontroller-inbound-ws-war/sdncontroller-sdncontroller-inbound-ws.wsdl</ns:notification-url>"
- + " <ns:order-number>10205000</ns:order-number>"
- + " <ns:order-version>1</ns:order-version>"
- + " </ns:request-information>"
- + " <sdncadapterworkflow:mso-bpel-name>UCPELayer3ServiceActivateV1</sdncadapterworkflow:mso-bpel-name>"
- + "</sdncadapterworkflow:MsoCompletionRequest>";
-
- return xml;
- }
-}
-
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ConfirmVolumeGroupNameTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ConfirmVolumeGroupNameTest.java deleted file mode 100644 index 845f06045a..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ConfirmVolumeGroupNameTest.java +++ /dev/null @@ -1,133 +0,0 @@ -/*- - * ============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.openecomp.mso.bpmn.common; - -import static org.junit.Assert.assertEquals; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVolumeGroupById; - -import java.util.HashMap; -import java.util.Map; - -import org.camunda.bpm.engine.RuntimeService; -import org.camunda.bpm.engine.test.Deployment; -import org.junit.Test; - -/** - * Unit test cases for ConfirmVolumeGroupName.bpmn - */ -public class ConfirmVolumeGroupNameTest extends WorkflowTest { - /** - * Sunny day scenario. - * - * @throws Exception - */ - @Test - @Deployment(resources = { - "subprocess/ConfirmVolumeGroupName.bpmn" - }) - public void sunnyDay() throws Exception { - - logStart(); - MockGetVolumeGroupById("MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml"); - - System.out.println("Before starting process"); - - RuntimeService runtimeService = processEngineRule.getRuntimeService(); - Map<String, Object> variables = new HashMap<>(); - variables.put("isDebugLogEnabled","true"); - variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_1"); - variables.put("ConfirmVolumeGroupName_volumeGroupName", "VOLUME_GROUP_ID_1_NAME"); - variables.put("ConfirmVolumeGroupName_aicCloudRegion", "MDTWNJ21"); - System.out.println("after setting variables"); - runtimeService.startProcessInstanceByKey("ConfirmVolumeGroupName", variables); - String response = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponse"); - String responseCode = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponseCode"); - - assertEquals("200", responseCode); - System.out.println(response); - logEnd(); - } - - /** - * Rainy day scenario - nonexisting volume group id. - * - * @throws Exception - */ - @Test - @Deployment(resources = { - "subprocess/ConfirmVolumeGroupName.bpmn" - }) - public void rainyDayNoVolumeGroupId() throws Exception { - - logStart(); - MockGetVolumeGroupById("MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml"); - - System.out.println("Before starting process"); - - RuntimeService runtimeService = processEngineRule.getRuntimeService(); - Map<String, Object> variables = new HashMap<>(); - variables.put("isDebugLogEnabled","true"); - variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_THAT_DOES_NOT_EXIST"); - variables.put("ConfirmVolumeGroupName_volumeGroupName", "cee6d136-e378-4678-a024-2cd15f0ee0cg"); - System.out.println("after setting variables"); - runtimeService.startProcessInstanceByKey("ConfirmVolumeGroupName", variables); - String response = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponse"); - String responseCode = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponseCode"); - - assertEquals("404", responseCode); - System.out.println(response); - - logEnd(); - } - - /** - * Rainy day scenario - volume group name does not match the name in AAI - * - * - * @throws Exception - */ - @Test - @Deployment(resources = { - "subprocess/ConfirmVolumeGroupName.bpmn" - }) - public void rainyDayNameDoesNotMatch() throws Exception { - - logStart(); - MockGetVolumeGroupById("MDTWNJ21", "VOLUME_GROUP_ID_1", "aai-volume-group-id-info.xml"); - - System.out.println("Before starting process"); - - RuntimeService runtimeService = processEngineRule.getRuntimeService(); - Map<String, Object> variables = new HashMap<>(); - variables.put("isDebugLogEnabled","true"); - variables.put("ConfirmVolumeGroupName_volumeGroupId", "VOLUME_GROUP_ID_1"); - variables.put("ConfirmVolumeGroupName_volumeGroupName", "BAD_VOLUME_GROUP_NAME"); - System.out.println("after setting variables"); - runtimeService.startProcessInstanceByKey("ConfirmVolumeGroupName", variables); - String response = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponse"); - String responseCode = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupName", "CVGN_queryVolumeGroupResponseCode"); - - assertEquals("404", responseCode); - System.out.println(response); - - logEnd(); - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ConfirmVolumeGroupTenantTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ConfirmVolumeGroupTenantTest.java deleted file mode 100644 index 13c400e71e..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ConfirmVolumeGroupTenantTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. - */ -/*- - * ============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.openecomp.mso.bpmn.common; - -import static org.junit.Assert.assertEquals; -import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow; -import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVolumeGroupById; - -import java.util.HashMap; -import java.util.Map; - -import org.camunda.bpm.engine.test.Deployment; -import org.junit.Test; -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; - -/** - * Please describe the ConfirmVolumeGroupTenantTest.java class - * - */ -public class ConfirmVolumeGroupTenantTest extends WorkflowTest { - - @Test - @Deployment(resources = {"subprocess/ConfirmVolumeGroupTenant.bpmn"}) - public void testRemoveLayer3Service_success() throws Exception{ - MockGetVolumeGroupById("MDTWNJ21", "a8399879-31b3-4973-be26-0a0cbe776b58", "CRTGVNF_queryAAIResponseVolume.xml"); - - Map<String, String> variables = new HashMap<>(); - setVariables(variables); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "ConfirmVolumeGroupTenant", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - String actualNameMatch = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupTenant", "groupNamesMatch"); - String actualIdMatch = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupTenant", "tenantIdsMatch"); - String actualResponse = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupTenant", "volumeHeatStackId"); - - assertEquals("Response", "true", actualNameMatch); - assertEquals("Response", "true", actualIdMatch); - assertEquals("Response", "MoG_CinderVolumes_2/19387dc6-060f-446e-b41f-dcfd29c73845", actualResponse); - } - - @Test - @Deployment(resources = {"subprocess/ConfirmVolumeGroupTenant.bpmn"}) - public void testRemoveLayer3Service_idsNotMatch() throws Exception{ - MockGetVolumeGroupById("MDTWNJ21", "a8399879-31b3-4973-be26-0a0cbe776b58", "CRTGVNF_queryAAIResponseVolume_idsNotMatch.xml"); - - Map<String, String> variables = new HashMap<>(); - setVariables(variables); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "ConfirmVolumeGroupTenant", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - String actualNameMatch = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupTenant", "groupNamesMatch"); - String actualIdMatch = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupTenant", "tenantIdsMatch"); - String actualResponse = BPMNUtil.getVariable(processEngineRule, "ConfirmVolumeGroupTenant", "WorkflowException"); - - assertEquals("Response", "true", actualNameMatch); - assertEquals("Response", "false", actualIdMatch); - assertEquals("Response", "WorkflowException[processKey=ConfirmVolumeGroupTenant,errorCode=1,errorMessage=Volume Group a8399879-31b3-4973-be26-0a0cbe776b58 does not belong to your tenant]", actualResponse); - - } - - private void setVariables(Map<String, String> variables) { - variables.put("isDebugLogEnabled", "true"); - variables.put("volumeGroupId","a8399879-31b3-4973-be26-0a0cbe776b58"); - variables.put("tenantId", "7dd5365547234ee8937416c65507d266"); - variables.put("aicCloudRegion", "MDTWNJ21"); - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleTest.java deleted file mode 100644 index b2b7760327..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleTest.java +++ /dev/null @@ -1,277 +0,0 @@ -/*-
- * ============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.openecomp.mso.bpmn.common;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.containing;
-import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-import static org.openecomp.mso.bpmn.common.DeleteAAIVfModuleTest.MockAAIGenericVnfSearch;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.camunda.bpm.engine.RuntimeService;
-import org.camunda.bpm.engine.test.Deployment;
-import org.junit.Assert;
-import org.junit.Test;
-import org.openecomp.mso.bpmn.core.WorkflowException;
-
-/**
- * Unit test for CreateAAIVfModule.bpmn.
- */
-public class CreateAAIVfModuleTest extends WorkflowTest {
-
- @Test
- @Deployment(resources = {
- "subprocess/CreateAAIVfModule.bpmn"
- })
- public void TestCreateGenericVnfSuccess_200() {
-
- MockAAIGenericVnfSearch();
- MockAAICreateGenericVnf();
- MockAAIVfModulePUT(true);
- RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("isVidRequest", "false");
- variables.put("vnfName", "STMTN5MMSC22");
- variables.put("serviceId", "00000000-0000-0000-0000-000000000000");
- variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
- variables.put("personaModelVersion", "1.0");
- variables.put("vfModuleName", "STMTN5MMSC22-MMSC::module-0-0");
- variables.put("vfModuleModelName", "MMSC::module-0");
-
- runtimeService.startProcessInstanceByKey("CreateAAIVfModule", variables);
- String response = BPMNUtil.getVariable(processEngineRule, "CreateAAIVfModule", "CAAIVfMod_createVfModuleResponseCode");
- String responseCode = BPMNUtil.getVariable(processEngineRule, "CreateAAIVfModule", "CAAIVfMod_createVfModuleResponseCode");
- Assert.assertEquals("201", responseCode);
- System.out.println(response);
- }
-
- @Test
- @Deployment(resources = {
- "subprocess/CreateAAIVfModule.bpmn"
- })
- public void TestCreateVfModuleSuccess_200() {
- // create Add-on VF Module for existing Generic VNF
- MockAAIGenericVnfSearch();
- MockAAICreateGenericVnf();
- MockAAIVfModulePUT(true);
- RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("isVidRequest", "false");
- variables.put("vnfId", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
- variables.put("serviceId", "00000000-0000-0000-0000-000000000000");
- variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
- variables.put("personaModelVersion", "1.0");
- variables.put("vfModuleName", "STMTN5MMSC21-MMSC::module-1-0");
- variables.put("vfModuleModelName", "STMTN5MMSC21-MMSC::model-1-0");
- runtimeService.startProcessInstanceByKey("CreateAAIVfModule", variables);
- String response = BPMNUtil.getVariable(processEngineRule, "CreateAAIVfModule", "CAAIVfMod_createVfModuleResponseCode");
- String responseCode = BPMNUtil.getVariable(processEngineRule, "CreateAAIVfModule", "CAAIVfMod_createVfModuleResponseCode");
- Assert.assertEquals("201", responseCode);
- System.out.println(response);
- }
-
- @Test
- @Deployment(resources = {
- "subprocess/CreateAAIVfModule.bpmn"
- })
- public void TestQueryGenericVnfFailure_5000() {
- MockAAIGenericVnfSearch();
- MockAAICreateGenericVnf();
- MockAAIVfModulePUT(true);
- RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("isVidRequest", "false");
- variables.put("vnfName", "STMTN5MMSC23");
- variables.put("serviceId", "00000000-0000-0000-0000-000000000000");
- variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
- variables.put("personaModelVersion", "1.0");
- variables.put("vfModuleName", "STMTN5MMSC23-MMSC::module-0-0");
- variables.put("vfModuleModelName", "MMSC::module-0");
- runtimeService.startProcessInstanceByKey("CreateAAIVfModule", variables);
- WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "CreateAAIVfModule", "WorkflowException");
- Assert.assertEquals(500, exception.getErrorCode());
- Assert.assertEquals(true, exception.getErrorMessage().contains("Error occurred attempting to query AAI"));
- System.out.println(exception.getErrorMessage());
- }
-
- @Test
- @Deployment(resources = {
- "subprocess/CreateAAIVfModule.bpmn"
- })
- public void TestCreateDupGenericVnfFailure_1002() {
- MockAAIGenericVnfSearch();
- MockAAICreateGenericVnf();
- MockAAIVfModulePUT(true);
- RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("isVidRequest", "false");
- variables.put("vnfName", "STMTN5MMSC21");
- variables.put("serviceId", "00000000-0000-0000-0000-000000000000");
- variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
- variables.put("personaModelVersion", "1.0");
- variables.put("vfModuleName", "STMTN5MMSC21-MMSC::module-0-0");
- variables.put("vfModuleModelName", "MMSC::module-0");
- runtimeService.startProcessInstanceByKey("CreateAAIVfModule", variables);
- WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "CreateAAIVfModule", "WorkflowException");
- Assert.assertEquals(1002, exception.getErrorCode());
- Assert.assertEquals(true, exception.getErrorMessage().contains("Invalid request for new Generic VNF which already exists"));
- System.out.println(exception.getErrorMessage());
- }
-
- @Test
- @Deployment(resources = {
- "subprocess/CreateAAIVfModule.bpmn"
- })
- public void TestCreateDupVfModuleFailure_1002() {
- MockAAIGenericVnfSearch();
- MockAAICreateGenericVnf();
- MockAAIVfModulePUT(true);
- RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("isVidRequest", "false");
- variables.put("vnfId", "2f6aee38-1e2a-11e6-82d1-ffc7d9ee8aa4");
- variables.put("serviceId", "00000000-0000-0000-0000-000000000000");
- variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
- variables.put("personaModelVersion", "1.0");
- variables.put("vfModuleName", "STMTN5MMSC20-MMSC::module-1-0");
- variables.put("vfModuleModelName", "STMTN5MMSC20-MMSC::model-1-0");
- runtimeService.startProcessInstanceByKey("CreateAAIVfModule", variables);
- WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "CreateAAIVfModule", "WorkflowException");
- Assert.assertEquals(1002, exception.getErrorCode());
- Assert.assertEquals(true, exception.getErrorMessage().contains("already exists for Generic VNF"));
- System.out.println(exception.getErrorMessage());
- }
-
- @Test
- @Deployment(resources = {
- "subprocess/CreateAAIVfModule.bpmn"
- })
- public void TestCreateGenericVnfFailure_5000() {
- MockAAIGenericVnfSearch();
- MockAAICreateGenericVnf();
- MockAAIVfModulePUT(true);
- RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("isVidRequest", "false");
- variables.put("vnfName", "STMTN5MMSC22");
- variables.put("serviceId", "99999999-9999-9999-9999-999999999999");
- variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
- variables.put("personaModelVersion", "1.0");
- variables.put("vfModuleName", "STMTN5MMSC22-PCRF::module-1-0");
- variables.put("vfModuleModelName", "PCRF::module-0");
- runtimeService.startProcessInstanceByKey("CreateAAIVfModule", variables);
- WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "CreateAAIVfModule", "WorkflowException");
- Assert.assertEquals(5000, exception.getErrorCode());
- Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>"));
- System.out.println(exception.getErrorMessage());
- }
-
- @Test
- @Deployment(resources = {
- "subprocess/CreateAAIVfModule.bpmn"
- })
- public void TestCreateGenericVnfFailure_1002() {
- MockAAIGenericVnfSearch();
- MockAAICreateGenericVnf();
- MockAAIVfModulePUT(true);
- RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("isVidRequest", "false");
- variables.put("vnfId", "768073c7-f41f-4822-9323-b75962763d74");
- variables.put("serviceId", "00000000-0000-0000-0000-000000000000");
- variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
- variables.put("personaModelVersion", "1.0");
- variables.put("vfModuleName", "STMTN5MMSC22-PCRF::module-1-0");
- variables.put("vfModuleModelName", "PCRF::module-0");
- runtimeService.startProcessInstanceByKey("CreateAAIVfModule", variables);
- WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "CreateAAIVfModule", "WorkflowException");
- Assert.assertEquals(1002, exception.getErrorCode());
- Assert.assertEquals(true, exception.getErrorMessage().contains("Generic VNF Not Found"));
- System.out.println(exception.getErrorMessage());
- }
-
- @Test
- @Deployment(resources = {
- "subprocess/CreateAAIVfModule.bpmn"
- })
- public void TestCreateVfModuleFailure_5000() {
- MockAAIGenericVnfSearch();
- MockAAICreateGenericVnf();
- MockAAIVfModulePUT(true);
- RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("isVidRequest", "false");
- variables.put("vnfId", "a27ce5a9-29c4-4c22-a017-6615ac73c721");
- variables.put("serviceId", "99999999-9999-9999-9999-999999999999");
- variables.put("personaModelId", "973ed047-d251-4fb9-bf1a-65b8949e0a73");
- variables.put("personaModelVersion", "1.0");
- variables.put("vfModuleName", "STMTN5MMSC21-PCRF::module-1-0");
- variables.put("vfModuleModelName", "STMTN5MMSC21-PCRF::model-1-0");
- runtimeService.startProcessInstanceByKey("CreateAAIVfModule", variables);
- WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "CreateAAIVfModule", "WorkflowException");
- Assert.assertEquals(5000, exception.getErrorCode());
- Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>"));
- System.out.println(exception.getErrorMessage());
- }
-
- public static void MockAAICreateGenericVnf(){
- stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*"))
- .withRequestBody(containing("<service-id>00000000-0000-0000-0000-000000000000</service-id>"))
- .willReturn(aResponse()
- .withStatus(201)));
- stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*"))
- .withRequestBody(containing("<service-id>99999999-9999-9999-9999-999999999999</service-id>"))
- .willReturn(aResponse()
- .withStatus(500)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("aaiFault.xml")));
- }
-
- // start of mocks used locally and by other VF Module unit tests
- public static void MockAAIVfModulePUT(boolean isCreate){
- stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*/vf-modules/vf-module/.*"))
- .withRequestBody(containing("MMSC"))
- .willReturn(aResponse()
- .withStatus(isCreate ? 201 : 200)));
- stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/.*/vf-modules/vf-module/.*"))
- .withRequestBody(containing("PCRF"))
- .willReturn(aResponse()
- .withStatus(500)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("aaiFault.xml")));
- stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721"))
- .willReturn(aResponse()
- .withStatus(200)));
- }
-
-}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleVolumeGroupTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleVolumeGroupTest.java deleted file mode 100644 index 5cc26459e8..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/CreateAAIVfModuleVolumeGroupTest.java +++ /dev/null @@ -1,136 +0,0 @@ -/*-
- * ============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.openecomp.mso.bpmn.common;
-
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVfModuleId;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutVfModuleIdNoResponse;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.camunda.bpm.engine.test.Deployment;
-import org.junit.Assert;
-import org.junit.Test;
-import org.openecomp.mso.bpmn.mock.FileUtil;
-
-/**
- * Unit tests for CreateAAIVfModuleVolumeGroup.bpmn.
- */
-public class CreateAAIVfModuleVolumeGroupTest extends WorkflowTest {
-
- /**
- * Test the happy path through the flow.
- */
- @Test
- @Deployment(resources = {
- "subprocess/CreateAAIVfModuleVolumeGroup.bpmn"
- })
- public void happyPath() throws IOException {
-
- logStart();
-
- String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml");
- MockGetGenericVnfByIdWithPriority("skask", "lukewarm", 200, "VfModularity/VfModule-lukewarm.xml", 2);
- MockPutVfModuleIdNoResponse("skask", "PCRF", "lukewarm");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", "999-99-9999");
- variables.put("isDebugLogEnabled","true");
- variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest);
- invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponse");
- Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponseCode");
- System.out.println("Subflow response code: " + responseCode);
- System.out.println("Subflow response: " + response);
- Assert.assertEquals(200, responseCode.intValue());
-
- logEnd();
- }
-
- /**
- * Test the case where the GET to AAI returns a 404.
- */
- @Test
- @Deployment(resources = {
- "subprocess/CreateAAIVfModuleVolumeGroup.bpmn"
- })
- public void badGet() throws IOException {
-
- logStart();
-
- String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml");
- MockGetVfModuleId("skask", ".*", "VfModularity/VfModule-supercool.xml", 404);
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", "999-99-9999");
- variables.put("isDebugLogEnabled","true");
- variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest);
- invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponse");
- Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_getVfModuleResponseCode");
- System.out.println("Subflow response code: " + responseCode);
- System.out.println("Subflow response: " + response);
- Assert.assertEquals(404, responseCode.intValue());
-
- logEnd();
- }
-
- /**
- * Test the case where the GET to AAI is successful, but he subsequent PUT returns 404.
- */
- @Test
- @Deployment(resources = {
- "subprocess/CreateAAIVfModuleVolumeGroup.bpmn"
- })
- public void badPatch() throws IOException {
-
- logStart();
-
- String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/CreateAAIVfModuleVolumeGroupRequest.xml");
- MockGetVfModuleId("skask", "lukewarm", "VfModularity/VfModule-lukewarm.xml", 200);
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", "999-99-9999");
- variables.put("isDebugLogEnabled","true");
- variables.put("CreateAAIVfModuleVolumeGroupRequest", updateAAIVfModuleRequest);
- invokeSubProcess("CreateAAIVfModuleVolumeGroup", businessKey, variables);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- String response = (String) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponse");
- Integer responseCode = (Integer) getVariableFromHistory(businessKey, "CAAIVfModVG_updateVfModuleResponseCode");
- System.out.println("Subflow response code: " + responseCode);
- System.out.println("Subflow response: " + response);
- Assert.assertEquals(404, responseCode.intValue());
-
- logEnd();
- }
-}
-
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/DecomposeServiceTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/DecomposeServiceTest.java deleted file mode 100644 index 873e87cc49..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/DecomposeServiceTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/*- - * ============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.openecomp.mso.bpmn.common; - -import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogData; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.camunda.bpm.engine.test.Deployment; -import org.junit.Assert; -import org.junit.Test; -import org.openecomp.mso.bpmn.common.WorkflowTest; - -/** - * Unit Test for the DecomposeService Flow - * - */ -public class DecomposeServiceTest extends WorkflowTest { - - - public DecomposeServiceTest() throws IOException { - - } - - @Test - @Deployment(resources = {"subprocess/BuildingBlock/DecomposeService.bpmn"}) - public void testDecomposeService_success() throws Exception{ - MockGetServiceResourcesCatalogData("cmw-123-456-789", "1.0", "/getCatalogServiceResourcesDataWithConfig.json"); - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - setVariablesSuccess(variables, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff"); - invokeSubProcess("DecomposeService", businessKey, variables); - - waitForProcessEnd(businessKey, 10000); - - Assert.assertTrue(isProcessEnded(businessKey)); - - } - - //@Test - @Deployment(resources = {"subprocess/BuildingBlock/DecomposeService.bpmn"}) - public void testDecomposeService_success_partial() throws Exception{ - MockGetServiceResourcesCatalogData("cmw-123-456-789", "/getCatalogServiceResourcesDataNoNetwork.json"); - - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - setVariablesSuccess(variables, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff"); - invokeSubProcess("DecomposeService", businessKey, variables); - - waitForProcessEnd(businessKey, 10000); - - Assert.assertTrue(isProcessEnded(businessKey)); - - } - - private void setVariablesSuccess(Map<String, Object> variables, String requestId, String siId) { - variables.put("isDebugLogEnabled", "true"); - variables.put("mso-request-id", requestId); - variables.put("msoRequestId", requestId); - variables.put("serviceInstanceId",siId); - - String serviceModelInfo = "{ "+ "\"modelType\": \"service\"," + - "\"modelInvariantUuid\": \"cmw-123-456-789\"," + - "\"modelVersionId\": \"ab6478e5-ea33-3346-ac12-ab121484a3fe\"," + - "\"modelName\": \"ServicevSAMP12\"," + - "\"modelVersion\": \"1.0\"," + - "}"; - variables.put("serviceModelInfo", serviceModelInfo); - - } - -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/DeleteAAIVfModuleTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/DeleteAAIVfModuleTest.java deleted file mode 100644 index 564927a854..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/DeleteAAIVfModuleTest.java +++ /dev/null @@ -1,643 +0,0 @@ -/*-
- * ============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.openecomp.mso.bpmn.common;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.delete;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.camunda.bpm.engine.RuntimeService;
-import org.camunda.bpm.engine.test.Deployment;
-import org.junit.Assert;
-import org.junit.Test;
-import org.openecomp.mso.bpmn.core.WorkflowException;
-
-/**
- * Unit test for DeleteAAIVfModule.bpmn.
- */
-public class DeleteAAIVfModuleTest extends WorkflowTest {
- private static final String EOL = "\n";
-
- @Test
- @Deployment(resources = {
- "subprocess/DeleteAAIVfModule.bpmn"
- })
- public void TestDeleteGenericVnfSuccess_200() {
- // delete the Base Module and Generic Vnf
- // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c721, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a73
- MockAAIGenericVnfSearch();
- MockAAIDeleteGenericVnf();
- MockAAIDeleteVfModule();
- RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("DeleteAAIVfModuleRequest","<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\"> <request-info> <action>DELETE_VF_MODULE</action> <source>PORTAL</source> </request-info> <vnf-inputs> <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id> <vnf-name>STMTN5MMSC21</vnf-name> <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id> <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name> </vnf-inputs> <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/> </vnf-request>");
- runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables);
- String response = BPMNUtil.getVariable(processEngineRule, "DeleteAAIVfModule", "DAAIVfMod_deleteGenericVnfResponseCode");
- String responseCode = BPMNUtil.getVariable(processEngineRule, "DeleteAAIVfModule", "DAAIVfMod_deleteGenericVnfResponseCode");
- Assert.assertEquals("200", responseCode);
- System.out.println(response);
- }
-
- @Test
- @Deployment(resources = {
- "subprocess/DeleteAAIVfModule.bpmn"
- })
- public void TestDeleteVfModuleSuccess_200() {
- // delete Add-on Vf Module for existing Generic Vnf
- // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c720, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a75
- String request =
- "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL +
- " <request-info>" + EOL +
- " <action>DELETE_VF_MODULE</action>" + EOL +
- " <source>PORTAL</source>" + EOL +
- " </request-info>" + EOL +
- " <vnf-inputs>" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC20</vnf-name>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a75</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL +
- " </vnf-inputs>" + EOL +
- " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +
- "</vnf-request>" + EOL;
-
- MockAAIGenericVnfSearch();
- MockAAIDeleteGenericVnf();
- MockAAIDeleteVfModule();
- RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("DeleteAAIVfModuleRequest",request);
- runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables);
- String response = BPMNUtil.getVariable(processEngineRule, "DeleteAAIVfModule", "DAAIVfMod_deleteVfModuleResponseCode");
- String responseCode = BPMNUtil.getVariable(processEngineRule, "DeleteAAIVfModule", "DAAIVfMod_deleteVfModuleResponseCode");
- Assert.assertEquals("200", responseCode);
- System.out.println(response);
- }
-
- @Test
- @Deployment(resources = {
- "subprocess/DeleteAAIVfModule.bpmn"
- })
- public void TestQueryGenericVnfFailure_5000() {
- // query Generic Vnf failure (non-404) with A&AI
- // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c723, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a71
- String request =
- "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL +
- " <request-info>" + EOL +
- " <action>DELETE_VF_MODULE</action>" + EOL +
- " <source>PORTAL</source>" + EOL +
- " </request-info>" + EOL +
- " <vnf-inputs>" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c723</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC23</vnf-name>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a71</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL +
- " </vnf-inputs>" + EOL +
- " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +
- "</vnf-request>" + EOL;
- MockAAIGenericVnfSearch();
- MockAAIDeleteGenericVnf();
- MockAAIDeleteVfModule();
- RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("DeleteAAIVfModuleRequest",request);
- runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables);
- WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "DeleteAAIVfModule", "WorkflowException");
- Assert.assertEquals(5000, exception.getErrorCode());
- Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>"));
- System.out.println(exception.getErrorMessage());
- }
-
- @Test
- @Deployment(resources = {
- "subprocess/DeleteAAIVfModule.bpmn"
- })
- public void TestQueryGenericVnfFailure_1002() {
- // attempt to delete Vf Module for Generic Vnf that does not exist (A&AI returns 404)
- // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c722, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a72
- String request =
- "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL +
- " <request-info>" + EOL +
- " <action>DELETE_VF_MODULE</action>" + EOL +
- " <source>PORTAL</source>" + EOL +
- " </request-info>" + EOL +
- " <vnf-inputs>" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c722</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC22</vnf-name>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a72</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC22-MMSC::module-1-0</vf-module-name>" + EOL +
- " </vnf-inputs>" + EOL +
- " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +
- "</vnf-request>" + EOL;
- MockAAIGenericVnfSearch();
- MockAAIDeleteGenericVnf();
- MockAAIDeleteVfModule();
- RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("DeleteAAIVfModuleRequest",request);
- runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables);
- WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "DeleteAAIVfModule", "WorkflowException");
- Assert.assertEquals(1002, exception.getErrorCode());
- Assert.assertEquals(true, exception.getErrorMessage().contains("Generic VNF Not Found"));
- System.out.println(exception.getErrorMessage());
- }
-
- @Test
- @Deployment(resources = {
- "subprocess/DeleteAAIVfModule.bpmn"
- })
- public void TestDeleteGenericVnfFailure_5000() {
- // A&AI failure (non-200) when attempting to delete a Generic Vnf
- // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c718, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a78
- String request =
- "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL +
- " <request-info>" + EOL +
- " <action>DELETE_VF_MODULE</action>" + EOL +
- " <source>PORTAL</source>" + EOL +
- " </request-info>" + EOL +
- " <vnf-inputs>" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c718</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC18</vnf-name>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a78</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC18-MMSC::module-0-0</vf-module-name>" + EOL +
- " </vnf-inputs>" + EOL +
- " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +
- "</vnf-request>" + EOL;
- MockAAIGenericVnfSearch();
- MockAAIDeleteGenericVnf();
- MockAAIDeleteVfModule();
- RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("DeleteAAIVfModuleRequest",request);
- runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables);
- WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "DeleteAAIVfModule", "WorkflowException");
- Assert.assertEquals(5000, exception.getErrorCode());
- Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>"));
- System.out.println(exception.getErrorMessage());
- }
-
- @Test
- @Deployment(resources = {
- "subprocess/DeleteAAIVfModule.bpmn"
- })
- public void TestDeleteVfModuleFailure_5000() {
- // A&AI failure (non-200) when attempting to delete a Vf Module
- // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c719, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a77
- String request =
- "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL +
- " <request-info>" + EOL +
- " <action>DELETE_VF_MODULE</action>" + EOL +
- " <source>PORTAL</source>" + EOL +
- " </request-info>" + EOL +
- " <vnf-inputs>" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c719</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC19</vnf-name>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a77</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC19-MMSC::module-1-0</vf-module-name>" + EOL +
- " </vnf-inputs>" + EOL +
- " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +
- "</vnf-request>" + EOL;
- MockAAIGenericVnfSearch();
- MockAAIDeleteGenericVnf();
- MockAAIDeleteVfModule();
- RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("DeleteAAIVfModuleRequest",request);
- runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables);
- WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "DeleteAAIVfModule", "WorkflowException");
- Assert.assertEquals(5000, exception.getErrorCode());
- Assert.assertEquals(true, exception.getErrorMessage().contains("<messageId>SVC3002</messageId>"));
- System.out.println(exception.getErrorMessage());
- }
-
- @Test
- @Deployment(resources = {
- "subprocess/DeleteAAIVfModule.bpmn"
- })
- public void TestDeleteVfModuleFailure_1002_1() {
- // failure attempting to delete Base Module when not the last Vf Module
- // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c720, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a74
- String request =
- "<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\">" + EOL +
- " <request-info>" + EOL +
- " <action>DELETE_VF_MODULE</action>" + EOL +
- " <source>PORTAL</source>" + EOL +
- " </request-info>" + EOL +
- " <vnf-inputs>" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC20</vnf-name>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC20-MMSC::module-0-0</vf-module-name>" + EOL +
- " </vnf-inputs>" + EOL +
- " <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/>" + EOL +
- "</vnf-request>" + EOL;
- MockAAIGenericVnfSearch();
- MockAAIDeleteGenericVnf();
- MockAAIDeleteVfModule();
- RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("DeleteAAIVfModuleRequest",request);
- runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables);
- WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "DeleteAAIVfModule", "WorkflowException");
- Assert.assertEquals(1002, exception.getErrorCode());
- Assert.assertEquals(true, exception.getErrorMessage().contains("is Base Module, not Last Module"));
- System.out.println(exception.getErrorMessage());
- }
-
- @Test
- @Deployment(resources = {
- "subprocess/DeleteAAIVfModule.bpmn"
- })
- public void TestDeleteVfModuleFailure_1002_2() {
- // failure attempting to delete a Vf Module that does not exist (A&AI returns 404)
- // vnf-id=a27ce5a9-29c4-4c22-a017-6615ac73c720, vf-module-id=973ed047-d251-4fb9-bf1a-65b8949e0a76
- MockAAIGenericVnfSearch();
- MockAAIDeleteGenericVnf();
- MockAAIDeleteVfModule();
- RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("DeleteAAIVfModuleRequest","<vnf-request xmlns=\"http://openecomp.org/mso/infra/vnf-request/v1\"> <request-info> <action>DELETE_VF_MODULE</action> <source>PORTAL</source> </request-info> <vnf-inputs> <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id> <vnf-name>STMTN5MMSC20</vnf-name> <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a76</vf-module-id> <vf-module-name>STMTN5MMSC20-MMSC::module-2-0</vf-module-name> </vnf-inputs> <vnf-params xmlns:tns=\"http://openecomp.org/mso/infra/vnf-request/v1\"/> </vnf-request>");
- runtimeService.startProcessInstanceByKey("DeleteAAIVfModule", variables);
- WorkflowException exception = BPMNUtil.getRawVariable(processEngineRule, "DeleteAAIVfModule", "WorkflowException");
- Assert.assertEquals(1002, exception.getErrorCode());
- Assert.assertEquals(true, exception.getErrorMessage().contains("does not exist for Generic Vnf Id"));
- System.out.println(exception.getErrorMessage());
- }
-
- // Start of VF Modularization A&AI mocks
-
- public static void MockAAIGenericVnfSearch(){
- String body;
-
- // The following stubs are for CreateAAIVfModule and UpdateAAIVfModule
-
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC23&depth=1"))
- .willReturn(aResponse()
- .withStatus(500)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("aaiFault.xml")));
-
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC22&depth=1"))
- .willReturn(aResponse()
- .withStatus(404)
- .withHeader("Content-Type", "text/xml")
- .withBody("Generic VNF Not Found")));
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/768073c7-f41f-4822-9323-b75962763d74[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(404)
- .withHeader("Content-Type", "text/xml")
- .withBody("Generic VNF Not Found")));
-
- body =
- "<generic-vnf xmlns=\"http://com.aai.inventory/v7\">" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC21</vnf-name>" + EOL +
- " <vnf-type>mmsc-capacity</vnf-type>" + EOL +
- " <service-id>SDN-MOBILITY</service-id>" + EOL +
- " <equipment-role>vMMSC</equipment-role>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <in-maint>false</in-maint>" + EOL +
- " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
- " <resource-version>1508691</resource-version>" + EOL +
- " <vf-modules>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>true</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>1508692</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " </vf-modules>" + EOL +
- " <relationship-list/>" + EOL +
- " <l-interfaces/>" + EOL +
- " <lag-interfaces/>" + EOL +
- "</generic-vnf>" + EOL;
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC21&depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
-
- body =
- "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +
- " <vnf-id>2f6aee38-1e2a-11e6-82d1-ffc7d9ee8aa4</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC20</vnf-name>" + EOL +
- " <vnf-type>mmsc-capacity</vnf-type>" + EOL +
- " <service-id>SDN-MOBILITY</service-id>" + EOL +
- " <equipment-role>vMMSC</equipment-role>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <in-maint>false</in-maint>" + EOL +
- " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
- " <resource-version>1508691</resource-version>" + EOL +
- " <vf-modules>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC20-MMSC::module-0-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>true</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>1508692</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>false</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>1508692</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " </vf-modules>" + EOL +
- " <relationship-list/>" + EOL +
- " <l-interfaces/>" + EOL +
- " <lag-interfaces/>" + EOL +
- "</generic-vnf>" + EOL;
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/[?]vnf-name=STMTN5MMSC20&depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/2f6aee38-1e2a-11e6-82d1-ffc7d9ee8aa4[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
-
- // The following stubs are for DeleteAAIVfModule
-
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c723[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(500)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("aaiFault.xml")));
-
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c722[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(404)
- .withHeader("Content-Type", "text/xml")
- .withBody("Generic VNF Not Found")));
-
- body =
- "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC21</vnf-name>" + EOL +
- " <vnf-type>mmsc-capacity</vnf-type>" + EOL +
- " <service-id>SDN-MOBILITY</service-id>" + EOL +
- " <equipment-role>vMMSC</equipment-role>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <in-maint>false</in-maint>" + EOL +
- " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
- " <resource-version>0000021</resource-version>" + EOL +
- " <vf-modules>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>true</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>0000073</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " </vf-modules>" + EOL +
- " <relationship-list/>" + EOL +
- " <l-interfaces/>" + EOL +
- " <lag-interfaces/>" + EOL +
- "</generic-vnf>" + EOL;
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
-
- body =
- "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c720</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC20</vnf-name>" + EOL +
- " <vnf-type>mmsc-capacity</vnf-type>" + EOL +
- " <service-id>SDN-MOBILITY</service-id>" + EOL +
- " <equipment-role>vMMSC</equipment-role>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <in-maint>false</in-maint>" + EOL +
- " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
- " <resource-version>0000020</resource-version>" + EOL +
- " <vf-modules>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC20-MMSC::module-0-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a74</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>true</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>0000074</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a75</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC20-MMSC::module-1-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a75</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>false</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>0000075</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " </vf-modules>" + EOL +
- " <relationship-list/>" + EOL +
- " <l-interfaces/>" + EOL +
- " <lag-interfaces/>" + EOL +
- "</generic-vnf>" + EOL;
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c720[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
-
- body =
- "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c719</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC19</vnf-name>" + EOL +
- " <vnf-type>mmsc-capacity</vnf-type>" + EOL +
- " <service-id>SDN-MOBILITY</service-id>" + EOL +
- " <equipment-role>vMMSC</equipment-role>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <in-maint>false</in-maint>" + EOL +
- " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
- " <resource-version>0000019</resource-version>" + EOL +
- " <vf-modules>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a76</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC19-MMSC::module-0-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a76</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>true</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>0000076</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a77</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC19-MMSC::module-1-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a77</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>false</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>0000077</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " </vf-modules>" + EOL +
- " <relationship-list/>" + EOL +
- " <l-interfaces/>" + EOL +
- " <lag-interfaces/>" + EOL +
- "</generic-vnf>" + EOL;
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c719[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
-
- body =
- "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c718</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC18</vnf-name>" + EOL +
- " <vnf-type>mmsc-capacity</vnf-type>" + EOL +
- " <service-id>SDN-MOBILITY</service-id>" + EOL +
- " <equipment-role>vMMSC</equipment-role>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <in-maint>false</in-maint>" + EOL +
- " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
- " <resource-version>0000018</resource-version>" + EOL +
- " <vf-modules>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a78</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC18-MMSC::module-0-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a78</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>true</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>0000078</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " </vf-modules>" + EOL +
- " <relationship-list/>" + EOL +
- " <l-interfaces/>" + EOL +
- " <lag-interfaces/>" + EOL +
- "</generic-vnf>" + EOL;
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718[?]depth=1"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
-
- body =
- "<generic-vnf xmlns=\"http://org.openecomp.aai.inventory/v7\">" + EOL +
- " <vnf-id>a27ce5a9-29c4-4c22-a017-6615ac73c721</vnf-id>" + EOL +
- " <vnf-name>STMTN5MMSC21</vnf-name>" + EOL +
- " <vnf-type>mmsc-capacity</vnf-type>" + EOL +
- " <service-id>SDN-MOBILITY</service-id>" + EOL +
- " <equipment-role>vMMSC</equipment-role>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <in-maint>false</in-maint>" + EOL +
- " <is-closed-loop-disabled>false</is-closed-loop-disabled>" + EOL +
- " <resource-version>0000021</resource-version>" + EOL +
- " <vf-modules>" + EOL +
- " <vf-module>" + EOL +
- " <vf-module-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</vf-module-id>" + EOL +
- " <vf-module-name>STMTN5MMSC21-MMSC::module-0-0</vf-module-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <is-base-vf-module>true</is-base-vf-module>" + EOL +
- " <heat-stack-id>FILLED-IN-BY-MSO</heat-stack-id>" + EOL +
- " <orchestration-status>pending-create</orchestration-status>" + EOL +
- " <resource-version>0000073</resource-version>" + EOL +
- " </vf-module>" + EOL +
- " </vf-modules>" + EOL +
- " <relationship-list/>" + EOL +
- " <l-interfaces/>" + EOL +
- " <lag-interfaces/>" + EOL +
- "</generic-vnf>" + EOL;
- stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a73"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody(body)));
- }
- public static void MockAAIDeleteGenericVnf(){
- stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/[?]resource-version=0000021"))
- .willReturn(aResponse()
- .withStatus(200)));
- stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718/[?]resource-version=0000018"))
- .willReturn(aResponse()
- .withStatus(500)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("aaiFault.xml")));
- }
-
- public static void MockAAIDeleteVfModule(){
- stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c721/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a73/[?]resource-version=0000073"))
- .willReturn(aResponse()
- .withStatus(200)));
- stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c720/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a75/[?]resource-version=0000075"))
- .willReturn(aResponse()
- .withStatus(200)));
- stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c718/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a78/[?]resource-version=0000078"))
- .willReturn(aResponse()
- .withStatus(200)));
- stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/a27ce5a9-29c4-4c22-a017-6615ac73c719/vf-modules/vf-module/973ed047-d251-4fb9-bf1a-65b8949e0a77/[?]resource-version=0000077"))
- .willReturn(aResponse()
- .withStatus(500)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("aaiFault.xml")));
- stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy\\?network-policy-fqdn=.*"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBodyFile("VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml")));
-
- stubFor(delete(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*"))
- .willReturn(aResponse()
- .withStatus(200)));
- }
-}
-
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/FalloutHandlerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/FalloutHandlerTest.java deleted file mode 100644 index c3259a0de5..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/FalloutHandlerTest.java +++ /dev/null @@ -1,235 +0,0 @@ -/*-
- * ============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.openecomp.mso.bpmn.common;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow;
-import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.camunda.bpm.engine.test.Deployment;
-import org.junit.Assert;
-import org.junit.Test;
-import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
-
-/**
- * Unit test for FalloutHandler.bpmn.
- */
-public class FalloutHandlerTest extends WorkflowTest {
- private void setupMocks() {
- stubFor(post(urlEqualTo("/dbadapters/MsoRequestsDbAdapter"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody("<DbTag>Notified</DbTag>")));
- stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "text/xml")
- .withBody("<DbTag>Notified</DbTag>")));
- }
-
- private void executeFlow(String inputRequestFile) throws InterruptedException {
- String method = getClass().getSimpleName() + "." + new Object() {
- }.getClass().getEnclosingMethod().getName();
- System.out.println("STARTED TEST: " + method);
-
- //String changeFeatureActivateRequest = FileUtil.readResourceFile("__files/SDN-ETHERNET-INTERNET/ChangeFeatureActivateV1/" + inputRequestFile);
- Map<String, String> variables = new HashMap<>();
- variables.put("FalloutHandlerRequest",inputRequestFile);
-
- WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "FalloutHandler", variables);
- waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId());
- System.out.println("ENDED TEST: " + method);
- }
-
- @Test
- @Deployment(resources = {"subprocess/FalloutHandler.bpmn",
- "subprocess/GenericNotificationService.bpmn"
- })
- public void msoFalloutHandlerWithNotificationurl_200() throws Exception{
- String method = getClass().getSimpleName() + "." + new Object() {
- }.getClass().getEnclosingMethod().getName();
- System.out.println("STARTED TEST: " + method);
-
- //Setup Mocks
- setupMocks();
- //Execute Flow
- executeFlow(gMsoFalloutHandlerWithNotificationurl());
- //Verify Error
- String FH_ResponseCode = BPMNUtil.getVariable(processEngineRule, "FalloutHandler", "FH_ResponseCode");
- Assert.assertEquals("200", FH_ResponseCode);
- Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "FalloutHandler", "FH_SuccessIndicator"));
- }
-
- public String gMsoFalloutHandlerWithNotificationurl() {
- //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
- String xml = ""
- + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:ns7=\"http://org.openecomp/mso/request/types/v1\">"
- + " <ns7:request-information>"
- + " <ns7:request-id>uCPE1020_STUW105_5002</ns7:request-id>"
- + " <ns7:request-action>Layer3ServiceActivateRequest</ns7:request-action>"
- + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
- + " <ns7:source>OMX</ns7:source>"
- + " <ns7:notification-url>http://localhost:28090/CCD/StatusNotification</ns7:notification-url>"
- + " <ns7:order-number>10205000</ns7:order-number>"
- + " <ns7:order-version>1</ns7:order-version>"
- + " </ns7:request-information>"
- + " <sdncadapterworkflow:WorkflowException>"
- + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
- + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
- + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
- + " </sdncadapterworkflow:WorkflowException>"
- + "</sdncadapterworkflow:FalloutHandlerRequest>";
-
- return xml;
-
- }
-
-
-
-
- @Test
- @Deployment(resources = {"subprocess/FalloutHandler.bpmn"})
- public void msoFalloutHandlerWithNoNotificationurl() throws Exception{
- String method = getClass().getSimpleName() + "." + new Object() {
- }.getClass().getEnclosingMethod().getName();
- System.out.println("STARTED TEST: " + method);
- //Setup Mocks
- setupMocks();
- //Execute Flow
- executeFlow(gMsoFalloutHandlerWithNoNotificationurl());
- //Verify Error
- String FH_ResponseCode = BPMNUtil.getVariable(processEngineRule, "FalloutHandler", "FH_ResponseCode");
- Assert.assertEquals("200", FH_ResponseCode);
- Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "FalloutHandler", "FH_SuccessIndicator"));
- }
-
- public String gMsoFalloutHandlerWithNoNotificationurl() {
- //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
- String xml = ""
- + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:ns7=\"http://org.openecomp/mso/request/types/v1\">"
- + " <ns7:request-information>"
- + " <ns7:request-id>uCPE1020_STUW105_5002</ns7:request-id>"
- + " <ns7:request-action>Layer3ServiceActivateRequest</ns7:request-action>"
- + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
- + " <ns7:source>OMX</ns7:source>"
- + " <ns7:notification-url></ns7:notification-url>"
- + " <ns7:order-number>10205000</ns7:order-number>"
- + " <ns7:order-version>1</ns7:order-version>"
- + " </ns7:request-information>"
- + " <sdncadapterworkflow:WorkflowException>"
- + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
- + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
- + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
- + " </sdncadapterworkflow:WorkflowException>"
- + "</sdncadapterworkflow:FalloutHandlerRequest>";
-
- return xml;
- }
-
- @Test
- @Deployment(resources = {"subprocess/FalloutHandler.bpmn",
- "subprocess/GenericNotificationService.bpmn"
- })
- public void msoFalloutHandlerWithNotificationurlNoRequestId() throws Exception{
- String method = getClass().getSimpleName() + "." + new Object() {
- }.getClass().getEnclosingMethod().getName();
- System.out.println("STARTED TEST: " + method);
- //Setup Mocks
- setupMocks();
- //Execute Flow
- executeFlow(gMsoFalloutHandlerWithNotificationurlNoRequestId());
- //Verify Error
- String FH_ResponseCode = BPMNUtil.getVariable(processEngineRule, "FalloutHandler", "FH_ResponseCode");
- Assert.assertEquals("200", FH_ResponseCode);
- Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "FalloutHandler", "FH_SuccessIndicator"));
- }
-
- public String gMsoFalloutHandlerWithNotificationurlNoRequestId() {
- //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
- String xml = ""
- + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:ns7=\"http://org.openecomp/mso/request/types/v1\">"
- + " <ns7:request-information>"
- + " <ns7:request-id></ns7:request-id>"
- + " <ns7:request-action>Layer3ServiceActivateRequest</ns7:request-action>"
- + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
- + " <ns7:source>OMX</ns7:source>"
- + " <ns7:notification-url>www.test.com</ns7:notification-url>"
- + " <ns7:order-number>10205000</ns7:order-number>"
- + " <ns7:order-version>1</ns7:order-version>"
- + " </ns7:request-information>"
- + " <sdncadapterworkflow:WorkflowException>"
- + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
- + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
- + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
- + " </sdncadapterworkflow:WorkflowException>"
- + "</sdncadapterworkflow:FalloutHandlerRequest>";
-
- return xml;
- }
-
- @Test
- @Deployment(resources = {"subprocess/FalloutHandler.bpmn"})
- public void msoFalloutHandlerWithNoNotificationurlNoRequestId() throws Exception{
- String method = getClass().getSimpleName() + "." + new Object() {
- }.getClass().getEnclosingMethod().getName();
- System.out.println("STARTED TEST: " + method);
- //Setup Mocks
- setupMocks();
- //Execute Flow
- executeFlow(gMsoFalloutHandlerWithNoNotificationurlNoRequestId());
- //Verify Error
- String FH_ResponseCode = BPMNUtil.getVariable(processEngineRule, "FalloutHandler", "FH_ResponseCode");
- Assert.assertEquals("200", FH_ResponseCode);
- Assert.assertTrue((boolean) BPMNUtil.getRawVariable(processEngineRule, "FalloutHandler", "FH_SuccessIndicator"));
- }
-
- public String gMsoFalloutHandlerWithNoNotificationurlNoRequestId() {
- //Generated the below XML from ActiveVOS moduler ... Using the generate sample XML feature in ActiveVOS
- String xml = ""
- + "<sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:ns7=\"http://org.openecomp/mso/request/types/v1\">"
- + " <ns7:request-information>"
- + " <ns7:request-id></ns7:request-id>"
- + " <ns7:request-action>Layer3ServiceActivateRequest</ns7:request-action>"
- + " <ns7:request-sub-action>CANCEL</ns7:request-sub-action>"
- + " <ns7:source>OMX</ns7:source>"
- + " <ns7:notification-url></ns7:notification-url>"
- + " <ns7:order-number>10205000</ns7:order-number>"
- + " <ns7:order-version>1</ns7:order-version>"
- + " </ns7:request-information>"
- + " <sdncadapterworkflow:WorkflowException>"
- + " <sdncadapterworkflow:ErrorMessage>Some Error Message - Fallout Handler</sdncadapterworkflow:ErrorMessage>"
- + " <sdncadapterworkflow:ErrorCode>Some Error Code - Fallout Handler</sdncadapterworkflow:ErrorCode>"
- + " <sdncadapterworkflow:SourceSystemErrorCode>Some Source System Error Code- Fallout Handler</sdncadapterworkflow:SourceSystemErrorCode>"
- + " </sdncadapterworkflow:WorkflowException>"
- + "</sdncadapterworkflow:FalloutHandlerRequest>";
-
- return xml;
- }
-
-}
-
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenerateVfModuleNameTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenerateVfModuleNameTest.java deleted file mode 100644 index 051d935527..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenerateVfModuleNameTest.java +++ /dev/null @@ -1,78 +0,0 @@ -/*- - * ============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.openecomp.mso.bpmn.common;
-
-import static org.junit.Assert.assertNotNull;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.camunda.bpm.engine.RuntimeService;
-import org.camunda.bpm.engine.test.Deployment;
-import org.junit.Test;
-
-/**
- * Unit test for GenerateVfModuleName.bpmn.
- */
-public class GenerateVfModuleNameTest extends WorkflowTest {
- private static final String EOL = "\n";
-
- @Test
- @Deployment(resources = {
- "subprocess/GenerateVfModuleName.bpmn"
- })
- public void TestGenerateVfModuleNameSuvvess() {
- //
- String request =
- "<vnf-request xmlns=\"http://ecomp.att.com/mso/infra/vnf-request/v1\">" + EOL +
- " <request-info>" + EOL +
- " <action>CREATE_VF_MODULE</action>" + EOL +
- " <source>PORTAL</source>" + EOL +
- " </request-info>" + EOL +
- " <vnf-inputs>" + EOL +
- " <vnf-name>STMTN5MMSC22</vnf-name>" + EOL +
- " <vf-module-name>STMTN5MMSC22-MMSC::module-0-0</vf-module-name>" + EOL +
- " <vf-module-model-name>MMSC::module-0</vf-module-model-name>" + EOL +
- " <persona-model-id>973ed047-d251-4fb9-bf1a-65b8949e0a73</persona-model-id>" + EOL +
- " <persona-model-version>1.0</persona-model-version>" + EOL +
- " <service-id>00000000-0000-0000-0000-000000000000</service-id>" + EOL +
- " <aic-node-clli>MDTWNJ21</aic-node-clli>" + EOL +
- " <tenant-id>fba1bd1e195a404cacb9ce17a9b2b421</tenant-id>" + EOL +
- " </vnf-inputs>" + EOL +
- " <vnf-params xmlns:tns=\"http://ecomp.att.com/mso/infra/vnf-request/v1\"/>" + EOL +
- "</vnf-request>" + EOL;
-
- MockGetGenericVnfById(".*", "GenericFlows/getGenericVnfByNameResponse.xml");
- RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("isDebugLogEnabled","true");
- variables.put("vnfName", "STMTN5MMSC20");
- variables.put("vfModuleLabel", "ModuleLabel1");
- variables.put("personaModelId", "extrovert");
- variables.put("vnfId", "12345678-f41f-4822-9323-b75962763d74");
-
- runtimeService.startProcessInstanceByKey("GenerateVfModuleName", variables);
- String response = BPMNUtil.getVariable(processEngineRule, "GenerateVfModuleName", "vfModuleName");
-
- assertNotNull(response);
- }
-}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericDeleteServiceTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericDeleteServiceTest.java deleted file mode 100644 index 67ac34c1d0..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericDeleteServiceTest.java +++ /dev/null @@ -1,279 +0,0 @@ -/* - * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. - */ -/*- - * ============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.openecomp.mso.bpmn.common; - -import static org.junit.Assert.assertEquals; -import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow; -import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteServiceInstance; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteServiceInstance_404; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance_404; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance_500; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceSubscription; - -import java.util.HashMap; -import java.util.Map; - -import org.camunda.bpm.engine.test.Deployment; -import org.junit.Test; -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; - - - -/** - * Please describe the GenericDeleteServiceTest.java class - * - */ -public class GenericDeleteServiceTest extends WorkflowTest { - @Test - @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"}) - public void testGenericDeleteService_success_serviceInstance() throws Exception{ - MockDeleteServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", "1234"); - Map<String, String> variables = new HashMap<>(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234"); - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator"); - String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator"); - String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException"); - assertEquals("true", foundIndicator); - assertEquals("true", successIndicator); - assertEquals("true", resourceVersionProvidedFlag); - assertEquals(null, workflowException); - } - @Test - @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"}) - public void testGenericDeleteService_success_serviceSubscription() throws Exception{ - - MockDeleteServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234", 204); - - Map<String, String> variables = new HashMap<>(); - setVariablesSubscription(variables, "", "1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator"); - String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator"); - String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException"); - - assertEquals("true", foundIndicator); - assertEquals("true", successIndicator); - assertEquals("true", resourceVersionProvidedFlag); - assertEquals(null, workflowException); - - } - - @Test - @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"}) - public void testGenericDeleteService_success_instanceNoResourceVersion() throws Exception { - MockGetServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceSubscription.xml"); - MockDeleteServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", "1234"); - - Map<String, String> variables = new HashMap<>(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", null); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator"); - String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator"); - String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException"); - - assertEquals("true", foundIndicator); - assertEquals("true", successIndicator); - assertEquals("false", resourceVersionProvidedFlag); - assertEquals(null, workflowException); - - } - - @Test - @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"}) - public void testGenericDeleteService_success_subscriptionNoResourceVersion() throws Exception{ - MockGetServiceSubscription("1604-MVM-26", "SDN-ETHERNET-INTERNET", "GenericFlows/getServiceSubscription.xml"); - MockDeleteServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234", 204); - - Map<String, String> variables = new HashMap<>(); - setVariablesSubscription(variables, null, "1604-MVM-26", "SDN-ETHERNET-INTERNET", null); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator"); - String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator"); - String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException"); - - assertEquals("true", foundIndicator); - assertEquals("true", successIndicator); - assertEquals("false", resourceVersionProvidedFlag); - assertEquals(null, workflowException); - - } - - @Test - @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"}) - public void testGenericDeleteService_success_get404Response() throws Exception{ - - MockGetServiceInstance_404("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET"); - - Map<String, String> variables = new HashMap<>(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", null); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator"); - String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator"); - String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException"); - - assertEquals("false", foundIndicator); - assertEquals("true", successIndicator); - assertEquals("false", resourceVersionProvidedFlag); - assertEquals(null, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"}) - public void testGenericDeleteService_success_subscriptionGetEmpty200() throws Exception{ - MockGetServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234", 200); - - Map<String, String> variables = new HashMap<>(); - setVariablesSubscription(variables, "", "1604-MVM-26", "SDN-ETHERNET-INTERNET", ""); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator"); - String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator"); - String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException"); - - assertEquals("false", foundIndicator); - assertEquals("true", successIndicator); - assertEquals("false", resourceVersionProvidedFlag); - assertEquals(null, workflowException); - - } - - @Test - @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"}) - public void testGenericDeleteService_success_delete404Response() throws Exception{ - - MockGetServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", "GENDSI_getServiceInstanceResponse.xml"); - MockDeleteServiceInstance_404("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", "1234"); - - Map<String, String> variables = new HashMap<>(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", "1234"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator"); - String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator"); - String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException"); - - assertEquals("false", foundIndicator); - assertEquals("true", successIndicator); - assertEquals("true", resourceVersionProvidedFlag); - assertEquals(null, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"}) - public void testGenericDeleteService_error_invalidVariables() throws Exception{ - - Map<String, String> variables = new HashMap<>(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "1234"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator"); - String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator"); - String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException"); - - String expectedResponse = "WorkflowException[processKey=GenericDeleteService,errorCode=500,errorMessage=Incoming Required Variable is Missing or Null!]"; - - assertEquals("false", foundIndicator); - assertEquals("false", successIndicator); - assertEquals("true", resourceVersionProvidedFlag); - assertEquals(expectedResponse, workflowException); - - } - - @Test - @Deployment(resources = {"subprocess/GenericDeleteService.bpmn"}) - public void testGenericDeleteService_error_getBadAAIResponse() throws Exception{ - - MockGetServiceInstance_500("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", "aaiFault.xml"); - - Map<String, String> variables = new HashMap<>(); - setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", null); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteService", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_SuccessIndicator"); - String foundIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_FoundIndicator"); - String resourceVersionProvidedFlag = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "GENDS_resourceVersionProvidedFlag"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteService", "WorkflowException"); - - String expectedResponse = "WorkflowException[processKey=GenericDeleteService,errorCode=500,errorMessage=<requestError><serviceException><messageId>SVC3002</messageId><text>Error writing output performing %1 on %2 (msg=%3) (ec=%4)</text><variables><variable>PUTcustomer</variable><variable>SubName01</variable><variable>Unexpected error reading/updating database:Adding this property for key [service-instance-id] and value [USSTU2CFCNC0101UJZZ01] violates a uniqueness constraint [service-instance-id]</variable><variable>ERR.5.4.5105</variable></variables></serviceException></requestError>" + "\n" + - "]"; - - assertEquals("false", foundIndicator); - assertEquals("false", successIndicator); - assertEquals("false", resourceVersionProvidedFlag); - assertEquals(expectedResponse, workflowException); - } - - - private void setVariablesInstance(Map<String, String> variables, String siId, String globalCustId, String serviceType, String reVersion) { - variables.put("isDebugLogEnabled", "true"); - variables.put("GENDS_serviceInstanceId", siId); - variables.put("GENDS_globalCustomerId",globalCustId); - variables.put("GENDS_serviceType", serviceType); - variables.put("GENDS_resourceVersion", reVersion); - variables.put("GENDS_type", "service-instance"); - } - - private void setVariablesSubscription(Map<String, String> variables, String siId, String globalCustId, String serviceType, String reVersion) { - variables.put("isDebugLogEnabled", "true"); - variables.put("GENDS_serviceInstanceId", siId); - variables.put("GENDS_globalCustomerId",globalCustId); - variables.put("GENDS_serviceType", serviceType); - variables.put("GENDS_resourceVersion", reVersion); - variables.put("GENDS_type", "service-subscription"); - } - - -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericDeleteVnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericDeleteVnfTest.java deleted file mode 100644 index a318be5b10..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericDeleteVnfTest.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. - */ -/*- - * ============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.openecomp.mso.bpmn.common; - -import static org.junit.Assert.assertEquals; -import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow; -import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteGenericVnf; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteGenericVnf_500; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDeleteVce; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_404; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVceById; - -import java.util.HashMap; -import java.util.Map; - -import org.camunda.bpm.engine.test.Deployment; -import org.junit.Test; -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; - -/** - * Please describe the GenericDeleteVnfTest.java class - * - */ -public class GenericDeleteVnfTest extends WorkflowTest { - - @Test - @Deployment(resources = {"subprocess/GenericDeleteVnf.bpmn"}) - public void testGenericDeleteVnf_success_genericVnf() throws Exception{ - MockDeleteGenericVnf("testVnfId123", "testReVer123"); - - Map<String, String> variables = new HashMap<>(); - setVariables(variables, "testVnfId123", "generic-vnf", "testReVer123"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - assertVariables("true", "true", "true", null); - - } - - @Test - @Deployment(resources = {"subprocess/GenericDeleteVnf.bpmn"}) - public void testGenericDeleteVnf_success_vce() throws Exception{ - MockDeleteVce("testVnfId123", "testReVer123", 204); - - Map<String, String> variables = new HashMap<>(); - setVariables(variables, "testVnfId123", "vce", "testReVer123"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - assertVariables("true", "true", "true", null); - - } - - @Test - @Deployment(resources = {"subprocess/GenericDeleteVnf.bpmn"}) - public void testGenericDeleteVnf_success_genericVnfNoResourceVersion() throws Exception{ - - MockGetGenericVnfById("/testVnfId123", "GenericFlows/getGenericVnfByNameResponse.xml", 200); - MockDeleteGenericVnf("testVnfId123", "testReVer123"); - - Map<String, String> variables = new HashMap<>(); - setVariables(variables, "testVnfId123", "generic-vnf", ""); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - assertVariables("true", "true", "false", null); - - } - - @Test - @Deployment(resources = {"subprocess/GenericDeleteVnf.bpmn"}) - public void testGenericDeleteVnf_success_vceNoResourceVersion() throws Exception{ - MockDeleteVce("testVnfId123", "testReVer123", 204); - MockGetVceById("testVnfId123", "GenericFlows/getVceResponse.xml"); - - Map<String, String> variables = new HashMap<>(); - setVariables(variables, "testVnfId123", "vce", null); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - assertVariables("true", "true", "false", null); - - } - - @Test - @Deployment(resources = {"subprocess/GenericDeleteVnf.bpmn"}) - public void testGenericDeleteVnf_success_genericVnf404() throws Exception{ - MockDeleteGenericVnf("testVnfId123", "testReVer123", 404); - - Map<String, String> variables = new HashMap<>(); - setVariables(variables, "testVnfId123", "generic-vnf", "testReVer123"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - assertVariables("true", "false", "true", null); - - } - - @Test - @Deployment(resources = {"subprocess/GenericDeleteVnf.bpmn"}) - public void testGenericDeleteVnf_success_vce404() throws Exception{ - MockDeleteVce("testVnfId123", "testReVer123", 404); - - Map<String, String> variables = new HashMap<>(); - setVariables(variables, "testVnfId123", "vce", "testReVer123"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - assertVariables("true", "false", "true", null); - - } - - @Test - @Deployment(resources = {"subprocess/GenericDeleteVnf.bpmn"}) - public void testGenericDeleteVnf_success_genericVnfNoResourceVersion404() throws Exception{ - MockGetGenericVnfById_404("testVnfId123"); - - Map<String, String> variables = new HashMap<>(); - setVariables(variables, "testVnfId123", "generic-vnf", ""); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - assertVariables("true", "false", "false", null); - - } - - @Test - @Deployment(resources = {"subprocess/GenericDeleteVnf.bpmn"}) - public void testGenericDeleteVnf_error_missingVariables() throws Exception{ - - Map<String, String> variables = new HashMap<>(); - setVariables(variables, "testVnfId123", "", "testReVer123"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - assertVariables("false", "false", "true", "WorkflowException[processKey=GenericDeleteVnf,errorCode=500,errorMessage=Incoming Required Variable is Missing or Null!]"); - - } - - @Test - @Deployment(resources = {"subprocess/GenericDeleteVnf.bpmn"}) - public void testGenericDeleteVnf_error_genericVnf500() throws Exception{ - - MockDeleteGenericVnf_500("testVnfId123", "testReVer123"); - Map<String, String> variables = new HashMap<>(); - setVariables(variables, "testVnfId123", "generic-vnf", "testReVer123"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - assertVariables("false", "false", "true", "WorkflowException[processKey=GenericDeleteVnf,errorCode=500,errorMessage=Received a bad response from AAI]"); - - } - - @Test - @Deployment(resources = {"subprocess/GenericDeleteVnf.bpmn"}) - public void testGenericDeleteVnf_error_genericVnf412() throws Exception{ - MockDeleteGenericVnf("testVnfId123", "testReVer123", 412); - - Map<String, String> variables = new HashMap<>(); - setVariables(variables, "testVnfId123", "generic-vnf", "testReVer123"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericDeleteVnf", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - assertVariables("false", "false", "true", "WorkflowException[processKey=GenericDeleteVnf,errorCode=412,errorMessage=Delete Vnf Received a resource-version Mismatch Error Response from AAI]"); - - } - - private void assertVariables(String exSuccessIndicator, String exFound, String exRVProvided, String exWorkflowException) { - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericDeleteVnf", "GENDV_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericDeleteVnf", "GENDV_FoundIndicator"); - String rvProvided = BPMNUtil.getVariable(processEngineRule, "GenericDeleteVnf", "GENDV_resourceVersionProvided"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericDeleteVnf", "WorkflowException"); - - assertEquals(exSuccessIndicator, successIndicator); - assertEquals(exFound, found); - assertEquals(exRVProvided, rvProvided); - assertEquals(exWorkflowException, workflowException); - } - - private void setVariables(Map<String, String> variables, String vnfId, String type, String resourceVer) { - variables.put("isDebugLogEnabled", "true"); - variables.put("GENDV_vnfId", vnfId); - variables.put("GENDV_type", type); - variables.put("GENDV_resourceVersion", resourceVer); - } - -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetServiceTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetServiceTest.java deleted file mode 100644 index 6da6924d11..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetServiceTest.java +++ /dev/null @@ -1,560 +0,0 @@ -/*
- * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property.
- */
-/*-
- * ============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.openecomp.mso.bpmn.common;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow;
-import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance_404;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceInstance_500;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetServiceSubscription;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById_404;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById_500;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName_404;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceByName_500;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.camunda.bpm.engine.test.Deployment;
-import org.junit.Test;
-import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
-
-
-/**
- * Unit Test for the GenericGetService Sub Flow
- */
-public class GenericGetServiceTest extends WorkflowTest {
-
-
- @Test
- @Deployment(resources = {"subprocess/GenericGetService.bpmn"})
- public void testGenericGetService_success_serviceInstance() throws Exception{
- MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml");
- Map<String, String> variables = new HashMap<>();
- setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789");
- WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
- waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId());
- String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");
- String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");
- String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");
- String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");
- String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse");
- String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");
- assertEquals("true", successIndicator);
- assertEquals("true", found);
- assertEquals("false", obtainUrl);
- assertEquals("false", byName);
- assertNotNull(response);
- assertEquals(null, workflowException);
- }
-
-
- @Test
- @Deployment(resources = {"subprocess/GenericGetService.bpmn"})
- public void testGenericGetService_success_serviceSubscription() throws Exception{
-
- MockGetServiceSubscription("1604-MVM-26", "SDN-ETHERNET-INTERNET", "GenericFlows/getServiceSubscription.xml");
-
- Map<String, String> variables = new HashMap<>();
- setVariablesSubscription(variables, "", null , "1604-MVM-26", "SDN-ETHERNET-INTERNET");
-
- WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
- waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId());
-
- String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");
- String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");
- String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");
- String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");
- String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse");
- String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");
-
- assertEquals("true", successIndicator);
- assertEquals("true", found);
- assertEquals("false", obtainUrl);
- assertEquals("false", byName);
- assertNotNull(response);
- assertEquals(null, workflowException);
- }
-
- @Test
- @Deployment(resources = {"subprocess/GenericGetService.bpmn"})
- public void testGenericGetService_success_serviceInstance_byName() throws Exception{
-
- MockNodeQueryServiceInstanceByName("1604-MVM-26", "GenericFlows/getSIUrlByName.xml");
- MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml");
-
- Map<String, String> variables = new HashMap<>();
- setVariablesInstance(variables, null, "1604-MVM-26", null, null);
-
- WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
- waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId());
-
- String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");
- String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");
- String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");
- String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");
- String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse");
- String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");
- String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode");
-
- assertEquals("true", successIndicator);
- assertEquals("true", found);
- assertEquals("true", obtainUrl);
- assertEquals("true", byName);
- assertNotNull(response);
- assertEquals("200", siUrlResponseCode);
- assertEquals(null, workflowException);
- }
-
- @Test
- @Deployment(resources = {"subprocess/GenericGetService.bpmn"})
- public void testGenericGetService_success_serviceInstance_byId() throws Exception{
-
- MockNodeQueryServiceInstanceById("MIS%2F1604%2F0026%2FSW_INTERNET", "GenericFlows/getSIUrlById.xml");
- MockGetServiceInstance("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml");
-
- Map<String, String> variables = new HashMap<>();
- setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null);
-
- WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
- waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId());
-
- String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");
- String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");
- String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");
- String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");
- String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse");
- String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");
- String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_genericQueryResponseCode");
-
- assertEquals("true", successIndicator);
- assertEquals("true", found);
- assertEquals("true", obtainUrl);
- assertEquals("false", byName);
- assertNotNull(response);
- assertEquals("200", siUrlResponseCode);
- assertEquals(null, workflowException);
- }
-
- @Test
- @Deployment(resources = {"subprocess/GenericGetService.bpmn"})
- public void testGenericGetService_success_serviceInstance_404Response() throws Exception{
-
- MockGetServiceInstance_404("SDN-ETHERNET-INTERNET", "123456789", "MIS%2F1604%2F0026%2FSW_INTERNET");
-
- Map<String, String> variables = new HashMap<>();
- setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789");
-
- WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
- waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId());
-
- String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");
- String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");
- String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");
- String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");
- String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");
-
- assertEquals("true", successIndicator);
- assertEquals("false", found);
- assertEquals("false", obtainUrl);
- assertEquals("false", byName);
- assertEquals(null, workflowException);
- }
-
- @Test
- @Deployment(resources = {"subprocess/GenericGetService.bpmn"})
- public void testGenericGetService_success_serviceSubscription404() throws Exception{
- MockGetServiceSubscription("1604-MVM-26", "SDN-ETHERNET-INTERNET", 404);
-
- Map<String, String> variables = new HashMap<>();
- setVariablesSubscription(variables, "", "", "SDN-ETHERNET-INTERNET", "1604-MVM-26");
-
- WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
- waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId());
-
- String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");
- String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");
- String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");
- String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");
- String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse");
- String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");
-
- assertEquals("true", successIndicator);
- assertEquals("false", found);
- assertEquals("false", obtainUrl);
- assertEquals("false", byName);
- assertNotNull(response);
- assertEquals(null, workflowException);
- }
-
- @Test
- @Deployment(resources = {"subprocess/GenericGetService.bpmn"})
- public void testGenericGetService_success_serviceInstanceByName404() throws Exception{
-
- MockNodeQueryServiceInstanceByName_404("1604-MVM-26");
-
- Map<String, String> variables = new HashMap<>();
- setVariablesInstance(variables, "", "1604-MVM-26", null, null);
-
- WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
- waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId());
-
- String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");
- String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");
- String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");
- String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");
- String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");
- String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode");
-
- assertEquals("true", successIndicator);
- assertEquals("false", found);
- assertEquals("true", obtainUrl);
- assertEquals("true", byName);
- assertEquals("404", siUrlResponseCode);
- assertEquals(null, workflowException);
- }
-
- @Test
- @Deployment(resources = {"subprocess/GenericGetService.bpmn"})
- public void testGenericGetService_success_serviceInstanceById404() throws Exception{
-
- MockNodeQueryServiceInstanceById_404("MIS%2F1604%2F0026%2FSW_INTERNET");
-
- Map<String, String> variables = new HashMap<>();
- setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null);
-
- WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
- waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId());
-
- String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");
- String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");
- String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");
- String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");
- String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");
- String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_genericQueryResponseCode");
-
- assertEquals("true", successIndicator);
- assertEquals("false", found);
- assertEquals("true", obtainUrl);
- assertEquals("false", byName);
- assertEquals("404", siUrlResponseCode);
- assertEquals(null, workflowException);
- }
-
- @Test
- @Deployment(resources = {"subprocess/GenericGetService.bpmn"})
- public void testGenericGetService_success_serviceInstanceEmptyResponse() throws Exception{
-
- MockGetServiceInstance("1604-MVM-26", "SDN-ETHERNET-INTERNET", "MIS%252F1604%252F0026%252FSW_INTERNET", " ");
-
- Map<String, String> variables = new HashMap<>();
- setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, "SDN-ETHERNET-INTERNET", "123456789");
-
- WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
- waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId());
-
- String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");
- String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");
- String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");
- String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");
- String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");
-
- assertEquals("true", successIndicator);
- assertEquals("false", found);
- assertEquals("false", obtainUrl);
- assertEquals("false", byName);
- assertEquals(null, workflowException);
- }
-
- @Test
- @Deployment(resources = {"subprocess/GenericGetService.bpmn"})
- public void testGenericGetService_success_serviceInstanceByNameEmpty() throws Exception{
- MockNodeQueryServiceInstanceByName("1604-MVM-26", "");
-
- Map<String, String> variables = new HashMap<>();
- setVariablesInstance(variables, "", "1604-MVM-26", null, null);
-
- WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
- waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId());
-
- String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");
- String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");
- String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");
- String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");
- String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");
- String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode");
-
- assertEquals("true", successIndicator);
- assertEquals("false", found);
- assertEquals("true", obtainUrl);
- assertEquals("true", byName);
- assertEquals("200", siUrlResponseCode);
- assertEquals(null, workflowException);
- }
-
- @Test
- @Deployment(resources = {"subprocess/GenericGetService.bpmn"})
- public void testGenericGetService_success_serviceInstanceByIdEmpty() throws Exception{
-
- MockNodeQueryServiceInstanceById("MIS[%]2F1604[%]2F0026[%]2FSW_INTERNET", "");
-
- Map<String, String> variables = new HashMap<>();
- setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null);
-
- WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
- waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId());
-
- String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");
- String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");
- String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");
- String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");
- String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");
- String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_genericQueryResponseCode");
-
- assertEquals("true", successIndicator);
- assertEquals("false", found);
- assertEquals("true", obtainUrl);
- assertEquals("false", byName);
- assertEquals("200", siUrlResponseCode);
- assertEquals(null, workflowException);
- }
-
-
- @Test
- @Deployment(resources = {"subprocess/GenericGetService.bpmn"})
- public void testGenericGetService_error_serviceInstanceInvalidVariables() throws Exception{
-
- Map<String, String> variables = new HashMap<>();
- setVariablesInstance(variables, null, null, "SDN-ETHERNET-INTERNET", null);
-
- WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
- waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId());
-
- String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");
- String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");
- String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");
- String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");
- String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");
-
- String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Incoming serviceInstanceId and serviceInstanceName are null. ServiceInstanceId or ServiceInstanceName is required to Get a service-instance.]";
-
- assertEquals("false", successIndicator);
- assertEquals("false", found);
- assertEquals("false", obtainUrl);
- assertEquals("false", byName);
- assertEquals(expectedWorkflowException, workflowException);
- }
-
- @Test
- @Deployment(resources = {"subprocess/GenericGetService.bpmn"})
- public void testGenericGetService_success_serviceSubscriptionInvalidVariables() throws Exception{
-
- Map<String, String> variables = new HashMap<>();
- setVariablesSubscription(variables, "", "", "SDN-ETHERNET-INTERNET", null);
-
- WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
- waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId());
-
- String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");
- String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");
- String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");
- String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");
- String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");
-
- String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Incoming ServiceType or GlobalCustomerId is null. These variables are required to Get a service-subscription.]";
-
-
- assertEquals("false", successIndicator);
- assertEquals("false", found);
- assertEquals("false", obtainUrl);
- assertEquals("false", byName);
- assertEquals(expectedWorkflowException, workflowException);
- }
-
- @Test
- @Deployment(resources = {"subprocess/GenericGetService.bpmn"})
- public void testGenericGetService_error_serviceInstance_getSIBadResponse() throws Exception{
-
- MockGetServiceInstance_500("SDN-ETHERNET-INTERNET", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET");
-
- Map<String, String> variables = new HashMap<>();
- setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", "1604-MVM-26", "SDN-ETHERNET-INTERNET", "123456789");
-
- WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
- waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId());
-
- String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");
- String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");
- String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");
- String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");
- String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");
-
- String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Received a bad response from AAI]";
-
- assertEquals("false", successIndicator);
- assertEquals("false", found);
- assertEquals("false", obtainUrl);
- assertEquals("false", byName);
- assertEquals(expectedWorkflowException, workflowException);
- }
-
- @Test
- @Deployment(resources = {"subprocess/GenericGetService.bpmn"})
- public void testGenericGetService_error_serviceInstance_getUrlByIdBadResponse() throws Exception{
-
- MockNodeQueryServiceInstanceById_500("MIS%2F1604%2F0026%2FSW_INTERNET");
-
- Map<String, String> variables = new HashMap<>();
- setVariablesInstance(variables, "MIS%2F1604%2F0026%2FSW_INTERNET", null, null, null);
-
- WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
- waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId());
-
- String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");
- String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");
- String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");
- String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");
- String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");
- String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_genericQueryResponseCode");
-
- String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Received a bad response from AAI]";
-
- assertEquals("false", successIndicator);
- assertEquals("false", found);
- assertEquals("true", obtainUrl);
- assertEquals("false", byName);
- assertEquals("500", siUrlResponseCode);
- assertEquals(expectedWorkflowException, workflowException);
- }
-
- @Test
- @Deployment(resources = {"subprocess/GenericGetService.bpmn"})
- public void testGenericGetService_error_serviceInstance_getUrlByNameBadResponse() throws Exception{
-
- MockNodeQueryServiceInstanceByName_500("1604-MVM-26");
-
- Map<String, String> variables = new HashMap<>();
- setVariablesInstance(variables, null, "1604-MVM-26", null, null);
-
- WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
- waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId());
-
- String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");
- String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");
- String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");
- String obtainUrl = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainObjectsUrl");
- String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainServiceInstanceUrlByName");
- String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode");
-
- String expectedWorkflowException = "WorkflowException[processKey=GenericGetService,errorCode=500,errorMessage=Received a bad response from AAI]";
-
- assertEquals("false", successIndicator);
- assertEquals("false", found);
- assertEquals("true", obtainUrl);
- assertEquals("true", byName);
- assertEquals("500", siUrlResponseCode);
- assertEquals(expectedWorkflowException, workflowException);
- }
-
- @Test
- @Deployment(resources = {"subprocess/GenericGetService.bpmn"})
- public void testGenericGetService_success_serviceInstance_byNameServicePresent() throws Exception{
-
- MockNodeQueryServiceInstanceByName("1604-MVM-26", "GenericFlows/getSIUrlByNameMultiCustomer.xml");
- MockGetServiceInstance("XyCorporation", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml");
-
- Map<String, String> variables = new HashMap<>();
- setVariablesInstance(variables, null, "1604-MVM-26", "XyCorporation", null);
-
- WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
- waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId());
-
- String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");
- String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");
- String resourceLink = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_resourceLink");
- String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse");
- String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");
- String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode");
-
- assertEquals("true", successIndicator);
- assertEquals("true", found);
- assertNotNull(resourceLink);
- assertNotNull(response);
- assertEquals("200", siUrlResponseCode);
- assertEquals(null, workflowException);
- }
-
- @Test
- @Deployment(resources = {"subprocess/GenericGetService.bpmn"})
- public void testGenericGetService_success_serviceInstance_byNameServiceNotPresent() throws Exception{
-
- MockNodeQueryServiceInstanceByName("1604-MVM-26", "GenericFlows/getSIUrlByNameMultiCustomer.xml");
- MockGetServiceInstance("CorporationNotPresent", "123456789", "MIS%252F1604%252F0026%252FSW_INTERNET", "GenericFlows/getServiceInstance.xml");
-
- Map<String, String> variables = new HashMap<>();
- setVariablesInstance(variables, null, "1604-MVM-26", "CorporationNotPresent", null);
-
- WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetService", variables);
- waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId());
-
- String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_SuccessIndicator");
- String found = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_FoundIndicator");
- String resourceLink = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_resourceLink");
- String response = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowResponse");
- String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "WorkflowException");
- String siUrlResponseCode = BPMNUtil.getVariable(processEngineRule, "GenericGetService", "GENGS_obtainSIUrlResponseCode");
-
- assertEquals("true", successIndicator);
- assertEquals("false", found);
- assertEquals(null, resourceLink);
- assertEquals(" ", response);
- assertEquals("200", siUrlResponseCode);
- assertEquals(null, workflowException);
- }
-
- private void setVariablesInstance(Map<String, String> variables, String siId, String siName, String globalCustId, String serviceType) {
- variables.put("isDebugLogEnabled", "true");
- variables.put("GENGS_serviceInstanceId", siId);
- variables.put("GENGS_serviceInstanceName", siName);
- variables.put("GENGS_globalCustomerId",globalCustId);
- variables.put("GENGS_serviceType", serviceType);
- variables.put("GENGS_type", "service-instance");
- }
-
- private void setVariablesSubscription(Map<String, String> variables, String siId, String siName, String globalCustId, String serviceType) {
- variables.put("isDebugLogEnabled", "true");
- variables.put("GENGS_serviceInstanceId", siId);
- variables.put("GENGS_serviceInstanceName", siName);
- variables.put("GENGS_globalCustomerId",globalCustId);
- variables.put("GENGS_serviceType", serviceType);
- variables.put("GENGS_type", "service-subscription");
- }
-
-
-}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetVnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetVnfTest.java deleted file mode 100644 index 7de493a621..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericGetVnfTest.java +++ /dev/null @@ -1,191 +0,0 @@ -/* - * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. - */ -/*- - * ============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.openecomp.mso.bpmn.common; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow; -import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_500; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByNameWithDepth; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVceByNameWithDepth; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVceById; - -import java.util.HashMap; -import java.util.Map; - -import org.camunda.bpm.engine.test.Deployment; -import org.junit.Ignore; -import org.junit.Test; -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; - -/** - * Please describe the GenericGetVnfTest.java class - * - */ -public class GenericGetVnfTest extends WorkflowTest { - - @Test - @Deployment(resources = {"subprocess/GenericGetVnf.bpmn"}) - public void testGenericGetVnf_success_genericVnf() throws Exception{ - MockGetGenericVnfByIdWithDepth("testVnfId123", 1, "GenericFlows/getGenericVnfByNameResponse.xml"); - - Map<String, String> variables = new HashMap<>(); - setVariables(variables, "testVnfId123", "testVnfName123", "generic-vnf"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetVnf", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_FoundIndicator"); - String vnf = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_vnf"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_getVnfByName"); - String response = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowResponse"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowException"); - - assertEquals("true", successIndicator); - assertEquals("true", found); - assertEquals("false", byName); - assertNotNull(response); - assertNotNull(vnf); - assertEquals(null, workflowException); - - } - - @Test - @Deployment(resources = {"subprocess/GenericGetVnf.bpmn"}) - public void testGenericGetVnf_success_vce() throws Exception{ - MockGetVceById("testVnfId123[?]depth=1", "GenericFlows/getVceResponse.xml"); - - Map<String, String> variables = new HashMap<>(); - setVariables(variables, "testVnfId123", "testVnfName123", "vce"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetVnf", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_FoundIndicator"); - String vnf = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_vnf"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_getVnfByName"); - String response = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowResponse"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowException"); - - assertEquals("true", successIndicator); - assertEquals("true", found); - assertEquals("false", byName); - assertNotNull(response); - assertNotNull(vnf); - assertEquals(null, workflowException); - - } - - @Test - @Deployment(resources = {"subprocess/GenericGetVnf.bpmn"}) - public void testGenericGetVnf_success_genericVnfByName() throws Exception{ - MockGetGenericVnfByNameWithDepth("testVnfName123", 1, "GenericFlows/getGenericVnfResponse.xml"); - - Map<String, String> variables = new HashMap<>(); - setVariables(variables, "", "testVnfName123", "generic-vnf"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetVnf", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_FoundIndicator"); - String vnf = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_vnf"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_getVnfByName"); - String response = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowResponse"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowException"); - - assertEquals("true", successIndicator); - assertEquals("true", found); - assertEquals("true", byName); - assertNotNull(response); - assertNotNull(vnf); - assertEquals(null, workflowException); - - } - - @Test - @Deployment(resources = {"subprocess/GenericGetVnf.bpmn"}) - public void testGenericGetVnf_success_vceByName() throws Exception{ - MockGetGenericVceByNameWithDepth("testVnfName123", 1, "GenericFlows/getVceByNameResponse.xml"); - - Map<String, String> variables = new HashMap<>(); - setVariables(variables, null, "testVnfName123", "vce"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetVnf", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_FoundIndicator"); - String vnf = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_vnf"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_getVnfByName"); - String response = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowResponse"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowException"); - - assertEquals("true", successIndicator); - assertEquals("true", found); - assertEquals("true", byName); - assertNotNull(response); - assertNotNull(vnf); - assertEquals(null, workflowException); - - } - - @Test - @Ignore // BROKEN TEST (previously ignored) - @Deployment(resources = {"subprocess/GenericGetVnf.bpmn"}) - public void testGenericGetVnf_error_genericVnf500() throws Exception{ - - MockGetGenericVnfById_500("testVnfId123"); - - Map<String, String> variables = new HashMap<>(); - setVariables(variables, "testVnfId123", "testVnfName123", "generic-vnf"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericGetVnf", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_SuccessIndicator"); - String found = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_FoundIndicator"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "WorkflowException"); - String byName = BPMNUtil.getVariable(processEngineRule, "GenericGetVnf", "GENGV_getVnfByName"); - - String expectedWorkflowException = "WorkflowException[processKey=GenericGetVnf,errorCode=500,errorMessage=Incoming VnfId and VnfName are null. VnfId or VnfName is required!]"; - - assertEquals("false", successIndicator); - assertEquals("false", found); - assertEquals("false", byName); - - assertEquals(expectedWorkflowException, workflowException); - } - - private void setVariables(Map<String, String> variables, String vnfId, String vnfName, String type) { - variables.put("isDebugLogEnabled", "true"); - variables.put("GENGV_vnfId", vnfId); - variables.put("GENGV_vnfName",vnfName); - variables.put("GENGV_type", type); - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericPutVnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericPutVnfTest.java deleted file mode 100644 index 7c003c986a..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenericPutVnfTest.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. - */ -/*- - * ============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.openecomp.mso.bpmn.common; - -import static org.junit.Assert.assertEquals; -import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow; -import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutVce; - -import java.util.HashMap; -import java.util.Map; - -import org.camunda.bpm.engine.test.Deployment; -import org.junit.Test; -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; - -/** - * Please describe the GenericPutVnf.java class - * - */ -public class GenericPutVnfTest extends WorkflowTest { - - private String genericVnfPayload = "<generic-vnf><vnf-id>testId</vnf-id></generic-vnf>"; - private String vcePayload = "<vce><vnf-id>testId</vnf-id></vce>"; - - @Test - @Deployment(resources = {"subprocess/GenericPutVnf.bpmn"}) - public void testGenericPutVnf_success_genericVnf() throws Exception{ - - MockPutGenericVnf("testVnfId123"); - - Map<String, String> variables = new HashMap<>(); - setVariables(variables, "testVnfId123", genericVnfPayload, "generic-vnf"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericPutVnf", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericPutVnf", "GENPV_SuccessIndicator"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericPutVnf", "WorkflowException"); - - assertEquals("true", successIndicator); - assertEquals(null, workflowException); - - } - - @Test - @Deployment(resources = {"subprocess/GenericPutVnf.bpmn"}) - public void testGenericPutVnf_success_vce() throws Exception{ - - MockPutVce("testVnfId123"); - - Map<String, String> variables = new HashMap<>(); - setVariables(variables, "testVnfId123", vcePayload, "vce"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericPutVnf", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericPutVnf", "GENPV_SuccessIndicator"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericPutVnf", "WorkflowException"); - - assertEquals("true", successIndicator); - assertEquals(null, workflowException); - - } - - @Test - @Deployment(resources = {"subprocess/GenericPutVnf.bpmn"}) - public void testGenericPutVnf_error_missingType() throws Exception{ - - MockPutGenericVnf("testVnfId123"); - - Map<String, String> variables = new HashMap<>(); - setVariables(variables, "testVnfId123", genericVnfPayload, ""); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericPutVnf", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericPutVnf", "GENPV_SuccessIndicator"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericPutVnf", "WorkflowException"); - - String expectedWFEX = "WorkflowException[processKey=GenericPutVnf,errorCode=500,errorMessage=Incoming Vnf Payload and/or Type is null. These Variables are required!]"; - - assertEquals("false", successIndicator); - assertEquals(expectedWFEX, workflowException); - - } - - @Test - @Deployment(resources = {"subprocess/GenericPutVnf.bpmn"}) - public void testGenericPutVnf_error_missingPayload() throws Exception{ - - MockPutGenericVnf("testVnfId123"); - - Map<String, String> variables = new HashMap<>(); - setVariables(variables, "testVnfId123", genericVnfPayload, ""); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericPutVnf", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericPutVnf", "GENPV_SuccessIndicator"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericPutVnf", "WorkflowException"); - - String expectedWFEX = "WorkflowException[processKey=GenericPutVnf,errorCode=500,errorMessage=Incoming Vnf Payload and/or Type is null. These Variables are required!]"; - - assertEquals("false", successIndicator); - assertEquals(expectedWFEX, workflowException); - - } - - @Test - @Deployment(resources = {"subprocess/GenericPutVnf.bpmn"}) - public void testGenericPutVnf_error_404() throws Exception{ - - Map<String, String> variables = new HashMap<>(); - setVariables(variables, "testVnfId123", genericVnfPayload, "generic-vnf"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericPutVnf", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericPutVnf", "GENPV_SuccessIndicator"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericPutVnf", "WorkflowException"); - - String expectedWFEX = "WorkflowException[processKey=GenericPutVnf,errorCode=404,errorMessage=Received a bad response from AAI]"; - - assertEquals("false", successIndicator); - assertEquals(expectedWFEX, workflowException); - } - - @Test - @Deployment(resources = {"subprocess/GenericPutVnf.bpmn"}) - public void testGenericPutVnf_error_400() throws Exception{ - - MockPutGenericVnf("/testVnfId123", 400); - - Map<String, String> variables = new HashMap<>(); - setVariables(variables, "testVnfId123", genericVnfPayload, "generic-vnf"); - - WorkflowResponse workflowResponse = executeWorkFlow(processEngineRule, "GenericPutVnf", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceId()); - - String successIndicator = BPMNUtil.getVariable(processEngineRule, "GenericPutVnf", "GENPV_SuccessIndicator"); - String workflowException = BPMNUtil.getVariable(processEngineRule, "GenericPutVnf", "WorkflowException"); - - String expectedWFEX = "WorkflowException[processKey=GenericPutVnf,errorCode=400,errorMessage=Received a bad response from AAI]"; - - assertEquals("false", successIndicator); - assertEquals(expectedWFEX, workflowException); - - - } - - private void setVariables(Map<String, String> variables, String vnfId, String payload, String type) { - variables.put("isDebugLogEnabled", "true"); - variables.put("GENPV_vnfId", vnfId); - variables.put("GENPV_vnfPayload",payload); - variables.put("GENPV_type", type); - } - - -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ManualHandlingTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ManualHandlingTest.java deleted file mode 100644 index 85a0bb789d..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ManualHandlingTest.java +++ /dev/null @@ -1,124 +0,0 @@ -/*- - * ============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.openecomp.mso.bpmn.common; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; - -import org.camunda.bpm.engine.TaskService; -import org.camunda.bpm.ProcessEngineService; -import org.camunda.bpm.engine.task.TaskQuery; -import org.camunda.bpm.engine.task.Task; -import org.camunda.bpm.engine.delegate.BpmnError; -import org.camunda.bpm.engine.delegate.DelegateTask; -import org.camunda.bpm.engine.runtime.Execution; - -import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow; -import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish; -import static com.github.tomakehurst.wiremock.client.WireMock.containing; -import static com.github.tomakehurst.wiremock.client.WireMock.put; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; -import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow; -import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish; -import static org.openecomp.mso.bpmn.mock.StubResponsePolicy.MockPolicyAbort; - -import java.io.DataOutputStream; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; -import java.util.List; - -import org.camunda.bpm.engine.RuntimeService; -import org.camunda.bpm.engine.test.Deployment; -import org.junit.Assert; -import org.junit.Test; -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; -import org.openecomp.mso.bpmn.core.WorkflowException; - -/** - * Unit test for RainyDayHandler.bpmn. - */ -public class ManualHandlingTest extends WorkflowTest { - - @Test - @Deployment(resources = { - "subprocess/BuildingBlock/ManualHandling.bpmn" - }) - public void TestManualHandlingSuccess() { - - RuntimeService runtimeService = processEngineRule.getRuntimeService(); - Map<String, Object> variables = new HashMap<>(); - variables.put("isDebugLogEnabled","true"); - variables.put("msoRequestId", "testRequestId"); - variables.put("serviceType", "X"); - variables.put("vnfType", "Y"); - variables.put("currentActivity", "BB1"); - variables.put("workStep", "1"); - variables.put("failedActivity", "AAI"); - variables.put("vnfName", "vSAMP12"); - variables.put("errorCode", "123"); - variables.put("errorText", "update failed"); - variables.put("validResponses", "Rollback"); - variables.put("vnfName", "vSAMP1"); - - - String businessKey = UUID.randomUUID().toString(); - invokeSubProcess("ManualHandling", businessKey, variables); - - try { - Thread.sleep(5); - } catch (Exception e) { - - } - - TaskService taskService = processEngineRule.getTaskService(); - - TaskQuery q = taskService.createTaskQuery(); - - List<Task> tasks = q.orderByTaskCreateTime().asc().list(); - int i = 0; - - for (Task task : tasks) { - - - System.out.println("TASK ID: " + task.getId()); - System.out.println("TASK NAME: " + task.getName()); - try { - System.out.println("Completing the task"); - Map<String,Object> completeVariables = new HashMap<>(); - completeVariables.put("responseValue", "skip"); - taskService.complete(task.getId(), completeVariables); - } - catch(Exception e) { - System.out.println("GOT EXCEPTION: " + e.getMessage()); - } - } - - waitForProcessEnd(businessKey, 100000); - - Assert.assertTrue(isProcessEnded(businessKey)); - - } - - -}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/OofHomingTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/OofHomingTest.java deleted file mode 100644 index 1f64fb55f8..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/OofHomingTest.java +++ /dev/null @@ -1,781 +0,0 @@ -/*- - * ============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========================================================= - */ - -/* - * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. - */ -package org.openecomp.mso.bpmn.common; - -import org.camunda.bpm.engine.test.Deployment; -import org.junit.Ignore; -import org.junit.Test; -import org.openecomp.mso.bpmn.core.WorkflowException; -import org.openecomp.mso.bpmn.core.domain.AllottedResource; -import org.openecomp.mso.bpmn.core.domain.CloudFlavor; -import org.openecomp.mso.bpmn.core.domain.HomingSolution; -import org.openecomp.mso.bpmn.core.domain.ModelInfo; -import org.openecomp.mso.bpmn.core.domain.NetworkResource; -import org.openecomp.mso.bpmn.core.domain.Resource; -import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition; -import org.openecomp.mso.bpmn.core.domain.ServiceInstance; -import org.openecomp.mso.bpmn.core.domain.VnfResource; -import org.openecomp.mso.bpmn.mock.FileUtil; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogDataByModelUuid; -import static org.openecomp.mso.bpmn.mock.StubResponseOof.mockOof; -import static org.openecomp.mso.bpmn.mock.StubResponseOof.mockOof_500; - - -/** - * Test the OOF Homing subflow building block. - */ -public class OofHomingTest extends WorkflowTest { - - ServiceDecomposition serviceDecomposition = new ServiceDecomposition(); - String subscriber = ""; - String subscriber2 = ""; - - private final CallbackSet callbacks = new CallbackSet(); - - public OofHomingTest() throws IOException { - String oofCallback = FileUtil.readResourceFile("__files/BuildingBlocks/oofCallbackInfraVnf"); - String oofCallback2 = FileUtil.readResourceFile("__files/BuildingBlocks/oofCallback2AR1Vnf"); - String oofCallback3 = FileUtil.readResourceFile("__files/BuildingBlocks/oofCallback2AR1Vnf2Net"); - - String oofCallbackNoSolution = FileUtil. - readResourceFile("__files/BuildingBlocks/oofCallbackNoSolutionFound"); - String oofCallbackPolicyException = FileUtil. - readResourceFile("__files/BuildingBlocks/oofCallbackPolicyException"); - String oofCallbackServiceException = FileUtil. - readResourceFile("__files/BuildingBlocks/oofCallbackServiceException"); - - callbacks.put("oof", JSON, "oofResponse", oofCallback); - callbacks.put("oof2", JSON, "oofResponse", oofCallback2); - callbacks.put("oof3", JSON, "oofResponse", oofCallback3); - callbacks.put("oofNoSol", JSON, "oofResponse", oofCallbackNoSolution); - callbacks.put("oofPolicyEx", JSON, "oofResponse", oofCallbackPolicyException); - callbacks.put("oofServiceEx", JSON, "oofResponse", oofCallbackServiceException); - - // Service Model - ModelInfo sModel = new ModelInfo(); - sModel.setModelCustomizationName("testModelCustomizationName"); - sModel.setModelInstanceName("testModelInstanceName"); - sModel.setModelInvariantUuid("testModelInvariantId"); - sModel.setModelName("testModelName"); - sModel.setModelUuid("testModelUuid"); - sModel.setModelVersion("testModelVersion"); - // Service Instance - ServiceInstance si = new ServiceInstance(); - si.setInstanceId("testServiceInstanceId123"); - // Allotted Resources - List<AllottedResource> arList = new ArrayList<AllottedResource>(); - AllottedResource ar = new AllottedResource(); - ar.setResourceId("testResourceIdAR"); - ar.setNfFunction("testARFunctionName"); - ModelInfo arModel = new ModelInfo(); - arModel.setModelCustomizationUuid("testModelCustomizationUuidAR"); - arModel.setModelInvariantUuid("testModelInvariantIdAR"); - arModel.setModelName("testModelNameAR"); - arModel.setModelVersion("testModelVersionAR"); - arModel.setModelUuid("testARModelUuid"); - arModel.setModelType("testModelTypeAR"); - ar.setModelInfo(arModel); - AllottedResource ar2 = new AllottedResource(); - ar2.setResourceId("testResourceIdAR2"); - ar2.setNfFunction("testAR2FunctionName"); - ModelInfo arModel2 = new ModelInfo(); - arModel2.setModelCustomizationUuid("testModelCustomizationUuidAR2"); - arModel2.setModelInvariantUuid("testModelInvariantIdAR2"); - arModel2.setModelName("testModelNameAR2"); - arModel2.setModelVersion("testModelVersionAR2"); - arModel2.setModelUuid("testAr2ModelUuid"); - arModel2.setModelType("testModelTypeAR2"); - ar2.setModelInfo(arModel2); - arList.add(ar); - arList.add(ar2); - // Vnfs - List<VnfResource> vnfList = new ArrayList<VnfResource>(); - VnfResource vnf = new VnfResource(); - vnf.setResourceId("testResourceIdVNF"); - vnf.setNfFunction("testVnfFunctionName"); - ArrayList<CloudFlavor> flavors = new ArrayList<>(); - CloudFlavor flavor1 = new CloudFlavor("flavorLabel1xxx", "vimFlavorxxx"); - CloudFlavor flavor2 = new CloudFlavor("flavorLabel2xxx", "vimFlavorxxx"); - flavors.add(flavor1); - flavors.add(flavor2); - vnf.getHomingSolution().setFlavors(flavors); - ModelInfo vnfModel = new ModelInfo(); - vnfModel.setModelCustomizationUuid("testModelCustomizationUuidVNF"); - vnfModel.setModelInvariantUuid("testModelInvariantIdVNF"); - vnfModel.setModelName("testModelNameVNF"); - vnfModel.setModelVersion("testModelVersionVNF"); - vnfModel.setModelUuid("testVnfModelUuid"); - vnfModel.setModelType("testModelTypeVNF"); - vnf.setModelInfo(vnfModel); - vnfList.add(vnf); - System.out.println("SERVICE DECOMP: " + serviceDecomposition.getServiceResourcesJsonString()); - serviceDecomposition.setModelInfo(sModel); - serviceDecomposition.setServiceAllottedResources(arList); - serviceDecomposition.setServiceVnfs(vnfList); - serviceDecomposition.setServiceInstance(si); - - // Subscriber - subscriber = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberCommonSiteId\": \"DALTX0101\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}"; - subscriber2 = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}"; - } - - @Test - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_success_2AR1Vnf() throws Exception { - - mockOof(); - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - setVariables(variables); - - invokeSubProcess("Homing", businessKey, variables); - - injectWorkflowMessages(callbacks, "oof2"); - - waitForProcessEnd(businessKey, 10000); - - //Get Variables - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, - "WorkflowException"); - ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, - "serviceDecomposition"); - String expectedOofRequest = (String) getVariableFromHistory(businessKey, "oofRequest"); - - Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR"); - HomingSolution resourceARHoming = resourceAR.getHomingSolution(); - Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2"); - HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution(); - Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF"); - HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution(); - String resourceARHomingString = resourceARHoming.toString(); - resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " "); - String resourceARHoming2String = resourceARHoming2.toString(); - resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " "); - String resourceVNFHomingString = resourceVNFHoming.toString(); - resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " "); - expectedOofRequest = expectedOofRequest.replaceAll("\\s+", ""); - - assertNull(workflowException); - assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", - resourceARHoming.getVnf().getResourceId(),"aic", "dfwtx", - "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", - "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), - resourceARHomingString); - assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2", - resourceARHoming2.getVnf().getResourceId(),"aic", "testCloudRegionId2", - null, null), resourceARHoming2String); - assertEquals(homingSolutionCloud("cloud","aic", "testCloudRegionId3", - true, "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"", - "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""), - resourceVNFHomingString); - assertEquals(verifyOofRequest(), expectedOofRequest); - } - - @Test - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_success_2AR1Vnf2Net() throws Exception { - - mockOof(); - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - setVariables2(variables); - - invokeSubProcess("Homing", businessKey, variables); - - injectWorkflowMessages(callbacks, "oof3"); - - waitForProcessEnd(businessKey, 10000); - - //Get Variables - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, - "WorkflowException"); - ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, - "serviceDecomposition"); - String expectedOofRequest = (String) getVariableFromHistory(businessKey, "oofRequest"); - - Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR"); - HomingSolution resourceARHoming = resourceAR.getHomingSolution(); - Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2"); - HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution(); - Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF"); - HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution(); - Resource resourceNet = serviceDecompositionExp.getServiceResource("testResourceIdNet"); - HomingSolution resourceNetHoming = resourceNet.getHomingSolution(); - Resource resourceNet2 = serviceDecompositionExp.getServiceResource("testResourceIdNet2"); - HomingSolution resourceNetHoming2 = resourceNet2.getHomingSolution(); - - String resourceARHomingString = resourceARHoming.toString(); - resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " "); - String resourceARHoming2String = resourceARHoming2.toString(); - resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " "); - String resourceVNFHomingString = resourceVNFHoming.toString(); - resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " "); - String resourceNetHomingString = resourceNetHoming.toString(); - resourceNetHomingString = resourceNetHomingString.replaceAll("\\s+", " "); - String resourceNetHoming2String = resourceNetHoming2.toString(); - resourceNetHoming2String = resourceNetHoming2String.replaceAll("\\s+", " "); - expectedOofRequest = expectedOofRequest.replaceAll("\\s+", ""); - - - assertNull(workflowException); - assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", - resourceARHoming.getVnf().getResourceId(),"aic", "dfwtx", - "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", - "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), - resourceARHomingString); - assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2", - resourceARHoming2.getVnf().getResourceId(), - "aic", "testCloudRegionId2", - null, null), resourceARHoming2String); - assertEquals(homingSolutionCloud("cloud","aic", - "testCloudRegionId3", - true, "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"", - "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""), - resourceVNFHomingString); - assertEquals(homingSolutionService("service", "testServiceInstanceIdNet", - "testVnfHostNameNet", resourceNetHoming.getVnf().getResourceId(),"aic", - "testCloudRegionIdNet", - null, null), resourceNetHomingString); - assertEquals(homingSolutionCloud("cloud", "aic", - "testCloudRegionIdNet2", - false, "\"f1d563e8-e714-4393-8f99-cc480144a05n\", \"j1d563e8-e714-4393-8f99-cc480144a05n\"", - "\"s1d563e8-e714-4393-8f99-cc480144a05n\", \"b1d563e8-e714-4393-8f99-cc480144a05n\""), - resourceNetHoming2String); - assertEquals(verifyOofRequest(), expectedOofRequest); - - } - - @Test - @Ignore - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/BuildingBlock/DecomposeService.bpmn", - "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_success_vnfResourceList() throws Exception { - - // Create a Service Decomposition - MockGetServiceResourcesCatalogDataByModelUuid("2f7f309d-c842-4644-a2e4-34167be5eeb4", - "/BuildingBlocks/oofCatalogResp.json"); - String busKey = UUID.randomUUID().toString(); - Map<String, Object> vars = new HashMap<>(); - setVariablesForServiceDecomposition(vars, "testRequestId123", - "ff5256d2-5a33-55df-13ab-12abad84e7ff"); - invokeSubProcess("DecomposeService", busKey, vars); - - ServiceDecomposition sd = (ServiceDecomposition) getVariableFromHistory(busKey, - "serviceDecomposition"); - System.out.println("In testHoming_success_vnfResourceList, ServiceDecomposition = " + sd); - List<VnfResource> vnfResourceList = sd.getServiceVnfs(); -//System.out.println(" vnfResourceList = " + vnfResourceList); - vnfResourceList.get(0).setResourceId("test-resource-id-000"); - - // Invoke Homing - - mockOof(); - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - variables.put("homingService", "oof"); - variables.put("isDebugLogEnabled", "true"); - variables.put("msoRequestId", "testRequestId"); - variables.put("serviceInstanceId", "testServiceInstanceId"); - variables.put("serviceDecomposition", sd); - variables.put("subscriberInfo", subscriber2); - HashMap customerLocation = new HashMap<String, Object>(); - customerLocation.put("customerLatitude", "32.89748"); - customerLocation.put("customerLongitude", "-97.040443"); - customerLocation.put("customerName", "xyz"); - variables.put("customerLatitude", "32.89748"); - variables.put("customerLongitude", "-97.040443"); - variables.put("customerName", "xyz"); - variables.put("customerLocation", customerLocation); - variables.put("cloudOwner", "amazon"); - variables.put("cloudRegionId", "TNZED"); - - invokeSubProcess("Homing", businessKey, variables); - injectWorkflowMessages(callbacks, "oof3"); - waitForProcessEnd(businessKey, 10000); - - //Get Variables - - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, - "WorkflowException"); - ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, - "serviceDecomposition"); - System.out.println("serviceDecompositionExp is: " + serviceDecompositionExp); - - Resource resourceVnf = serviceDecompositionExp.getServiceResource("test-resource-id-000"); - System.out.println("resourceVnf is: " + resourceVnf); - HomingSolution resourceVnfHoming = resourceVnf.getHomingSolution(); - - String resourceVnfHomingString = resourceVnfHoming.toString(); - System.out.println("resourceVnfHomingString is: " + resourceVnfHomingString); - resourceVnfHomingString = resourceVnfHomingString.replaceAll("\\s+", " "); - System.out.println("Now resourceVnfHomingString is: " + resourceVnfHomingString); - - assertNull(workflowException); - - //Verify request - String oofRequest = (String) getVariableFromHistory(businessKey, "oofRequest"); - System.out.println("oofRequest is: " + oofRequest); - assertEquals(FileUtil.readResourceFile("__files/BuildingBlocks/oofRequest_infravnf"). - replaceAll("\n", "").replaceAll("\r", ""). - replaceAll("\t", ""), oofRequest.replaceAll("\n", ""). - replaceAll("\r", "").replaceAll("\t", "")); - - //System.out.println("resourceVnfHoming.getVnf().getResourceId() is: " + resourceVnfHoming.getVnf().getResourceId()); - - assertEquals(homingSolutionService("service", "service-instance-01234", - "MDTNJ01", "test-resource-id-000","att-aic", - "mtmnj1a", - "\"f1d563e8-e714-4393-8f99-cc480144a05e\"," + - " \"j1d563e8-e714-4393-8f99-cc480144a05e\"", - "\"s1d563e8-e714-4393-8f99-cc480144a05e\"," + - " \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceVnfHomingString); - } - - @Test - @Ignore // 1802 merge - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_success_existingLicense() throws Exception { - - mockOof(); - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); - setVariablesExistingLicense(variables); - - invokeSubProcess("Homing", businessKey, variables); - - injectWorkflowMessages(callbacks, "sniro"); - - waitForProcessEnd(businessKey, 10000); - - //Get Variables - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition"); - String oofRequest = (String) getVariableFromHistory(businessKey, "sniroRequest"); - - Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR"); - HomingSolution resourceARHoming = (HomingSolution) resourceAR.getHomingSolution(); - Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2"); - HomingSolution resourceARHoming2 = (HomingSolution) resourceAR2.getHomingSolution(); - Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF"); - HomingSolution resourceVNFHoming = (HomingSolution) resourceVNF.getHomingSolution(); - String resourceARHomingString = resourceARHoming.toString(); - resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " "); - String resourceARHoming2String = resourceARHoming2.toString(); - resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " "); - String resourceVNFHomingString = resourceVNFHoming.toString(); - resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " "); - oofRequest = oofRequest.replaceAll("\\s+", ""); - - assertNull(workflowException); - assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", - "aic", "dfwtx", "KDTNJ01", - "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", - "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), - resourceARHomingString); - assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2", - resourceARHoming2.getVnf().getResourceId(),"aic", "testCloudRegionId2", - null, null), resourceARHoming2String); - assertEquals(homingSolutionCloud("cloud", "aic", - "testCloudRegionId3", - false, "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"", - "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""), - resourceVNFHomingString); - assertEquals(verifyOofRequestExistingLicense(), oofRequest); - - } - - @Test - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_error_inputVariable() throws Exception { - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - setVariables3(variables); - - invokeSubProcess("Homing", businessKey, variables); - - waitForProcessEnd(businessKey, 10000); - - //Get Variables - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, - "WorkflowException"); - - assertEquals("WorkflowException[processKey=Homing,errorCode=4000,errorMessage=A required " + - "input variable is missing or null]", workflowException.toString()); - } - - @Test - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_error_badResponse() throws Exception { - mockOof_500(); - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - setVariables(variables); - - invokeSubProcess("Homing", businessKey, variables); - - waitForProcessEnd(businessKey, 10000); - - //Get Variables - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, - "WorkflowException"); - - assertEquals("WorkflowException[processKey=Homing,errorCode=500,errorMessage=Received a " + - "Bad Sync Response from Sniro/OOF.]", workflowException.toString()); - } - - @Test - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_error_oofNoSolution() throws Exception { - mockOof(); - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - setVariables(variables); - - invokeSubProcess("Homing", businessKey, variables); - - injectWorkflowMessages(callbacks, "oofNoSol"); - - waitForProcessEnd(businessKey, 10000); - - //Get Variables - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, - "WorkflowException"); - Boolean errorMatch = workflowException.toString().contains("WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback " + - "Response contains error: Unable to find any candidate for demand *** Response:"); - assert(errorMatch); - } - - @Test - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_error_oofPolicyException() throws Exception { - mockOof(); - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - setVariables(variables); - - invokeSubProcess("Homing", businessKey, variables); - - injectWorkflowMessages(callbacks, "oofPolicyEx"); - - waitForProcessEnd(businessKey, 10000); - - //Get Variables - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, - "WorkflowException"); - - assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback " + - "Response contains a Request Error Policy Exception: Message content size exceeds the allowable " + - "limit]", workflowException.toString()); - } - - @Test - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_error_oofServiceException() throws Exception { - mockOof(); - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - setVariables(variables); - - invokeSubProcess("Homing", businessKey, variables); - - injectWorkflowMessages(callbacks, "oofServiceEx"); - - waitForProcessEnd(businessKey, 10000); - - //Get Variables - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, - "WorkflowException"); - - assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=OOF Async Callback " + - "Response contains a Request Error Service Exception: OOF PlacementError: " + - "requests.exceptions.HTTPError: 404 Client Error: Not Found for " + - "url: http://135.21.171.200:8091/v1/plans/97b4e303-5f75-492c-8fb2-21098281c8b8]", - workflowException.toString()); - } - - - private void setVariables(Map<String, Object> variables) { - variables.put("homingService", "oof"); - HashMap customerLocation = new HashMap<String, Object>(); - customerLocation.put("customerLatitude", "32.89748"); - customerLocation.put("customerLongitude", "-97.040443"); - customerLocation.put("customerName", "xyz"); - variables.put("customerLatitude", "32.89748"); - variables.put("customerLongitude", "-97.040443"); - variables.put("customerName", "xyz"); - variables.put("customerLocation", customerLocation); - variables.put("cloudOwner", "amazon"); - variables.put("cloudRegionId", "TNZED"); - variables.put("vgMuxInfraModelInvariantId", "testModelInvariantIdAR"); - variables.put("vgMuxInfraModelId", "testArModelUuid"); - // variables.put("mso-request-id", "testRequestId"); - variables.put("msoRequestId", "testRequestId"); - variables.put("serviceInstanceId", "testServiceInstanceId123"); - variables.put("serviceInstanceName", "testServiceName"); - variables.put("serviceDecomposition", serviceDecomposition); - variables.put("subscriberInfo", subscriber2); - } - - private void setVariables2(Map<String, Object> variables) { - List<NetworkResource> netList = new ArrayList<NetworkResource>(); - NetworkResource net = new NetworkResource(); - net.setResourceId("testResourceIdNet"); - ModelInfo netModel = new ModelInfo(); - netModel.setModelCustomizationUuid("testModelCustomizationUuidNet"); - netModel.setModelInvariantUuid("testModelInvariantIdNet"); - netModel.setModelName("testModelNameNet"); - netModel.setModelVersion("testModelVersionNet"); - net.setModelInfo(netModel); - netList.add(net); - NetworkResource net2 = new NetworkResource(); - net2.setResourceId("testResourceIdNet2"); - ModelInfo netModel2 = new ModelInfo(); - netModel2.setModelCustomizationUuid("testModelCustomizationUuidNet2"); - netModel2.setModelCustomizationName("testModelCustomizationNameNet2"); - netModel2.setModelInvariantUuid("testModelInvariantIdNet2"); - netModel2.setModelName("testModelNameNet2"); - netModel2.setModelVersion("testModelVersionNet2"); - net2.setModelInfo(netModel2); - netList.add(net2); - serviceDecomposition.setServiceNetworks(netList); - - variables.put("homingService", "oof"); - HashMap customerLocation = new HashMap<String, Object>(); - customerLocation.put("customerLatitude", "32.89748"); - customerLocation.put("customerLongitude", "-97.040443"); - customerLocation.put("customerName", "xyz"); - variables.put("customerLatitude", "32.89748"); - variables.put("customerLongitude", "-97.040443"); - variables.put("customerName", "xyz"); - variables.put("customerLocation", customerLocation); - variables.put("cloudOwner", "amazon"); - variables.put("cloudRegionId", "TNZED"); - variables.put("vgMuxInfraModelInvariantId", "testModelInvariantIdAR"); - variables.put("vgMuxInfraModelId", "testArModelUuid"); - variables.put("isDebugLogEnabled", "true"); - variables.put("msoRequestId", "testRequestId"); - variables.put("serviceInstanceId", "testServiceInstanceId123"); - variables.put("serviceInstanceName", "testServiceName"); - variables.put("serviceDecomposition", serviceDecomposition); - variables.put("subscriberInfo", subscriber2); - } - - private void setVariables3(Map<String, Object> variables) { - variables.put("homingService", "oof"); - HashMap customerLocation = new HashMap<String, Object>(); - customerLocation.put("customerLatitude", "32.89748"); - customerLocation.put("customerLongitude", "-97.040443"); - customerLocation.put("customerName", "xyz"); - variables.put("customerLatitude", "32.89748"); - variables.put("customerLongitude", "-97.040443"); - variables.put("customerName", "xyz"); - variables.put("customerLocation", customerLocation); - variables.put("cloudOwner", "amazon"); - variables.put("cloudRegionId", "TNZED"); - variables.put("vgMuxInfraModelInvariantId", "testModelInvariantIdAR"); - variables.put("vgMuxInfraModelId", "testArModelUuid"); - variables.put("isDebugLogEnabled", "true"); - // variables.put("mso-request-id", "testRequestId"); - variables.put("msoRequestId", "testRequestId"); - variables.put("serviceInstanceId", "testServiceInstanceId123"); - variables.put("serviceInstanceName", "testServiceName"); - variables.put("serviceDecomposition", null); - variables.put("subscriberInfo", subscriber2); - } - - private void setVariablesExistingLicense(Map<String, Object> variables) { - HomingSolution currentHomingSolution = new HomingSolution(); - serviceDecomposition.getServiceVnfs().get(0).setCurrentHomingSolution(currentHomingSolution); - serviceDecomposition.getServiceVnfs().get(0).getCurrentHomingSolution().getLicense().addEntitlementPool("testEntitlementPoolId1"); - serviceDecomposition.getServiceVnfs().get(0).getCurrentHomingSolution().getLicense().addEntitlementPool("testEntitlementPoolId2"); - - serviceDecomposition.getServiceVnfs().get(0).getCurrentHomingSolution().getLicense().addLicenseKeyGroup("testLicenseKeyGroupId1"); - serviceDecomposition.getServiceVnfs().get(0).getCurrentHomingSolution().getLicense().addLicenseKeyGroup("testLicenseKeyGroupId2"); - - variables.put("isDebugLogEnabled", "true"); - variables.put("msoRequestId", "testRequestId"); - variables.put("serviceInstanceId", "testServiceInstanceId"); - variables.put("serviceDecomposition", serviceDecomposition); - variables.put("subscriberInfo", subscriber2); - - } - - private String homingSolutionService(String type, String serviceInstanceId, String vnfHostname, - String vnfResourceId, String cloudOwner, - String cloudRegionId, String enList, - String licenseList){ - - String solution = ""; - if(enList == null){ - solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \"" + - serviceInstanceId + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" + - cloudRegionId + "\", " + "\"vnf\" : { \"resourceId\" : \"" + vnfResourceId + - "\", \"resourceType\" : \"VNF\", \"resourceInstance\" : { }, \"homingSolution\" : { \"license\" :" + - " { }, \"rehome\" : false }, \"vnfHostname\" : \"" + vnfHostname + "\" }, \"license\" : { }," + - " \"rehome\" : false } }"; - }else{ - //language=JSON - solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \"" + - serviceInstanceId + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" + - cloudRegionId + "\", \"vnf\" : { \"resourceId\" : \"" + vnfResourceId + "\", \"resourceType\" :" + - " \"VNF\", \"resourceInstance\" : { }, \"homingSolution\" : { \"license\" : { }, \"rehome\" :" + - " false }, \"vnfHostname\" : \"" + vnfHostname + "\" }, \"license\" : { \"entitlementPoolList\" :" + - " [ " + enList + " ], \"licenseKeyGroupList\" : [ " + licenseList + " ] }, \"rehome\" : false } }"; - } - return solution; - } - - private String homingSolutionCloud(String type, String cloudOwner, - String cloudRegionId, Boolean flavors, String enList, - String licenseList){ - String solution = ""; - if(enList == null){ - solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + - cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + - "\", \"license\" : { }, \"rehome\" : false } }"; - } else if (flavors && enList == null){ - solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + - cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + - "\", \"flavors\" : [ { \"flavorLabel\" : \"flavorLabel2xxx\", \"flavor\" : \"vimFlavorxxx\" }, " + - "{ \"flavorLabel\" : \"flavorLabel1xxx\", \"flavor\" : \"vimFlavorxxx\" } ], " + - "\"license\" : { }, \"rehome\" : false } }"; - } else if (flavors) { - solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + - cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + - "\", \"flavors\" : [ { \"flavorLabel\" : \"flavorLabel2xxx\", \"flavor\" : \"vimFlavorxxx\" }, " + - "{ \"flavorLabel\" : \"flavorLabel1xxx\", \"flavor\" : \"vimFlavorxxx\" } ], " + - "\"license\" : { \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ " + - licenseList + " ] }, \"rehome\" : false } }"; - } else { - solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + - cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + - "\", \"license\" : { \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ " + - licenseList + " ] }, \"rehome\" : false } }"; - } - return solution; - } - - private void setVariablesForServiceDecomposition(Map<String, Object> variables, String requestId, String siId) { - variables.put("homingService", "oof"); - variables.put("isDebugLogEnabled", "true"); - variables.put("mso-request-id", requestId); - variables.put("msoRequestId", requestId); - variables.put("serviceInstanceId", siId); - HashMap customerLocation = new HashMap<String, Object>(); - customerLocation.put("customerLatitude", "32.89748"); - customerLocation.put("customerLongitude", "-97.040443"); - customerLocation.put("customerName", "xyz"); - variables.put("customerLatitude", "32.89748"); - variables.put("customerLongitude", "-97.040443"); - variables.put("customerName", "xyz"); - variables.put("customerLocation", customerLocation); - variables.put("cloudOwner", "amazon"); - variables.put("cloudRegionId", "TNZED"); - - - String serviceModelInfo = "{\"modelInvariantId\":\"1cc4e2e4-eb6e-404d-a66f-c8733cedcce8\",\"modelUuid\":" + - "\"2f7f309d-c842-4644-a2e4-34167be5eeb4\",\"modelName\":\"vCPE Service\",\"modelVersion\":\"2.0\",}"; - variables.put("serviceModelInfo", serviceModelInfo); - } - - private String verifyOofRequest() { - String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\"," + - "\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/oofResponse/testRequestId\"," + - "\"sourceId\":\"so\",\"requestType\":\"create\",\"numSolutions\":1,\"optimizers\":[\"placement\"]," + - "\"timeout\":600},\"placementInfo\":{\"requestParameters\":{\"customerLatitude\":" + - "\"32.89748\",\"customerLongitude\":\"-97.040443\",\"customerName\":\"xyz\"},\"subscriberInfo\":" + - "{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\"," + - "\"subscriberCommonSiteId\":\"\"},\"placementDemands\":[{\"resourceModuleName\":\"testARFunctionName\"" + - ",\"serviceResourceId\":\"testResourceIdAR\",\"tenantId\":" + - "\"\",\"resourceModelInfo\":{\"modelInvariantId\":\"no-resourceModelInvariantId\"," + - "\"modelVersionId\":\"no-resourceModelVersionId\",\"modelName\":\"\",\"modelType\":" + - "\"\",\"modelVersion\":\"\",\"modelCustomizationName\":\"\"}}," + - "{\"resourceModuleName\":\"testAR2FunctionName\",\"serviceResourceId\":\"testResourceIdAR2\"," + - "\"tenantId\":\"\",\"resourceModelInfo\":{\"modelInvariantId\":\"no-resourceModelInvariantId\"," + - "\"modelVersionId\":\"no-resourceModelVersionId\",\"modelName\":\"\"," + - "\"modelType\":\"\",\"modelVersion\":\"\"," + - "\"modelCustomizationName\":\"\"}},{\"resourceModuleName\":\"testVnfFunctionName\",\"serviceResourceId\":\"" + - "testResourceIdVNF\",\"tenantId\":\"\",\"resourceModelInfo\":{\"modelInvariantId\"" + - ":\"testModelInvariantIdVNF\",\"modelVersionId\":\"testVnfModelUuid\",\"modelName\":\"" + - "testModelNameVNF\",\"modelType\":\"testModelTypeVNF\",\"modelVersion\":\"testModelVersionVNF\"" + - ",\"modelCustomizationName\":\"\"}}]},\"serviceInfo\":" + - "{\"serviceInstanceId\":\"testServiceInstanceId123\"," + - "\"serviceName\":\"testServiceName\",\"modelInfo\":{\"modelType\":\"\",\"modelInvariantId\":" + - "\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":\"testModelName\"," + - "\"modelVersion\":\"testModelVersion\",\"modelCustomizationName\":\"" + - "\"}}}"; - return request; - } - - private String verifyOofRequestExistingLicense(){ - String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\"," + - "\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/SNIROResponse/testRequestId\"," + - "\"sourceId\":\"mso\",\"requestType\":\"speedchanged\",\"optimizer\":[\"placement\",\"license\"]," + - "\"numSolutions\":1,\"timeout\":1800},\"placementInfo\":{\"serviceModelInfo\":{\"modelType\":\"\"," + - "\"modelInvariantId\":\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":" + - "\"testModelName\",\"modelVersion\":\"testModelVersion\"},\"subscriberInfo\":" + - "{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\"," + - "\"subscriberCommonSiteId\":\"\"},\"demandInfo\":{\"placementDemand\":[{\"resourceInstanceType\":" + - "\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR\",\"resourceModuleName\":\"\"," + - "\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR\"," + - "\"modelInvariantId\":\"testModelInvariantIdAR\",\"modelName\":\"testModelNameAR\"," + - "\"modelVersion\":\"testModelVersionAR\",\"modelVersionId\":\"testARModelUuid\",\"modelType\":" + - "\"testModelTypeAR\"},\"tenantId\":\"\",\"tenantName\":\"\"},{\"resourceInstanceType\":" + - "\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\",\"resourceModuleName\":" + - "\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR2\"," + - "\"modelInvariantId\":\"testModelInvariantIdAR2\",\"modelName\":\"testModelNameAR2\"," + - "\"modelVersion\":\"testModelVersionAR2\",\"modelVersionId\":\"testAr2ModelUuid\"," + - "\"modelType\":\"testModelTypeAR2\"},\"tenantId\":\"\",\"tenantName\":\"\"}],\"licenseDemand\":" + - "[{\"resourceInstanceType\":\"VNF\",\"serviceResourceId\":\"testResourceIdVNF\"," + - "\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":" + - "\"testModelCustomizationUuidVNF\",\"modelInvariantId\":\"testModelInvariantIdVNF\"," + - "\"modelName\":\"testModelNameVNF\",\"modelVersion\":\"testModelVersionVNF\"," + - "\"modelVersionId\":\"testVnfModelUuid\",\"modelType\":\"testModelTypeVNF\"}," + - "\"existingLicense\":[{\"entitlementPoolUUID\":[\"testEntitlementPoolId1\"," + - "\"testEntitlementPoolId2\"],\"licenseKeyGroupUUID\":[\"testLicenseKeyGroupId1\"," + - "\"testLicenseKeyGroupId2\"]}]}]},\"policyId\":[],\"serviceInstanceId\":" + - "\"testServiceInstanceId123\",\"orderInfo\":\"{\\\"requestParameters\\\":null}\"}}"; - return request; - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/PrepareUpdateAAIVfModuleTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/PrepareUpdateAAIVfModuleTest.java deleted file mode 100644 index be74770e98..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/PrepareUpdateAAIVfModuleTest.java +++ /dev/null @@ -1,212 +0,0 @@ -/*-
- * ============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.openecomp.mso.bpmn.common;
-
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockAAIVfModuleBadPatch;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_404;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchVfModuleId;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.camunda.bpm.engine.test.Deployment;
-import org.junit.Assert;
-import org.junit.Test;
-import org.openecomp.mso.bpmn.core.WorkflowException;
-import org.openecomp.mso.bpmn.mock.FileUtil;
-
-/**
- * Unit tests for PrepareUpdateAAIVfModule.bpmn.
- */
-public class PrepareUpdateAAIVfModuleTest extends WorkflowTest {
-
- /**
- * Test the happy path through the flow.
- */
- @Test
- @Deployment(resources = {
- "subprocess/PrepareUpdateAAIVfModule.bpmn"
- })
- public void happyPath() throws IOException {
-
- logStart();
-
- String prepareUpdateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml");
-
- MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml");
- MockPutGenericVnf("/skask/vf-modules/vf-module/supercool", "PCRF", 200);
- MockPatchVfModuleId("skask", "supercool");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", "999-99-9999");
- variables.put("isDebugLogEnabled","true");
- variables.put("PrepareUpdateAAIVfModuleRequest", prepareUpdateAAIVfModuleRequest);
- invokeSubProcess("PrepareUpdateAAIVfModule", businessKey, variables);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- String response = (String) getVariableFromHistory(businessKey, "PUAAIVfMod_updateVfModuleResponse");
- Integer responseCode = (Integer) getVariableFromHistory(businessKey, "PUAAIVfMod_updateVfModuleResponseCode");
- System.out.println("Subflow response code: " + responseCode);
- System.out.println("Subflow response: " + response);
- Assert.assertEquals(200, responseCode.intValue());
- String heatStackId = (String) getVariableFromHistory(businessKey, "PUAAIVfMod_heatStackId");
- System.out.println("Ouput heat-stack-id:" + heatStackId);
- Assert.assertEquals("slowburn", heatStackId);
-
- logEnd();
- }
-
- /**
- * Test the case where the GET to AAI returns a 404.
- */
- @Test
- @Deployment(resources = {
- "subprocess/PrepareUpdateAAIVfModule.bpmn"
- })
- public void badGet() throws IOException {
-
- logStart();
-
- String prepareUpdateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml");
- MockGetGenericVnfById_404("skask[?]depth=1");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", "999-99-9999");
- variables.put("isDebugLogEnabled","true");
- variables.put("PrepareUpdateAAIVfModuleRequest", prepareUpdateAAIVfModuleRequest);
- invokeSubProcess("PrepareUpdateAAIVfModule", businessKey, variables);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- String response = (String) getVariableFromHistory(businessKey, "PUAAIVfMod_getVnfResponse");
- Integer responseCode = (Integer) getVariableFromHistory(businessKey, "PUAAIVfMod_getVnfResponseCode");
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- System.out.println("Subflow response code: " + responseCode);
- System.out.println("Subflow response: " + response);
- Assert.assertEquals(404, responseCode.intValue());
- Assert.assertNotNull(workflowException);
- System.out.println("Subflow WorkflowException error message: " + workflowException.getErrorMessage());
-
- logEnd();
- }
-
- /**
- * Test the case where the validation of the VF Module fails.
- */
- @Test
- @Deployment(resources = {
- "subprocess/PrepareUpdateAAIVfModule.bpmn"
- })
- public void failValidation1() throws IOException {
-
- logStart();
-
- String prepareUpdateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml").replaceFirst("supercool", "lukewarm");
-
- MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", "999-99-9999");
- variables.put("isDebugLogEnabled","true");
- variables.put("PrepareUpdateAAIVfModuleRequest", prepareUpdateAAIVfModuleRequest);
- invokeSubProcess("PrepareUpdateAAIVfModule", businessKey, variables);
-
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- Assert.assertNotNull(workflowException);
- System.out.println("Subflow WorkflowException error message: " + workflowException.getErrorMessage());
- Assert.assertTrue(workflowException.getErrorMessage().startsWith("VF Module validation error: Orchestration"));
-
- logEnd();
- }
-
- /**
- * Test the case where the validation of the VF Module fails.
- */
- @Test
- @Deployment(resources = {
- "subprocess/PrepareUpdateAAIVfModule.bpmn"
- })
- public void failValidation2() throws IOException {
-
- logStart();
-
- String prepareUpdateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml").replaceFirst("supercool", "notsocool");
-
- MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", "999-99-9999");
- variables.put("isDebugLogEnabled","true");
- variables.put("PrepareUpdateAAIVfModuleRequest", prepareUpdateAAIVfModuleRequest);
- invokeSubProcess("PrepareUpdateAAIVfModule", businessKey, variables);
-
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- Assert.assertNotNull(workflowException);
- System.out.println("Subflow WorkflowException error message: " + workflowException.getErrorMessage());
- Assert.assertTrue(workflowException.getErrorMessage().startsWith("VF Module validation error: VF Module"));
-
- logEnd();
- }
-
- /**
- * Test the case where the GET to AAI is successful, but the subsequent PUT returns 404.
- */
- @Test
- @Deployment(resources = {
- "subprocess/PrepareUpdateAAIVfModule.bpmn"
- })
- public void badPatch() throws IOException {
-
- logStart();
-
- String prepareUpdateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/PrepareUpdateAAIVfModuleRequest.xml");
-
- MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml");
- MockAAIVfModuleBadPatch("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool", 404);
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", "999-99-9999");
- variables.put("isDebugLogEnabled","true");
- variables.put("PrepareUpdateAAIVfModuleRequest", prepareUpdateAAIVfModuleRequest);
- invokeSubProcess("PrepareUpdateAAIVfModule", businessKey, variables);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- String response = (String) getVariableFromHistory(businessKey, "PUAAIVfMod_updateVfModuleResponse");
- Integer responseCode = (Integer) getVariableFromHistory(businessKey, "PUAAIVfMod_updateVfModuleResponseCode");
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- System.out.println("Subflow response code: " + responseCode);
- System.out.println("Subflow response: " + response);
- Assert.assertEquals(404, responseCode.intValue());
- Assert.assertNotNull(workflowException);
- System.out.println("Subflow WorkflowException error message: " + workflowException.getErrorMessage());
-
- logEnd();
- }
-}
-
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/RainyDayHandlerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/RainyDayHandlerTest.java deleted file mode 100644 index d450dad05e..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/RainyDayHandlerTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/*-
- * ============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.openecomp.mso.bpmn.common;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow;
-import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish;
-import static com.github.tomakehurst.wiremock.client.WireMock.containing;
-import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
-import static org.openecomp.mso.bpmn.common.BPMNUtil.executeWorkFlow;
-import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish;
-import static org.openecomp.mso.bpmn.mock.StubResponsePolicy.MockPolicyAbort;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.camunda.bpm.engine.RuntimeService;
-import org.camunda.bpm.engine.test.Deployment;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
-import org.openecomp.mso.bpmn.core.WorkflowException;
-
-/**
- * Unit test for RainyDayHandler.bpmn.
- */
-public class RainyDayHandlerTest extends WorkflowTest {
-
- @Test
- @Deployment(resources = {
- "subprocess/BuildingBlock/RainyDayHandler.bpmn",
- "subprocess/BuildingBlock/ManualHandling.bpmn"
- })
- public void TestRainyDayHandlingSuccess() {
-
- RuntimeService runtimeService = processEngineRule.getRuntimeService();
- Map<String, Object> variables = new HashMap<>();
- variables.put("isDebugLogEnabled","true");
- variables.put("msoRequestId", "testRequestId");
- variables.put("serviceType", "X");
- variables.put("vnfType", "Y");
- variables.put("currentActivity", "BB1");
- variables.put("workStep", "1");
- variables.put("failedActivity", "");
- variables.put("errorCode", "123");
- variables.put("errorText", "update failed");
- variables.put("vnfName", "vSAMP1");
-
- MockPolicyAbort();
-
-
- String businessKey = UUID.randomUUID().toString();
- invokeSubProcess("RainyDayHandler", businessKey, variables);
-
- waitForProcessEnd(businessKey, 10000);
-
- Assert.assertTrue(isProcessEnded(businessKey));
-
- }
-
-
-
-}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ReceiveWorkflowMessageTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ReceiveWorkflowMessageTest.java deleted file mode 100644 index 64b8ba53b7..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ReceiveWorkflowMessageTest.java +++ /dev/null @@ -1,143 +0,0 @@ -/*- - * ============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.openecomp.mso.bpmn.common; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.camunda.bpm.engine.test.Deployment; -import org.junit.Test; -import org.openecomp.mso.bpmn.common.WorkflowTest; -import org.openecomp.mso.bpmn.common.WorkflowTest.CallbackSet; -import org.openecomp.mso.bpmn.core.WorkflowException; - -/** - * Unit tests for SDNCAdapterRestV1. - */ -public class ReceiveWorkflowMessageTest extends WorkflowTest { - - private static final String EOL = "\n"; - - private final CallbackSet callbacks = new CallbackSet(); - - public ReceiveWorkflowMessageTest() throws IOException { - callbacks.put("sdnc-event-success", JSON, "SDNCAEvent", - "{" + EOL + - " \"SDNCEvent\": {" + EOL + - " \"eventType\": \"UCPE-ACTIVATION\"," + EOL + - " \"eventCorrelatorType\": \"UCPE-HOST-NAME\"," + EOL + - " \"eventCorrelator\": \"((CORRELATOR))\"," + EOL + - " \"params\": {" + EOL + - " \"success-indicator\":\"Y\"" + EOL + - " }" +EOL + - " }" + EOL + - "}" + EOL); - - callbacks.put("sdnc-event-fail", JSON, "SDNCAEvent", - "{" + EOL + - " \"SDNCEvent\": {" + EOL + - " \"eventType\": \"UCPE-ACTIVATION\"," + EOL + - " \"eventCorrelatorType\": \"UCPE-HOST-NAME\"," + EOL + - " \"eventCorrelator\": \"((CORRELATOR))\"," + EOL + - " \"params\": {" + EOL + - " \"success-indicator\":\"N\"," + EOL + - " \"error-message\":\"SOMETHING BAD HAPPENED\"" + EOL + - " }" +EOL + - " }" + EOL + - "}" + EOL); - } - - /** - * Test the happy path. - */ - @Test - @Deployment(resources = { - "subprocess/ReceiveWorkflowMessage.bpmn" - }) - public void happyPath() throws Exception { - - logStart(); - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - variables.put("mso-request-id", "dffbae0e-5588-4bd6-9749-b0f0adb52312"); - variables.put("isDebugLogEnabled", "true"); - variables.put("RCVWFMSG_timeout", "PT1M"); - variables.put("RCVWFMSG_messageType", "SDNCAEvent"); - variables.put("RCVWFMSG_correlator", "USOSTCDALTX0101UJZZ31"); - - invokeSubProcess("ReceiveWorkflowMessage", businessKey, variables); - injectWorkflowMessages(callbacks, "sdnc-event-success"); - waitForProcessEnd(businessKey, 10000); - - String response = (String) getVariableFromHistory(businessKey, "WorkflowResponse"); - System.out.println("Response:\n" + response); - assertTrue(response.contains("\"SDNCEvent\"")); - assertTrue((boolean)getVariableFromHistory(businessKey, "RCVWFMSG_SuccessIndicator")); - - logEnd(); - } - - /** - * Test the timeout scenario. - */ - @Test - @Deployment(resources = { - "subprocess/ReceiveWorkflowMessage.bpmn" - }) - public void timeout() throws Exception { - - logStart(); - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - variables.put("mso-request-id", "dffbae0e-5588-4bd6-9749-b0f0adb52312"); - variables.put("isDebugLogEnabled", "true"); - variables.put("RCVWFMSG_timeout", "PT5S"); - variables.put("RCVWFMSG_messageType", "SDNCAEvent"); - variables.put("RCVWFMSG_correlator", "USOSTCDALTX0101UJZZ31"); - - invokeSubProcess("ReceiveWorkflowMessage", businessKey, variables); - - // No injection - - waitForProcessEnd(businessKey, 10000); - - // There is no response from SDNC, so the flow doesn't set WorkflowResponse. - String response = (String) getVariableFromHistory(businessKey, "WorkflowResponse"); - assertNull(response); - WorkflowException wfe = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - assertNotNull(wfe); - System.out.println(wfe.toString()); - assertEquals("Receive Workflow Message Timeout Error", wfe.getErrorMessage()); - assertFalse((boolean)getVariableFromHistory(businessKey, "RCVWFMSG_SuccessIndicator")); - - logEnd(); - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterCallbackRule.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterCallbackRule.java deleted file mode 100644 index ec1a22347b..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterCallbackRule.java +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * ============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.openecomp.mso.bpmn.common; - -import javax.xml.ws.Endpoint; - -import org.camunda.bpm.engine.ProcessEngineServices; -import org.junit.rules.TestRule; -import org.junit.runner.Description; -import org.junit.runners.model.Statement; -import org.openecomp.mso.bpmn.common.workflow.service.SDNCAdapterCallbackServiceImpl; - -/** - * A JUnit rule that starts the SDNC Adapter Callback Service before - * every test, and tears it down after every test. Example: - * <pre> - * @Rule - * public final SDNCAdapterCallbackRule sdncAdapterCallbackRule = - * new SDNCAdapterCallbackRule(processEngineRule); - * </pre> - */ -public class SDNCAdapterCallbackRule implements TestRule { - public static final String DEFAULT_ENDPOINT_URL = - "http://localhost:28080/mso/SDNCAdapterCallbackService"; - - private final ProcessEngineServices processEngineServices; - private final String endpointUrl; - - public SDNCAdapterCallbackRule(ProcessEngineServices processEngineServices) { - this(processEngineServices, DEFAULT_ENDPOINT_URL); - } - - public SDNCAdapterCallbackRule(ProcessEngineServices processEngineServices, - String endpointUrl) { - this.processEngineServices = processEngineServices; - this.endpointUrl = endpointUrl; - } - - @Override - public Statement apply(final Statement baseStmt, Description description) { - return new Statement() { - @Override - public void evaluate() throws Throwable { - Endpoint endpoint = null; - - try { - SDNCAdapterCallbackServiceImpl sdncCallbackService = new SDNCAdapterCallbackServiceImpl(); - sdncCallbackService.setProcessEngineServices4junit(processEngineServices); - - System.setProperty("com.sun.xml.ws.transport.http.HttpAdapter.dump", "true"); - System.setProperty("com.sun.xml.internal.ws.transport.http.HttpAdapter.dump", "true"); - - System.out.println("Publishing Endpoint - " + endpointUrl); - endpoint = Endpoint.publish(endpointUrl, sdncCallbackService); - - baseStmt.evaluate(); - } finally { - if (endpoint != null) { - System.out.println("Stopping Endpoint - " + endpointUrl); - endpoint.stop(); - } - } - } - }; - } -}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterRestV2Test.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterRestV2Test.java deleted file mode 100644 index 90336bb391..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterRestV2Test.java +++ /dev/null @@ -1,152 +0,0 @@ -/*- - * ============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.openecomp.mso.bpmn.common;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.ws.rs.core.Response;
-
-import org.camunda.bpm.engine.test.Deployment;
-import org.junit.Assert;
-import org.junit.Test;
-import org.openecomp.mso.bpmn.common.WorkflowTest;
-import org.openecomp.mso.bpmn.common.workflow.service.WorkflowMessageResource;
-import org.openecomp.mso.bpmn.mock.FileUtil;
-
-/**
- * Unit tests for SDNCAdapterRestV2.bpmn.
- *
- * This version of SDNCAdapterRest allows for interim notifications to be sent for
- * any non-final response received from SDNC.
- */
-public class SDNCAdapterRestV2Test extends WorkflowTest {
-
- private final CallbackSet callbacks = new CallbackSet();
-
- /**
- * Constructor. Insert callbacks.
- *
- * @throws IOException
- */
- public SDNCAdapterRestV2Test() throws IOException {
- String sdncCallbackFinal = FileUtil.readResourceFile("__files/SDNCAdapterRestCallbackFinal.json");
- String sdncCallbackNonFinal = FileUtil.readResourceFile("__files/SDNCAdapterRestCallbackNonFinal.json");
- callbacks.put("nonfinal", sdncCallbackNonFinal);
- callbacks.put("final", sdncCallbackFinal);
- }
-
- /**
- * Test the success path through the subflow.
- */
- @Test
- @Deployment(resources = {
- "subprocess/SDNCAdapterRestV2.bpmn",
- "subprocess/GenericNotificationService.bpmn"
- })
- public void success() throws IOException {
- logStart();
- mocks();
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<String, Object>();
- variables.put("mso-request-id", "a4383a52-b9de-4bc4-bedf-02f3f9466535");
- variables.put("mso-service-instance-id", "fd8bcdbb-b799-43ce-a7ff-ed8f2965a3b5");
- variables.put("isDebugLogEnabled", "true");
- variables.put("SDNCREST_Request",
- FileUtil.readResourceFile("__files/SDNCAdapterRestV2Request.json"));
- variables.put("SDNCREST_InterimNotification1",
- FileUtil.readResourceFile("__files/SDNCInterimNotification1.json"));
-
- invokeSubProcess("SDNCAdapterRestV2", businessKey, variables);
-
- injectSDNCRestCallbacks(callbacks, "nonfinal");
-
- // First non-final response will have done a notification
- Object interimNotification = getVariableFromHistory(businessKey, "SDNCREST_interimNotification");
- Assert.assertNotNull(interimNotification);
-
- injectSDNCRestCallbacks(callbacks, "nonfinal");
-
- // Second non-final response will not have done a notification
- interimNotification = getVariableFromHistory(businessKey, "SDNCREST_interimNotification");
- Assert.assertNull(interimNotification);
-
- injectSDNCRestCallbacks(callbacks, "final");
-
- interimNotification = this.getVariableFromHistory(businessKey, "SDNCREST_interimNotification");
- Assert.assertNull(interimNotification);
-
- waitForProcessEnd(businessKey, 10000);
-
- Assert.assertTrue(isProcessEnded(businessKey));
-
- logEnd();
- }
-
- /**
- * Injects a single SDNC adapter callback request. The specified callback data
- * may contain the placeholder string ((REQUEST-ID)) which is replaced with
- * the actual SDNC request ID. Note: this is not the requestId in the original
- * MSO request.
- * @param contentType the HTTP content type for the callback
- * @param content the content of the callback
- * @param timeout the timeout in milliseconds
- * @return true if the callback could be injected, false otherwise
- */
- @Override
- protected boolean injectSDNCRestCallback(String contentType, String content, long timeout) {
- String sdncRequestId = (String) getProcessVariable("SDNCAdapterRestV2",
- "SDNCAResponse_CORRELATOR", timeout);
-
- if (sdncRequestId == null) {
- return false;
- }
-
- content = content.replace("((REQUEST-ID))", sdncRequestId);
- // Deprecated usage. All test code should switch to the (( ... )) syntax.
- content = content.replace("{{REQUEST-ID}}", sdncRequestId);
-
- System.out.println("Injecting SDNC adapter callback");
- WorkflowMessageResource workflowMessageResource = new WorkflowMessageResource();
- workflowMessageResource.setProcessEngineServices4junit(processEngineRule);
- Response response = workflowMessageResource.deliver(contentType, "SDNCAResponse", sdncRequestId, content);
- System.out.println("Workflow response to SDNC adapter callback: " + response);
- return true;
- }
-
- /**
- * Defines WireMock stubs needed by these tests.
- */
- private void mocks() {
- stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services"))
- .willReturn(aResponse()
- .withStatus(202)
- .withHeader("Content-Type", "application/json")));
- }
-}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterV1Test.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterV1Test.java deleted file mode 100644 index 02e029de46..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterV1Test.java +++ /dev/null @@ -1,475 +0,0 @@ -/*-
- * ============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.openecomp.mso.bpmn.common;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB;
-import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.ws.rs.core.Response;
-
-import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl;
-import org.camunda.bpm.engine.runtime.Job;
-import org.camunda.bpm.engine.test.Deployment;
-import org.camunda.bpm.engine.variable.impl.VariableMapImpl;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.openecomp.mso.bpmn.common.adapter.sdnc.CallbackHeader;
-import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCAdapterCallbackRequest;
-import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCAdapterResponse;
-import org.openecomp.mso.bpmn.common.workflow.service.SDNCAdapterCallbackServiceImpl;
-import org.openecomp.mso.bpmn.common.workflow.service.SDNCAdapterCallbackServiceImpl.SDNCAdapterErrorResponse;
-import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResource;
-import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
-import org.openecomp.mso.bpmn.core.PropertyConfigurationSetup;
-import org.openecomp.mso.bpmn.core.xml.XmlTool;
-import org.openecomp.mso.bpmn.mock.FileUtil;
-
-/**
- * Unit test cases for SDNCAdapterV1.bpmn
- */
-public class SDNCAdapterV1Test extends WorkflowTest {
-
- private String sdncAdapterWorkflowRequest;
- private String sdncAdapterWorkflowRequestAct;
- private String sdncAdapterCallbackRequestData;
- private String sdncAdapterCallbackRequestDataNonfinal;
-
- public SDNCAdapterV1Test() throws IOException {
- sdncAdapterWorkflowRequest = FileUtil.readResourceFile("sdncadapterworkflowrequest.xml");
- sdncAdapterWorkflowRequestAct = FileUtil.readResourceFile("sdncadapterworkflowrequest-act.xml");
- sdncAdapterCallbackRequestData = FileUtil.readResourceFile("sdncadaptercallbackrequestdata.text");
- sdncAdapterCallbackRequestDataNonfinal = FileUtil.readResourceFile("sdncadaptercallbackrequestdata-nonfinal.text");
- }
-
- /**
- * End-to-End flow - Unit test for SDNCAdapterV1.bpmn
- * - String input & String response
- */
-
- private WorkflowResponse invokeFlow(String workflowRequest) {
-
- Map<String, Object>valueMap = new HashMap<>();
- valueMap.put("value", workflowRequest);
- Map<String, Object> variables = new HashMap<>();
- variables.put("sdncAdapterWorkflowRequest", valueMap);
-
- Map<String, Object> valueMap2 = new HashMap<>();
- valueMap2.put("value", "true");
- variables.put("isDebugLogEnabled", valueMap2);
-
- VariableMapImpl varMap = new VariableMapImpl();
- varMap.put("variables", variables);
-
- //System.out.println("Invoking the flow");
-
- WorkflowResource workflowResource = new WorkflowResource();
- workflowResource.setProcessEngineServices4junit(processEngineRule);
-
- Response response = workflowResource.startProcessInstanceByKey("sdncAdapter", varMap);
- WorkflowResponse workflowResponse = (WorkflowResponse) response.getEntity();
-
- //String pid = workflowResponse.getProcessInstanceId();
- //System.out.println("Back from executing process instance with pid=" + pid);
- return workflowResponse;
- }
-
- @Test
- @Deployment(resources = {"subprocess/SDNCAdapterV1.bpmn",
- "subprocess/GenericNotificationService.bpmn"
- })
- public void sunnyDay() throws InterruptedException {
-
- mockSDNCAdapter(200);
-
- //System.out.println("SDNCAdapter sunny day flow Started!");
-
- ProcessExecutionThread thread = new ProcessExecutionThread(sdncAdapterWorkflowRequest);
- thread.start();
- waitForExecutionToStart("sdncAdapter", 3);
- String pid = getPid();
-
- assertProcessInstanceNotFinished(pid);
-
- System.out.println("Injecting SDNC Adapter asynchronous callback message to continue processing");
- String generatedRequestId = (String) processEngineRule.getRuntimeService().getVariable(pid, "SDNCA_requestId");
- CallbackHeader callbackHeader = new CallbackHeader();
- callbackHeader.setRequestId(generatedRequestId);
- callbackHeader.setResponseCode("200");
- callbackHeader.setResponseMessage("OK");
- SDNCAdapterCallbackRequest sdncAdapterCallbackRequest = new SDNCAdapterCallbackRequest();
- sdncAdapterCallbackRequest.setCallbackHeader(callbackHeader);
- sdncAdapterCallbackRequest.setRequestData(sdncAdapterCallbackRequestData);
- SDNCAdapterCallbackServiceImpl callbackService = new SDNCAdapterCallbackServiceImpl();
- callbackService.setProcessEngineServices4junit(processEngineRule);
- SDNCAdapterResponse sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest);
- //System.out.println("Back from executing process again");
-
- assertFalse(sdncAdapterResponse instanceof SDNCAdapterErrorResponse);
- assertProcessInstanceFinished(pid);
-
- //System.out.println("SDNCAdapter sunny day flow Completed!");
- }
-
- @Test
- @Deployment(resources = {"subprocess/SDNCAdapterV1.bpmn",
- "subprocess/GenericNotificationService.bpmn"
- })
- public void nonFinalWithTimeout() throws InterruptedException {
-
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBAdapter.xml");
-
- //System.out.println("SDNCAdapter interim status processing flow Started!");
-
- ProcessExecutionThread thread = new ProcessExecutionThread(sdncAdapterWorkflowRequestAct);
- thread.start();
- waitForExecutionToStart("sdncAdapter", 3);
- String pid = getPid();
-
- assertProcessInstanceNotFinished(pid);
-
- //System.out.println("Injecting SDNC Adapter asynchronous callback message to continue processing");
- String generatedRequestId = (String) processEngineRule.getRuntimeService().getVariable(pid, "SDNCA_requestId");
- CallbackHeader callbackHeader = new CallbackHeader();
- callbackHeader.setRequestId(generatedRequestId);
- callbackHeader.setResponseCode("200");
- callbackHeader.setResponseMessage("OK");
- SDNCAdapterCallbackRequest sdncAdapterCallbackRequest = new SDNCAdapterCallbackRequest();
- sdncAdapterCallbackRequest.setCallbackHeader(callbackHeader);
- sdncAdapterCallbackRequest.setRequestData(sdncAdapterCallbackRequestDataNonfinal);
- SDNCAdapterCallbackServiceImpl callbackService = new SDNCAdapterCallbackServiceImpl();
- callbackService.setProcessEngineServices4junit(processEngineRule);
- SDNCAdapterResponse sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest);
- //System.out.println("Back from executing process again");
-
- assertFalse(sdncAdapterResponse instanceof SDNCAdapterErrorResponse);
- assertProcessInstanceNotFinished(pid);
-
- checkForTimeout(pid);
-
- assertEquals(true, (Boolean) (getVariable(pid, "continueListening")));
- assertEquals(false, (Boolean) (getVariable(pid, "SDNCA_InterimNotify")));
-
-
- //System.out.println("SDNCAdapter interim status processing flow Completed!");
- }
-
- @Test
- @Deployment(resources = {"subprocess/SDNCAdapterV1.bpmn",
- "subprocess/GenericNotificationService.bpmn"
- })
- public void nonFinalThenFinal() throws InterruptedException {
-
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBAdapter.xml");
-
- //System.out.println("SDNCAdapter non-final then final processing flow Started!");
-
- // Start the flow
- ProcessExecutionThread thread = new ProcessExecutionThread(sdncAdapterWorkflowRequestAct);
- thread.start();
- waitForExecutionToStart("sdncAdapter", 3);
- String pid = getPid();
-
- assertProcessInstanceNotFinished(pid);
-
- // Inject a "non-final" SDNC Adapter asynchronous callback message
- //System.out.println("Injecting SDNC Adapter asynchronous callback message to continue processing");
- String generatedRequestId = (String) processEngineRule.getRuntimeService().getVariable(pid, "SDNCA_requestId");
- CallbackHeader callbackHeader = new CallbackHeader();
- callbackHeader.setRequestId(generatedRequestId);
- callbackHeader.setResponseCode("200");
- callbackHeader.setResponseMessage("OK");
- SDNCAdapterCallbackRequest sdncAdapterCallbackRequest = new SDNCAdapterCallbackRequest();
- sdncAdapterCallbackRequest.setCallbackHeader(callbackHeader);
- sdncAdapterCallbackRequest.setRequestData(sdncAdapterCallbackRequestDataNonfinal);
- SDNCAdapterCallbackServiceImpl callbackService = new SDNCAdapterCallbackServiceImpl();
- callbackService.setProcessEngineServices4junit(processEngineRule);
- SDNCAdapterResponse sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest);
- //System.out.println("Back from executing process again");
-
- assertFalse(sdncAdapterResponse instanceof SDNCAdapterErrorResponse);
- assertProcessInstanceNotFinished(pid);
- assertEquals(true, (Boolean) (getVariable(pid, "continueListening")));
- assertEquals(false, (Boolean) (getVariable(pid, "SDNCA_InterimNotify")));
-
- // Inject a "final" SDNC Adapter asynchronous callback message
- sdncAdapterCallbackRequest.setRequestData(sdncAdapterCallbackRequestData);
- sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest);
- //System.out.println("Back from executing process again");
-
- assertFalse(sdncAdapterResponse instanceof SDNCAdapterErrorResponse);
- assertProcessInstanceFinished(pid);
- assertEquals(false, (Boolean) (getVariable(pid, "continueListening")));
- assertEquals(false, (Boolean) (getVariable(pid, "SDNCA_InterimNotify")));
-
- //System.out.println("SDNCAdapter non-final then final processing flow Completed!");
- }
-
-
- @Test
- @Deployment(resources = {"subprocess/SDNCAdapterV1.bpmn",
- "subprocess/GenericNotificationService.bpmn"
- })
- public void nonFinalThenFinalWithNotify() throws InterruptedException {
-
- mockSDNCAdapter(200);
- mockUpdateRequestDB(200, "Database/DBAdapter.xml");
-
- //System.out.println("SDNCAdapter non-final then final processing flow Started!");
-
- String modSdncAdapterWorkflowRequestAct = sdncAdapterWorkflowRequestAct;
- try {
- // only service-type "uCPE-VMS" is applicable to notification, so modify the test request
- modSdncAdapterWorkflowRequestAct = XmlTool.modifyElement(sdncAdapterWorkflowRequestAct, "tag0:service-type", "uCPE-VMS").get();
- System.out.println("modified request: " + modSdncAdapterWorkflowRequestAct);
- } catch (Exception e) {
- System.out.println("request modification failed");
- //e.printStackTrace();
- }
-
- // Start the flow
- ProcessExecutionThread thread = new ProcessExecutionThread(modSdncAdapterWorkflowRequestAct);
- thread.start();
- waitForExecutionToStart("sdncAdapter", 3);
- String pid = getPid();
-
- assertProcessInstanceNotFinished(pid);
-
- // Inject a "non-final" SDNC Adapter asynchronous callback message
- //System.out.println("Injecting SDNC Adapter asynchronous callback message to continue processing");
- String generatedRequestId = (String) processEngineRule.getRuntimeService().getVariable(pid, "SDNCA_requestId");
- CallbackHeader callbackHeader = new CallbackHeader();
- callbackHeader.setRequestId(generatedRequestId);
- callbackHeader.setResponseCode("200");
- callbackHeader.setResponseMessage("OK");
- SDNCAdapterCallbackRequest sdncAdapterCallbackRequest = new SDNCAdapterCallbackRequest();
- sdncAdapterCallbackRequest.setCallbackHeader(callbackHeader);
- sdncAdapterCallbackRequest.setRequestData(sdncAdapterCallbackRequestDataNonfinal);
- SDNCAdapterCallbackServiceImpl callbackService = new SDNCAdapterCallbackServiceImpl();
- callbackService.setProcessEngineServices4junit(processEngineRule);
- SDNCAdapterResponse sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest);
- //System.out.println("Back from executing process again");
-
- assertFalse(sdncAdapterResponse instanceof SDNCAdapterErrorResponse);
- assertProcessInstanceNotFinished(pid);
- assertEquals(true, (Boolean) (getVariable(pid, "continueListening")));
- assertEquals(true, (Boolean) (getVariable(pid, "SDNCA_InterimNotify")));
-
- // Inject a "final" SDNC Adapter asynchronous callback message
- sdncAdapterCallbackRequest.setRequestData(sdncAdapterCallbackRequestData);
- sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest);
- //System.out.println("Back from executing process again");
-
- assertFalse(sdncAdapterResponse instanceof SDNCAdapterErrorResponse);
- assertProcessInstanceFinished(pid);
- assertEquals(false, (Boolean) (getVariable(pid, "continueListening")));
- assertEquals(false, (Boolean) (getVariable(pid, "SDNCA_InterimNotify")));
-
- //System.out.println("SDNCAdapter non-final then final processing flow Completed!");
- }
-
-
- private void waitForExecutionToStart(String processDefintion, int count) throws InterruptedException {
- //System.out.println(processEngineRule.getRuntimeService().createExecutionQuery().processDefinitionKey(processDefintion).count());
- while (processEngineRule.getRuntimeService().createExecutionQuery().processDefinitionKey(processDefintion).count() != count) {
- Thread.sleep(200);
- }
- }
-
- @Test
- @Ignore // Ignored because PropertyConfigurationSetup is timing out
- @Deployment(resources = {"subprocess/SDNCAdapterV1.bpmn",
- "subprocess/GenericNotificationService.bpmn"
- })
- public void badCorrelationIdTest() throws InterruptedException, IOException {
-
- mockSDNCAdapter(200);
-
- Map<String, String> urnProperties = PropertyConfigurationSetup.createBpmnUrnProperties();
- urnProperties.put("mso.correlation.timeout", "5");
- PropertyConfigurationSetup.addProperties(urnProperties, 10000);
-
- //System.out.println("SDNCAdapter bad RequestId test Started!");
-
- ProcessExecutionThread thread = new ProcessExecutionThread(sdncAdapterWorkflowRequest);
- thread.start();
- waitForExecutionToStart("sdncAdapter", 3);
- String pid = getPid();
- assertProcessInstanceNotFinished(pid);
-
- //System.out.println("Injecting SDNC Adapter asynchronous callback message to continue processing");
- String badRequestId = "This is not the RequestId that was used";
- CallbackHeader callbackHeader = new CallbackHeader();
- callbackHeader.setRequestId(badRequestId);
- callbackHeader.setResponseCode("200");
- callbackHeader.setResponseMessage("OK");
- SDNCAdapterCallbackRequest sdncAdapterCallbackRequest = new SDNCAdapterCallbackRequest();
- sdncAdapterCallbackRequest.setCallbackHeader(callbackHeader);
- sdncAdapterCallbackRequest.setRequestData(sdncAdapterCallbackRequestData);
- SDNCAdapterCallbackServiceImpl callbackService = new SDNCAdapterCallbackServiceImpl();
- callbackService.setProcessEngineServices4junit(processEngineRule);
- SDNCAdapterResponse sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest);
- //System.out.println("Back from executing process again");
-
- assertTrue(sdncAdapterResponse instanceof SDNCAdapterErrorResponse);
- assertTrue(((SDNCAdapterErrorResponse) sdncAdapterResponse).getError().contains("No process is waiting for sdncAdapterCallbackRequest"));
- assertProcessInstanceNotFinished(pid);
-
- //System.out.println("SDNCAdapter bad RequestId test Completed!");
- }
-
- @Test
- @Deployment(resources = {"subprocess/SDNCAdapterV1.bpmn",
- "subprocess/GenericNotificationService.bpmn"
- })
- public void badSynchronousResponse() throws IOException, InterruptedException {
-
- mockSDNCAdapter(404);
-
- //System.out.println("SDNCAdapter bad synchronous response flow Started!");
-
- ProcessExecutionThread thread = new ProcessExecutionThread(sdncAdapterWorkflowRequest);
- thread.start();
- while (thread.isAlive()) {
- Thread.sleep(200);
- }
- WorkflowResponse response = thread.workflowResponse;
- Assert.assertNotNull(response);
- Assert.assertEquals("404 error", response.getMessageCode(),7000);
-// assertProcessInstanceFinished(response.getProcessInstanceId());
- //System.out.println("SDNCAdapter bad synchronous response flow Completed!");
- }
-
- @Test
- @Deployment(resources = {"subprocess/SDNCAdapterV1.bpmn",
- "subprocess/GenericNotificationService.bpmn"
- })
- public void sdncNotFound() throws IOException, InterruptedException {
- mockSDNCAdapter(200);
- mockSDNCAdapter("/sdncAdapterMock/404", 400, "sdncCallbackErrorResponse.xml");
-
- ProcessExecutionThread thread = new ProcessExecutionThread(sdncAdapterWorkflowRequest);
- thread.start();
- waitForExecutionToStart("sdncAdapter", 3);
- String pid = getPid();
-
- //System.out.println("Injecting SDNC Adapter asynchronous callback message to continue processing");
- String generatedRequestId = (String) processEngineRule.getRuntimeService().getVariable(pid, "SDNCA_requestId");
- CallbackHeader callbackHeader = new CallbackHeader();
- callbackHeader.setRequestId(generatedRequestId);
- callbackHeader.setResponseCode("404");
- callbackHeader.setResponseMessage("Error processing request to SDNC. Not Found. https://sdncodl.it.us.aic.cip.com:8443/restconf/config/L3SDN-API:services/layer3-service-list/AS%2FVLXM%2F000199%2F%2FSB_INTERNET. SDNC Returned-[error-type:application, error-tag:data-missing, error-message:Request could not be completed because the relevant data model content does not exist.]");
- SDNCAdapterCallbackRequest sdncAdapterCallbackRequest = new SDNCAdapterCallbackRequest();
- sdncAdapterCallbackRequest.setCallbackHeader(callbackHeader);
- SDNCAdapterCallbackServiceImpl callbackService = new SDNCAdapterCallbackServiceImpl();
- callbackService.setProcessEngineServices4junit(processEngineRule);
- SDNCAdapterResponse sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest);
- //System.out.println("Back from executing process again");
-
- assertProcessInstanceFinished(pid);
- assertNotNull(sdncAdapterResponse);
- //TODO query history to see SDNCA_ResponseCode, SDNCA_ErrorResponse
- //System.out.println("SDNCAdapter SDNC Notfound test Completed!");
- }
-
- @Test
- @Deployment(resources = {"subprocess/SDNCAdapterV1.bpmn",
- "subprocess/GenericNotificationService.bpmn"
- })
- public void asynchronousMessageTimeout() throws IOException, InterruptedException {
- mockSDNCAdapter(200);
- //System.out.println("SDNCAdapter asynchronous message timeout flow Started!");
- ProcessExecutionThread thread = new ProcessExecutionThread(sdncAdapterWorkflowRequest);
- thread.start();
- waitForExecutionToStart("sdncAdapter", 3);
- checkForTimeout(getPid());
- }
-
- private void checkForTimeout(String pid) throws InterruptedException {
-
- assertProcessInstanceNotFinished(pid);
-
- ProcessEngineConfigurationImpl processEngineConfiguration =
- (ProcessEngineConfigurationImpl) processEngineRule.getProcessEngine().getProcessEngineConfiguration();
- assertTrue(processEngineConfiguration.getJobExecutor().isActive());
-
- Job timerJob = processEngineRule.getManagementService().createJobQuery().processInstanceId(pid).singleResult();
- assertNotNull(timerJob);
-
- processEngineRule.getManagementService().executeJob(timerJob.getId());
-
- assertProcessInstanceFinished(pid);
-
- //System.out.println("SDNCAdapter asynchronous message timeout flow Completed!");
- }
-
- class ProcessExecutionThread extends Thread {
-
- private String workflowRequest;
- private WorkflowResponse workflowResponse;
-
- public ProcessExecutionThread(String workflowRequest) {
- this.workflowRequest = workflowRequest;
- }
-
- public void run() {
- workflowResponse = invokeFlow(workflowRequest);
- workflowResponse.getProcessInstanceId();
- }
- }
-
- private String getPid() {
- return processEngineRule.getHistoryService().createHistoricProcessInstanceQuery().list().get(0).getId();
- }
-
- private Object getVariable(String pid, String variableName) {
- try {
- return
- processEngineRule
- .getHistoryService()
- .createHistoricVariableInstanceQuery()
- .processInstanceId(pid).variableName(variableName)
- .singleResult()
- .getValue();
- } catch(Exception ex) {
- return null;
- }
- }
-
- private void assertProcessInstanceFinished(String pid) {
- assertEquals(1, processEngineRule.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(pid).finished().count());
- }
-
- private void assertProcessInstanceNotFinished(String pid) {
- assertEquals(0, processEngineRule.getHistoryService().createHistoricProcessInstanceQuery().processInstanceId(pid).finished().count());
- }
-
-}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SPIPropertiesTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SPIPropertiesTest.java deleted file mode 100644 index e9a5492b6f..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SPIPropertiesTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ============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.openecomp.mso.bpmn.common; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; - -import java.io.FileNotFoundException; -import java.io.IOException; - -import org.junit.BeforeClass; -import org.junit.Test; -import org.openecomp.mso.client.RestPropertiesLoader; -import org.openecomp.mso.client.aai.AAIProperties; -import org.openecomp.mso.client.dmaap.DmaapProperties; -import org.openecomp.mso.client.dmaap.DmaapPropertiesLoader; -import org.openecomp.mso.client.sdno.dmaap.SDNOHealthCheckDmaapConsumer; - -public class SPIPropertiesTest { - - @BeforeClass - public static void beforeClass() { - System.setProperty("mso.config.path", "src/test/resources"); - } - - @Test - public void notEqual() { - DmaapProperties one = DmaapPropertiesLoader.getInstance().getNewImpl(); - DmaapProperties two = DmaapPropertiesLoader.getInstance().getNewImpl(); - assertNotEquals(one, two); - } - @Test - public void equal() { - DmaapProperties one = DmaapPropertiesLoader.getInstance().getImpl(); - DmaapProperties two = DmaapPropertiesLoader.getInstance().getImpl(); - assertEquals(one, two); - } - @Test - public void restNotEqual() { - AAIProperties one = RestPropertiesLoader.getInstance().getNewImpl(AAIProperties.class); - AAIProperties two = RestPropertiesLoader.getInstance().getNewImpl(AAIProperties.class); - assertNotEquals(one, two); - } - @Test - public void restEqual() { - AAIProperties one = RestPropertiesLoader.getInstance().getImpl(AAIProperties.class); - AAIProperties two = RestPropertiesLoader.getInstance().getImpl(AAIProperties.class); - assertEquals(one, two); - } - -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SniroHomingTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SniroHomingTest.java deleted file mode 100644 index 314d4d3b42..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SniroHomingTest.java +++ /dev/null @@ -1,548 +0,0 @@ -/*- - * ============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========================================================= - */ - -/* - * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. - */ -package org.openecomp.mso.bpmn.common; - -import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.MockGetServiceResourcesCatalogDataByModelUuid; -import static org.openecomp.mso.bpmn.mock.StubResponseSNIRO.*; -import static org.junit.Assert.*; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -import org.camunda.bpm.engine.test.Deployment; -import org.junit.Ignore; -import org.junit.Test; - -import org.openecomp.mso.bpmn.core.WorkflowException; -import org.openecomp.mso.bpmn.core.domain.*; -import org.openecomp.mso.bpmn.mock.FileUtil; - - -/** - * Test the SNIRO Homing subflow building block. - */ -public class SniroHomingTest extends WorkflowTest { - - ServiceDecomposition serviceDecomposition = new ServiceDecomposition(); - String subscriber = ""; - String subscriber2 = ""; - - private final CallbackSet callbacks = new CallbackSet(); - - public SniroHomingTest() throws IOException { - String sniroCallback = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallback2AR1Vnf"); - String sniroCallback2 = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallback2AR1Vnf2Net"); - String sniroCallback3 = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackInfraVnf"); - String sniroCallbackNoSolution = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackNoSolutionFound"); - String sniroCallbackPolicyException = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackPolicyException"); - String sniroCallbackServiceException = FileUtil.readResourceFile("__files/BuildingBlocks/sniroCallbackServiceException"); - callbacks.put("sniro", JSON, "SNIROResponse", sniroCallback); - callbacks.put("sniro2", JSON, "SNIROResponse", sniroCallback2); - callbacks.put("sniro3", JSON, "SNIROResponse", sniroCallback3); - callbacks.put("sniroNoSol", JSON, "SNIROResponse", sniroCallbackNoSolution); - callbacks.put("sniroPolicyEx", JSON, "SNIROResponse", sniroCallbackPolicyException); - callbacks.put("sniroServiceEx", JSON, "SNIROResponse", sniroCallbackServiceException); - - // Service Model - ModelInfo sModel = new ModelInfo(); - sModel.setModelCustomizationUuid("testModelCustomizationUuid"); - sModel.setModelInstanceName("testModelInstanceName"); - sModel.setModelInvariantUuid("testModelInvariantId"); - sModel.setModelName("testModelName"); - sModel.setModelUuid("testModelUuid"); - sModel.setModelVersion("testModelVersion"); - // Service Instance - ServiceInstance si = new ServiceInstance(); - si.setInstanceId("testServiceInstanceId123"); - // Allotted Resources - List<AllottedResource> arList = new ArrayList<AllottedResource>(); - AllottedResource ar = new AllottedResource(); - ar.setResourceId("testResourceIdAR"); - ar.setResourceInstanceName("testARInstanceName"); - ModelInfo arModel = new ModelInfo(); - arModel.setModelCustomizationUuid("testModelCustomizationUuidAR"); - arModel.setModelInvariantUuid("testModelInvariantIdAR"); - arModel.setModelName("testModelNameAR"); - arModel.setModelVersion("testModelVersionAR"); - arModel.setModelUuid("testARModelUuid"); - arModel.setModelType("testModelTypeAR"); - ar.setModelInfo(arModel); - AllottedResource ar2 = new AllottedResource(); - ar2.setResourceId("testResourceIdAR2"); - ar2.setResourceInstanceName("testAR2InstanceName"); - ModelInfo arModel2 = new ModelInfo(); - arModel2.setModelCustomizationUuid("testModelCustomizationUuidAR2"); - arModel2.setModelInvariantUuid("testModelInvariantIdAR2"); - arModel2.setModelName("testModelNameAR2"); - arModel2.setModelVersion("testModelVersionAR2"); - arModel2.setModelUuid("testAr2ModelUuid"); - arModel2.setModelType("testModelTypeAR2"); - ar2.setModelInfo(arModel2); - arList.add(ar); - arList.add(ar2); - // Vnfs - List<VnfResource> vnfList = new ArrayList<VnfResource>(); - VnfResource vnf = new VnfResource(); - vnf.setResourceId("testResourceIdVNF"); - vnf.setResourceInstanceName("testVnfInstanceName"); - ModelInfo vnfModel = new ModelInfo(); - vnfModel.setModelCustomizationUuid("testModelCustomizationUuidVNF"); - vnfModel.setModelInvariantUuid("testModelInvariantIdVNF"); - vnfModel.setModelName("testModelNameVNF"); - vnfModel.setModelVersion("testModelVersionVNF"); - vnfModel.setModelUuid("testVnfModelUuid"); - vnfModel.setModelType("testModelTypeVNF"); - vnf.setModelInfo(vnfModel); - vnfList.add(vnf); - System.out.println("SERVICE DECOMP: " + serviceDecomposition.getServiceResourcesJsonString()); - serviceDecomposition.setModelInfo(sModel); - serviceDecomposition.setServiceAllottedResources(arList); - serviceDecomposition.setServiceVnfs(vnfList); - serviceDecomposition.setServiceInstance(si); - - // Subscriber - subscriber = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberCommonSiteId\": \"DALTX0101\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}"; - subscriber2 = "{\"globalSubscriberId\": \"SUB12_0322_DS_1201\",\"subscriberName\": \"SUB_12_0322_DS_1201\"}"; - } - - @Test - @Ignore // 1802 merge - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_success_2AR1Vnf() throws Exception { - - mockSNIRO(); - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - setVariables(variables); - - invokeSubProcess("Homing", businessKey, variables); - - injectWorkflowMessages(callbacks, "sniro"); - - waitForProcessEnd(businessKey, 10000); - - //Get Variables - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition"); - String expectedSniroRequest = (String) getVariableFromHistory(businessKey, "sniroRequest"); - - Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR"); - HomingSolution resourceARHoming = resourceAR.getHomingSolution(); - Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2"); - HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution(); - Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF"); - HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution(); - String resourceARHomingString = resourceARHoming.toString(); - resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " "); - String resourceARHoming2String = resourceARHoming2.toString(); - resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " "); - String resourceVNFHomingString = resourceVNFHoming.toString(); - resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " "); - expectedSniroRequest = expectedSniroRequest.replaceAll("\\s+", ""); - - assertNull(workflowException); - assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", "aic", "dfwtx", "KDTNJ01", "3.0", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceARHomingString); - assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2", "aic", "testCloudRegionId2", "testAicClli2", "3.0", null, null), resourceARHoming2String); - assertEquals(homingSolutionCloud("cloud", "", "", "aic", "testCloudRegionId3", "testAicClli3", "3.0", "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"", "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""), resourceVNFHomingString); - assertEquals(verifySniroRequest(), expectedSniroRequest); - - } - - @Test - @Ignore // 1802 merge - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_success_2AR1Vnf2Net() throws Exception { - - mockSNIRO(); - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - setVariables2(variables); - - invokeSubProcess("Homing", businessKey, variables); - - injectWorkflowMessages(callbacks, "sniro2"); - - waitForProcessEnd(businessKey, 10000); - - //Get Variables - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition"); - String expectedSniroRequest = (String) getVariableFromHistory(businessKey, "sniroRequest"); - - Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR"); - HomingSolution resourceARHoming = resourceAR.getHomingSolution(); - Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2"); - HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution(); - Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF"); - HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution(); - Resource resourceNet = serviceDecompositionExp.getServiceResource("testResourceIdNet"); - HomingSolution resourceNetHoming = resourceNet.getHomingSolution(); - Resource resourceNet2 = serviceDecompositionExp.getServiceResource("testResourceIdNet2"); - HomingSolution resourceNetHoming2 = resourceNet2.getHomingSolution(); - - String resourceARHomingString = resourceARHoming.toString(); - resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " "); - String resourceARHoming2String = resourceARHoming2.toString(); - resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " "); - String resourceVNFHomingString = resourceVNFHoming.toString(); - resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " "); - String resourceNetHomingString = resourceNetHoming.toString(); - resourceNetHomingString = resourceNetHomingString.replaceAll("\\s+", " "); - String resourceNetHoming2String = resourceNetHoming2.toString(); - resourceNetHoming2String = resourceNetHoming2String.replaceAll("\\s+", " "); - expectedSniroRequest = expectedSniroRequest.replaceAll("\\s+", ""); - - assertNull(workflowException); - assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", "aic", "dfwtx", "KDTNJ01", "3.0", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceARHomingString); - assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2", "aic", "testCloudRegionId2", "testAicClli2", "3.0", null, null), resourceARHoming2String); - assertEquals(homingSolutionCloud("cloud", "", "", "aic", "testCloudRegionId3", "testAicClli3", "3.0", "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"", "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""), resourceVNFHomingString); - assertEquals(homingSolutionService("service", "testServiceInstanceIdNet", "testVnfHostNameNet", "aic", "testCloudRegionIdNet", "testAicClliNet", "3.0", null, null), resourceNetHomingString); - assertEquals(homingSolutionCloud("cloud", "", "", "aic", "testCloudRegionIdNet2", "testAicClliNet2", "3.0", "\"f1d563e8-e714-4393-8f99-cc480144a05n\", \"j1d563e8-e714-4393-8f99-cc480144a05n\"", "\"s1d563e8-e714-4393-8f99-cc480144a05n\", \"b1d563e8-e714-4393-8f99-cc480144a05n\""), resourceNetHoming2String); - assertEquals(verifySniroRequest(), expectedSniroRequest); - } - - @Test - @Ignore // 1802 merge - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/BuildingBlock/DecomposeService.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_success_vnfResourceList() throws Exception { - - // Create a Service Decomposition - MockGetServiceResourcesCatalogDataByModelUuid("2f7f309d-c842-4644-a2e4-34167be5eeb4", "/BuildingBlocks/catalogResp.json"); - String busKey = UUID.randomUUID().toString(); - Map<String, Object> vars = new HashMap<>(); - setVariablesForServiceDecomposition(vars, "testRequestId123", "ff5256d2-5a33-55df-13ab-12abad84e7ff"); - invokeSubProcess("DecomposeService", busKey, vars); - - ServiceDecomposition sd = (ServiceDecomposition) getVariableFromHistory(busKey, "serviceDecomposition"); - List<VnfResource> vnfResourceList = sd.getServiceVnfs(); - vnfResourceList.get(0).setResourceId("test-resource-id-000"); - - // Invoke Homing - - mockSNIRO(); - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - variables.put("homingService", "sniro"); - variables.put("isDebugLogEnabled", "true"); - variables.put("msoRequestId", "testRequestId"); - variables.put("serviceInstanceId", "testServiceInstanceId"); - variables.put("serviceDecomposition", sd); - variables.put("subscriberInfo", subscriber2); - - invokeSubProcess("Homing", businessKey, variables); - injectWorkflowMessages(callbacks, "sniro3"); - waitForProcessEnd(businessKey, 10000); - - //Get Variables - - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition"); - - Resource resourceVnf = serviceDecompositionExp.getServiceResource("test-resource-id-000"); - HomingSolution resourceVnfHoming = resourceVnf.getHomingSolution(); - - String resourceVnfHomingString = resourceVnfHoming.toString(); - resourceVnfHomingString = resourceVnfHomingString.replaceAll("\\s+", " "); - - assertNull(workflowException); - - //Verify request - String sniroRequest = (String) getVariableFromHistory(businessKey, "sniroRequest"); - assertEquals(FileUtil.readResourceFile("__files/BuildingBlocks/sniroRequest_infravnf").replaceAll("\n", "").replaceAll("\r", "").replaceAll("\t", ""), sniroRequest.replaceAll("\n", "").replaceAll("\r", "").replaceAll("\t", "")); - - assertEquals(homingSolutionService("service", "service-instance-01234", "MDTNJ01", "att-aic", "mtmnj1a", "KDTNJ01", "3.0", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceVnfHomingString); - } - - @Test - @Ignore // 1802 merge - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_success_existingLicense() throws Exception { - - mockSNIRO(); - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<String, Object>(); - setVariablesExistingLicense(variables); - - invokeSubProcess("Homing", businessKey, variables); - - injectWorkflowMessages(callbacks, "sniro"); - - waitForProcessEnd(businessKey, 10000); - - //Get Variables - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - ServiceDecomposition serviceDecompositionExp = (ServiceDecomposition) getVariableFromHistory(businessKey, "serviceDecomposition"); - String sniroRequest = (String) getVariableFromHistory(businessKey, "sniroRequest"); - - Resource resourceAR = serviceDecompositionExp.getServiceResource("testResourceIdAR"); - HomingSolution resourceARHoming = resourceAR.getHomingSolution(); - Resource resourceAR2 = serviceDecompositionExp.getServiceResource("testResourceIdAR2"); - HomingSolution resourceARHoming2 = resourceAR2.getHomingSolution(); - Resource resourceVNF = serviceDecompositionExp.getServiceResource("testResourceIdVNF"); - HomingSolution resourceVNFHoming = resourceVNF.getHomingSolution(); - String resourceARHomingString = resourceARHoming.toString(); - resourceARHomingString = resourceARHomingString.replaceAll("\\s+", " "); - String resourceARHoming2String = resourceARHoming2.toString(); - resourceARHoming2String = resourceARHoming2String.replaceAll("\\s+", " "); - String resourceVNFHomingString = resourceVNFHoming.toString(); - resourceVNFHomingString = resourceVNFHomingString.replaceAll("\\s+", " "); - sniroRequest = sniroRequest.replaceAll("\\s+", ""); - - assertNull(workflowException); - assertEquals(homingSolutionService("service", "testSIID1", "MDTNJ01", "aic", "dfwtx", "KDTNJ01", "3.0", "\"f1d563e8-e714-4393-8f99-cc480144a05e\", \"j1d563e8-e714-4393-8f99-cc480144a05e\"", "\"s1d563e8-e714-4393-8f99-cc480144a05e\", \"b1d563e8-e714-4393-8f99-cc480144a05e\""), resourceARHomingString); - assertEquals(homingSolutionService("service", "testSIID2", "testVnfHostname2", "aic", "testCloudRegionId2", "testAicClli2", "3.0", null, null), resourceARHoming2String); - assertEquals(homingSolutionCloud("cloud", "", "", "aic", "testCloudRegionId3", "testAicClli3", "3.0", "\"91d563e8-e714-4393-8f99-cc480144a05e\", \"21d563e8-e714-4393-8f99-cc480144a05e\"", "\"31d563e8-e714-4393-8f99-cc480144a05e\", \"71d563e8-e714-4393-8f99-cc480144a05e\""), resourceVNFHomingString); - assertEquals(verifySniroRequest_existingLicense(), sniroRequest); - - } - - - @Test - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_error_inputVariable() throws Exception { - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - setVariables3(variables); - - invokeSubProcess("Homing", businessKey, variables); - - waitForProcessEnd(businessKey, 10000); - - //Get Variables - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - - assertEquals("WorkflowException[processKey=Homing,errorCode=4000,errorMessage=A required input variable is missing or null]", workflowException.toString()); - } - - @Test - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_error_badResponse() throws Exception { - mockSNIRO_500(); - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - setVariables(variables); - - invokeSubProcess("Homing", businessKey, variables); - - waitForProcessEnd(businessKey, 10000); - - //Get Variables - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - - assertEquals("WorkflowException[processKey=Homing,errorCode=500,errorMessage=Received a Bad Sync Response from Sniro/OOF.]", workflowException.toString()); - } - - @Test - @Ignore // 1802 merge - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_error_sniroNoSolution() throws Exception { - mockSNIRO(); - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - setVariables(variables); - - invokeSubProcess("Homing", businessKey, variables); - - injectWorkflowMessages(callbacks, "sniroNoSol"); - - waitForProcessEnd(businessKey, 10000); - - //Get Variables - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - - assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=No solution found for plan 08e1b8cf-144a-4bac-b293-d5e2eedc97e8]", workflowException.toString()); - } - - @Test - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_error_sniroPolicyException() throws Exception { - mockSNIRO(); - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - setVariables(variables); - - invokeSubProcess("Homing", businessKey, variables); - - injectWorkflowMessages(callbacks, "sniroPolicyEx"); - - waitForProcessEnd(businessKey, 10000); - - //Get Variables - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - - assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=Sniro Async Callback Response contains a Request Error Policy Exception: Message content size exceeds the allowable limit]", workflowException.toString()); - } - - @Test - @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) - public void testHoming_error_sniroServiceException() throws Exception { - mockSNIRO(); - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - setVariables(variables); - - invokeSubProcess("Homing", businessKey, variables); - - injectWorkflowMessages(callbacks, "sniroServiceEx"); - - waitForProcessEnd(businessKey, 10000); - - //Get Variables - WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - - assertEquals("WorkflowException[processKey=Homing,errorCode=400,errorMessage=Sniro Async Callback Response contains a Request Error Service Exception: SNIROPlacementError: requests.exceptions.HTTPError: 404 Client Error: Not Found for url: http://135.21.171.200:8091/v1/plans/97b4e303-5f75-492c-8fb2-21098281c8b8]", workflowException.toString()); - } - - - - private void setVariables(Map<String, Object> variables) { - variables.put("homingService", "sniro"); - variables.put("isDebugLogEnabled", "true"); - // variables.put("mso-request-id", "testRequestId"); - variables.put("msoRequestId", "testRequestId"); - variables.put("serviceInstanceId", "testServiceInstanceId"); - variables.put("serviceDecomposition", serviceDecomposition); - variables.put("subscriberInfo", subscriber2); - - } - - private void setVariables2(Map<String, Object> variables) { - List<NetworkResource> netList = new ArrayList<NetworkResource>(); - NetworkResource net = new NetworkResource(); - net.setResourceId("testResourceIdNet"); - ModelInfo netModel = new ModelInfo(); - netModel.setModelCustomizationUuid("testModelCustomizationUuidNet"); - netModel.setModelInvariantUuid("testModelInvariantIdNet"); - netModel.setModelName("testModelNameNet"); - netModel.setModelVersion("testModelVersionNet"); - net.setModelInfo(netModel); - netList.add(net); - NetworkResource net2 = new NetworkResource(); - net2.setResourceId("testResourceIdNet2"); - ModelInfo netModel2 = new ModelInfo(); - netModel2.setModelCustomizationUuid("testModelCustomizationUuidNet2"); - netModel2.setModelInvariantUuid("testModelInvariantIdNet2"); - netModel2.setModelName("testModelNameNet2"); - netModel2.setModelVersion("testModelVersionNet2"); - net2.setModelInfo(netModel2); - netList.add(net2); - serviceDecomposition.setServiceNetworks(netList); - - variables.put("homingService", "sniro"); - variables.put("isDebugLogEnabled", "true"); - variables.put("msoRequestId", "testRequestId"); - variables.put("serviceInstanceId", "testServiceInstanceId"); - variables.put("serviceDecomposition", serviceDecomposition); - variables.put("subscriberInfo", subscriber2); - } - - private void setVariables3(Map<String, Object> variables) { - variables.put("homingService", "sniro"); - variables.put("isDebugLogEnabled", "true"); - // variables.put("mso-request-id", "testRequestId"); - variables.put("msoRequestId", "testRequestId"); - variables.put("serviceInstanceId", "testServiceInstanceId"); - variables.put("serviceDecomposition", null); - variables.put("subscriberInfo", subscriber2); - - } - - private void setVariablesExistingLicense(Map<String, Object> variables) { - HomingSolution currentHomingSolution = new HomingSolution(); - serviceDecomposition.getServiceVnfs().get(0).setCurrentHomingSolution(currentHomingSolution); - serviceDecomposition.getServiceVnfs().get(0).getCurrentHomingSolution().getLicense().addEntitlementPool("testEntitlementPoolId1"); - serviceDecomposition.getServiceVnfs().get(0).getCurrentHomingSolution().getLicense().addEntitlementPool("testEntitlementPoolId2"); - - serviceDecomposition.getServiceVnfs().get(0).getCurrentHomingSolution().getLicense().addLicenseKeyGroup("testLicenseKeyGroupId1"); - serviceDecomposition.getServiceVnfs().get(0).getCurrentHomingSolution().getLicense().addLicenseKeyGroup("testLicenseKeyGroupId2"); - - variables.put("isDebugLogEnabled", "true"); - // variables.put("mso-request-id", "testRequestId"); - variables.put("msoRequestId", "testRequestId"); - variables.put("serviceInstanceId", "testServiceInstanceId"); - variables.put("serviceDecomposition", serviceDecomposition); - variables.put("subscriberInfo", subscriber2); - - } - - private String homingSolutionService(String type, String serviceInstanceId, String vnfHostname, String cloudOwner, String cloudRegionId, String aicClli, String aicVersion, String enList, String licenseList){ - String solution = ""; - if(enList == null){ - solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \"" + serviceInstanceId + "\", \"vnfHostname\" : \"" + vnfHostname + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"aicClli\" : \"" + aicClli + "\", \"aicVersion\" : \"" + aicVersion + "\", \"license\" : { }, \"rehome\" : false } }"; - }else{ - solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"serviceInstanceId\" : \"" + serviceInstanceId + "\", \"vnfHostname\" : \"" + vnfHostname + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"aicClli\" : \"" + aicClli + "\", \"aicVersion\" : \"" + aicVersion + "\", \"license\" : { \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ " + licenseList + " ] }, \"rehome\" : false } }"; - } - return solution; - } - - private String homingSolutionCloud(String type, String serviceInstanceId, String vnfHostname, String cloudOwner, String cloudRegionId, String aicClli, String aicVersion, String enList, String licenseList){ - String solution = ""; - if(enList == null){ - solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"aicClli\" : \"" + aicClli + "\", \"aicVersion\" : \"" + aicVersion + "\", \"license\" : { }, \"rehome\" : false } }"; - }else{ - solution = "{ \"homingSolution\" : { \"inventoryType\" : \"" + type + "\", \"cloudOwner\" : \"" + cloudOwner + "\", \"cloudRegionId\" : \"" + cloudRegionId + "\", \"aicClli\" : \"" + aicClli + "\", \"aicVersion\" : \"" + aicVersion + "\", \"license\" : { \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ " + licenseList + " ] }, \"rehome\" : false } }"; - } - return solution; - } - - private void setVariablesForServiceDecomposition(Map<String, Object> variables, String requestId, String siId) { - variables.put("homingService", "sniro"); - variables.put("isDebugLogEnabled", "true"); - variables.put("mso-request-id", requestId); - variables.put("msoRequestId", requestId); - variables.put("serviceInstanceId",siId); - - String serviceModelInfo = "{ "+ "\"modelType\": \"service\"," + - "\"modelInvariantUuid\": \"1cc4e2e4-eb6e-404d-a66f-c8733cedcce8\"," + - "\"modelUuid\": \"2f7f309d-c842-4644-a2e4-34167be5eeb4\"," + - "\"modelName\": \"ADIOD vRouter vCE 011017 Service\"," + - "\"modelVersion\": \"5.0\"," + - "}"; - variables.put("serviceModelInfo", serviceModelInfo); - } - - private String verifySniroRequest(){ - String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\",\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/SNIROResponse/testRequestId\",\"sourceId\":\"mso\",\"requestType\":\"initial\",\"optimizer\":[\"placement\",\"license\"],\"numSolutions\":1,\"timeout\":1800},\"placement\":{\"serviceModelInfo\":{\"modelType\":\"\",\"modelInvariantId\":\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":\"testModelName\",\"modelVersion\":\"testModelVersion\"},\"subscriberInfo\":{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\",\"subscriberCommonSiteId\":\"\"},\"demandInfo\":{\"placementDemand\":[{\"resourceInstanceType\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR\",\"modelInvariantId\":\"testModelInvariantIdAR\",\"modelName\":\"testModelNameAR\",\"modelVersion\":\"testModelVersionAR\",\"modelVersionId\":\"testARModelUuid\",\"modelType\":\"testModelTypeAR\"},\"tenantId\":\"\",\"tenantName\":\"\"},{\"resourceInstanceType\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR2\",\"modelInvariantId\":\"testModelInvariantIdAR2\",\"modelName\":\"testModelNameAR2\",\"modelVersion\":\"testModelVersionAR2\",\"modelVersionId\":\"testAr2ModelUuid\",\"modelType\":\"testModelTypeAR2\"},\"tenantId\":\"\",\"tenantName\":\"\"}],\"licenseDemand\":[{\"resourceInstanceType\":\"VNF\",\"serviceResourceId\":\"testResourceIdVNF\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidVNF\",\"modelInvariantId\":\"testModelInvariantIdVNF\",\"modelName\":\"testModelNameVNF\",\"modelVersion\":\"testModelVersionVNF\",\"modelVersionId\":\"testVnfModelUuid\",\"modelType\":\"testModelTypeVNF\"}}]},\"policyId\":[],\"serviceInstanceId\":\"testServiceInstanceId123\",\"orderInfo\":\"{\\\"requestParameters\\\":null}\"}}"; - return request; - } - - private String verifySniroRequest_existingLicense(){ - String request = "{\"requestInfo\":{\"transactionId\":\"testRequestId\",\"requestId\":\"testRequestId\",\"callbackUrl\":\"http://localhost:28090/workflows/messages/message/SNIROResponse/testRequestId\",\"sourceId\":\"mso\",\"requestType\":\"speedchanged\",\"optimizer\":[\"placement\",\"license\"],\"numSolutions\":1,\"timeout\":1800},\"placement\":{\"serviceModelInfo\":{\"modelType\":\"\",\"modelInvariantId\":\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":\"testModelName\",\"modelVersion\":\"testModelVersion\"},\"subscriberInfo\":{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\",\"subscriberCommonSiteId\":\"\"},\"demandInfo\":{\"placementDemand\":[{\"resourceInstanceType\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR\",\"modelInvariantId\":\"testModelInvariantIdAR\",\"modelName\":\"testModelNameAR\",\"modelVersion\":\"testModelVersionAR\",\"modelVersionId\":\"testARModelUuid\",\"modelType\":\"testModelTypeAR\"},\"tenantId\":\"\",\"tenantName\":\"\"},{\"resourceInstanceType\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidAR2\",\"modelInvariantId\":\"testModelInvariantIdAR2\",\"modelName\":\"testModelNameAR2\",\"modelVersion\":\"testModelVersionAR2\",\"modelVersionId\":\"testAr2ModelUuid\",\"modelType\":\"testModelTypeAR2\"},\"tenantId\":\"\",\"tenantName\":\"\"}],\"licenseDemand\":[{\"resourceInstanceType\":\"VNF\",\"serviceResourceId\":\"testResourceIdVNF\",\"resourceModuleName\":\"\",\"resourceModelInfo\":{\"modelCustomizationId\":\"testModelCustomizationUuidVNF\",\"modelInvariantId\":\"testModelInvariantIdVNF\",\"modelName\":\"testModelNameVNF\",\"modelVersion\":\"testModelVersionVNF\",\"modelVersionId\":\"testVnfModelUuid\",\"modelType\":\"testModelTypeVNF\"},\"existingLicense\":[{\"entitlementPoolUUID\":[\"testEntitlementPoolId1\",\"testEntitlementPoolId2\"],\"licenseKeyGroupUUID\":[\"testLicenseKeyGroupId1\",\"testLicenseKeyGroupId2\"]}]}]},\"policyId\":[],\"serviceInstanceId\":\"testServiceInstanceId123\",\"orderInfo\":\"{\\\"requestParameters\\\":null}\"}}"; - return request; - } - -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIGenericVnfTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIGenericVnfTest.java deleted file mode 100644 index 7c557ffe63..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIGenericVnfTest.java +++ /dev/null @@ -1,175 +0,0 @@ -/*-
- * ============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.openecomp.mso.bpmn.common;
-
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockAAIVfModuleBadPatch;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_404;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchGenericVnf;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf_Bad;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.camunda.bpm.engine.test.Deployment;
-import org.junit.Assert;
-import org.junit.Test;
-import org.openecomp.mso.bpmn.core.WorkflowException;
-import org.openecomp.mso.bpmn.mock.FileUtil;
-
-/**
- * Unit tests for UpdateAAIGenericVnf bpmn.
- */
-public class UpdateAAIGenericVnfTest extends WorkflowTest {
-
- /**
- * Test the happy path through the flow.
- */
- @Test
- @Deployment(resources = {
- "subprocess/UpdateAAIGenericVnf.bpmn"
- })
- public void happyPath() throws IOException {
- logStart();
-
- String updateAAIGenericVnfRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIGenericVnfRequest.xml");
- MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml");
- MockPutGenericVnf("/skask", 200);
- MockPatchGenericVnf("skask");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", "999-99-9999");
- variables.put("isDebugLogEnabled","true");
- variables.put("UpdateAAIGenericVnfRequest", updateAAIGenericVnfRequest);
- invokeSubProcess("UpdateAAIGenericVnf", businessKey, variables);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- String response = (String) getVariableFromHistory(businessKey, "UAAIGenVnf_updateGenericVnfResponse");
- Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIGenVnf_updateGenericVnfResponseCode");
- System.out.println("Subflow response code: " + responseCode);
- System.out.println("Subflow response: " + response);
- Assert.assertEquals(200, responseCode.intValue());
-
- logEnd();
- }
-
- /**
- * Test the happy path through the flow.
- */
- @Test
- @Deployment(resources = {
- "subprocess/UpdateAAIGenericVnf.bpmn"
- })
- public void personaMismatch() throws IOException {
-
- logStart();
-
- String updateAAIGenericVnfRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIGenericVnfRequest.xml");
- updateAAIGenericVnfRequest = updateAAIGenericVnfRequest.replaceFirst("introvert", "extrovert");
-
- MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", "999-99-9999");
- variables.put("isDebugLogEnabled","true");
- variables.put("UpdateAAIGenericVnfRequest", updateAAIGenericVnfRequest);
- invokeSubProcess("UpdateAAIGenericVnf", businessKey, variables);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- WorkflowException workflowException = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException");
- System.out.println("Workflow Exception: " + workflowException);
- Assert.assertNotNull(workflowException);
-
- logEnd();
- }
-
- /**
- * Test the case where the GET to AAI returns a 404.
- */
- @Test
- @Deployment(resources = {
- "subprocess/UpdateAAIGenericVnf.bpmn"
- })
- public void badGet() throws IOException {
-
- logStart();
-
- String updateAAIGenericVnfRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIGenericVnfRequest.xml");
-
- MockGetGenericVnfById_404("skask[?]depth=1");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", "999-99-9999");
- variables.put("isDebugLogEnabled","true");
- variables.put("UpdateAAIGenericVnfRequest", updateAAIGenericVnfRequest);
- invokeSubProcess("UpdateAAIGenericVnf", businessKey, variables);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- String response = (String) getVariableFromHistory(businessKey, "UAAIGenVnf_getGenericVnfResponse");
- Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIGenVnf_getGenericVnfResponseCode");
- System.out.println("Subflow response code: " + responseCode);
- System.out.println("Subflow response: " + response);
- Assert.assertEquals(404, responseCode.intValue());
-
- logEnd();
- }
-
- /**
- * Test the case where the GET to AAI is successful, but he subsequent PUT returns 404.
- */
- @Test
- @Deployment(resources = {
- "subprocess/UpdateAAIGenericVnf.bpmn"
- })
- public void badPatch() throws IOException {
-
- logStart();
-
- String updateAAIGenericVnfRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIGenericVnfRequest.xml");
-
- MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml");
- MockPutGenericVnf_Bad("skask", 404);
- MockAAIVfModuleBadPatch("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask", 404);
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", "999-99-9999");
- variables.put("isDebugLogEnabled","true");
- variables.put("UpdateAAIGenericVnfRequest", updateAAIGenericVnfRequest);
- invokeSubProcess("UpdateAAIGenericVnf", businessKey, variables);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- String response = (String) getVariableFromHistory(businessKey, "UAAIGenVnf_updateGenericVnfResponse");
- Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIGenVnf_updateGenericVnfResponseCode");
- System.out.println("Subflow response code: " + responseCode);
- System.out.println("Subflow response: " + response);
- Assert.assertEquals(404, responseCode.intValue());
-
- logEnd();
- }
-}
-
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIVfModuleTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIVfModuleTest.java deleted file mode 100644 index 30d7e6d8c6..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/UpdateAAIVfModuleTest.java +++ /dev/null @@ -1,141 +0,0 @@ -/*-
- * ============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.openecomp.mso.bpmn.common;
-
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockAAIVfModuleBadPatch;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById_404;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchVfModuleId;
-import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-
-import org.camunda.bpm.engine.test.Deployment;
-import org.junit.Assert;
-import org.junit.Test;
-import org.openecomp.mso.bpmn.mock.FileUtil;
-
-/**
- * Unit tests for UpdateAAIVfModuleTest.bpmn.
- */
-public class UpdateAAIVfModuleTest extends WorkflowTest {
-
- /**
- * Test the happy path through the flow.
- */
- @Test
- @Deployment(resources = {
- "subprocess/UpdateAAIVfModule.bpmn"
- })
- public void happyPath() throws IOException {
- logStart();
-
- String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml");
- MockGetGenericVnfByIdWithPriority("/skask/vf-modules/vf-module/supercool", 200, "VfModularity/VfModule-supercool.xml");
- MockPutGenericVnf("/skask/vf-modules/vf-module/supercool", "PCRF", 200);
- MockPatchVfModuleId("skask", "supercool");
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", "999-99-9999");
- variables.put("isDebugLogEnabled","true");
- variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest);
- invokeSubProcess("UpdateAAIVfModule", businessKey, variables);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponse");
- Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponseCode");
- System.out.println("Subflow response code: " + responseCode);
- System.out.println("Subflow response: " + response);
- Assert.assertEquals(200, responseCode.intValue());
-
- logEnd();
- }
-
- /**
- * Test the case where the GET to AAI returns a 404.
- */
- @Test
- @Deployment(resources = {
- "subprocess/UpdateAAIVfModule.bpmn"
- })
- public void badGet() throws IOException {
-
- logStart();
-
- String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml");
- MockGetGenericVnfById("/skask/vf-modules/vf-module/.*", "VfModularity/VfModule-supercool.xml", 404);
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", "999-99-9999");
- variables.put("isDebugLogEnabled","true");
- variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest);
- invokeSubProcess("UpdateAAIVfModule", businessKey, variables);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_getVfModuleResponse");
- Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_getVfModuleResponseCode");
- System.out.println("Subflow response code: " + responseCode);
- System.out.println("Subflow response: " + response);
- Assert.assertEquals(404, responseCode.intValue());
-
- logEnd();
- }
-
- /**
- * Test the case where the GET to AAI is successful, but he subsequent PUT returns 404.
- */
- @Test
- @Deployment(resources = {
- "subprocess/UpdateAAIVfModule.bpmn"
- })
- public void badPatch() throws IOException {
-
- logStart();
-
- String updateAAIVfModuleRequest = FileUtil.readResourceFile("__files/VfModularity/UpdateAAIVfModuleRequest.xml");
- MockGetGenericVnfById_404("/skask/vf-modules/vf-module/supercool");
- MockGetGenericVnfById("/skask/vf-modules/vf-module/supercool", "VfModularity/VfModule-supercool.xml", 200);
- MockAAIVfModuleBadPatch("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool", 404);
-
- String businessKey = UUID.randomUUID().toString();
- Map<String, Object> variables = new HashMap<>();
- variables.put("mso-request-id", "999-99-9999");
- variables.put("isDebugLogEnabled","true");
- variables.put("UpdateAAIVfModuleRequest", updateAAIVfModuleRequest);
- invokeSubProcess("UpdateAAIVfModule", businessKey, variables);
-
- Assert.assertTrue(isProcessEnded(businessKey));
- String response = (String) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponse");
- Integer responseCode = (Integer) getVariableFromHistory(businessKey, "UAAIVfMod_updateVfModuleResponseCode");
- System.out.println("Subflow response code: " + responseCode);
- System.out.println("Subflow response: " + response);
- Assert.assertEquals(404, responseCode.intValue());
-
- logEnd();
- }
-}
-
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/VnfAdapterRestV1Test.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/VnfAdapterRestV1Test.java deleted file mode 100644 index ea49176df0..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/VnfAdapterRestV1Test.java +++ /dev/null @@ -1,390 +0,0 @@ -/*- - * ============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.openecomp.mso.bpmn.common; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockVNFDelete; -import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockVNFPost; -import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockVNFPut; -import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockVNFRollbackDelete; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.camunda.bpm.engine.test.Deployment; -import org.junit.Ignore; -import org.junit.Test; -import org.openecomp.mso.bpmn.core.WorkflowException; - -/** - * Unit tests for VnfAdapterRestV1. - */ -public class VnfAdapterRestV1Test extends WorkflowTest { - - private static final String EOL = "\n"; - - private final CallbackSet callbacks = new CallbackSet(); - - private final String CREATE_VF_MODULE_REQUEST = - "<createVfModuleRequest>" + EOL + - " <cloudSiteId>cloudSiteId</cloudSiteId>" + EOL + - " <tenantId>tenantId</tenantId>" + EOL + - " <vnfId>vnfId</vnfId>" + EOL + - " <vfModuleName>vfModuleName</vfModuleName>" + EOL + - " <vfModuleId>vfModuleId</vfModuleId>" + EOL + - " <vnfType>vnfType</vnfType>" + EOL + - " <vnfVersion>vnfVersion</vnfVersion>" + EOL + - " <vfModuleType>vfModuleType</vfModuleType>" + EOL + - " <volumeGroupId>volumeGroupId</volumeGroupId>" + EOL + - " <volumeGroupStackId>volumeGroupStackId</volumeGroupStackId>" + EOL + - " <baseVfModuleId>baseVfModuleId</baseVfModuleId>" + EOL + - " <baseVfModuleStackId>baseVfModuleStackId</baseVfModuleStackId>" + EOL + - " <skipAAI>true</skipAAI>" + EOL + - " <backout>false</backout>" + EOL + - " <failIfExists>true</failIfExists>" + EOL + - " <vfModuleParams>" + EOL + - " <entry>" + EOL + - " <key>key1</key>" + EOL + - " <value>value1</value>" + EOL + - " </entry>" + EOL + - " <entry>" + EOL + - " <key>key2</key>" + EOL + - " <value>value2</value>" + EOL + - " </entry>" + EOL + - " </vfModuleParams>" + EOL + - " <msoRequest>" + EOL + - " <requestId>requestId</requestId>" + EOL + - " <serviceInstanceId>serviceInstanceId</serviceInstanceId>" + EOL + - " </msoRequest>" + EOL + - " <messageId>{{MESSAGE-ID}}</messageId>" + EOL + - " <notificationUrl>http://localhost:28080/mso/WorkflowMessage</notificationUrl>" + EOL + - "</createVfModuleRequest>" + EOL; - - private final String UPDATE_VF_MODULE_REQUEST = - "<updateVfModuleRequest>" + EOL + - " <cloudSiteId>cloudSiteId</cloudSiteId>" + EOL + - " <tenantId>tenantId</tenantId>" + EOL + - " <vnfId>vnfId</vnfId>" + EOL + - " <vfModuleName>vfModuleName</vfModuleName>" + EOL + - " <vfModuleId>vfModuleId</vfModuleId>" + EOL + - " <vfModuleStackId>vfModuleStackId</vfModuleStackId>" + EOL + - " <vnfType>vnfType</vnfType>" + EOL + - " <vnfVersion>vnfVersion</vnfVersion>" + EOL + - " <vfModuleType>vfModuleType</vfModuleType>" + EOL + - " <volumeGroupId>volumeGroupId</volumeGroupId>" + EOL + - " <volumeGroupStackId>volumeGroupStackId</volumeGroupStackId>" + EOL + - " <baseVfModuleId>baseVfModuleId</baseVfModuleId>" + EOL + - " <baseVfModuleStackId>baseVfModuleStackId</baseVfModuleStackId>" + EOL + - " <skipAAI>true</skipAAI>" + EOL + - " <backout>false</backout>" + EOL + - " <failIfExists>true</failIfExists>" + EOL + - " <vfModuleParams>" + EOL + - " <entry>" + EOL + - " <key>key1</key>" + EOL + - " <value>value1</value>" + EOL + - " </entry>" + EOL + - " <entry>" + EOL + - " <key>key2</key>" + EOL + - " <value>value2</value>" + EOL + - " </entry>" + EOL + - " </vfModuleParams>" + EOL + - " <msoRequest>" + EOL + - " <requestId>requestId</requestId>" + EOL + - " <serviceInstanceId>serviceInstanceId</serviceInstanceId>" + EOL + - " </msoRequest>" + EOL + - " <messageId>{{MESSAGE-ID}}</messageId>" + EOL + - " <notificationUrl>http://localhost:28080/mso/WorkflowMessage</notificationUrl>" + EOL + - "</updateVfModuleRequest>" + EOL; - - private final String DELETE_VF_MODULE_REQUEST = - "<deleteVfModuleRequest>" + EOL + - " <cloudSiteId>cloudSiteId</cloudSiteId>" + EOL + - " <tenantId>tenantId</tenantId>" + EOL + - " <vnfId>vnfId</vnfId>" + EOL + - " <vfModuleId>vfModuleId</vfModuleId>" + EOL + - " <vfModuleStackId>vfModuleStackId</vfModuleStackId>" + EOL + - " <skipAAI>true</skipAAI>" + EOL + - " <msoRequest>" + EOL + - " <requestId>requestId</requestId>" + EOL + - " <serviceInstanceId>serviceInstanceId</serviceInstanceId>" + EOL + - " </msoRequest>" + EOL + - " <messageId>{{MESSAGE-ID}}</messageId>" + EOL + - " <notificationUrl>http://localhost:28080/mso/WorkflowMessage</notificationUrl>" + EOL + - "</deleteVfModuleRequest>" + EOL; - - private final String ROLLBACK_VF_MODULE_REQUEST = - "<rollbackVfModuleRequest>" + EOL + - " <messageId>{{MESSAGE-ID}}</messageId>" + EOL + - " <notificationUrl>http://localhost:28080/mso/WorkflowMessage</notificationUrl>" + EOL + - " <skipAAI>true</skipAAI>" + EOL + - " <vfModuleRollback>" + EOL + - " <cloudSiteId>cloudSiteId</cloudSiteId>" + EOL + - " <tenantId>tenantId</tenantId>" + EOL + - " <vnfId>vnfId</vnfId>" + EOL + - " <vfModuleId>vfModuleId</vfModuleId>" + EOL + - " <vfModuleStackId>vfModuleStackId</vfModuleStackId>" + EOL + - " <msoRequest>" + EOL + - " <requestId>requestId</requestId>" + EOL + - " <serviceInstanceId>serviceInstanceId</serviceInstanceId>" + EOL + - " </msoRequest>" + EOL + - " <messageId>{{MESSAGE-ID}}</messageId>" + EOL + - " <vfModuleCreated>true</vfModuleCreated>" + EOL + - " </vfModuleRollback>" + EOL + - "</rollbackVfModuleRequest>" + EOL; - - public VnfAdapterRestV1Test() throws IOException { - callbacks.put("createVfModule", - "<createVfModuleResponse>" + EOL + - " <vnfId>vnfId</vnfId>" + EOL + - " <vfModuleId>vfModuleId</vfModuleId>" + EOL + - " <vfModuleStackId>vfModuleStackId</vfModuleStackId>" + EOL + - " <vfModuleCreated>true</vfModuleCreated>" + EOL + - " <vfModuleOutputs>" + EOL + - " <entry>" + EOL + - " <key>key1</key>" + EOL + - " <value>value1</value>" + EOL + - " </entry>" + EOL + - " <entry>" + EOL + - " <key>key2</key>" + EOL + - " <value>value2</value>" + EOL + - " </entry>" + EOL + - " </vfModuleOutputs>" + EOL + - " <rollback>" + EOL + - " <vnfId>vnfId</vnfId>" + EOL + - " <vfModuleId>vfModuleId</vfModuleId>" + EOL + - " <vfModuleStackId>vfModuleStackId</vfModuleStackId>" + EOL + - " <vfModuleCreated>true</vfModuleCreated>" + EOL + - " <tenantId>tenantId</tenantId>" + EOL + - " <cloudSiteId>cloudSiteId</cloudSiteId>" + EOL + - " <msoRequest>" + EOL + - " <requestId>requestId</requestId>" + EOL + - " <serviceInstanceId>serviceInstanceId</serviceInstanceId>" + EOL + - " </msoRequest>" + EOL + - " <messageId>messageId</messageId>" + EOL + - " </rollback>" + EOL + - " <messageId>{{MESSAGE-ID}}</messageId>" + EOL + - "</createVfModuleResponse>" + EOL); - - callbacks.put("updateVfModule", - "<updateVfModuleResponse>" + EOL + - " <vnfId>vnfId</vnfId>" + EOL + - " <vfModuleId>vfModuleId</vfModuleId>" + EOL + - " <vfModuleStackId>vfModuleStackId</vfModuleStackId>" + EOL + - " <vfModuleOutputs>" + EOL + - " <entry>" + EOL + - " <key>key1</key>" + EOL + - " <value>value1</value>" + EOL + - " </entry>" + EOL + - " <entry>" + EOL + - " <key>key2</key>" + EOL + - " <value>value2</value>" + EOL + - " </entry>" + EOL + - " </vfModuleOutputs>" + EOL + - " <messageId>{{MESSAGE-ID}}</messageId>" + EOL + - "</updateVfModuleResponse>" + EOL); - - callbacks.put("deleteVfModule", - "<deleteVfModuleResponse>" + EOL + - " <vnfId>vnfId</vnfId>" + EOL + - " <vfModuleId>vfModuleId</vfModuleId>" + EOL + - " <vfModuleDeleted>true</vfModuleDeleted>" + EOL + - " <messageId>{{MESSAGE-ID}}</messageId>" + EOL + - "</deleteVfModuleResponse>" + EOL); - - callbacks.put("rollbackVfModule", - "<rollbackVfModuleResponse>" + EOL + - " <messageId>{{MESSAGE-ID}}</messageId>" + EOL + - " <vfModuleRolledback>true</vfModuleRolledback>" + EOL + - "</rollbackVfModuleResponse>" + EOL); - - callbacks.put("vfModuleException", - "<vfModuleException>" + EOL + - " <message>message</message>" + EOL + - " <category>category</category>" + EOL + - " <rolledBack>false</rolledBack>" + EOL + - " <messageId>{{MESSAGE-ID}}</messageId>" + EOL + - "</vfModuleException>" + EOL); - } - - @Test - @Deployment(resources = { - "subprocess/VnfAdapterRestV1.bpmn" - }) - public void testCreateVfModuleSuccess() throws Exception { - logStart(); - - mockVNFPost("", 202, "vnfId"); - - String requestId = "dffbae0e-5588-4bd6-9749-b0f0adb52312"; - String messageId = requestId + "-" + System.currentTimeMillis(); - String request = CREATE_VF_MODULE_REQUEST.replace("{{MESSAGE-ID}}", messageId); - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - variables.put("mso-request-id", requestId); - variables.put("isDebugLogEnabled", "true"); - variables.put("vnfAdapterRestV1Request", request); - - invokeSubProcess("vnfAdapterRestV1", businessKey, variables); - injectVNFRestCallbacks(callbacks, "createVfModule"); - waitForProcessEnd(businessKey, 10000); - - String response = (String) getVariableFromHistory(businessKey, "vnfAdapterRestV1Response"); - System.out.println("Response:\n" + response); - assertTrue(response!=null && response.contains("<createVfModuleResponse>")); - assertTrue((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator")); - - logEnd(); - } - - @Test - @Deployment(resources = { - "subprocess/VnfAdapterRestV1.bpmn" - }) - public void testUpdateVfModuleSuccess() throws Exception { - logStart(); - - mockVNFPut("/vfModuleId", 202); - - String requestId = "dffbae0e-5588-4bd6-9749-b0f0adb52312"; - String messageId = requestId + "-" + System.currentTimeMillis(); - String request = UPDATE_VF_MODULE_REQUEST.replace("{{MESSAGE-ID}}", messageId); - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - variables.put("mso-request-id", requestId); - variables.put("isDebugLogEnabled", "true"); - variables.put("vnfAdapterRestV1Request", request); - - invokeSubProcess("vnfAdapterRestV1", businessKey, variables); - injectVNFRestCallbacks(callbacks, "updateVfModule"); - waitForProcessEnd(businessKey, 10000); - - String response = (String) getVariableFromHistory(businessKey, "vnfAdapterRestV1Response"); - System.out.println("Response:\n" + response); - assertTrue(response.contains("<updateVfModuleResponse>")); - assertTrue((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator")); - - logEnd(); - } - - @Test - @Deployment(resources = { - "subprocess/VnfAdapterRestV1.bpmn" - }) - public void testDeleteVfModuleSuccess() throws Exception { - logStart(); - - mockVNFDelete("vnfId", "/vfModuleId", 202); - - String requestId = "dffbae0e-5588-4bd6-9749-b0f0adb52312"; - String messageId = requestId + "-" + System.currentTimeMillis(); - String request = DELETE_VF_MODULE_REQUEST.replace("{{MESSAGE-ID}}", messageId); - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - variables.put("mso-request-id", requestId); - variables.put("isDebugLogEnabled", "true"); - variables.put("vnfAdapterRestV1Request", request); - - invokeSubProcess("vnfAdapterRestV1", businessKey, variables); - injectVNFRestCallbacks(callbacks, "deleteVfModule"); - waitForProcessEnd(businessKey, 10000); - - String response = (String) getVariableFromHistory(businessKey, "vnfAdapterRestV1Response"); - System.out.println("Response:\n" + response); - assertTrue(response.contains("<deleteVfModuleResponse>")); - assertTrue((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator")); - - logEnd(); - } - - @Test - @Deployment(resources = { - "subprocess/VnfAdapterRestV1.bpmn" - }) - public void testRollbackVfModuleSuccess() throws Exception { - logStart(); - - mockVNFRollbackDelete("/vfModuleId", 202); - - String requestId = "dffbae0e-5588-4bd6-9749-b0f0adb52312"; - String messageId = requestId + "-" + System.currentTimeMillis(); - String request = ROLLBACK_VF_MODULE_REQUEST.replace("{{MESSAGE-ID}}", messageId); - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - variables.put("mso-request-id", requestId); - variables.put("isDebugLogEnabled", "true"); - variables.put("vnfAdapterRestV1Request", request); - - invokeSubProcess("vnfAdapterRestV1", businessKey, variables); - injectVNFRestCallbacks(callbacks, "rollbackVfModule"); - waitForProcessEnd(businessKey, 10000); - - String response = (String) getVariableFromHistory(businessKey, "vnfAdapterRestV1Response"); - System.out.println("Response:\n" + response); - assertTrue(response.contains("<rollbackVfModuleResponse>")); - assertTrue((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator")); - - logEnd(); - } - - @Test - @Deployment(resources = { - "subprocess/VnfAdapterRestV1.bpmn" - }) - public void testCreateVfModuleException() throws Exception { - logStart(); - - mockVNFPost("", 202, "vnfId"); - - String requestId = "dffbae0e-5588-4bd6-9749-b0f0adb52312"; - String messageId = requestId + "-" + System.currentTimeMillis(); - String request = CREATE_VF_MODULE_REQUEST.replace("{{MESSAGE-ID}}", messageId); - - String businessKey = UUID.randomUUID().toString(); - Map<String, Object> variables = new HashMap<>(); - variables.put("mso-request-id", requestId); - variables.put("isDebugLogEnabled", "true"); - variables.put("vnfAdapterRestV1Request", request); - - invokeSubProcess("vnfAdapterRestV1", businessKey, variables); - injectVNFRestCallbacks(callbacks, "vfModuleException"); - waitForProcessEnd(businessKey, 10000); - - WorkflowException wfe = (WorkflowException) getVariableFromHistory(businessKey, "WorkflowException"); - assertNotNull(wfe); - System.out.println(wfe.toString()); - - String response = (String) getVariableFromHistory(businessKey, "WorkflowResponse"); - System.out.println("Response:\n" + response); - assertTrue(response.contains("<vfModuleException>")); - assertFalse((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator")); - - logEnd(); - } -} - diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowAsyncResourceTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowAsyncResourceTest.java deleted file mode 100644 index 5562cb80ae..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowAsyncResourceTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * ============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.openecomp.mso.bpmn.common; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.mock; - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.camunda.bpm.engine.test.Deployment; -import org.camunda.bpm.engine.variable.impl.VariableMapImpl; -import org.jboss.resteasy.spi.AsynchronousResponse; -import org.junit.Test; -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowAsyncResource; -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; - -public class WorkflowAsyncResourceTest extends WorkflowTest { - - @Test - @Deployment(resources = { "testAsyncResource.bpmn" }) - public void asyncRequestSuccess() throws InterruptedException { - //it can be any request which asynchronously processed by the workflow - String request = "<aetgt:CreateTenantRequest xmlns:aetgt=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:sdncadapterworkflow=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:ns5=\"http://org.openecomp/mso/request/types/v1\"> <msoservtypes:service-information xmlns:msoservtypes=\"http://org.openecomp/mso/request/types/v1\"> <msoservtypes:service-type>SDN-ETHERNET-INTERNET</msoservtypes:service-type> <msoservtypes:service-instance-id>HI/VLXM/950604//SW_INTERNET</msoservtypes:service-instance-id> <msoservtypes:subscriber-name>SubName01</msoservtypes:subscriber-name> </msoservtypes:service-information> </aetgt:CreateTenantRequest>"; - - Map<String,String> variables = new HashMap<>(); - variables.put("testAsyncRequestMsg", request); - variables.put("mso-request-id", UUID.randomUUID().toString()); - variables.put("mso-service-request-timeout", "5"); - - WorkflowResponse workflowResponse = BPMNUtil.executeAsyncWorkflow(processEngineRule, "testAsyncProcess", variables); - assertEquals("Received the request, the process is getting executed, request message<aetgt:CreateTenantRequest xmlns:aetgt=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:sdncadapterworkflow=\"http://org.openecomp/mso/workflow/schema/v1\" xmlns:ns5=\"http://org.openecomp/mso/request/types/v1\"> <msoservtypes:service-information xmlns:msoservtypes=\"http://org.openecomp/mso/request/types/v1\"> <msoservtypes:service-type>SDN-ETHERNET-INTERNET</msoservtypes:service-type> <msoservtypes:service-instance-id>HI/VLXM/950604//SW_INTERNET</msoservtypes:service-instance-id> <msoservtypes:subscriber-name>SubName01</msoservtypes:subscriber-name> </msoservtypes:service-information> </aetgt:CreateTenantRequest>", workflowResponse.getContent()); - assertEquals(200, workflowResponse.getMessageCode()); - } - - private void executeWorkflow(String request, String requestId, AsynchronousResponse asyncResponse, String processKey) { - WorkflowAsyncResource workflowResource = new WorkflowAsyncResource(); - VariableMapImpl variableMap = new VariableMapImpl(); - - Map<String, Object> variableValueType = new HashMap<>(); - - Map<String, Object> requestMsg = new HashMap<>(); - requestMsg.put("value", request); - requestMsg.put("type", "String"); - - Map<String, Object> msorequestId = new HashMap<>(); - msorequestId.put("type", "String"); - msorequestId.put("value",requestId); - - Map<String, Object> timeout = new HashMap<>(); - timeout.put("type", "String"); - timeout.put("value","5"); - - variableValueType.put("testAsyncRequestMsg", requestMsg); - variableValueType.put("mso-request-id", msorequestId); - variableValueType.put("mso-service-request-timeout", timeout); - - variableMap.put("variables", variableValueType); - - workflowResource.setProcessEngineServices4junit(processEngineRule); - workflowResource.startProcessInstanceByKey(asyncResponse, processKey, variableMap); - } - - class ProcessThread extends Thread { - - public WorkflowResponse workflowResponse; - public String requestId; - public String processKey; - public AsynchronousResponse asyncResponse = mock(AsynchronousResponse.class); - public String request; - public boolean started; - public void run() { - started = true; - executeWorkflow(request, requestId, asyncResponse, processKey); - } - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowContextHolderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowContextHolderTest.java deleted file mode 100644 index de346d2dbe..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowContextHolderTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/*- - * ============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.openecomp.mso.bpmn.common; - -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -import java.util.UUID; - -import javax.ws.rs.core.Response; - -import org.jboss.resteasy.spi.AsynchronousResponse; -import org.junit.Assert; -import org.junit.Ignore; -import org.junit.Test; -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowCallbackResponse; -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowContext; -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowContextHolder; -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; - -public class WorkflowContextHolderTest { - - private WorkflowContext createContext(AsynchronousResponse asyncResponse) { - WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance(); - String requestId = UUID.randomUUID().toString(); - WorkflowContext workflowContext = new WorkflowContext("testAsyncProcess", - requestId, asyncResponse, 1000L); - contextHolder.put(workflowContext); - return workflowContext; - } - - @Test - @Ignore // BROKEN TEST (previously ignored) - public void testContextExpiry() throws InterruptedException { - - WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance(); - AsynchronousResponse asyncResponse = mock(AsynchronousResponse.class); - WorkflowContext workflowContext = createContext(asyncResponse); - String requestId = workflowContext.getRequestId(); - WorkflowContext context1 = contextHolder.getWorkflowContext(requestId); - - Assert.assertNotNull(context1); - Assert.assertEquals(requestId, context1.getRequestId()); - Assert.assertEquals(workflowContext.getProcessKey(), context1.getProcessKey()); - Assert.assertEquals(workflowContext.getStartTime(), context1.getStartTime()); - - Thread.sleep(1000); - //context should not be available after a second - WorkflowContext context2 = contextHolder.getWorkflowContext(requestId); - Assert.assertNull(context2); - } - -/* @Test - public void testProcessCallback() { - WorkflowContextHolder contextHolder = WorkflowContextHolder.getInstance(); - AsynchronousResponse asyncResponse = mock(AsynchronousResponse.class); - WorkflowContext workflowContext = createContext(asyncResponse); - - WorkflowCallbackResponse callbackResponse = new WorkflowCallbackResponse(); - callbackResponse.setMessage("Success"); - callbackResponse.setResponse("Successfully processed request"); - callbackResponse.setStatusCode(200); - - Response response = contextHolder.processCallback("testAsyncProcess", - "process-instance-id", workflowContext.getRequestId(), - callbackResponse); - WorkflowResponse response1 = (WorkflowResponse) response.getEntity(); - Assert.assertNotNull(response1.getMessage()); - Assert.assertEquals(200,response1.getMessageCode()); - Assert.assertEquals("Success", response1.getMessage()); - Assert.assertEquals("Successfully processed request", response1.getContent()); - verify(asyncResponse).setResponse(any(Response.class)); - - WorkflowContext context1 = contextHolder.getWorkflowContext(workflowContext.getRequestId()); - Assert.assertNull(context1); - }*/ - -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java deleted file mode 100644 index de25107fcc..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTest.java +++ /dev/null @@ -1,2094 +0,0 @@ -/*-
- * ============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.openecomp.mso.bpmn.common;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-import static org.openecomp.mso.bpmn.core.json.JsonUtils.getJsonValue;
-import static org.openecomp.mso.bpmn.core.json.JsonUtils.updJsonValue;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.lang.management.ManagementFactory;
-import java.lang.management.RuntimeMXBean;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import javax.ws.rs.core.Response;
-import javax.xml.bind.JAXBException;
-import javax.xml.namespace.NamespaceContext;
-import javax.xml.namespace.QName;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpression;
-import javax.xml.xpath.XPathExpressionException;
-import javax.xml.xpath.XPathFactory;
-
-import org.camunda.bpm.engine.RuntimeService;
-import org.camunda.bpm.engine.history.HistoricProcessInstance;
-import org.camunda.bpm.engine.history.HistoricVariableInstance;
-import org.camunda.bpm.engine.runtime.ProcessInstance;
-import org.camunda.bpm.engine.test.ProcessEngineRule;
-import org.camunda.bpm.engine.variable.impl.VariableMapImpl;
-import org.custommonkey.xmlunit.DetailedDiff;
-import org.custommonkey.xmlunit.XMLUnit;
-import org.jboss.resteasy.spi.AsynchronousResponse;
-import org.json.JSONArray;
-import org.json.JSONObject;
-import org.junit.Before;
-import org.junit.Rule;
-import org.openecomp.mso.bpmn.common.adapter.sdnc.CallbackHeader;
-import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCAdapterCallbackRequest;
-import org.openecomp.mso.bpmn.common.adapter.sdnc.SDNCAdapterResponse;
-import org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification;
-import org.openecomp.mso.bpmn.common.adapter.vnf.DeleteVnfNotification;
-import org.openecomp.mso.bpmn.common.adapter.vnf.MsoExceptionCategory;
-import org.openecomp.mso.bpmn.common.adapter.vnf.MsoRequest;
-import org.openecomp.mso.bpmn.common.adapter.vnf.UpdateVnfNotification;
-import org.openecomp.mso.bpmn.common.adapter.vnf.VnfRollback;
-import org.openecomp.mso.bpmn.common.workflow.service.SDNCAdapterCallbackServiceImpl;
-import org.openecomp.mso.bpmn.common.workflow.service.VnfAdapterNotifyServiceImpl;
-import org.openecomp.mso.bpmn.common.workflow.service.WorkflowAsyncResource;
-import org.openecomp.mso.bpmn.common.workflow.service.WorkflowMessageResource;
-import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse;
-import org.openecomp.mso.bpmn.core.PropertyConfigurationSetup;
-import org.openecomp.mso.bpmn.core.domain.Resource;
-import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition;
-import org.openecomp.mso.bpmn.core.utils.CamundaDBSetup;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
-import com.github.tomakehurst.wiremock.extension.ResponseTransformer;
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-
-
-
-/**
- * A base class for Workflow tests.
- * <p>
- * WireMock response transformers may be specified by declaring public
- * static fields with the @WorkflowTestTransformer annotation. For example:
- * <pre>
- * @WorkflowTestTransformer
- * public static final ResponseTransformer sdncAdapterMockTransformer =
- * new SDNCAdapterMockTransformer();
- * </pre>
- */
-public class WorkflowTest {
- @Rule
- public final ProcessEngineRule processEngineRule = new ProcessEngineRule();
-
- @Rule
- public final WireMockRule wireMockRule;
-
- /**
- * Content-Type for XML.
- */
- protected static final String XML = "application/xml";
-
- /**
- * Content-Type for JSON.
- */
- protected static final String JSON = "application/json; charset=UTF-8";
-
-
- /**
- * Constructor.
- */
- public WorkflowTest() throws RuntimeException {
- // Process WorkflowTestTransformer annotations
- List<ResponseTransformer> transformerList = new ArrayList<ResponseTransformer>();
-
- for (Field field : getClass().getFields()) {
- WorkflowTestTransformer annotation = field.getAnnotation(WorkflowTestTransformer.class);
-
- if (annotation == null) {
- continue;
- }
-
- if (!Modifier.isStatic(field.getModifiers())) {
- throw new RuntimeException(field.getDeclaringClass().getName()
- + "#" + field.getName() + " has a @WorkflowTestTransformer "
- + " annotation but it is not declared static");
- }
-
- ResponseTransformer transformer;
-
- try {
- transformer = (ResponseTransformer) field.get(null);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(field.getDeclaringClass().getName()
- + "#" + field.getName() + " is not accessible", e);
- } catch (ClassCastException e) {
- throw new RuntimeException(field.getDeclaringClass().getName()
- + "#" + field.getName() + " is not a ResponseTransformer", e);
- }
-
- if (transformer == null) {
- continue;
- }
-
- transformerList.add(transformer);
- }
-
- ResponseTransformer[] transformerArray =
- transformerList.toArray(new ResponseTransformer[transformerList.size()]);
-
- wireMockRule = new WireMockRule(WireMockConfiguration.wireMockConfig()
- .port(28090).extensions(transformerArray));
- }
-
- @Before
- public void testSetup() throws Exception {
- CamundaDBSetup.configure();
- PropertyConfigurationSetup.init();
- }
-
- /**
- * The current request ID. Normally set when an "invoke" method is called.
- */
- protected volatile String msoRequestId = null;
-
- /**
- * The current service instance ID. Normally set when an "invoke" method
- * is called.
- */
- protected volatile String msoServiceInstanceId = null;
-
- /**
- * Logs a test start method.
- */
- protected void logStart() {
- StackTraceElement[] st = Thread.currentThread().getStackTrace();
- String method = st[2].getMethodName();
- System.out.println("STARTED TEST: " + method);
- }
-
- /**
- * Logs a test end method.
- */
- protected void logEnd() {
- StackTraceElement[] st = Thread.currentThread().getStackTrace();
- String method = st[2].getMethodName();
- System.out.println("ENDED TEST: " + method);
- }
-
- /**
- * Invokes a subprocess.
- * @param processKey the process key
- * @param businessKey a unique key that will identify the process instance
- * @param injectedVariables variables to inject into the process
- */
- protected void invokeSubProcess(String processKey, String businessKey, Map<String, Object> injectedVariables) {
- RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
- List<String> arguments = runtimeMxBean.getInputArguments();
- System.out.println("JVM args = " + arguments);
-
- msoRequestId = (String) injectedVariables.get("mso-request-id");
- String requestId = (String) injectedVariables.get("msoRequestId");
-
- if (msoRequestId == null && requestId == null) {
- String msg = "mso-request-id variable was not provided";
- System.out.println(msg);
- fail(msg);
- }
-
- // Note: some scenarios don't have a service-instance-id, may be null
- msoServiceInstanceId = (String) injectedVariables.get("mso-service-instance-id");
-
- RuntimeService runtimeService = processEngineRule.getRuntimeService();
- runtimeService.startProcessInstanceByKey(processKey, businessKey, injectedVariables);
- }
-
- /**
- * Invokes an asynchronous process.
- * Errors are handled with junit assertions and will cause the test to fail.
- * @param processKey the process key
- * @param schemaVersion the API schema version, e.g. "v1"
- * @param businessKey a unique key that will identify the process instance
- * @param request the request
- * @return a TestAsyncResponse object associated with the test
- */
- protected TestAsyncResponse invokeAsyncProcess(String processKey,
- String schemaVersion, String businessKey, String request) {
- return invokeAsyncProcess(processKey, schemaVersion, businessKey, request, null);
- }
-
- /**
- * Invokes an asynchronous process.
- * Errors are handled with junit assertions and will cause the test to fail.
- * @param processKey the process key
- * @param schemaVersion the API schema version, e.g. "v1"
- * @param businessKey a unique key that will identify the process instance
- * @param request the request
- * @param injectedVariables optional variables to inject into the process
- * @return a TestAsyncResponse object associated with the test
- */
- protected TestAsyncResponse invokeAsyncProcess(String processKey,
- String schemaVersion, String businessKey, String request,
- Map<String, Object> injectedVariables) {
-
- RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
- List<String> arguments = runtimeMxBean.getInputArguments();
- System.out.println("JVM args = " + arguments);
-
- Map<String, Object> variables = createVariables(schemaVersion, businessKey,
- request, injectedVariables, false);
- VariableMapImpl variableMapImpl = createVariableMapImpl(variables);
-
- System.out.println("Sending " + request + " to " + processKey + " process");
- WorkflowAsyncResource workflowResource = new WorkflowAsyncResource();
- workflowResource.setProcessEngineServices4junit(processEngineRule);
-
- TestAsyncResponse asyncResponse = new TestAsyncResponse();
- workflowResource.startProcessInstanceByKey(asyncResponse, processKey, variableMapImpl);
- return asyncResponse;
- }
-
- /**
- * Invokes an asynchronous process.
- * Errors are handled with junit assertions and will cause the test to fail.
- * @param processKey the process key
- * @param schemaVersion the API schema version, e.g. "v1"
- * @param businessKey a unique key that will identify the process instance
- * @param request the request
- * @param injectedVariables optional variables to inject into the process
- * @param serviceInstantiationModel indicates whether this method is being
- * invoked for a flow that is designed using the service instantiation model
- * @return a TestAsyncResponse object associated with the test
- */
- protected TestAsyncResponse invokeAsyncProcess(String processKey,
- String schemaVersion, String businessKey, String request,
- Map<String, Object> injectedVariables, boolean serviceInstantiationModel) {
-
- RuntimeMXBean runtimeMxBean = ManagementFactory.getRuntimeMXBean();
- List<String> arguments = runtimeMxBean.getInputArguments();
- System.out.println("JVM args = " + arguments);
-
- Map<String, Object> variables = createVariables(schemaVersion, businessKey,
- request, injectedVariables, serviceInstantiationModel);
- VariableMapImpl variableMapImpl = createVariableMapImpl(variables);
-
- System.out.println("Sending " + request + " to " + processKey + " process");
- WorkflowAsyncResource workflowResource = new WorkflowAsyncResource();
- workflowResource.setProcessEngineServices4junit(processEngineRule);
-
- TestAsyncResponse asyncResponse = new TestAsyncResponse();
- workflowResource.startProcessInstanceByKey(asyncResponse, processKey, variableMapImpl);
- return asyncResponse;
- }
-
- /**
- * Private helper method that creates a variable map for a request.
- * Errors are handled with junit assertions and will cause the test to fail.
- * @param schemaVersion the API schema version, e.g. "v1"
- * @param businessKey a unique key that will identify the process instance
- * @param request the request
- * @param injectedVariables optional variables to inject into the process
- * @param serviceInstantiationModel indicates whether this method is being
- * invoked for a flow that is designed using the service instantiation model
- * @return a variable map
- */
- private Map<String, Object> createVariables(String schemaVersion,
- String businessKey, String request, Map<String, Object> injectedVariables,
- boolean serviceInstantiationModel) {
-
- Map<String, Object> variables = new HashMap<>();
-
- // These variables may be overridded by injected variables.
- variables.put("mso-service-request-timeout", "180");
- variables.put("isDebugLogEnabled", "true");
-
- // These variables may not be overridded by injected variables.
- String[] notAllowed = new String[] {
- "mso-schema-version",
- "mso-business-key",
- "bpmnRequest",
- "mso-request-id",
- "mso-service-instance-id"
- };
-
- if (injectedVariables != null) {
- for (String key : injectedVariables.keySet()) {
- for (String var : notAllowed) {
- if (var.equals(key)) {
- String msg = "Cannot specify " + var + " in injected variables";
- System.out.println(msg);
- fail(msg);
- }
- }
-
- variables.put(key, injectedVariables.get(key));
- }
- }
-
- variables.put("mso-schema-version", schemaVersion);
- variables.put("mso-business-key", businessKey);
- variables.put("bpmnRequest", request);
-
- if (serviceInstantiationModel) {
-
- /*
- * The request ID and the service instance ID are generated for flows
- * that follow the service instantiation model unless "requestId" and
- * "serviceInstanceId" are injected variables.
- */
-
- try {
- msoRequestId = (String) injectedVariables.get("requestId");
- variables.put("mso-request-id", msoRequestId);
- msoServiceInstanceId = (String) injectedVariables.get("serviceInstanceId");
- variables.put("mso-service-instance-id", msoServiceInstanceId);
- }
- catch(Exception e) {
- }
- if (msoRequestId == null || msoRequestId.trim().equals("")) {
- System.out.println("No requestId element in injectedVariables");
- variables.put("mso-request-id", UUID.randomUUID().toString());
- }
- if (msoServiceInstanceId == null || msoServiceInstanceId.trim().equals("")) {
- System.out.println("No seviceInstanceId element in injectedVariables");
- variables.put("mso-service-instance-id", UUID.randomUUID().toString());
- }
-
- } else {
- msoRequestId = getXMLTextElement(request, "request-id");
-
- if (msoRequestId == null) {
- //check in injected variables
- try {
- msoRequestId = (String) injectedVariables.get("requestId");
- }
- catch(Exception e) {
- }
- if (msoRequestId == null || msoRequestId.trim().equals("")) {
- String msg = "No request-id element in " + request;
- System.out.println(msg);
- fail(msg);
- }
- }
-
- variables.put("mso-request-id", msoRequestId);
-
- // Note: some request types don't have a service-instance-id
- msoServiceInstanceId = getXMLTextElement(request, "service-instance-id");
-
- if (msoServiceInstanceId != null) {
- variables.put("mso-service-instance-id", msoServiceInstanceId);
- }
- }
-
- return variables;
- }
-
- /**
- * Private helper method that creates a camunda VariableMapImpl from a simple
- * variable map.
- * @param variables the simple variable map
- * @return a VariableMap
- */
- private VariableMapImpl createVariableMapImpl(Map<String, Object> variables) {
- Map<String, Object> wrappedVariables = new HashMap<>();
-
- for (String key : variables.keySet()) {
- Object value = variables.get(key);
- wrappedVariables.put(key, wrapVariableValue(value));
- }
-
- VariableMapImpl variableMapImpl = new VariableMapImpl();
- variableMapImpl.put("variables", wrappedVariables);
- return variableMapImpl;
- }
-
- /**
- * Private helper method that wraps a variable value for inclusion in a
- * camunda VariableMapImpl.
- * @param value the variable value
- * @return the wrapped variable
- */
- private Map<String, Object> wrapVariableValue(Object value) {
- HashMap<String, Object> valueMap = new HashMap<>();
- valueMap.put("value", value);
- return valueMap;
- }
-
- /**
- * Receives a response from an asynchronous process.
- * Errors are handled with junit assertions and will cause the test to fail.
- * @param businessKey the process business key
- * @param asyncResponse the TestAsyncResponse object associated with the test
- * @param timeout the timeout in milliseconds
- * @return the WorkflowResponse
- */
- protected WorkflowResponse receiveResponse(String businessKey,
- TestAsyncResponse asyncResponse, long timeout) {
- System.out.println("Waiting " + timeout + "ms for process with business key " + businessKey
- + " to send a response");
-
- long now = System.currentTimeMillis() + timeout;
- long endTime = now + timeout;
-
- while (now <= endTime) {
- Response response = asyncResponse.getResponse();
-
- if (response != null) {
- System.out.println("Received a response from process with business key " + businessKey);
-
- Object entity = response.getEntity();
-
- if (!(entity instanceof WorkflowResponse)) {
- String msg = "Response entity is " +
- (entity == null ? "null" : entity.getClass().getName()) +
- ", expected WorkflowResponse";
- System.out.println(msg);
- fail(msg);
- return null; // unreachable
- }
-
- return (WorkflowResponse) entity;
- }
-
- try {
- Thread.sleep(200);
- } catch (InterruptedException e) {
- String msg = "Interrupted waiting for a response from process with business key " +
- businessKey;
- System.out.println(msg);
- fail(msg);
- return null; // unreachable
- }
-
- now = System.currentTimeMillis();
- }
-
- String msg = "No response received from process with business key " + businessKey +
- " within " + timeout + "ms";
- System.out.println(msg);
- fail("Process with business key " + businessKey + " did not end within 10000ms");
- return null; // unreachable
- }
-
- /**
- * Runs a program to inject SDNC callback data into the test environment.
- * A program is essentially just a list of keys that identify callback data
- * to be injected, in sequence. An example program:
- * <pre>
- * reserve, assign, delete:ERR
- * </pre>
- * Errors are handled with junit assertions and will cause the test to fail.
- * @param callbacks an object containing callback data for the program
- * @param program the program to execute
- */
- protected void injectSDNCRestCallbacks(CallbackSet callbacks, String program) {
-
- String[] cmds = program.replaceAll("\\s+", "").split(",");
-
- for (String cmd : cmds) {
- String action = cmd;
- String modifier = "STD";
-
- if (cmd.contains(":")) {
- String[] parts = cmd.split(":");
- action = parts[0];
- modifier = parts[1];
- }
-
- String content = null;
- String contentType = null;
-
- if ("STD".equals(modifier)) {
- CallbackData callbackData = callbacks.get(action);
-
- if (callbackData == null) {
- String msg = "No callback defined for '" + action + "' SDNC request";
- System.out.println(msg);
- fail(msg);
- }
-
- content = callbackData.getContent();
- contentType = callbackData.getContentType();
- } else if ("ERR".equals(modifier)) {
- content = "{\"SDNCServiceError\":{\"sdncRequestId\":\"((REQUEST-ID))\",\"responseCode\":\"500\",\"responseMessage\":\"SIMULATED ERROR FROM SDNC ADAPTER\",\"ackFinalIndicator\":\"Y\"}}";
- contentType = JSON;
- } else {
- String msg = "Invalid SDNC program modifier: '" + modifier + "'";
- System.out.println(msg);
- fail(msg);
- }
-
- if (contentType == null) {
- // Default for backward compatibility with existing tests.
- contentType = JSON;
- }
-
- if (!injectSDNCRestCallback(contentType, content, 10000)) {
- fail("Failed to inject SDNC '" + action + "' callback");
- }
-
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- fail("Interrupted after injection of SDNC '" + action + "' callback");
- }
- }
- }
-
- /**
- * Runs a program to inject SDNC events into the test environment.
- * A program is essentially just a list of keys that identify event data
- * to be injected, in sequence. An example program:
- * <pre>
- * event1, event2
- * </pre>
- * NOTE: Each callback must have a message type associated with it, e.g.
- * "SDNCAEvent".
- * Errors are handled with junit assertions and will cause the test to fail.
- * @param callbacks an object containing event data for the program
- * @param program the program to execute
- */
- protected void injectSDNCEvents(CallbackSet callbacks, String program) {
- injectWorkflowMessages(callbacks, program);
- }
-
- /**
- * Runs a program to inject SDNC callback data into the test environment.
- * A program is essentially just a list of keys that identify callback data
- * to be injected, in sequence. An example program:
- * <pre>
- * reserve, assign, delete:ERR
- * </pre>
- * Errors are handled with junit assertions and will cause the test to fail.
- * @param callbacks an object containing callback data for the program
- * @param program the program to execute
- */
- protected void injectSDNCCallbacks(CallbackSet callbacks, String program) {
-
- String[] cmds = program.replaceAll("\\s+", "").split(",");
-
- for (String cmd : cmds) {
- String action = cmd;
- String modifier = "STD";
-
- if (cmd.contains(":")) {
- String[] parts = cmd.split(":");
- action = parts[0];
- modifier = parts[1];
- }
-
- String content = null;
- int respCode = 200;
- String respMsg = "OK";
-
- if ("STD".equals(modifier)) {
- CallbackData callbackData = callbacks.get(action);
-
- if (callbackData == null) {
- String msg = "No callback defined for '" + action + "' SDNC request";
- System.out.println(msg);
- fail(msg);
- }
-
- content = callbackData.getContent();
- respCode = 200;
- respMsg = "OK";
- } else if ("CREATED".equals(modifier)) {
- CallbackData callbackData = callbacks.get(action);
-
- if (callbackData == null) {
- String msg = "No callback defined for '" + action + "' SDNC request";
- System.out.println(msg);
- fail(msg);
- }
-
- content = callbackData.getContent();
- respCode = 201;
- respMsg = "Created";
- } else if ("ERR".equals(modifier)) {
- content = "<svc-request-id>((REQUEST-ID))</svc-request-id><response-code>500</response-code><response-message>SIMULATED ERROR FROM SDNC ADAPTER</response-message>";
- respCode = 500;
- respMsg = "SERVER ERROR";
- } else {
- String msg = "Invalid SDNC program modifier: '" + modifier + "'";
- System.out.println(msg);
- fail(msg);
- }
-
- if (!injectSDNCCallback(respCode, respMsg, content, 10000)) {
- fail("Failed to inject SDNC '" + action + "' callback");
- }
-
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- fail("Interrupted after injection of SDNC '" + action + "' callback");
- }
- }
- }
-
- /**
- * Runs a program to inject VNF adapter REST callback data into the test environment.
- * A program is essentially just a list of keys that identify callback data
- * to be injected, in sequence. An example program:
- * <pre>
- * create, rollback
- * </pre>
- * Errors are handled with junit assertions and will cause the test to fail.
- * @param callbacks an object containing callback data for the program
- * @param program the program to execute
- */
- protected void injectVNFRestCallbacks(CallbackSet callbacks, String program) {
-
- String[] cmds = program.replaceAll("\\s+", "").split(",");
-
- for (String cmd : cmds) {
- String action = cmd;
- String modifier = "STD";
-
- if (cmd.contains(":")) {
- String[] parts = cmd.split(":");
- action = parts[0];
- modifier = parts[1];
- }
-
- String content = null;
- String contentType = null;
-
- if ("STD".equals(modifier)) {
- CallbackData callbackData = callbacks.get(action);
-
- if (callbackData == null) {
- String msg = "No callback defined for '" + action + "' VNF REST request";
- System.out.println(msg);
- fail(msg);
- }
-
- content = callbackData.getContent();
- contentType = callbackData.getContentType();
- } else if ("ERR".equals(modifier)) {
- content = "SIMULATED ERROR FROM VNF ADAPTER";
- contentType = "text/plain";
- } else {
- String msg = "Invalid VNF REST program modifier: '" + modifier + "'";
- System.out.println(msg);
- fail(msg);
- }
-
- if (contentType == null) {
- // Default for backward compatibility with existing tests.
- contentType = XML;
- }
-
- if (!injectVnfAdapterRestCallback(contentType, content, 10000)) {
- fail("Failed to inject VNF REST '" + action + "' callback");
- }
-
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- fail("Interrupted after injection of VNF REST '" + action + "' callback");
- }
- }
- }
-
- /**
- * Runs a program to inject VNF callback data into the test environment.
- * A program is essentially just a list of keys that identify callback data
- * to be injected, in sequence. An example program:
- * <pre>
- * createVnf, deleteVnf
- * </pre>
- * Errors are handled with junit assertions and will cause the test to fail.
- * @param callbacks an object containing callback data for the program
- * @param program the program to execute
- */
- protected void injectVNFCallbacks(CallbackSet callbacks, String program) {
-
- String[] cmds = program.replaceAll("\\s+", "").split(",");
-
- for (String cmd : cmds) {
- String action = cmd;
- String modifier = "STD";
-
- if (cmd.contains(":")) {
- String[] parts = cmd.split(":");
- action = parts[0];
- modifier = parts[1];
- }
-
- String content = null;
-
- if ("STD".equals(modifier)) {
- CallbackData callbackData = callbacks.get(action);
-
- if (callbackData == null) {
- String msg = "No callback defined for '" + action + "' VNF request";
- System.out.println(msg);
- fail(msg);
- }
-
- content = callbackData.getContent();
- } else if ("ERR".equals(modifier)) {
- String msg = "Currently unsupported VNF program modifier: '" + modifier + "'";
- System.out.println(msg);
- fail(msg);
- } else {
- String msg = "Invalid VNF program modifier: '" + modifier + "'";
- System.out.println(msg);
- fail(msg);
- }
-
- boolean injected = false;
-
- if (content.contains("createVnfNotification")) {
- injected = injectCreateVNFCallback(content, 10000);
- } else if (content.contains("deleteVnfNotification")) {
- injected = injectDeleteVNFCallback(content, 10000);
- } else if (content.contains("updateVnfNotification")) {
- injected = injectUpdateVNFCallback(content, 10000);
- }
-
- if (!injected) {
- String msg = "Failed to inject VNF '" + action + "' callback";
- System.out.println(msg);
- fail(msg);
- }
-
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- fail("Interrupted after injection of VNF '" + action + "' callback");
- }
- }
- }
-
- /**
- * Waits for the number of running processes with the specified process
- * definition key to equal a particular count.
- * @param processKey the process definition key
- * @param count the desired count
- * @param timeout the timeout in milliseconds
- */
- protected void waitForRunningProcessCount(String processKey, int count, long timeout) {
- System.out.println("Waiting " + timeout + "ms for there to be " + count + " "
- + processKey + " instances");
-
- long now = System.currentTimeMillis() + timeout;
- long endTime = now + timeout;
- int last = -1;
-
- while (now <= endTime) {
- int actual = processEngineRule.getRuntimeService()
- .createProcessInstanceQuery()
- .processDefinitionKey(processKey)
- .list().size();
-
- if (actual != last) {
- System.out.println("There are now " + actual + " "
- + processKey + " instances");
- last = actual;
- }
-
- if (actual == count) {
- return;
- }
-
- try {
- Thread.sleep(200);
- } catch (InterruptedException e) {
- String msg = "Interrupted waiting for there to be " + count + " "
- + processKey + " instances";
- System.out.println(msg);
- fail(msg);
- }
-
- now = System.currentTimeMillis();
- }
-
- String msg = "Timed out waiting for there to be " + count + " "
- + processKey + " instances";
- System.out.println(msg);
- fail(msg);
- }
-
- /**
- * Waits for the specified process variable to be set.
- * @param processKey the process definition key
- * @param variable the variable name
- * @param timeout the timeout in milliseconds
- * @return the variable value, or null if it cannot be obtained
- * in the specified time
- */
- protected Object getProcessVariable(String processKey, String variable,
- long timeout) {
-
- System.out.println("Waiting " + timeout + "ms for "
- + processKey + "." + variable + " to be set");
-
- long now = System.currentTimeMillis() + timeout;
- long endTime = now + timeout;
-
- ProcessInstance processInstance = null;
- Object value = null;
-
- while (value == null) {
- if (now > endTime) {
- if (processInstance == null) {
- System.out.println("Timed out waiting for "
- + processKey + " to start");
- } else {
- System.out.println("Timed out waiting for "
- + processKey + "[" + processInstance.getId()
- + "]." + variable + " to be set");
- }
-
- return null;
- }
-
- if (processInstance == null) {
- processInstance = processEngineRule.getRuntimeService()
- .createProcessInstanceQuery()
- .processDefinitionKey(processKey)
- .singleResult();
- }
-
- if (processInstance != null) {
- value = processEngineRule.getRuntimeService()
- .getVariable(processInstance.getId(), variable);
- }
-
- try {
- Thread.sleep(200);
- } catch (InterruptedException e) {
- System.out.println("Interrupted waiting for "
- + processKey + "." + variable + " to be set");
- return null;
- }
-
- now = System.currentTimeMillis();
- }
-
- System.out.println(processKey + "["
- + processInstance.getId() + "]." + variable + "="
- + value);
-
- return value;
- }
-
- /**
- * Injects a single SDNC adapter callback request. The specified callback data
- * may contain the placeholder string ((REQUEST-ID)) which is replaced with
- * the actual SDNC request ID. Note: this is not the requestId in the original
- * MSO request.
- * @param contentType the HTTP content type for the callback
- * @param content the content of the callback
- * @param timeout the timeout in milliseconds
- * @return true if the callback could be injected, false otherwise
- */
- protected boolean injectSDNCRestCallback(String contentType, String content, long timeout) {
- String sdncRequestId = (String) getProcessVariable("SDNCAdapterRestV1",
- "SDNCAResponse_CORRELATOR", timeout);
-
- if (sdncRequestId == null) {
- return false;
- }
-
- content = content.replace("((REQUEST-ID))", sdncRequestId);
- // Deprecated usage. All test code should switch to the (( ... )) syntax.
- content = content.replace("{{REQUEST-ID}}", sdncRequestId);
-
- System.out.println("Injecting SDNC adapter callback");
- WorkflowMessageResource workflowMessageResource = new WorkflowMessageResource();
- workflowMessageResource.setProcessEngineServices4junit(processEngineRule);
- Response response = workflowMessageResource.deliver(contentType, "SDNCAResponse", sdncRequestId, content);
- System.out.println("Workflow response to SDNC adapter callback: " + response);
- return true;
- }
-
- /**
- * Injects a single SDNC adapter callback request. The specified callback data
- * may contain the placeholder string ((REQUEST-ID)) which is replaced with
- * the actual SDNC request ID. Note: this is not the requestId in the original
- * MSO request.
- * @param content the content of the callback
- * @param respCode the response code (normally 200)
- * @param respMsg the response message (normally "OK")
- * @param timeout the timeout in milliseconds
- * @return true if the callback could be injected, false otherwise
- */
- protected boolean injectSDNCCallback(int respCode, String respMsg,
- String content, long timeout) {
-
- String sdncRequestId = (String) getProcessVariable("sdncAdapter",
- "SDNCA_requestId", timeout);
-
- if (sdncRequestId == null) {
- return false;
- }
-
- content = content.replace("((REQUEST-ID))", sdncRequestId);
- // Deprecated usage. All test code should switch to the (( ... )) syntax.
- content = content.replace("{{REQUEST-ID}}", sdncRequestId);
-
- System.out.println("Injecting SDNC adapter callback");
- CallbackHeader callbackHeader = new CallbackHeader();
- callbackHeader.setRequestId(sdncRequestId);
- callbackHeader.setResponseCode(String.valueOf(respCode));
- callbackHeader.setResponseMessage(respMsg);
- SDNCAdapterCallbackRequest sdncAdapterCallbackRequest = new SDNCAdapterCallbackRequest();
- sdncAdapterCallbackRequest.setCallbackHeader(callbackHeader);
- sdncAdapterCallbackRequest.setRequestData(content);
- SDNCAdapterCallbackServiceImpl callbackService = new SDNCAdapterCallbackServiceImpl();
- callbackService.setProcessEngineServices4junit(processEngineRule);
- SDNCAdapterResponse sdncAdapterResponse = callbackService.sdncAdapterCallback(sdncAdapterCallbackRequest);
- System.out.println("Workflow response to SDNC adapter callback: " + sdncAdapterResponse);
-
- return true;
- }
-
- /**
- * Injects a single VNF adapter callback request. The specified callback data
- * may contain the placeholder string ((MESSAGE-ID)) which is replaced with
- * the actual message ID. Note: this is not the requestId in the original
- * MSO request.
- * @param contentType the HTTP content type for the callback
- * @param content the content of the callback
- * @param timeout the timeout in milliseconds
- * @return true if the callback could be injected, false otherwise
- */
- protected boolean injectVnfAdapterRestCallback(String contentType, String content, long timeout) {
- String messageId = (String) getProcessVariable("vnfAdapterRestV1",
- "VNFAResponse_CORRELATOR", timeout);
-
- if (messageId == null) {
- return false;
- }
-
- content = content.replace("((MESSAGE-ID))", messageId);
- // Deprecated usage. All test code should switch to the (( ... )) syntax.
- content = content.replace("{{MESSAGE-ID}}", messageId);
-
- System.out.println("Injecting VNF adapter callback");
- WorkflowMessageResource workflowMessageResource = new WorkflowMessageResource();
- workflowMessageResource.setProcessEngineServices4junit(processEngineRule);
- Response response = workflowMessageResource.deliver(contentType, "VNFAResponse", messageId, content);
- System.out.println("Workflow response to VNF adapter callback: " + response);
- return true;
- }
-
- /**
- * Injects a Create VNF adapter callback request. The specified callback data
- * may contain the placeholder string ((MESSAGE-ID)) which is replaced with
- * the actual message ID. It may also contain the placeholder string
- * ((REQUEST-ID)) which is replaced request ID of the original MSO request.
- * @param content the content of the callback
- * @param timeout the timeout in milliseconds
- * @return true if the callback could be injected, false otherwise
- * @throws JAXBException if the content does not adhere to the schema
- */
- protected boolean injectCreateVNFCallback(String content, long timeout) {
-
- String messageId = (String) getProcessVariable("vnfAdapterCreateV1",
- "VNFC_messageId", timeout);
-
- if (messageId == null) {
- return false;
- }
-
- content = content.replace("((MESSAGE-ID))", messageId);
- // Deprecated usage. All test code should switch to the (( ... )) syntax.
- content = content.replace("{{MESSAGE-ID}}", messageId);
-
- if(content.contains("((REQUEST-ID))")){
- content = content.replace("((REQUEST-ID))", msoRequestId);
- // Deprecated usage. All test code should switch to the (( ... )) syntax.
- content = content.replace("{{REQUEST-ID}}", msoRequestId);
- }
-
- System.out.println("Injecting VNF adapter callback");
-
- // Is it possible to unmarshal this with JAXB? I couldn't.
-
- CreateVnfNotification createVnfNotification = new CreateVnfNotification();
- XPathTool xpathTool = new VnfNotifyXPathTool();
- xpathTool.setXML(content);
-
- try {
- String completed = xpathTool.evaluate(
- "/tns:createVnfNotification/tns:completed/text()");
- createVnfNotification.setCompleted("true".equals(completed));
-
- String vnfId = xpathTool.evaluate(
- "/tns:createVnfNotification/tns:vnfId/text()");
- createVnfNotification.setVnfId(vnfId);
-
- NodeList entries = (NodeList) xpathTool.evaluate(
- "/tns:createVnfNotification/tns:outputs/tns:entry",
- XPathConstants.NODESET);
-
- CreateVnfNotificationOutputs outputs = new CreateVnfNotificationOutputs();
-
- for (int i = 0; i < entries.getLength(); i++) {
- Node node = entries.item(i);
-
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- Element entry = (Element) node;
- String key = entry.getElementsByTagNameNS("*", "key").item(0).getTextContent();
- String value = entry.getElementsByTagNameNS("*", "value").item(0).getTextContent();
- outputs.add(key, value);
- }
- }
-
- createVnfNotification.setOutputs(outputs);
-
- VnfRollback rollback = new VnfRollback();
-
- String cloudSiteId = xpathTool.evaluate(
- "/tns:createVnfNotification/tns:rollback/tns:cloudSiteId/text()");
- rollback.setCloudSiteId(cloudSiteId);
-
- String requestId = xpathTool.evaluate(
- "/tns:createVnfNotification/tns:rollback/tns:msoRequest/tns:requestId/text()");
- String serviceInstanceId = xpathTool.evaluate(
- "/tns:createVnfNotification/tns:rollback/tns:msoRequest/tns:serviceInstanceId/text()");
-
- if (requestId != null || serviceInstanceId != null) {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId(requestId);
- msoRequest.setServiceInstanceId(serviceInstanceId);
- rollback.setMsoRequest(msoRequest);
- }
-
- String tenantCreated = xpathTool.evaluate(
- "/tns:createVnfNotification/tns:rollback/tns:tenantCreated/text()");
- rollback.setTenantCreated("true".equals(tenantCreated));
-
- String tenantId = xpathTool.evaluate(
- "/tns:createVnfNotification/tns:rollback/tns:tenantId/text()");
- rollback.setTenantId(tenantId);
-
- String vnfCreated = xpathTool.evaluate(
- "/tns:createVnfNotification/tns:rollback/tns:vnfCreated/text()");
- rollback.setVnfCreated("true".equals(vnfCreated));
-
- String rollbackVnfId = xpathTool.evaluate(
- "/tns:createVnfNotification/tns:rollback/tns:vnfId/text()");
- rollback.setVnfId(rollbackVnfId);
-
- createVnfNotification.setRollback(rollback);
-
- } catch (Exception e) {
- System.out.println("Failed to unmarshal VNF callback content:");
- System.out.println(content);
- return false;
- }
-
- VnfAdapterNotifyServiceImpl notifyService = new VnfAdapterNotifyServiceImpl();
- notifyService.setProcessEngineServices4junit(processEngineRule);
-
- notifyService.createVnfNotification(
- messageId,
- createVnfNotification.isCompleted(),
- createVnfNotification.getException(),
- createVnfNotification.getErrorMessage(),
- createVnfNotification.getVnfId(),
- createVnfNotification.getOutputs(),
- createVnfNotification.getRollback());
-
- return true;
- }
-
- /**
- * Injects a Delete VNF adapter callback request. The specified callback data
- * may contain the placeholder string ((MESSAGE-ID)) which is replaced with
- * the actual message ID. It may also contain the placeholder string
- * ((REQUEST-ID)) which is replaced request ID of the original MSO request.
- * @param content the content of the callback
- * @param timeout the timeout in milliseconds
- * @return true if the callback could be injected, false otherwise
- * @throws JAXBException if the content does not adhere to the schema
- */
- protected boolean injectDeleteVNFCallback(String content, long timeout) {
-
- String messageId = (String) getProcessVariable("vnfAdapterDeleteV1",
- "VNFDEL_uuid", timeout);
-
- if (messageId == null) {
- return false;
- }
-
- content = content.replace("((MESSAGE-ID))", messageId);
- // Deprecated usage. All test code should switch to the (( ... )) syntax.
- content = content.replace("{{MESSAGE-ID}}", messageId);
-
- System.out.println("Injecting VNF adapter delete callback");
-
- // Is it possible to unmarshal this with JAXB? I couldn't.
-
- DeleteVnfNotification deleteVnfNotification = new DeleteVnfNotification();
- XPathTool xpathTool = new VnfNotifyXPathTool();
- xpathTool.setXML(content);
-
- try {
- String completed = xpathTool.evaluate(
- "/tns:deleteVnfNotification/tns:completed/text()");
- deleteVnfNotification.setCompleted("true".equals(completed));
- // if notification failure, set the exception and error message
- if (deleteVnfNotification.isCompleted() == false) {
- deleteVnfNotification.setException(MsoExceptionCategory.INTERNAL);
- deleteVnfNotification.setErrorMessage(xpathTool.evaluate(
- "/tns:deleteVnfNotification/tns:errorMessage/text()")) ;
- }
-
- } catch (Exception e) {
- System.out.println("Failed to unmarshal VNF Delete callback content:");
- System.out.println(content);
- return false;
- }
-
- VnfAdapterNotifyServiceImpl notifyService = new VnfAdapterNotifyServiceImpl();
- notifyService.setProcessEngineServices4junit(processEngineRule);
-
- notifyService.deleteVnfNotification(
- messageId,
- deleteVnfNotification.isCompleted(),
- deleteVnfNotification.getException(),
- deleteVnfNotification.getErrorMessage());
-
- return true;
- }
-
- /**
- * Injects a Update VNF adapter callback request. The specified callback data
- * may contain the placeholder string ((MESSAGE-ID)) which is replaced with
- * the actual message ID. It may also contain the placeholder string
- * ((REQUEST-ID)) which is replaced request ID of the original MSO request.
- * @param content the content of the callback
- * @param timeout the timeout in milliseconds
- * @return true if the callback could be injected, false otherwise
- * @throws JAXBException if the content does not adhere to the schema
- */
- protected boolean injectUpdateVNFCallback(String content, long timeout) {
-
- String messageId = (String) getProcessVariable("vnfAdapterUpdate",
- "VNFU_messageId", timeout);
-
- if (messageId == null) {
- return false;
- }
-
- content = content.replace("((MESSAGE-ID))", messageId);
- // Deprecated usage. All test code should switch to the (( ... )) syntax.
- content = content.replace("{{MESSAGE-ID}}", messageId);
-
- content = content.replace("((REQUEST-ID))", msoRequestId);
- // Deprecated usage. All test code should switch to the (( ... )) syntax.
- content = content.replace("{{REQUEST-ID}}", msoRequestId);
-
- System.out.println("Injecting VNF adapter callback");
-
- // Is it possible to unmarshal this with JAXB? I couldn't.
-
- UpdateVnfNotification updateVnfNotification = new UpdateVnfNotification();
- XPathTool xpathTool = new VnfNotifyXPathTool();
- xpathTool.setXML(content);
-
- try {
- String completed = xpathTool.evaluate(
- "/tns:updateVnfNotification/tns:completed/text()");
- updateVnfNotification.setCompleted("true".equals(completed));
-
- NodeList entries = (NodeList) xpathTool.evaluate(
- "/tns:updateVnfNotification/tns:outputs/tns:entry",
- XPathConstants.NODESET);
-
- UpdateVnfNotificationOutputs outputs = new UpdateVnfNotificationOutputs();
-
- for (int i = 0; i < entries.getLength(); i++) {
- Node node = entries.item(i);
-
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- Element entry = (Element) node;
- String key = entry.getElementsByTagNameNS("*", "key").item(0).getTextContent();
- String value = entry.getElementsByTagNameNS("*", "value").item(0).getTextContent();
- outputs.add(key, value);
- }
- }
-
- updateVnfNotification.setOutputs(outputs);
-
- VnfRollback rollback = new VnfRollback();
-
- String cloudSiteId = xpathTool.evaluate(
- "/tns:updateVnfNotification/tns:rollback/tns:cloudSiteId/text()");
- rollback.setCloudSiteId(cloudSiteId);
-
- String requestId = xpathTool.evaluate(
- "/tns:updateVnfNotification/tns:rollback/tns:msoRequest/tns:requestId/text()");
- String serviceInstanceId = xpathTool.evaluate(
- "/tns:updateVnfNotification/tns:rollback/tns:msoRequest/tns:serviceInstanceId/text()");
-
- if (requestId != null || serviceInstanceId != null) {
- MsoRequest msoRequest = new MsoRequest();
- msoRequest.setRequestId(requestId);
- msoRequest.setServiceInstanceId(serviceInstanceId);
- rollback.setMsoRequest(msoRequest);
- }
-
- String tenantCreated = xpathTool.evaluate(
- "/tns:updateVnfNotification/tns:rollback/tns:tenantCreated/text()");
- rollback.setTenantCreated("true".equals(tenantCreated));
-
- String tenantId = xpathTool.evaluate(
- "/tns:updateVnfNotification/tns:rollback/tns:tenantId/text()");
- rollback.setTenantId(tenantId);
-
- String vnfCreated = xpathTool.evaluate(
- "/tns:updateVnfNotification/tns:rollback/tns:vnfCreated/text()");
- rollback.setVnfCreated("true".equals(vnfCreated));
-
- String rollbackVnfId = xpathTool.evaluate(
- "/tns:updateVnfNotification/tns:rollback/tns:vnfId/text()");
- rollback.setVnfId(rollbackVnfId);
-
- updateVnfNotification.setRollback(rollback);
-
- } catch (Exception e) {
- System.out.println("Failed to unmarshal VNF callback content:");
- System.out.println(content);
- return false;
- }
-
- VnfAdapterNotifyServiceImpl notifyService = new VnfAdapterNotifyServiceImpl();
- notifyService.setProcessEngineServices4junit(processEngineRule);
-
- notifyService.updateVnfNotification(
- messageId,
- updateVnfNotification.isCompleted(),
- updateVnfNotification.getException(),
- updateVnfNotification.getErrorMessage(),
- updateVnfNotification.getOutputs(),
- updateVnfNotification.getRollback());
-
- return true;
- }
-
- /**
- * Runs a program to inject workflow messages into the test environment.
- * A program is essentially just a list of keys that identify event data
- * to be injected, in sequence. An example program:
- * <pre>
- * event1, event2
- * </pre>
- * Errors are handled with junit assertions and will cause the test to fail.
- * NOTE: Each callback must have a workflow message type associated with it.
- * @param callbacks an object containing event data for the program
- * @param program the program to execute
- */
- protected void injectWorkflowMessages(CallbackSet callbacks, String program) {
-
- String[] cmds = program.replaceAll("\\s+", "").split(",");
-
- for (String cmd : cmds) {
- String action = cmd;
- String modifier = "STD";
-
- if (cmd.contains(":")) {
- String[] parts = cmd.split(":");
- action = parts[0];
- modifier = parts[1];
- }
-
- String messageType = null;
- String content = null;
- String contentType = null;
-
- if ("STD".equals(modifier)) {
- CallbackData callbackData = callbacks.get(action);
-
- if (callbackData == null) {
- String msg = "No '" + action + "' workflow message callback is defined";
- System.out.println(msg);
- fail(msg);
- }
-
- messageType = callbackData.getMessageType();
-
- if (messageType == null || messageType.trim().equals("")) {
- String msg = "No workflow message type is defined in the '" + action + "' callback";
- System.out.println(msg);
- fail(msg);
- }
-
- content = callbackData.getContent();
- contentType = callbackData.getContentType();
- } else {
- String msg = "Invalid workflow message program modifier: '" + modifier + "'";
- System.out.println(msg);
- fail(msg);
- }
-
- if (!injectWorkflowMessage(contentType, messageType, content, 10000)) {
- fail("Failed to inject '" + action + "' workflow message");
- }
-
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- fail("Interrupted after injection of '" + action + "' workflow message");
- }
- }
- }
-
- /**
- * Injects a workflow message. The specified callback data may contain the
- * placeholder string ((CORRELATOR)) which is replaced with the actual
- * correlator value.
- * @param contentType the HTTP contentType for the message (possibly null)
- * @param messageType the message type
- * @param content the message content (possibly null)
- * @param timeout the timeout in milliseconds
- * @return true if the message could be injected, false otherwise
- */
- protected boolean injectWorkflowMessage(String contentType, String messageType, String content, long timeout) {
- String correlator = (String) getProcessVariable("ReceiveWorkflowMessage",
- messageType + "_CORRELATOR", timeout);
-
- if (correlator == null) {
- return false;
- }
-
- if (content != null) {
- content = content.replace("((CORRELATOR))", correlator);
- }
-
- System.out.println("Injecting " + messageType + " message");
- WorkflowMessageResource workflowMessageResource = new WorkflowMessageResource();
- workflowMessageResource.setProcessEngineServices4junit(processEngineRule);
- Response response = workflowMessageResource.deliver(contentType, messageType, correlator, content);
- System.out.println("Workflow response to " + messageType + " message: " + response);
- return true;
- }
-
- /**
- * Runs a program to inject sniro workflow messages into the test environment.
- * A program is essentially just a list of keys that identify event data
- * to be injected, in sequence. For more details, see
- * injectSNIROCallbacks(String contentType, String messageType, String content, long timeout)
- *
- * Errors are handled with junit assertions and will cause the test to fail.
- * NOTE: Each callback must have a workflow message type associated with it.
- *
- * @param callbacks an object containing event data for the program
- * @param program the program to execute
- */
- protected void injectSNIROCallbacks(CallbackSet callbacks, String program) {
-
- String[] cmds = program.replaceAll("\\s+", "").split(",");
-
- for (String cmd : cmds) {
- String action = cmd;
- String modifier = "STD";
-
- if (cmd.contains(":")) {
- String[] parts = cmd.split(":");
- action = parts[0];
- modifier = parts[1];
- }
-
- String messageType = null;
- String content = null;
- String contentType = null;
-
- if ("STD".equals(modifier)) {
- CallbackData callbackData = callbacks.get(action);
-
- if (callbackData == null) {
- String msg = "No '" + action + "' workflow message callback is defined";
- System.out.println(msg);
- fail(msg);
- }
-
- messageType = callbackData.getMessageType();
-
- if (messageType == null || messageType.trim().equals("")) {
- String msg = "No workflow message type is defined in the '" + action + "' callback";
- System.out.println(msg);
- fail(msg);
- }
-
- content = callbackData.getContent();
- contentType = callbackData.getContentType();
- } else {
- String msg = "Invalid workflow message program modifier: '" + modifier + "'";
- System.out.println(msg);
- fail(msg);
- }
-
- if (!injectSNIROCallbacks(contentType, messageType, content, 10000)) {
- fail("Failed to inject '" + action + "' workflow message");
- }
-
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- fail("Interrupted after injection of '" + action + "' workflow message");
- }
- }
- }
-
- /**
- * Injects a sniro workflow message. The specified callback response may
- * contain the placeholder strings ((CORRELATOR)) and ((SERVICE_RESOURCE_ID))
- * The ((CORRELATOR)) is replaced with the actual correlator value from the
- * request. The ((SERVICE_RESOURCE_ID)) is replaced with the actual serviceResourceId
- * value from the sniro request. Currently this only works with sniro request
- * that contain only 1 resource.
- *
- * @param contentType the HTTP contentType for the message (possibly null)
- * @param messageType the message type
- * @param content the message content (possibly null)
- * @param timeout the timeout in milliseconds
- * @return true if the message could be injected, false otherwise
- */
- protected boolean injectSNIROCallbacks(String contentType, String messageType, String content, long timeout) {
- String correlator = (String) getProcessVariable("ReceiveWorkflowMessage",
- messageType + "_CORRELATOR", timeout);
-
- if (correlator == null) {
- return false;
- }
- if (content != null) {
- content = content.replace("((CORRELATOR))", correlator);
- if(messageType.equalsIgnoreCase("SNIROResponse")){
- //TODO figure out a solution for when there is more than 1 resource being homed (i.e. more than 1 reason in the placement list)
- ServiceDecomposition decomp = (ServiceDecomposition) getProcessVariable("Homing", "serviceDecomposition", timeout);
- List<Resource> resourceList = decomp.getServiceResources();
- if(resourceList.size() == 1){
- String resourceId = "";
- for(Resource resource:resourceList){
- resourceId = resource.getResourceId();
- }
- //TODO.. most other locations refer to solutionInfo.placementInfo
- String homingList = getJsonValue(content, "solutionInfo.placement");
- JSONArray placementArr = null;
- try {
- placementArr = new JSONArray(homingList);
- }
- catch (Exception e) {
- return false;
- }
- if(placementArr.length() == 1){
- content = content.replace("((SERVICE_RESOURCE_ID))", resourceId);
- }
- String licenseInfoList = getJsonValue(content, "solutionInfo.licenseInfo");
- JSONArray licenseArr = null;
- try {
- licenseArr = new JSONArray(licenseInfoList);
- }
- catch (Exception e) {
- return false;
- }
- if(licenseArr.length() == 1){
- content = content.replace("((SERVICE_RESOURCE_ID))", resourceId);
- }
- }
- else {
- try {
- String homingList = getJsonValue(content, "solutionInfo.placement");
- String licenseInfoList = getJsonValue(content, "solutionInfo.licenseInfo");
- JSONArray placementArr = new JSONArray(homingList);
- JSONArray licenseArr = new JSONArray(licenseInfoList);
- for (Resource resource: resourceList) {
- String resourceModuleName = resource.getModelInfo().getModelInstanceName();
- String resourceId = resource.getResourceId();
-
- for (int i=0; i<placementArr.length(); i++) {
- JSONObject placementObj = placementArr.getJSONObject(i);
- String placementModuleName = placementObj.getString("resourceModuleName");
- if (placementModuleName.equalsIgnoreCase(resourceModuleName)) {
- String placementString = placementObj.toString();
- placementString = placementString.replace("((SERVICE_RESOURCE_ID))", resourceId);
- JSONObject newPlacementObj = new JSONObject(placementString);
- placementArr.put(i, newPlacementObj);
- }
- }
-
- for (int i=0; i<licenseArr.length(); i++) {
- JSONObject licenseObj = licenseArr.getJSONObject(i);
- String licenseModuleName = licenseObj.getString("resourceModuleName");
- if (licenseModuleName.equalsIgnoreCase(resourceModuleName)) {
- String licenseString = licenseObj.toString();
- licenseString = licenseString.replace("((SERVICE_RESOURCE_ID))", resourceId);
- JSONObject newLicenseObj = new JSONObject(licenseString);
- licenseArr.put(i, newLicenseObj);
- }
- }
- }
- String newPlacementInfos = placementArr.toString();
- String newLicenseInfos = licenseArr.toString();
- content = updJsonValue(content, "solutionInfo.placement", newPlacementInfos);
- content = updJsonValue(content, "solutionInfo.licenseInfo", newLicenseInfos);
- }
- catch(Exception e) {
- return false;
- }
-
- }
- }
- }
- System.out.println("Injecting " + messageType + " message");
- WorkflowMessageResource workflowMessageResource = new WorkflowMessageResource();
- workflowMessageResource.setProcessEngineServices4junit(processEngineRule);
- Response response = workflowMessageResource.deliver(contentType, messageType, correlator, content);
- System.out.println("Workflow response to " + messageType + " message: " + response);
- return true;
- }
-
-
- /**
- * Wait for the process to end.
- * @param businessKey the process business key
- * @param timeout the amount of time to wait, in milliseconds
- */
- protected void waitForProcessEnd(String businessKey, long timeout) {
- System.out.println("Waiting " + timeout + "ms for process with business key " +
- businessKey + " to end");
-
- long now = System.currentTimeMillis() + timeout;
- long endTime = now + timeout;
-
- while (now <= endTime) {
- if (isProcessEnded(businessKey)) {
- System.out.println("Process with business key " + businessKey + " has ended");
- return;
- }
-
- try {
- Thread.sleep(200);
- } catch (InterruptedException e) {
- String msg = "Interrupted waiting for process with business key " +
- businessKey + " to end";
- System.out.println(msg);
- fail(msg);
- }
-
- now = System.currentTimeMillis();
- }
-
- String msg = "Process with business key " + businessKey +
- " did not end within " + timeout + "ms";
- System.out.println(msg);
- fail(msg);
- }
-
- /**
- * Verifies that the specified historic process variable has the specified value.
- * If the variable does not have the specified value, the test is failed.
- * @param businessKey the process business key
- * @param variable the variable name
- * @param value the expected variable value
- */
- protected void checkVariable(String businessKey, String variable, Object value) {
- if (!isProcessEnded(businessKey)) {
- fail("Cannot get historic variable " + variable + " because process with business key " +
- businessKey + " has not ended");
- }
-
- Object variableValue = getVariableFromHistory(businessKey, variable);
- assertEquals(value, variableValue);
- }
-
- /**
- * Checks to see if the specified process is ended.
- * @param businessKey the process business Key
- * @return true if the process is ended
- */
- protected boolean isProcessEnded(String businessKey) {
- HistoricProcessInstance processInstance = processEngineRule.getHistoryService()
- .createHistoricProcessInstanceQuery().processInstanceBusinessKey(businessKey).singleResult();
- return processInstance != null && processInstance.getEndTime() != null;
- }
-
- /**
- * Gets a variable value from a historical process instance.
- * @param businessKey the process business key
- * @param variableName the variable name
- * @return the variable value, or null if the variable could not be
- * obtained
- */
- protected Object getVariableFromHistory(String businessKey, String variableName) {
- try {
- HistoricProcessInstance processInstance = processEngineRule.getHistoryService()
- .createHistoricProcessInstanceQuery().processInstanceBusinessKey(businessKey).singleResult();
-
- if (processInstance == null) {
- return null;
- }
-
- HistoricVariableInstance v = processEngineRule.getHistoryService()
- .createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId())
- .variableName(variableName).singleResult();
- return v == null ? null : v.getValue();
- } catch (Exception e) {
- System.out.println("Error retrieving variable " + variableName +
- " from historical process with business key " + businessKey + ": " + e);
- return null;
- }
- }
-
- /**
- * Gets the value of a subflow variable from the specified subflow's
- * historical process instance.
- *
- * @param subflowName - the name of the subflow that contains the variable
- * @param variableName the variable name
- *
- * @return the variable value, or null if the variable could not be obtained
- *
- */
- protected Object getVariableFromSubflowHistory(String subflowName, String variableName) {
- try {
- List<HistoricProcessInstance> processInstanceList = processEngineRule.getHistoryService()
- .createHistoricProcessInstanceQuery().processDefinitionName(subflowName).list();
-
- if (processInstanceList == null) {
- return null;
- }
-
- processInstanceList.sort((m1, m2) -> m1.getStartTime().compareTo(m2.getStartTime()));
-
- HistoricProcessInstance processInstance = processInstanceList.get(0);
-
- HistoricVariableInstance v = processEngineRule.getHistoryService()
- .createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId())
- .variableName(variableName).singleResult();
- return v == null ? null : v.getValue();
- } catch (Exception e) {
- System.out.println("Error retrieving variable " + variableName +
- " from sub flow: " + subflowName + ", Exception is: " + e);
- return null;
- }
- }
-
- /**
- * Gets the value of a subflow variable from the subflow's
- * historical process x instance.
- *
- * @param subflowName - the name of the subflow that contains the variable
- * @param variableName the variable name
- * @param subflowInstanceIndex - the instance of the subflow (use when same subflow is called more than once from mainflow)
- *
- * @return the variable value, or null if the variable could not be obtained
- */
- protected Object getVariableFromSubflowHistory(int subflowInstanceIndex, String subflowName, String variableName) {
- try {
- List<HistoricProcessInstance> processInstanceList = processEngineRule.getHistoryService()
- .createHistoricProcessInstanceQuery().processDefinitionName(subflowName).list();
-
- if (processInstanceList == null) {
- return null;
- }
-
- processInstanceList.sort((m1, m2) -> m1.getStartTime().compareTo(m2.getStartTime()));
-
- HistoricProcessInstance processInstance = processInstanceList.get(subflowInstanceIndex);
-
- HistoricVariableInstance v = processEngineRule.getHistoryService()
- .createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId())
- .variableName(variableName).singleResult();
- return v == null ? null : v.getValue();
- } catch (Exception e) {
- System.out.println("Error retrieving variable " + variableName +
- " from " + subflowInstanceIndex + " instance index of sub flow: " + subflowName + ", Exception is: " + e);
- return null;
- }
- }
-
-
- /**
- * Extracts text from an XML element. This method is not namespace aware
- * (namespaces are ignored). The first matching element is selected.
- * @param xml the XML document or fragment
- * @param tag the desired element, e.g. "<name>"
- * @return the element text, or null if the element was not found
- */
- protected String getXMLTextElement(String xml, String tag) {
- xml = removeXMLNamespaces(xml);
-
- if (!tag.startsWith("<")) {
- tag = "<" + tag + ">";
- }
-
- int start = xml.indexOf(tag);
-
- if (start == -1) {
- return null;
- }
-
- int end = xml.indexOf('<', start + tag.length());
-
- if (end == -1) {
- return null;
- }
-
- return xml.substring(start + tag.length(), end);
- }
-
- /**
- * Removes namespace definitions and prefixes from XML, if any.
- */
- private String removeXMLNamespaces(String xml) {
- // remove xmlns declaration
- xml = xml.replaceAll("xmlns.*?(\"|\').*?(\"|\')", "");
-
- // remove opening tag prefix
- xml = xml.replaceAll("(<)(\\w+:)(.*?>)", "$1$3");
-
- // remove closing tags prefix
- xml = xml.replaceAll("(</)(\\w+:)(.*?>)", "$1$3");
-
- // remove extra spaces left when xmlns declarations are removed
- xml = xml.replaceAll("\\s+>", ">");
-
- return xml;
- }
-
- /**
- * Asserts that two XML documents are semantically equivalent. Differences
- * in whitespace or in namespace usage do not affect the comparison.
- * @param expected the expected XML
- * @param actual the XML to test
- * @throws SAXException
- * @throws IOException
- */
- public static void assertXMLEquals(String expected, String actual)
- throws SAXException, IOException {
- XMLUnit.setIgnoreWhitespace(true);
- XMLUnit.setIgnoreAttributeOrder(true);
- DetailedDiff diff = new DetailedDiff(XMLUnit.compareXML(expected, actual));
- List<?> allDifferences = diff.getAllDifferences();
- assertEquals("Differences found: " + diff.toString(), 0, allDifferences.size());
- }
-
- /**
- * A test implementation of AsynchronousResponse.
- */
- public class TestAsyncResponse implements AsynchronousResponse {
- Response response = null;
-
- /**
- * {@inheritDoc}
- */
- @Override
- public synchronized void setResponse(Response response) {
- this.response = response;
- }
-
- /**
- * Gets the response.
- * @return the response, or null if none has been produced yet
- */
- public synchronized Response getResponse() {
- return response;
- }
- }
-
- /**
- * An object that contains callback data for a "program".
- */
- public class CallbackSet {
- private final Map<String, CallbackData> map = new HashMap<>();
-
- /**
- * Add untyped callback data to the set.
- * @param action the action with which the data is associated
- * @param content the callback data
- */
- public void put(String action, String content) {
- map.put(action, new CallbackData(null, null, content));
- }
-
- /**
- * Add callback data to the set.
- * @param action the action with which the data is associated
- * @param messageType the callback message type
- * @param content the callback data
- */
- public void put(String action, String messageType, String content) {
- map.put(action, new CallbackData(null, messageType, content));
- }
-
- /**
- * Add callback data to the set.
- * @param action the action with which the data is associated
- * @param contentType the callback HTTP content type
- * @param messageType the callback message type
- * @param content the callback data
- */
- public void put(String action, String contentType, String messageType, String content) {
- map.put(action, new CallbackData(contentType, messageType, content));
- }
-
- /**
- * Retrieve callback data from the set.
- * @param action the action with which the data is associated
- * @return the callback data, or null if there is none for the specified operation
- */
- public CallbackData get(String action) {
- return map.get(action);
- }
- }
-
- /**
- * Represents a callback data item.
- */
- public class CallbackData {
- private final String contentType;
- private final String messageType;
- private final String content;
-
- /**
- * Constructor
- * @param contentType the HTTP content type (optional)
- * @param messageType the callback message type (optional)
- * @param content the content
- */
- public CallbackData(String contentType, String messageType, String content) {
- this.contentType = contentType;
- this.messageType = messageType;
- this.content = content;
- }
-
- /**
- * Gets the callback HTTP content type, possibly null.
- */
- public String getContentType() {
- return contentType;
- }
-
- /**
- * Gets the callback message type, possibly null.
- */
- public String getMessageType() {
- return messageType;
- }
-
- /**
- * Gets the callback content.
- */
- public String getContent() {
- return content;
- }
- }
-
- /**
- * A tool for evaluating XPath expressions.
- */
- protected class XPathTool {
- private final DocumentBuilderFactory factory;
- private final SimpleNamespaceContext context = new SimpleNamespaceContext();
- private final XPath xpath = XPathFactory.newInstance().newXPath();
- private String xml = null;
- private Document doc = null;
-
- /**
- * Constructor.
- */
- public XPathTool() {
- factory = DocumentBuilderFactory.newInstance();
- factory.setNamespaceAware(true);
- xpath.setNamespaceContext(context);
- }
-
- /**
- * Adds a namespace.
- * @param prefix the namespace prefix
- * @param uri the namespace uri
- */
- public synchronized void addNamespace(String prefix, String uri) {
- context.add(prefix, uri);
- }
-
- /**
- * Sets the XML content to be operated on.
- * @param xml the XML content
- */
- public synchronized void setXML(String xml) {
- this.xml = xml;
- this.doc = null;
- }
-
- /**
- * Returns the document object.
- * @return the document object, or null if XML has not been set
- * @throws SAXException
- * @throws IOException
- * @throws ParserConfigurationException
- */
- public synchronized Document getDocument()
- throws ParserConfigurationException, IOException, SAXException {
- if (xml == null) {
- return null;
- }
-
- buildDocument();
- return doc;
- }
-
- /**
- * Evaluates the specified XPath expression and returns a string result.
- * This method throws exceptions on error.
- * @param expression the expression
- * @return the result object
- * @throws ParserConfigurationException
- * @throws IOException
- * @throws SAXException
- * @throws XPathExpressionException on error
- */
- public synchronized String evaluate(String expression)
- throws ParserConfigurationException, SAXException,
- IOException, XPathExpressionException {
- return (String) evaluate(expression, XPathConstants.STRING);
- }
-
- /**
- * Evaluates the specified XPath expression.
- * This method throws exceptions on error.
- * @param expression the expression
- * @param returnType the return type
- * @return the result object
- * @throws ParserConfigurationException
- * @throws IOException
- * @throws SAXException
- * @throws XPathExpressionException on error
- */
- public synchronized Object evaluate(String expression, QName returnType)
- throws ParserConfigurationException, SAXException,
- IOException, XPathExpressionException {
-
- buildDocument();
- XPathExpression expr = xpath.compile(expression);
- return expr.evaluate(doc, returnType);
- }
-
- /**
- * Private helper method that builds the document object.
- * Assumes the calling method is synchronized.
- * @throws ParserConfigurationException
- * @throws IOException
- * @throws SAXException
- */
- private void buildDocument() throws ParserConfigurationException,
- IOException, SAXException {
- if (doc == null) {
- if (xml == null) {
- throw new IOException("XML input is null");
- }
-
- DocumentBuilder builder = factory.newDocumentBuilder();
- InputSource source = new InputSource(new StringReader(xml));
- doc = builder.parse(source);
- }
- }
- }
-
- /**
- * A NamespaceContext class based on a Map.
- */
- private class SimpleNamespaceContext implements NamespaceContext {
- private Map<String, String> prefixMap = new HashMap<>();
- private Map<String, String> uriMap = new HashMap<>();
-
- public synchronized void add(String prefix, String uri) {
- prefixMap.put(prefix, uri);
- uriMap.put(uri, prefix);
- }
-
- @Override
- public synchronized String getNamespaceURI(String prefix) {
- return prefixMap.get(prefix);
- }
-
- @Override
- public Iterator<String> getPrefixes(String uri) {
- List<String> list = new ArrayList<>();
- String prefix = uriMap.get(uri);
- if (prefix != null) {
- list.add(prefix);
- }
- return list.iterator();
- }
-
- @Override
- public String getPrefix(String uri) {
- return uriMap.get(uri);
- }
- }
-
- /**
- * A VnfNotify XPathTool.
- */
- protected class VnfNotifyXPathTool extends XPathTool {
- public VnfNotifyXPathTool() {
- addNamespace("tns", "http://org.openecomp.mso/vnfNotify");
- }
- }
-
- /**
- * Helper class to make it easier to create this type.
- */
- private static class CreateVnfNotificationOutputs
- extends CreateVnfNotification.Outputs {
- public void add(String key, String value) {
- Entry entry = new Entry();
- entry.setKey(key);
- entry.setValue(value);
- getEntry().add(entry);
- }
- }
-
- /**
- * Helper class to make it easier to create this type.
- */
- private static class UpdateVnfNotificationOutputs
- extends UpdateVnfNotification.Outputs {
- public void add(String key, String value) {
- Entry entry = new Entry();
- entry.setKey(key);
- entry.setValue(value);
- getEntry().add(entry);
- }
- }
-}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTestTransformer.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTestTransformer.java deleted file mode 100644 index ea338c21bf..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/WorkflowTestTransformer.java +++ /dev/null @@ -1,41 +0,0 @@ -/*-
- * ============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.openecomp.mso.bpmn.common;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Allows a subclass of WorkflowTest to specify one or more WireMock
- * response transformers. A transformer must be declared as a public
- * static field in the subclass. For example:
- * <pre>
- * @WorkflowTestTransformer
- * public static final ResponseTransformer sdncAdapterMockTransformer =
- * new SDNCAdapterMockTransformer();
- * </pre>
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-public @interface WorkflowTestTransformer {
-}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/CreateVnfNotificationTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/CreateVnfNotificationTest.java deleted file mode 100644 index 18a2108c86..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/CreateVnfNotificationTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* 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.openecomp.mso.bpmn.common.adapter.vnf;
-
-import static org.junit.Assert.*;
-import org.junit.Test;
-import org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification.Outputs;
-import org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification.Outputs.Entry;
-
-public class CreateVnfNotificationTest {
-
- @Test
- public void test() {
- CreateVnfNotification cvn=new CreateVnfNotification();
- Entry ent = new Entry();
- MsoExceptionCategory exception = MsoExceptionCategory.OPENSTACK;
- Outputs value=new Outputs();
- VnfRollback vnf=new VnfRollback();
- vnf.setCloudSiteId("cloud");
- cvn.setCompleted(true);
- cvn.setErrorMessage("emsg");
- cvn.setException(exception);
- cvn.setMessageId("id");
- cvn.setOutputs(value);
- ent.setKey("key");
- ent.setValue("value");
- cvn.setRollback(vnf);
- cvn.setVnfId("vnf");
- assertTrue(cvn.isCompleted());
- assert(cvn.getErrorMessage().equals("emsg"));
- assert(cvn.getException()).equals(exception);
- assert(cvn.getMessageId()).equals("id");
- assert(cvn.getRollback()).equals(vnf);
- assert(cvn.getOutputs()).equals(value);
- assert(cvn.getVnfId()).equals("vnf");
- assert(ent.getKey()).equals("key");
- assert(ent.getValue()).equals("value");
- assert(ent.toString()!=null);
- assert(cvn.toString()!=null);
- assert(vnf.getCloudSiteId().equals("cloud"));
- assert(value.getEntry()!=null);
- }
-}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/DeleteVnfNotificationTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/DeleteVnfNotificationTest.java deleted file mode 100644 index 10e760e8de..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/DeleteVnfNotificationTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* 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.openecomp.mso.bpmn.common.adapter.vnf;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class DeleteVnfNotificationTest {
-
- @Test
- public void test() {
- DeleteVnfNotification dvn=new DeleteVnfNotification();
- MsoExceptionCategory exception = MsoExceptionCategory.OPENSTACK;
- dvn.setCompleted(true);
- dvn.setErrorMessage("msg");
- dvn.setMessageId("id");
- dvn.setException(exception);
- assert(dvn.getErrorMessage().equals("msg"));
- assert(dvn.getMessageId().equals("id"));
- assert(dvn.getException().equals(exception));
- assert(dvn.toString()!=null);
- assertTrue(dvn.isCompleted());
- }
-}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/MsoRequestTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/MsoRequestTest.java deleted file mode 100644 index 59aff8cf77..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/MsoRequestTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* 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.openecomp.mso.bpmn.common.adapter.vnf;
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
-
-public class MsoRequestTest {
- private MsoRequest msorequest = new MsoRequest();
- @Test
- public void testMsoRequest() {
- msorequest.setRequestId("requestId");
- msorequest.setServiceInstanceId("serviceInstanceId");
- assertEquals(msorequest.getRequestId(), "requestId");
- assertEquals(msorequest.getServiceInstanceId(), "serviceInstanceId");
- }
- @Test
- public void testtoString() {
- assert(msorequest.toString())!= null;
- }
-}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/ObjectFactoryTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/ObjectFactoryTest.java deleted file mode 100644 index 77ba0ea59b..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/ObjectFactoryTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* 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.openecomp.mso.bpmn.common.adapter.vnf;
-
-import static org.mockito.Mockito.mock;
-import org.junit.Test;
-import org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification.Outputs;
-
-public class ObjectFactoryTest {
- private ObjectFactory ofa=new ObjectFactory();
-
- @Test
- public void test() {
- CreateVnfNotification cvn=mock( CreateVnfNotification.class);
- UpdateVnfNotification uvn=mock (UpdateVnfNotification.class);
- QueryVnfNotification qn=mock(QueryVnfNotification.class);
- DeleteVnfNotification dvn=mock( DeleteVnfNotification.class);
- RollbackVnfNotification rvn=mock( RollbackVnfNotification.class);
- MsoRequest mr=mock( MsoRequest.class);
- Outputs opt=mock(Outputs.class);
- ofa.createCreateVnfNotification();
- ofa.createCreateVnfNotificationOutputs();
- ofa.createDeleteVnfNotification();
- ofa.createQueryVnfNotification();
- ofa.createUpdateVnfNotification();
- ofa.createMsoRequest();
- ofa.createRollbackVnfNotification();
- ofa.createUpdateVnfNotificationOutputs();
- ofa.createQueryVnfNotificationOutputs();
- ofa.createVnfRollback();
- ofa.createUpdateVnfNotificationOutputsEntry();
- ofa.createQueryVnfNotificationOutputsEntry();
- ofa.createCreateVnfNotificationOutputsEntry();
- ofa.createCreateVnfNotification(cvn);
- ofa.createDeleteVnfNotification(dvn);
- ofa.createQueryVnfNotification(qn);
- ofa.createRollbackVnfNotification(rvn);
- ofa.createUpdateVnfNotification(uvn);
- }
-}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/QueryVnfNotificationTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/QueryVnfNotificationTest.java deleted file mode 100644 index 59e10baedc..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/QueryVnfNotificationTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* 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.openecomp.mso.bpmn.common.adapter.vnf;
-
-import static org.junit.Assert.*;
-import org.junit.Test;
-import org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification.Outputs;
-import org.openecomp.mso.bpmn.common.adapter.vnf.CreateVnfNotification.Outputs.Entry;
-
-public class QueryVnfNotificationTest {
- private QueryVnfNotification qvn=new QueryVnfNotification();
-
- @Test
- public void test() {
- Entry ent = new Entry();
- MsoExceptionCategory exception = MsoExceptionCategory.OPENSTACK;
- Outputs opt=new Outputs();
- VnfStatus vnf=VnfStatus.ACTIVE;
- qvn.setCompleted(true);
- qvn.setErrorMessage("error");
- qvn.setException(exception);
- qvn.setMessageId("id");
- qvn.setStatus(vnf);
- qvn.setVnfId("id");
- qvn.setVnfExists(true);
- ent.setKey("key");
- ent.setValue("value");
- assert(qvn.getErrorMessage().equals("error"));
- assert(qvn.getException()).equals(exception);
- assert(qvn.getMessageId()).equals("id");
- assert(qvn.getStatus()).equals(vnf);
- assert(qvn.getVnfId()).equals("id");
- assertTrue(qvn.isVnfExists());
- assertTrue(qvn.isCompleted());
- assert(opt.getEntry()!=null);
- assert(opt.toString()!=null);
- assert(ent.getValue()).equals("value");
- assert(ent.getKey()).equals("key");
- assert(ent.toString()!=null);
- assert(qvn.toString()!=null);
- }
-}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/RollbackVnfNotificationTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/RollbackVnfNotificationTest.java deleted file mode 100644 index c6602d33f9..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/RollbackVnfNotificationTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/*-
- * ============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.openecomp.mso.bpmn.common.adapter.vnf;
-
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
-
-public class RollbackVnfNotificationTest {
- private RollbackVnfNotification rvn = new RollbackVnfNotification();
- MsoExceptionCategory mso= MsoExceptionCategory.OPENSTACK;
- @Test
- public void testRollbackVnfNotification() {
- rvn.setMessageId("messageId");
- rvn.setCompleted(true);
- rvn.setException(mso);
- rvn.setErrorMessage("errorMessage");
- assertEquals(rvn.getMessageId(), "messageId");
- assertEquals(rvn.isCompleted(), true);
- assertEquals(rvn.getException(), mso);
- assertEquals(rvn.getErrorMessage(), "errorMessage");
- }
- @Test
- public void testtoString() {
- assert(rvn.toString()!=null);
- }
-}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/UpdateVnfNotificationTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/UpdateVnfNotificationTest.java deleted file mode 100644 index 825695b3dd..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/UpdateVnfNotificationTest.java +++ /dev/null @@ -1,59 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* 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.openecomp.mso.bpmn.common.adapter.vnf;
-
-import static org.junit.Assert.*;
-import org.junit.Test;
-import org.openecomp.mso.bpmn.common.adapter.vnf.UpdateVnfNotification.Outputs;
-import org.openecomp.mso.bpmn.common.adapter.vnf.UpdateVnfNotification.Outputs.Entry;
-
-public class UpdateVnfNotificationTest {
- private UpdateVnfNotification updatevnf = new UpdateVnfNotification();
- MsoExceptionCategory mso;
- Outputs value= new Outputs();
- VnfRollback roll = new VnfRollback();
- private Entry entry = new Entry();
-
- @Test
- public void testUpdateVnfNotification() {
- updatevnf.setMessageId("messageId");
- updatevnf.setCompleted(true);
- updatevnf.setException(mso);
- updatevnf.setErrorMessage("errorMessage");
- updatevnf.setOutputs(value);
- updatevnf.setRollback(roll);
- entry.setKey("key");
- entry.setValue("value");
- assertEquals(updatevnf.getMessageId(), "messageId");
- assertEquals(updatevnf.isCompleted(), true);
- assertEquals(updatevnf.getException(), mso);
- assertEquals(updatevnf.getErrorMessage(), "errorMessage");
- assertEquals(updatevnf.getOutputs(), value);
- assertEquals(updatevnf.getRollback(), roll);
- assertEquals(entry.getKey(), "key");
- assertEquals(entry.getValue(), "value");
- }
- @Test
- public void testtoString() {
- assert(updatevnf.toString()!= null);
- assert(entry.toString()!= null);
- }
-}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/VnfRollbackTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/VnfRollbackTest.java deleted file mode 100644 index ebed8714df..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/adapter/vnf/VnfRollbackTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* 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.openecomp.mso.bpmn.common.adapter.vnf;
-
-import static org.junit.Assert.assertEquals;
-import org.junit.Test;
-
-public class VnfRollbackTest {
- private VnfRollback vnfrollback = new VnfRollback();
- MsoRequest mso = new MsoRequest();
- @Test
- public void testVnfRollback() {
- vnfrollback.setCloudSiteId("cloudSiteId");
- vnfrollback.setMsoRequest(mso);
- vnfrollback.setTenantCreated(true);
- vnfrollback.setTenantId("tenantId");
- vnfrollback.setVnfCreated(true);
- vnfrollback.setVnfId("vnfId");
- assertEquals(vnfrollback.getCloudSiteId(), "cloudSiteId");
- assertEquals(vnfrollback.getMsoRequest(), mso);
- assertEquals(vnfrollback.isTenantCreated(), true);
- assertEquals(vnfrollback.getTenantId(), "tenantId");
- assertEquals(vnfrollback.isVnfCreated(), true);
- assertEquals(vnfrollback.getVnfId(), "vnfId");
- }
- @Test
- public void testtoString() {
- assert(vnfrollback.toString() != null);
- }
-}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/recipe/BpmnParamTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/recipe/BpmnParamTest.java deleted file mode 100644 index 166e3d78c1..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/recipe/BpmnParamTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.openecomp.mso.bpmn.common.recipe; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; - -public class BpmnParamTest { - - BpmnParam bp=new BpmnParam(); - - @Test - public void test() { - bp.setValue("testdata"); - assertEquals(bp.getValue(),"testdata"); - } - @Test - public void testToString(){ - assert(bp.toString()!=null); - } - -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/recipe/BpmnRestClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/recipe/BpmnRestClientTest.java deleted file mode 100644 index 89f538b085..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/recipe/BpmnRestClientTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.openecomp.mso.bpmn.common.recipe; - -import static org.junit.Assert.*; -import org.junit.Test; - -public class BpmnRestClientTest { - - @Test - public void test() { - BpmnRestClient.getEncryptedPropValue("prop", "123", "456"); - BpmnRestClient.loadMsoProperties(); - assertEquals(true,BpmnRestClient.getNoPropertiesState()); - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/recipe/ResourceInputTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/recipe/ResourceInputTest.java deleted file mode 100644 index 466f4a1f3f..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/recipe/ResourceInputTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.openecomp.mso.bpmn.common.recipe; - -import static org.junit.Assert.assertEquals; - -import org.junit.Test; -import org.openecomp.mso.bpmn.core.domain.ModelInfo; - -public class ResourceInputTest { - - ResourceInput ri=new ResourceInput(); - @Test - public void test() { - ri.setResourceInstanceName("resourceInstanceName"); - ri.setResourceInstanceDes("resourceInstanceDes"); - ri.setGlobalSubscriberId("globalSubscriberId"); - ri.setServiceType("serviceType"); - ri.setServiceInstanceId("serviceId"); - ri.setOperationId("operationId"); - ModelInfo serviceModelInfo = new ModelInfo(); - serviceModelInfo.setModelCustomizationUuid("modelCustomizationUuid"); - serviceModelInfo.setModelInvariantUuid("modelInvariantUuid"); - serviceModelInfo.setModelUuid("modelUuid"); - ri.setServiceModelInfo(serviceModelInfo); - ModelInfo resourceModelInfo = new ModelInfo(); - resourceModelInfo.setModelCustomizationUuid("modelCustomizationUuid"); - resourceModelInfo.setModelInvariantUuid("modelInvariantUuid"); - resourceModelInfo.setModelUuid("modelUuid"); - ri.setResourceModelInfo(resourceModelInfo); - ri.setResourceInstancenUuid("resourceInstancenUuid"); - ri.setResourceParameters("resourceParameters"); - ri.setOperationType("operationType"); - assertEquals(ri.getResourceInstanceName(), "resourceInstanceName"); - assertEquals(ri.getResourceInstanceDes(), "resourceInstanceDes"); - assertEquals(ri.getGlobalSubscriberId(), "globalSubscriberId"); - assertEquals(ri.getServiceType(), "serviceType"); - assertEquals(ri.getServiceInstanceId(), "serviceId"); - assertEquals(ri.getOperationId(), "operationId"); - assertEquals(ri.getResourceInstancenUuid(), "resourceInstancenUuid"); - assertEquals(ri.getResourceParameters(), "resourceParameters"); - assertEquals(ri.getOperationType(), "operationType"); - } - @Test - public void testToString(){ - assert(ri.toString()!=null); - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/recipe/ResourceRecipeRequestTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/recipe/ResourceRecipeRequestTest.java deleted file mode 100644 index 3b185bae22..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/recipe/ResourceRecipeRequestTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.openecomp.mso.bpmn.common.recipe; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class ResourceRecipeRequestTest { - - ResourceRecipeRequest rr=new ResourceRecipeRequest(); - BpmnParam bp=new BpmnParam(); - @Test - public void test() { - rr.setResourceInput(bp); - rr.setHost(bp); - rr.setRequestId(bp); - rr.setRequestAction(bp); - rr.setServiceInstanceId(bp); - rr.setServiceType(bp); - rr.setRecipeParams(bp); - assertEquals(rr.getResourceInput(),bp); - assertEquals(rr.getHost(),bp); - assertEquals(rr.getRequestId(),bp); - assertEquals(rr.getRequestAction(),bp); - assertEquals(rr.getServiceInstanceId(),bp); - assertEquals(rr.getServiceType(),bp); - assertEquals(rr.getRecipeParams(),bp); - } - @Test - public void testToString(){ - assert(rr.toString()!=null); - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/resource/ResourceRequestBuilderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/resource/ResourceRequestBuilderTest.java deleted file mode 100644 index 5170e9d5d9..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/resource/ResourceRequestBuilderTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Huawei 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.openecomp.mso.bpmn.common.resource; - -import org.junit.Test; - -import java.util.HashMap; - -public class ResourceRequestBuilderTest { - - @Test - public void buildResouceRequestTest() throws Exception { - - ResourceRequestBuilder.buildResouceRequest("aa4535", - "a1074969-944f-4ddc-b687-9550b0c8cd57", new HashMap<>()); - } - - @Test - public void buildResouceRequestParametersTest() throws Exception { - - String parameters = - "{ \"locationConstraints\":[ ], \"resources\":[ { \"resourceName\":\"vEPC_ONAP01\", \"resourceInvariantUuid\":\"36ebe421-283a-4ee8-92f1-d09e7c44b911\", \"resourceUuid\":\"27a0e235-b67a-4ea4-a0cf-25761afed111\", \"resourceCustomizationUuid\":\"27a0e235-b67a-4ea4-a0cf-25761afed231\", \"parameters\":{ \"locationConstraints\":[ { \"vnfProfileId\":\"b244d433-8c9c-49ad-9c70-8e34b8dc8328\", \"locationConstraints\":{ \"vimId\":\"vmware_vio\" } }, { \"vnfProfileId\":\"8a9f7c48-21ce-41b7-95b8-a8ac61ccb1ff\", \"locationConstraints\":{ \"vimId\":\"core-dc_RegionOne\" } } ], \"resources\":[ ], \"requestInputs\":{ \"sdncontroller\":\"\" } } }, { \"resourceName\":\"VL OVERLAYTUNNEL\", \"resourceInvariantUuid\":\"184494cf-472f-436f-82e2-d83dddde21cb\", \"resourceUuid\":\"95bc3e59-c9c5-458f-ad6e-78874ab4b3cc\", \"resourceCustomizationUuid\":\"27a0e235-b67a-4ea4-a0cf-25761afed232\", \"parameters\":{ \"locationConstraints\":[ ], \"resources\":[ ], \"requestInputs\":{ } } } ], \"requestInputs\":{ \"vlunderlayvpn0_name\":\"l3connect\", \"vlunderlayvpn0_site1_id\":\"IP-WAN-Controller-1\", \"vlunderlayvpn0_site2_id\":\"SPTNController\", \"vlunderlayvpn0_site1_networkName\":\"network1,network2\", \"vlunderlayvpn0_site2_networkName\":\"network3,network4\", \"vlunderlayvpn0_site1_routerId\":\"a8098c1a-f86e-11da-bd1a-00112444be1a\", \"vlunderlayvpn0_site2_routerId\":\"a8098c1a-f86e-11da-bd1a-00112444be1e\", \"vlunderlayvpn0_site2_importRT1\":\"200:1,200:2\", \"vlunderlayvpn0_site1_exportRT1\":\"300:1,300:2\", \"vlunderlayvpn0_site2_exportRT1\":\"400:1,400:2\", \"vlunderlayvpn0_site1_vni\":\"2000\", \"vlunderlayvpn0_site2_vni\":\"3000\", \"vlunderlayvpn0_tunnelType\":\"L3-DCI\" } }"; - ResourceRequestBuilder.buildResourceRequestParameters(null, "1bd0eae6-2dcc-4461-9ae6-56d641f369d6", "27a0e235-b67a-4ea4-a0cf-25761afed231", parameters); - } -}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/util/CryptoHandlerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/util/CryptoHandlerTest.java deleted file mode 100644 index 724d3edf4d..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/util/CryptoHandlerTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 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.openecomp.mso.bpmn.common.util;
-
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
-
-public class CryptoHandlerTest {
-
- @Test
- public void test() throws Exception {
- String plainPswd = "mso0206";
- String encryptPwd = "C1FC4A39E16419DD41DFC1212843F440";
- CryptoHandler cryptoHandler = new CryptoHandler();
- String aaiPassword = cryptoHandler.getMsoAaiPassword();
- assertEquals(plainPswd, aaiPassword);
- String encryptPassword = cryptoHandler.encryptMsoPassword(plainPswd);
- assertEquals(encryptPwd, encryptPassword);
- String decryptPassword = cryptoHandler.decryptMsoPassword(encryptPwd);
- assertEquals(plainPswd, decryptPassword);
- }
-
-}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/FileUtil.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/FileUtil.java deleted file mode 100644 index 38d0584d0d..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/FileUtil.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.bpmn.mock; - -import java.io.IOException; -import java.io.InputStream; -import org.openecomp.mso.logger.MsoLogger; - -/** - * - * File utility class.<br/> - * <p> - * </p> - * - * @author - * @version ONAP Sep 15, 2017 - */ -public class FileUtil { - - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA); - - /** - * Read the specified resource file and return the contents as a String. - * - * @param fileName Name of the resource file - * @return the contents of the resource file as a String - * @throws IOException if there is a problem reading the file - */ - public static String readResourceFile(String fileName) { - InputStream stream; - try { - stream = getResourceAsStream(fileName); - byte[] bytes; - bytes = new byte[stream.available()]; - stream.read(bytes); - stream.close(); - return new String(bytes); - } catch (IOException e) { - LOGGER.debug("Exception:", e); - return ""; - } - } - - /** - * Get an InputStream for the resource specified. - * - * @param resourceName Name of resource for which to get InputStream. - * @return an InputStream for the resource specified. - * @throws IOException If we can't get the InputStream for whatever reason. - */ - private static InputStream getResourceAsStream(String resourceName) throws IOException { - InputStream stream = - FileUtil.class.getClassLoader().getResourceAsStream(resourceName); - if (stream == null) { - throw new IOException("Can't access resource '" + resourceName + "'"); - } - return stream; - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/MockResource.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/MockResource.java deleted file mode 100644 index 9ead882b07..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/MockResource.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.bpmn.mock; - -import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; - -import java.util.HashMap; -import java.util.Map; - -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Response; - -import com.github.tomakehurst.wiremock.WireMockServer; -import com.github.tomakehurst.wiremock.client.WireMock; - -/** - * - * Mock Resource which is used to start, stop the WireMock Server - * Also up to 50 mock properties can be added at run-time to change the properties used in transformers such as sdnc_delay in SDNCAdapterMockTransformer - * You can also selectively setup a stub (use reset before setting up), reset all stubs - */ -@Path("/server") -public class MockResource { - - private boolean started = false; - private final Integer defaultPort = 28090; - private WireMockServer wireMockServer = null; - private static Map<String,String> mockProperties = new HashMap<>(); - - public static String getMockProperties(String key) { - return mockProperties.get(key); - } - - private synchronized void initMockServer(int portNumber) { - String path = FileUtil.class.getClassLoader().getResource("__files/sdncSimResponse.xml").getFile(); - path = path.substring(0,path.indexOf("__files/")); - - wireMockServer = new WireMockServer(wireMockConfig().port(portNumber).extensions("org.openecomp.mso.bpmn.mock.SDNCAdapterMockTransformer") - .extensions("org.openecomp.mso.bpmn.mock.SDNCAdapterNetworkTopologyMockTransformer") - .extensions("org.openecomp.mso.bpmn.mock.VnfAdapterCreateMockTransformer") - .extensions("org.openecomp.mso.bpmn.mock.VnfAdapterDeleteMockTransformer") - .extensions("org.openecomp.mso.bpmn.mock.VnfAdapterUpdateMockTransformer") - .extensions("org.openecomp.mso.bpmn.mock.VnfAdapterRollbackMockTransformer") - .extensions("org.openecomp.mso.bpmn.mock.VnfAdapterQueryMockTransformer")); - //.withRootDirectory(path)); - //Mocks were failing - commenting out for now, both mock and transformers seem to work fine - WireMock.configureFor("localhost", portNumber); - wireMockServer.start(); -// StubResponse.setupAllMocks(); - started= true; - } - - public static void main(String [] args) { - MockResource mockresource = new MockResource(); - mockresource.start(28090); - mockresource.reset(); -// mockresource.setupStub("MockCreateTenant"); - } - - /** - * Starts the wiremock server in default port - * @return - */ - @GET - @Path("/start") - @Produces("application/json") - public Response start() { - return startMockServer(defaultPort); - } - - private Response startMockServer(int port) { - if (!started) { - initMockServer(defaultPort); - System.out.println("Started Mock Server in port " + port); - return Response.status(200).entity("Started Mock Server in port " + port).build(); - } else { - return Response.status(200).entity("Mock Server is already running").build(); - } - } - - /** - * Starts the wiremock server in a different port - * @param portNumber - * @return - */ - @GET - @Path("/start/{portNumber}") - @Produces("application/json") - public Response start(@PathParam("portNumber") Integer portNumber) { - if (portNumber == null) portNumber = defaultPort; - return startMockServer(portNumber); - } - - - /** - * Stop the wiremock server - * @return - */ - @GET - @Path("/stop") - @Produces("application/json") - public synchronized Response stop() { - if (wireMockServer.isRunning()) { - wireMockServer.stop(); - started = false; - return Response.status(200).entity("Stopped Mock Server in port ").build(); - } - return Response.status(200).entity("Mock Server is not running").build(); - } - - - /** - * Return list of mock properties - * @return - */ - @GET - @Path("/properties") - @Produces("application/json") - public Response getProperties() { - return Response.status(200).entity(mockProperties).build(); - } - - /** - * Update a particular mock property at run-time - * @param name - * @param value - * @return - */ - @POST - @Path("/properties/{name}/{value}") - public Response updateProperties(@PathParam("name") String name, @PathParam("value") String value) { - if (mockProperties.size() > 50) return Response.serverError().build(); - mockProperties.put(name, value); - return Response.status(200).build(); - } - - /** - * Reset all stubs - * @return - */ - @GET - @Path("/reset") - @Produces("application/json") - public Response reset() { - WireMock.reset(); - return Response.status(200).entity("Wiremock stubs are reset").build(); - } - - - /** - * Setup a stub selectively - * Prior to use, make sure that stub method is available in StubResponse class - * @param methodName - * @return - */ - - // commenting for now until we figure out a way to use new StubResponse classes to setupStubs -// @GET -// @Path("/stub/{methodName}") -// @Produces("application/json") -// public Response setupStub(@PathParam("methodName") String methodName) { -// -// @SuppressWarnings("rawtypes") -// Class params[] = {}; -// Object paramsObj[] = {}; -// -// try { -// Method thisMethod = StubResponse.class.getDeclaredMethod(methodName, params); -// try { -// thisMethod.invoke(StubResponse.class, paramsObj); -// } catch (IllegalAccessException | IllegalArgumentException -// | InvocationTargetException e) { -// return Response.status(200).entity("Error invoking " + methodName ).build(); -// } -// } catch (NoSuchMethodException | SecurityException e) { -// return Response.status(200).entity("Stub " + methodName + " not found...").build(); -// } -// return Response.status(200).entity("Successfully invoked " + methodName).build(); -// } - - - public static Map<String,String> getMockProperties(){ - return mockProperties; - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/MockResourceApplication.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/MockResourceApplication.java deleted file mode 100644 index ba48bffca0..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/MockResourceApplication.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.bpmn.mock; - -import java.util.HashSet; -import java.util.Set; - -import javax.ws.rs.ApplicationPath; -import javax.ws.rs.core.Application; - -/** - * - * JAX RS Application wiring for Mock Resource - */ -@ApplicationPath("/console") -public class MockResourceApplication extends Application { - - private Set<Object> singletons = new HashSet<>(); - private Set<Class<?>> classes = new HashSet<>(); - - public MockResourceApplication() { - singletons.add(new MockResource()); - } - - @Override - public Set<Class<?>> getClasses() { - return classes; - } - - @Override - public Set<Object> getSingletons() { - return singletons; - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/SDNCAdapterAsyncTransformer.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/SDNCAdapterAsyncTransformer.java deleted file mode 100644 index 93cf0bddef..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/SDNCAdapterAsyncTransformer.java +++ /dev/null @@ -1,157 +0,0 @@ -/*- - * ============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.openecomp.mso.bpmn.mock; - -import org.jboss.resteasy.client.ClientRequest; -import org.jboss.resteasy.client.ClientResponse; - -import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder; -import com.github.tomakehurst.wiremock.common.BinaryFile; -import com.github.tomakehurst.wiremock.common.FileSource; -import com.github.tomakehurst.wiremock.extension.ResponseTransformer; -import com.github.tomakehurst.wiremock.http.Request; -import com.github.tomakehurst.wiremock.http.ResponseDefinition; - -/** - * - * Simulates SDNC Adapter Callback response - * - */ -public class SDNCAdapterAsyncTransformer extends ResponseTransformer { - - private String syncResponse; - private String callbackResponseWrapper; - - public SDNCAdapterAsyncTransformer() { - syncResponse = FileUtil.readResourceFile("__files/StandardSDNCSynchResponse.xml"); - callbackResponseWrapper = FileUtil.readResourceFile("__files/sdncCallbackSoapWrapper.xml"); - } - - public String name() { - return "sdnc-adapter-vf-module-assign"; - } - - /** - * Grab the incoming request xml,extract the request id and replace the stub response with the incoming request id - * so that callback response can be correlated - * - * Mock Resource can be used to add dynamic properties. If sdnc_delay is not in the list by default waits for 300ms before - * the callback response is sent - */ - @Override - public ResponseDefinition transform(Request request, ResponseDefinition responseDefinition, - FileSource fileSource) { - - String requestBody = request.getBodyAsString(); - - String callbackUrl = requestBody.substring(requestBody.indexOf("<sdncadapter:CallbackUrl>")+25, requestBody.indexOf("</sdncadapter:CallbackUrl>")); - String requestId = requestBody.substring(requestBody.indexOf("<sdncadapter:RequestId>")+23, requestBody.indexOf("</sdncadapter:RequestId>")); - - System.out.println("responseDefinition: " + responseDefinition); - - // For this mock, the mapped response body is the Async callback (since the sync response is generic for all requests) - String sdncResponse = responseDefinition.getBody(); - System.out.println("sdncResponse:" + sdncResponse); - - if (sdncResponse == null) { - // Body wasn't specified. Check for a body file - String bodyFileName = responseDefinition.getBodyFileName(); - System.out.println("bodyFileName" + bodyFileName); - if (bodyFileName != null) { - System.out.println("fileSource Class: " + fileSource.getClass().getName()); - BinaryFile bodyFile = fileSource.getBinaryFileNamed(bodyFileName); - byte[] responseFile = bodyFile.readContents(); - sdncResponse = new String(responseFile); - System.out.println("sdncResponse(2):" + sdncResponse); - } - } - - // Transform the SDNC response to escape < and > - sdncResponse = sdncResponse.replaceAll ("<", "<"); - sdncResponse = sdncResponse.replaceAll (">", ">"); - - // Next substitute the SDNC response into the callbackResponse (SOAP wrapper). - // Also, replace the request ID wherever it appears - String callbackResponse = callbackResponseWrapper.replace("SDNC_RESPONSE_DATA", sdncResponse).replaceAll("SDNC_REQUEST_ID", requestId); - - Object sdncDelay = MockResource.getMockProperties().get("sdnc_delay"); - int delay = 2000; - if (sdncDelay != null) { - delay = Integer.parseInt(sdncDelay.toString()); - } - - //Kick off callback thread - System.out.println("callback Url:" + callbackUrl + ":delay:" + delay); - CallbackResponseThread calbackResponseThread = new CallbackResponseThread(callbackUrl,callbackResponse, delay); - calbackResponseThread.start(); - - //return 200 OK with empty body - return ResponseDefinitionBuilder - .like(responseDefinition).but() - .withStatus(200).withBody(syncResponse).withHeader("Content-Type", "text/xml") - .build(); - } - - @Override - public boolean applyGlobally() { - return false; - } - - /** - * - * Callback response thread which sends the callback response asynchronously - * - */ - private class CallbackResponseThread extends Thread { - - private String callbackUrl; - private String payLoad; - private int delay; - - public CallbackResponseThread(String callbackUrl, String payLoad, int delay) { - this.callbackUrl = callbackUrl; - this.payLoad = payLoad; - this.delay = delay; - } - - public void run () { - try { - //Delay sending callback response - sleep(delay); - } catch (InterruptedException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - System.out.println("Sending callback response:" + callbackUrl); - ClientRequest request = new ClientRequest(callbackUrl); - request.body("text/xml", payLoad); - System.err.println(payLoad); - try { - ClientResponse result = request.post(); - //System.err.println("Successfully posted callback:" + result.getStatus()); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/SDNCAdapterMockTransformer.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/SDNCAdapterMockTransformer.java deleted file mode 100644 index 9c4e7936b1..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/SDNCAdapterMockTransformer.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.bpmn.mock; - -import org.jboss.resteasy.client.ClientRequest; -import org.jboss.resteasy.client.ClientResponse; -import org.openecomp.mso.logger.MsoLogger; - -import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder; -import com.github.tomakehurst.wiremock.common.FileSource; -import com.github.tomakehurst.wiremock.extension.ResponseTransformer; -import com.github.tomakehurst.wiremock.http.Request; -import com.github.tomakehurst.wiremock.http.ResponseDefinition; - -import org.openecomp.mso.logger.MsoLogger; -/** - * - * Simulates SDNC Adapter Callback response - * - */ -public class SDNCAdapterMockTransformer extends ResponseTransformer { - - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); - private String callbackResponse; - private String requestId; - - public SDNCAdapterMockTransformer() { - callbackResponse = FileUtil.readResourceFile("__files/sdncSimResponse.xml"); - } - - public SDNCAdapterMockTransformer(String requestId) { - this.requestId = requestId; - } - - public String name() { - return "sdnc-adapter-transformer"; - } - - /** - * Grab the incoming request xml,extract the request id and replace the stub response with the incoming request id - * so that callback response can be correlated - * - * Mock Resource can be used to add dynamic properties. If sdnc_delay is not in the list by default waits for 300ms before - * the callback response is sent - */ - @Override - public ResponseDefinition transform(Request request, ResponseDefinition responseDefinition, - FileSource fileSource) { - String requestBody = request.getBodyAsString(); - - String callbackUrl = requestBody.substring(requestBody.indexOf("<sdncadapter:CallbackUrl>")+25, requestBody.indexOf("</sdncadapter:CallbackUrl>")); - String requestId = requestBody.substring(requestBody.indexOf("<sdncadapter:RequestId>")+23, requestBody.indexOf("</sdncadapter:RequestId>")); - - callbackResponse = FileUtil.readResourceFile("__files/" + responseDefinition.getBodyFileName()); - System.out.println("callbackResponse:" + callbackResponse); - - if (this.requestId != null) { - callbackResponse = callbackResponse.replace(this.requestId, requestId); - } else { - callbackResponse = callbackResponse.replace("testRequestId", requestId); - } - - - Object sdncDelay = MockResource.getMockProperties().get("sdnc_delay"); - int delay = 300; - if (sdncDelay != null) { - delay = Integer.parseInt(sdncDelay.toString()); - } - - //Kick off callback thread - System.out.println("callback Url:" + callbackUrl + ":delay:" + delay); - CallbackResponseThread calbackResponseThread = new CallbackResponseThread(callbackUrl,callbackResponse, delay); - calbackResponseThread.start(); - - //return 200 OK with empty body - return ResponseDefinitionBuilder - .like(responseDefinition).but() - .withStatus(200).withBody("").withHeader("Content-Type", "text/xml") - .build(); - } - - @Override - public boolean applyGlobally() { - return false; - } - - /** - * - * Callback response thread which sends the callback response asynchronously - * - */ - private class CallbackResponseThread extends Thread { - - private String callbackUrl; - private String payLoad; - private int delay; - - public CallbackResponseThread(String callbackUrl, String payLoad, int delay) { - this.callbackUrl = callbackUrl; - this.payLoad = payLoad; - this.delay = delay; - } - - public void run () { - try { - //Delay sending callback response - sleep(delay); - } catch (InterruptedException e1) { - LOGGER.debug("Exception :",e1); - } - LOGGER.debug("Sending callback response:" + callbackUrl); - ClientRequest request = new ClientRequest(callbackUrl); - request.body("text/xml", payLoad); - System.err.println(payLoad); - try { - ClientResponse result = request.post(); - //System.err.println("Successfully posted callback:" + result.getStatus()); - } catch (Exception e) { - LOGGER.debug("Exception :",e); - } - } - - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/SDNCAdapterNetworkTopologyMockTransformer.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/SDNCAdapterNetworkTopologyMockTransformer.java deleted file mode 100644 index e59e3b67d2..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/SDNCAdapterNetworkTopologyMockTransformer.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.bpmn.mock; - -import org.jboss.resteasy.client.ClientRequest; -import org.jboss.resteasy.client.ClientResponse; - -import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder; -import com.github.tomakehurst.wiremock.common.FileSource; -import com.github.tomakehurst.wiremock.extension.ResponseTransformer; -import com.github.tomakehurst.wiremock.http.Request; -import com.github.tomakehurst.wiremock.http.ResponseDefinition; - -import org.openecomp.mso.logger.MsoLogger; - -public class SDNCAdapterNetworkTopologyMockTransformer extends ResponseTransformer { - - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); - - private String callbackResponse; - private String requestId; - - public SDNCAdapterNetworkTopologyMockTransformer() { - callbackResponse = ""; // FileUtil.readResourceFile("__files/sdncDeleteNetworkTopologySimResponse.xml"); - } - - public SDNCAdapterNetworkTopologyMockTransformer(String requestId) { - this.requestId = requestId; - } - - public String name() { - return "network-topology-operation-transformer"; - } - - @Override - public ResponseDefinition transform(Request request, ResponseDefinition responseDefinition, FileSource fileSource) { - String requestBody = request.getBodyAsString(); - - String callbackUrl = requestBody.substring(requestBody.indexOf("<sdncadapter:CallbackUrl>")+25, requestBody.indexOf("</sdncadapter:CallbackUrl>")); - String requestId = requestBody.substring(requestBody.indexOf("<sdncadapter:RequestId>")+23, requestBody.indexOf("</sdncadapter:RequestId>")); - System.out.println("request callbackUrl : " + callbackUrl); - System.out.println("request requestId : " + requestId); - - System.out.println("file path/name : " + responseDefinition.getBodyFileName()); - callbackResponse = FileUtil.readResourceFile("__files/" + responseDefinition.getBodyFileName()); - // extract Response responseRequestId - String responseRequestId = callbackResponse.substring(callbackResponse.indexOf("<RequestId>")+11, callbackResponse.indexOf("</RequestId>")); - System.out.println("response requestId: " + responseRequestId); - System.out.println("callbackResponse (before): " + callbackResponse); - callbackResponse = callbackResponse.replace(responseRequestId, requestId); - if (this.requestId != null) { - callbackResponse = callbackResponse.replace(this.requestId, requestId); - } else { - callbackResponse = callbackResponse.replace(responseRequestId, requestId); - } - System.out.println("callbackResponse (after):" + callbackResponse); - - Object sdncDelay = MockResource.getMockProperties().get("sdnc_delay"); - int delay = 300; - if (sdncDelay != null) { - delay = Integer.parseInt(sdncDelay.toString()); - } - - //Kick off callback thread - System.out.println("(NetworkTopologyMockTransformer) callback Url:" + callbackUrl + ":delay:" + delay); - CallbackResponseThread calbackResponseThread = new CallbackResponseThread(callbackUrl,callbackResponse, delay); - calbackResponseThread.start(); - - //return 200 OK with body - return ResponseDefinitionBuilder - .like(responseDefinition).but() - .withStatus(200).withBody(callbackResponse).withHeader("Content-Type", "text/xml") - .build(); - } - - @Override - public boolean applyGlobally() { - return false; - } - - private class CallbackResponseThread extends Thread { - - private String callbackUrl; - private String payLoad; - private int delay; - - public CallbackResponseThread(String callbackUrl, String payLoad, int delay) { - this.callbackUrl = callbackUrl; - this.payLoad = payLoad; - this.delay = delay; - } - - public void run () { - try { - //Delay sending callback response - sleep(delay); - } catch (InterruptedException e1) { - // TODO Auto-generated catch block - LOGGER.debug("Exception :",e1); - } - LOGGER.debug("Sending callback response to url: " + callbackUrl); - ClientRequest request = new ClientRequest(callbackUrl); - request.body("text/xml", payLoad); - //System.err.println(payLoad); - try { - ClientResponse result = request.post(); - LOGGER.debug("Successfully posted callback? Status: " + result.getStatus()); - } catch (Exception e) { - // TODO Auto-generated catch block - LOGGER.debug("catch error in - request.post() "); - LOGGER.debug("Exception :",e); - } - } - - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseAAI.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseAAI.java deleted file mode 100644 index 6efd992566..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseAAI.java +++ /dev/null @@ -1,1093 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.bpmn.mock; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.containing; -import static com.github.tomakehurst.wiremock.client.WireMock.delete; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.patch; -import static com.github.tomakehurst.wiremock.client.WireMock.put; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; - - -/** - * Reusable Mock StubResponses for AAI Endpoints - * - */ -public class StubResponseAAI { - - public static void setupAllMocks() { - - } - - - /** - * Tunnel-XConnect Mock Stub Response - */ - public static void MockPutTunnelXConnect(String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId, String tunnelId){ - stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId + "/tunnel-xconnects/tunnel-xconnect/" + tunnelId)) - .willReturn(aResponse() - .withStatus(200))); - } - - - /** - * Allotted Resource Mock StubResponses below - */ - public static void MockGetAllottedResource(String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId, String responseFile) { - stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockPutAllottedResource(String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId) { - stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId)) - .willReturn(aResponse() - .withStatus(200))); - } - - public static void MockPutAllottedResource_500(String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId) { - stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId)) - .willReturn(aResponse() - .withStatus(500))); - } - - public static void MockDeleteAllottedResource(String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId, String resourceVersion) { - stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId + "[?]resource-version=" + resourceVersion)) - .willReturn(aResponse() - .withStatus(204))); - } - - public static void MockPatchAllottedResource(String globalCustId, String subscriptionType, String serviceInstanceId, String allottedResourceId) { - stubFor(patch(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId + "/allotted-resources/allotted-resource/" + allottedResourceId)) - .willReturn(aResponse() - .withStatus(200))); - } - - public static void MockQueryAllottedResourceById(String allottedResourceId, String responseFile){ - stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=allotted-resource[&]filter=id:EQUALS:" + allottedResourceId)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - - /** - * Service Instance Mock StubResponses below - */ - public static void MockGetServiceInstance(String globalCustId, String subscriptionType, String serviceInstanceId, String responseFile) { - stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetServiceInstance_404(String customer, String serviceSubscription, String serviceInstanceId){ - stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId)) - .willReturn(aResponse() - .withStatus(404))); - } - - public static void MockGetServiceInstance_500(String customer, String serviceSubscription, String serviceInstanceId){ - stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId)) - .willReturn(aResponse() - .withStatus(500))); - } - - public static void MockGetServiceInstance_500(String customer, String serviceSubscription, String serviceInstanceId, String responseFile){ - stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId)) - .willReturn(aResponse() - .withStatus(500) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockNodeQueryServiceInstanceByName(String serviceInstanceName, String responseFile){ - stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance[&]filter=service-instance-name:EQUALS:" + serviceInstanceName)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockNodeQueryServiceInstanceByName_404(String serviceInstanceName){ - stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-name:EQUALS:" + serviceInstanceName)) - .willReturn(aResponse() - .withStatus(404))); - } - - public static void MockNodeQueryServiceInstanceByName_500(String serviceInstanceName){ - stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-name:EQUALS:" + serviceInstanceName)) - .willReturn(aResponse() - .withStatus(500))); - } - - public static void MockNodeQueryServiceInstanceById(String serviceInstanceId, String responseFile){ - stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance[&]filter=service-instance-id:EQUALS:" + serviceInstanceId)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockNodeQueryServiceInstanceById_404(String serviceInstanceId){ - stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-id:EQUALS:" + serviceInstanceId)) - .willReturn(aResponse() - .withStatus(404))); - } - - public static void MockNodeQueryServiceInstanceById_500(String serviceInstanceId){ - stubFor(get(urlMatching("/aai/v[0-9]+/search/nodes-query[?]search-node-type=service-instance&filter=service-instance-id:EQUALS:" + serviceInstanceId)) - .willReturn(aResponse() - .withStatus(500))); - } - - public static void MockDeleteServiceInstance(String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion){ - stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion)) - .willReturn(aResponse() - .withStatus(204))); - } - - public static void MockGetServiceInstance(String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion, int statusCode){ - stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion)) - .willReturn(aResponse() - .withStatus(statusCode))); - } - - public static void MockGetServiceInstance(String customer, String serviceSubscription, String resourceVersion, int statusCode){ - stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "[?]resource-version=" + resourceVersion)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml"))); - } - - public static void MockDeleteServiceInstance(String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion, int statusCode){ - stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion)) - .willReturn(aResponse() - .withStatus(statusCode))); - } - - public static void MockDeleteServiceInstance(String customer, String serviceSubscription, String resourceVersion, int statusCode){ - stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "[?]resource-version=" +1234)) - .willReturn(aResponse() - .withStatus(statusCode))); - } - - public static void MockDeleteServiceInstance_404(String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion){ - stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion)) - .willReturn(aResponse() - .withStatus(404))); - } - - public static void MockDeleteServiceInstance_500(String customer, String serviceSubscription, String serviceInstanceId, String resourceVersion){ - stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + customer + "/service-subscriptions/service-subscription/" + serviceSubscription + "/service-instances/service-instance/" + serviceInstanceId + "[?]resource-version=" + resourceVersion)) - .willReturn(aResponse() - .withStatus(500))); - } - - public static void MockPutServiceInstance(String globalCustId, String subscriptionType, String serviceInstanceId, String responseFile) { - stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockPutServiceInstance_500(String globalCustId, String subscriptionType, String serviceInstanceId) { - stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId)) - .willReturn(aResponse() - .withStatus(500))); - } - - /** - * Service-Subscription Mock StubResponses below - */ - public static void MockGetServiceSubscription(String globalCustId, String subscriptionType, String responseFile) { - stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockDeleteServiceSubscription(String globalCustId, String subscriptionType, int statusCode) { - stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType)) - .willReturn(aResponse() - .withStatus(statusCode))); - } - - public static void MockDeleteServiceInstanceId(String globalCustId, String subscriptionType, String serviceInstanceId) { - stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType + "/service-instances/service-instance/" + serviceInstanceId)) - .willReturn(aResponse() - .withStatus(200))); - } - - public static void MockPutServiceSubscription(String globalCustId, String subscriptionType) { - stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType)) - .willReturn(aResponse() - .withStatus(200))); - } - - public static void MockGetServiceSubscription(String globalCustId, String subscriptionType, int statusCode) { - stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId + "/service-subscriptions/service-subscription/" + subscriptionType)) - .willReturn(aResponse() - .withStatus(statusCode))); - } - - /** - * Customer Mock StubResponses below - */ - public static void MockGetCustomer(String globalCustId, String responseFile) { - stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockDeleteCustomer(String globalCustId) { - stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId)) - .willReturn(aResponse() - .withStatus(200))); - } - - public static void MockPutCustomer(String globalCustId) { - stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId)) - .willReturn(aResponse() - .withStatus(200))); - } - - public static void MockPutCustomer_500(String globalCustId) { - stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/" + globalCustId)) - .willReturn(aResponse() - .withStatus(500))); - } - - - /** - * Generic-Vnf Mock StubResponses below - */ - - public static void MockGetGenericVnfById(String vnfId, String responseFile){ - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]depth=1")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetGenericVnfById(String vnfId, String responseFile, int statusCode){ - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetGenericVnfByIdWithPriority(String vnfId, int statusCode, String responseFile) { - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId)) - .atPriority(1) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetGenericVnfByIdWithPriority(String vnfId, String vfModuleId, int statusCode, String responseFile, int priority) { - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId)) - .atPriority(priority) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetGenericVnfByIdWithDepth(String vnfId, int depth, String responseFile){ - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]depth=" + depth)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetGenericVnfById_404(String vnfId){ - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId)) - .willReturn(aResponse() - .withStatus(404))); - } - - public static void MockGetGenericVnfById_500(String vnfId){ - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId)) - .willReturn(aResponse() - .withStatus(500))); - } - - public static void MockGetGenericVnfByName(String vnfName, String responseFile){ - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetGenericVnfByNameWithDepth(String vnfName, int depth, String responseFile){ - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName + "[&]depth=" + depth)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetGenericVnfByName_404(String vnfName){ - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=" + vnfName)) - .willReturn(aResponse() - .withStatus(404))); - } - - public static void MockDeleteGenericVnf(String vnfId, String resourceVersion){ - stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion)) - .willReturn(aResponse() - .withStatus(204))); - } - - public static void MockDeleteGenericVnf(String vnfId, String resourceVersion, int statusCode){ - stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion)) - .willReturn(aResponse() - .withStatus(statusCode))); - } - - public static void MockDeleteGenericVnf_500(String vnfId, String resourceVersion){ - stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "[?]resource-version=" + resourceVersion)) - .willReturn(aResponse() - .withStatus(500))); - } - - public static void MockPutGenericVnf(String vnfId){ - stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId)) - .willReturn(aResponse() - .withStatus(200))); - } - - public static void MockPutGenericVnf(String vnfId, String requestBodyContaining, int statusCode) { - stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId)) - .withRequestBody(containing(requestBodyContaining)) - .willReturn(aResponse() - .withStatus(statusCode))); - } - - public static void MockPutGenericVnf(String vnfId, int statusCode) { - stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf" + vnfId)) - .willReturn(aResponse() - .withStatus(statusCode))); - } - - public static void MockPutGenericVnf_Bad(String vnfId, int statusCode){ - stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId)) - .willReturn(aResponse() - .withStatus(statusCode))); - } - - public static void MockPatchGenericVnf(String vnfId){ - stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId)) - .willReturn(aResponse() - .withStatus(200))); - } - /** - * Vce Mock StubResponses below - */ - public static void MockGetVceById(String vnfId, String responseFile){ - stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetVceByName(String vnfName, String responseFile){ - stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=" + vnfName)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockDeleteVce(String vnfId, String resourceVersion, int statusCode){ - stubFor(delete(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId + "[?]resource-version=" + resourceVersion)) - .willReturn(aResponse() - .withStatus(statusCode))); - } - - public static void MockPutVce(String vnfId){ - stubFor(put(urlMatching("/aai/v[0-9]+/network/vces/vce/" + vnfId)) - .willReturn(aResponse() - .withStatus(200))); - } - - public static void MockGetGenericVceByNameWithDepth(String vnfName, int depth, String responseFile){ - stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=" + vnfName + "[&]depth=" + depth)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetVceGenericQuery(String serviceInstanceName, int depth, int statusCode, String responseFile){ - stubFor(get(urlMatching("/aai/v[0-9]+/search/generic-query[?]key=service-instance.service-instance-name:" + serviceInstanceName + "[&]start-node-type=service-instance[&]include=vce[&]depth=" + depth)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - /** - * Tenant Mock StubResponses below - */ - public static void MockGetTenantGenericQuery(String customer, String serviceType, String responseFile) { - stubFor(get(urlMatching("/aai/v[0-9]+/search/generic-query[?]key=customer.global-customer-id:" + customer + "&key=service-subscription.service-type:" + serviceType + "&start-node-type=service-subscription&include=tenant&include=service-subscription&depth=1")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetTenant(String tenantId, String responseFile) { - stubFor(get(urlEqualTo("/aai/v2/cloud-infrastructure/tenants/tenant/" + tenantId)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - /** - * Network Mock StubResponses below - */ - public static void MockGetNetwork(String networkId, String responseFile, int statusCode) { - stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetNetworkByIdWithDepth(String networkId, String responseFile, String depth) { - stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId + "[?]depth=" + depth)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetNetworkCloudRegion(String responseFile, String cloudRegion) { - stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/"+cloudRegion)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetNetworkByName(String networkName, String responseFile) { - stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name="+networkName)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetNetworkByName_404(String responseFile, String networkName) { - stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name="+networkName)) - .willReturn(aResponse() - .withStatus(404) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetNetworkCloudRegion_404(String cloudRegion) { - stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/"+cloudRegion)) - .willReturn(aResponse() - .withStatus(404))); - } - - public static void MockPutNetwork(String networkId, int statusCode, String responseFile) { - stubFor(put(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/" + networkId)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockPutNetwork(String networkPolicyId, String responseFile, int statusCode) { - stubFor(put(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/" + networkPolicyId)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetNetworkName(String networkPolicyName, String responseFile, int statusCode) { - stubFor(get(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network[?]network-name=" + networkPolicyName)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetNetworkVpnBinding(String responseFile, String vpnBinding) { - stubFor(get(urlMatching("/aai/v[0-9]+/network/vpn-bindings/vpn-binding/"+vpnBinding + "[?]depth=all")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetNetworkPolicy(String responseFile, String policy) { - stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/"+policy + "[?]depth=all")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetNetworkVpnBinding(String networkBindingId, String responseFile, int statusCode) { - stubFor(get(urlMatching("/aai/v[0-9]+/network/vpn-bindings/vpn-binding/" + networkBindingId)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetNetworkPolicy(String networkPolicy, String responseFile, int statusCode) { - stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/" + networkPolicy)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetNetworkTableReference(String responseFile, String tableReference) { - stubFor(get(urlMatching("/aai/v[0-9]+/network/route-table-references/route-table-reference/"+tableReference + "[?]depth=all")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockPutNetworkIdWithDepth(String responseFile, String networkId, String depth) { - stubFor(put(urlMatching("/aai/v[0-9]+/network/l3-networks/l3-network/"+networkId+"[?]depth="+depth )) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetNetworkPolicyfqdn(String networkPolicy, String responseFile, int statusCode) { - stubFor(get(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy[?]network-policy-fqdn=" + networkPolicy)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetNetworkRouteTable(String networkRouteId, String responseFile, int statusCode) { - stubFor(get(urlMatching("/aai/v[0-9]+/network/route-table-references/route-table-reference/" + networkRouteId)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockPatchVfModuleId(String vnfId, String vfModuleId) { - stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId)) - .willReturn(aResponse() - .withStatus(200))); - } - - ///////////// - - public static void MockVNFAdapterRestVfModule() { - stubFor(put(urlEqualTo("/vnfs/v1/vnfs/skask/vf-modules/supercool")) - .willReturn(aResponse() - .withStatus(202) - .withHeader("Content-Type", "application/xml"))); - stubFor(post(urlMatching("/vnfs/v1/vnfs/.*/vf-modules")) - .willReturn(aResponse() - .withStatus(202) - .withHeader("Content-Type", "application/xml"))); - stubFor(post(urlEqualTo("/vnfs/v1/vnfs/skask/vf-modules")) - .willReturn(aResponse() - .withStatus(202) - .withHeader("Content-Type", "application/xml"))); - stubFor(put(urlEqualTo("/vnfs/v1/volume-groups/78987")) - .willReturn(aResponse() - .withStatus(202) - .withHeader("Content-Type", "application/xml"))); - } - - public static void MockDBUpdateVfModule(){ - stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("VfModularity/DBUpdateResponse.xml"))); - } - - // start of mocks used locally and by other VF Module unit tests - public static void MockSDNCAdapterVfModule() { - // simplified the implementation to return "success" for all requests - stubFor(post(urlEqualTo("/SDNCAdapter")) -// .withRequestBody(containing("SvcInstanceId><")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("VfModularity/StandardSDNCSynchResponse.xml"))); - - } - - // start of mocks used locally and by other VF Module unit tests - public static void MockAAIVfModule() { - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool")) - .atPriority(1) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("VfModularity/VfModule-supercool.xml"))); - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/lukewarm")) - .atPriority(2) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("VfModularity/VfModule-lukewarm.xml"))); - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*")) - .atPriority(5) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("VfModularity/VfModule-new.xml"))); - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask[?]depth=1")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("VfModularity/GenericVnf.xml"))); - stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/supercool")) -// .withRequestBody(containing("PCRF")) - .willReturn(aResponse() - .withStatus(200))); - stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*")) -// .withRequestBody(containing("PCRF")) - .willReturn(aResponse() - .withStatus(200))); - // HTTP PUT stub still used by CreateAAIvfModuleVolumeGroup - stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*")) - .withRequestBody(containing("PCRF")) - .willReturn(aResponse() - .withStatus(200))); - // HTTP PUT stub still used by DoCreateVfModuleTest - stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/.*")) - .withRequestBody(containing("MODULELABEL")) - .willReturn(aResponse() - .withStatus(200))); - stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group[?]volume-group-id=78987")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("VfModularity/ConfirmVolumeGroupTenantResponse.xml"))); - stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group[?]volume-group-id=78987")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("VfModularity/ConfirmVolumeGroupTenantResponse.xml"))); - stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/MDTWNJ21/volume-groups/volume-group/78987")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("VfModularity/VolumeGroup.xml"))); - stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/volume-groups/volume-group/78987")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("VfModularity/VolumeGroup.xml"))); - stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/volume-groups/volume-group/78987[?]resource-version=0000020")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("DeleteCinderVolumeV1/DeleteVolumeId_AAIResponse_Success.xml"))); - stubFor(put(urlMatching("/aai/v[0-9]+/network/network-policies/network-policy/.*")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("VfModularity/AddNetworkPolicy_AAIResponse_Success.xml"))); - stubFor(patch(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/skask/vf-modules/vf-module/NEWvBNGModuleId")) - .withRequestBody(containing("NEWvBNGModuleId")) - .willReturn(aResponse() - .withStatus(200))); - } - - - - ////////////// - - /** - * Cloud infrastructure below - */ - - public static void MockGetCloudRegion(String cloudRegionId, int statusCode, String responseFile) { - stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/" + cloudRegionId)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - /** - * Volume Group StubResponse below - */ - public static void MockGetVolumeGroupById(String cloudRegionId, String volumeGroupId, String responseFile) { - stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockPutVolumeGroupById(String cloudRegionId, String volumeGroupId, String responseFile, int statusCode) { - stubFor(put(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetVolumeGroupByName(String cloudRegionId, String volumeGroupName, String responseFile, int statusCode) { - stubFor(get(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/" + cloudRegionId + "/volume-groups[?]volume-group-name=" + volumeGroupName)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockDeleteVolumeGroupById(String cloudRegionId, String volumeGroupId, String resourceVersion, int statusCode) { - stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId + "[?]resource-version=" + resourceVersion)) - .willReturn(aResponse() - .withStatus(statusCode))); - } - - public static void MockGetVolumeGroupByName_404(String cloudRegionId, String volumeGroupName) { - stubFor(get(urlMatching("/aai/v9/cloud-infrastructure/cloud-regions/cloud-region/att-aic/" + cloudRegionId + "/volume-groups[?]volume-group-name=" + volumeGroupName)) - .willReturn(aResponse() - .withStatus(404))); - } - - public static void MockDeleteVolumeGroup(String cloudRegionId, String volumeGroupId, String resourceVersion) { - stubFor(delete(urlMatching("/aai/v[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/" + cloudRegionId + "/volume-groups/volume-group/" + volumeGroupId + "[?]resource-version=" + resourceVersion)) - .willReturn(aResponse() - .withStatus(200))); - } - - /** - * VF-Module StubResponse below - * @param statusCode TODO - */ - public static void MockGetVfModuleId(String vnfId, String vfModuleId, String responseFile, int statusCode) { - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetVfModuleByNameWithDepth(String vnfId, String vfModuleName, int depth, String responseFile, int statusCode) { - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module[?]vf-module-name=" + vfModuleName + "[?]depth=" + depth)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetVfModuleByName(String vnfId, String vfModuleName, String responseFile, int statusCode) { - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module[?]vf-module-name=" + vfModuleName)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockGetVfModuleIdNoResponse(String vnfId, String requestContaining, String vfModuleId) { - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId)) - .withRequestBody(containing(requestContaining)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml"))); - } - - public static void MockPutVfModuleIdNoResponse(String vnfId, String requestContaining, String vfModuleId) { - stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId +"/vf-modules/vf-module/" +vfModuleId)) - .withRequestBody(containing(requestContaining)) - .willReturn(aResponse() - .withStatus(200))); - } - - public static void MockPutVfModuleId(String vnfId, String vfModuleId) { - stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId)) - .willReturn(aResponse() - .withStatus(200))); - } - - public static void MockPutVfModuleId(String vnfId, String vfModuleId, int returnCode) { - stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId)) - .willReturn(aResponse() - .withStatus(returnCode))); - } - - public static void MockDeleteVfModuleId(String vnfId, String vfModuleId, String resourceVersion, int returnCode) { - stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/" + vnfId + "/vf-modules/vf-module/" + vfModuleId + "/[?]resource-version=" + resourceVersion)) - .willReturn(aResponse() - .withStatus(returnCode))); - } - - public static void MockAAIVfModuleBadPatch(String endpoint, int statusCode) { - stubFor(patch(urlMatching(endpoint)) - .willReturn(aResponse() - .withStatus(statusCode))); - } - - /* AAI Pserver Queries */ - public static void MockGetPserverByVnfId(String vnfId, String responseFile, int statusCode) { - stubFor(put(urlMatching("/aai/v1[0-9]/query.*")) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "application/json") - .withBodyFile(responseFile))); - } - - public static void MockGetGenericVnfsByVnfId(String vnfId, String responseFile, int statusCode) { - stubFor(get(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*")) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "application/json; charset=utf-8") - .withBodyFile(responseFile))); - } - - public static void MockSetInMaintFlagByVnfId(String vnfId, int statusCode) { - stubFor(patch(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*")) - .willReturn(aResponse() - .withStatus(statusCode) - )); - } - - public static void MockSetInMaintFlagByVnfId(String vnfId, String responseFile, int statusCode) { - stubFor(post(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*")) - .willReturn(aResponse() - .withStatus(statusCode) - .withBodyFile(responseFile) - )); - } - - public static void MockGetDefaultCloudRegionByCloudRegionId(String cloudRegionId, String responseFile, int statusCode) { - stubFor(get(urlMatching("/aai/v1[0-9]+/cloud-infrastructure/cloud-regions/cloud-region/att-aic/"+cloudRegionId + ".*")) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "application/json; charset=utf-8") - .withBodyFile(responseFile))); - } - - //// Deprecated Stubs below - to be deleted once unit test that reference them are refactored to use common ones above //// - @Deprecated - public static void MockGetVceById(){ - stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123?depth=1")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("GenericFlows/getVceResponse.xml"))); - } - @Deprecated - public static void MockGetVceByName(){ - stubFor(get(urlMatching("/aai/v[0-9]+/network/vces/vce[?]vnf-name=testVnfName123")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("GenericFlows/getVceByNameResponse.xml"))); - } - @Deprecated - public static void MockPutVce(){ - stubFor(put(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123")) - .willReturn(aResponse() - .withStatus(200))); - } - @Deprecated - public static void MockDeleteVce(){ - stubFor(delete(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123[?]resource-version=testReVer123")) - .willReturn(aResponse() - .withStatus(204))); - } - @Deprecated - public static void MockDeleteVce_404(){ - stubFor(delete(urlMatching("/aai/v[0-9]+/network/vces/vce/testVnfId123[?]resource-version=testReVer123")) - .willReturn(aResponse() - .withStatus(404))); - } - - @Deprecated - public static void MockDeleteServiceSubscription(){ - stubFor(delete(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET[?]resource-version=1234")) - .willReturn(aResponse() - .withStatus(204))); - } - @Deprecated - public static void MockGetServiceSubscription(){ - stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("GenericFlows/getServiceSubscription.xml"))); - } - @Deprecated - public static void MockGetServiceSubscription_200Empty(){ - stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET[?]resource-version=1234")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBody(" "))); - } - @Deprecated - public static void MockGetServiceSubscription_404() { - stubFor(get(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET")) - .willReturn(aResponse() - .withStatus(404))); - } - @Deprecated - public static void MockGENPSIPutServiceInstance(){ - stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("GenericPutServiceInstance/GenericPutServiceInstance_PutServiceInstance_AAIResponse_Success.xml"))); - } - - @Deprecated - public static void MockGENPSIPutServiceSubscription(){ - stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("GenericPutServiceInstance/GenericPutServiceInstance_PutServiceInstance_AAIResponse_Success.xml"))); - } - @Deprecated - public static void MockGENPSIPutServiceInstance_get500(){ - stubFor(put(urlMatching("/aai/v[0-9]+/business/customers/customer/1604-MVM-26/service-subscriptions/service-subscription/SDN-ETHERNET-INTERNET/service-instances/service-instance/MIS%252F1604%252F0026%252FSW_INTERNET")) - .willReturn(aResponse() - .withStatus(500) - .withHeader("Content-Type", "text/xml") - .withBodyFile("GenericPutServiceInstance/aaiFault.xml"))); - } - - @Deprecated - public static void MockGetGenericVnfById(){ - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("GenericFlows/getGenericVnfByNameResponse.xml"))); - } - @Deprecated - public static void MockGetGenericVnfById_404(){ - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123")) - .willReturn(aResponse() - .withStatus(404))); - } - @Deprecated - public static void MockGetGenericVnfByName(){ - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("GenericFlows/getGenericVnfResponse.xml"))); - } - @Deprecated - public static void MockGetGenericVnfByName_hasRelationships(){ - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("GenericFlows/getGenericVnfResponse_hasRelationships.xml"))); - } - @Deprecated - public static void MockGetGenericVnfById_hasRelationships(){ - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile("GenericFlows/getGenericVnfResponse_hasRelationships.xml"))); - } - @Deprecated - public static void MockGetGenericVnfById_500(){ - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123")) - .willReturn(aResponse() - .withStatus(500))); - } - @Deprecated - public static void MockGetGenericVnfByName_404(){ - stubFor(get(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf[?]vnf-name=testVnfName123")) - .willReturn(aResponse() - .withStatus(404))); - } - @Deprecated - public static void MockPutGenericVnf(){ - stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123")) - .willReturn(aResponse() - .withStatus(200))); - } - @Deprecated - public static void MockPutGenericVnf_400(){ - stubFor(put(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123")) - .willReturn(aResponse() - .withStatus(400))); - } - @Deprecated - public static void MockDeleteGenericVnf(){ - stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123")) - .willReturn(aResponse() - .withStatus(204))); - } - @Deprecated - public static void MockDeleteGenericVnf_404(){ - stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123")) - .willReturn(aResponse() - .withStatus(404))); - } - @Deprecated - public static void MockDeleteGenericVnf_500(){ - stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[?]resource-version=testReVer123")) - .willReturn(aResponse() - .withStatus(500))); - } - @Deprecated - public static void MockDeleteGenericVnf_412(){ - stubFor(delete(urlMatching("/aai/v[0-9]+/network/generic-vnfs/generic-vnf/testVnfId123[[?]]resource-version=testReVer123")) - .willReturn(aResponse() - .withStatus(412))); - } - -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseAPPC.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseAPPC.java deleted file mode 100644 index e94f0142d2..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseAPPC.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ============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.openecomp.mso.bpmn.mock; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.containing; -import static com.github.tomakehurst.wiremock.client.WireMock.delete; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.patch; -import static com.github.tomakehurst.wiremock.client.WireMock.put; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; - -/** - * Reusable Mock StubResponses for Policy - * - */ -public class StubResponseAPPC { - - public static void setupAllMocks() { - - } - - // start of Policy mocks - public static void MockAppcError() { - stubFor(get(urlMatching("/events/.*")) - // .withRequestBody(containing("APPC")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "application/json") - .withBodyFile("APPC/appc_error.json"))); - stubFor(put(urlMatching("/events/.*")) - // .withRequestBody(containing("APPC")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "application/json") - .withBodyFile("APPC/appc_error.json"))); - - - - } - - - -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseDatabase.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseDatabase.java deleted file mode 100644 index ffa6701a89..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseDatabase.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.bpmn.mock; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; - -/** - * Stub response class for Database stubs - * including database adapter, catalog db, - * and other databases. - */ -public class StubResponseDatabase { - - public static void setupAllMocks() { - - } - - public static void MockUpdateRequestDB(String fileName){ - stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(fileName))); - } - - public static void mockUpdateRequestDB(int statusCode, String reponseFile) { - stubFor(post(urlEqualTo("/dbadapters/RequestsDbAdapter")) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "text/xml") - .withBodyFile(reponseFile))); - } - - public static void MockGetAllottedResourcesByModelInvariantId(String modelInvariantId, String responseFile){ - stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "application/json") - .withBodyFile(responseFile))); - } - - public static void MockGetAllottedResourcesByModelInvariantId_500(String modelInvariantId, String responseFile){ - stubFor(get(urlEqualTo("/v1/serviceAllottedResources?serviceModelInvariantUuid=" + modelInvariantId)) - .willReturn(aResponse() - .withStatus(500))); - } - - public static void MockGetVnfCatalogDataCustomizationUuid(String vnfModelCustomizationUuid, String responseFile){ - stubFor(get(urlEqualTo("/v2/serviceVnfs?vnfModelCustomizationUuid=" + vnfModelCustomizationUuid)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "application/json") - .withBodyFile(responseFile))); - } - - public static void MockGetVfModuleByModelNameCatalogData(String vfModuleModelName, String responseFile){ - stubFor(get(urlEqualTo("/v2/vfModules?vfModuleModelName=" + vfModuleModelName)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "application/json") - .withBodyFile(responseFile))); - } - - public static void MockGetServiceResourcesCatalogData(String serviceModelInvariantUuid, String serviceModelVersion, String responseFile){ - stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=" + serviceModelInvariantUuid + - "&serviceModelVersion=" + serviceModelVersion)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "application/json") - .withBodyFile(responseFile))); - } - - public static void MockGetServiceResourcesCatalogData(String serviceModelInvariantUuid, String responseFile){ - stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelInvariantUuid=" + serviceModelInvariantUuid)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "application/json") - .withBodyFile(responseFile))); - } - - public static void MockGetServiceResourcesCatalogDataByModelUuid(String serviceModelUuid, String responseFile){ - stubFor(get(urlEqualTo("/v2/serviceResources?serviceModelUuid=" + serviceModelUuid)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "application/json") - .withBodyFile(responseFile))); - } - - -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseNetworkAdapter.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseNetworkAdapter.java deleted file mode 100644 index 8baeb1b137..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseNetworkAdapter.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.bpmn.mock; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.containing; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.put; -import static com.github.tomakehurst.wiremock.client.WireMock.delete; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; - -/** - * Please describe the StubResponseNetwork.java class - * - */ -public class StubResponseNetworkAdapter { - - private static final String EOL = "\n"; - - public static void setupAllMocks() { - - } - - - public static void MockNetworkAdapter() { - stubFor(post(urlEqualTo("/networks/NetworkAdapter")) - .willReturn(aResponse() - .withStatus(200))); - } - - public static void MockNetworkAdapter(String response) { - stubFor(post(urlEqualTo("/networks/NetworkAdapter")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(response))); - } - - public static void MockNetworkAdapter_500() { - stubFor(post(urlEqualTo("/networks/NetworkAdapter")) - .willReturn(aResponse() - .withStatus(500))); - } - - public static void MockNetworkAdapterPost(String responseFile, String requestContaining) { - stubFor(post(urlEqualTo("/networks/NetworkAdapter")) - .withRequestBody(containing(requestContaining)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockNetworkAdapter(String networkId, int statusCode, String responseFile) { - stubFor(delete(urlEqualTo("/networks/NetworkAdapter/" + networkId)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "application/xml") - .withBodyFile(responseFile))); - } - - public static void MockNetworkAdapterContainingRequest(String requestContaining, int statusCode, String responseFile) { - stubFor(post(urlEqualTo("/networks/NetworkAdapter")) - .withRequestBody(containing(requestContaining)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockPutNetworkAdapter(String networkId, String requestContaining, int statusCode, String responseFile) { - stubFor(put(urlEqualTo("/networks/NetworkAdapter/" + networkId)) - .withRequestBody(containing(requestContaining)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockNetworkAdapterRestRollbackDelete(String responseFile, String networkId) { - stubFor(delete(urlEqualTo("/networks/NetworkAdapter/"+networkId+"/rollback")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void MockNetworkAdapterRestPut(String responseFile, String networkId) { - stubFor(put(urlEqualTo("/networks/NetworkAdapter/"+networkId)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseOof.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseOof.java deleted file mode 100644 index b969b382c0..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseOof.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -/* - * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. - */ -package org.openecomp.mso.bpmn.mock; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; - -/** - * StubResponseOof.java class - */ -public class StubResponseOof { - - public static void setupAllMocks() { - - } - - public static void mockOof() { - stubFor(post(urlEqualTo("/api/oof/v1/placement")) - .willReturn(aResponse() - .withStatus(202) - .withHeader("Content-Type", "application/json"))); - } - - public static void mockOof(String responseFile) { - stubFor(post(urlEqualTo("/api/oof/v1/placement")) - .willReturn(aResponse() - .withStatus(202) - .withHeader("Content-Type", "application/json") - .withBodyFile(responseFile))); - } - - public static void mockOof_400() { - stubFor(post(urlEqualTo("/api/oof/v1/placement")) - .willReturn(aResponse() - .withStatus(400) - .withHeader("Content-Type", "application/json"))); - } - - public static void mockOof_500() { - stubFor(post(urlEqualTo("/api/oof/v1/placement")) - .willReturn(aResponse() - .withStatus(500) - .withHeader("Content-Type", "application/json"))); - } - -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponsePolicy.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponsePolicy.java deleted file mode 100644 index fd13084613..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponsePolicy.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.bpmn.mock; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.containing; -import static com.github.tomakehurst.wiremock.client.WireMock.delete; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.patch; -import static com.github.tomakehurst.wiremock.client.WireMock.put; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; - -/** - * Reusable Mock StubResponses for Policy - * - */ -public class StubResponsePolicy { - - public static void setupAllMocks() { - - } - - // start of Policy mocks - public static void MockPolicyAbort() { - stubFor(post(urlEqualTo("/pdp/api/getDecision")) - .withRequestBody(containing("BB1")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "application/json") - .withBodyFile("policyAbortResponse.json"))); - - stubFor(post(urlEqualTo("/pdp/api/getDecision")) - .withRequestBody(containing("UPDVnfI")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "application/json") - .withBodyFile("policyAbortResponse.json"))); - - stubFor(post(urlEqualTo("/pdp/api/getDecision")) - .withRequestBody(containing("RPLVnfI")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "application/json") - .withBodyFile("policyAbortResponse.json"))); - - stubFor(post(urlEqualTo("/pdp/api/getDecision")) - .withRequestBody(containing("VnfIPU")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "application/json") - .withBodyFile("policyAbortResponse.json"))); - - stubFor(post(urlEqualTo("/pdp/api/getDecision")) - .withRequestBody(containing("VnfCU")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "application/json") - .withBodyFile("policyAbortResponse.json"))); - - - - } - - public static void MockPolicySkip() { - stubFor(post(urlEqualTo("/pdp/api/getDecision")) - .withRequestBody(containing("BB1")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "application/json") - .withBodyFile("Policy/policySkipResponse.json"))); - - stubFor(post(urlEqualTo("/pdp/api/getDecision")) - .withRequestBody(containing("UPDVnfI")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "application/json") - .withBodyFile("Policy/policySkipResponse.json"))); - - stubFor(post(urlEqualTo("/pdp/api/getDecision")) - .withRequestBody(containing("RPLVnfI")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "application/json") - .withBodyFile("Policy/policySkipResponse.json"))); - - stubFor(post(urlEqualTo("/pdp/api/getDecision")) - .withRequestBody(containing("VnfIPU")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "application/json") - .withBodyFile("Policy/policySkipResponse.json"))); - - stubFor(post(urlEqualTo("/pdp/api/getDecision")) - .withRequestBody(containing("VnfCU")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "application/json") - .withBodyFile("Policy/policySkipResponse.json"))); - - - } - - -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseSDNCAdapter.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseSDNCAdapter.java deleted file mode 100644 index f41d6d7dba..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseSDNCAdapter.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.bpmn.mock; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.containing; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; - -/** - * Please describe the StubResponseSDNC.java class - */ -public class StubResponseSDNCAdapter { - - public static void setupAllMocks() { - - } - - public static void mockSDNCAdapter_500() { - stubFor(post(urlEqualTo("/SDNCAdapter")) - .willReturn(aResponse() - .withStatus(500))); - } - - public static void mockSDNCAdapter_500(String requestContaining) { - stubFor(post(urlEqualTo("/SDNCAdapter")) - .withRequestBody(containing(requestContaining)) - .willReturn(aResponse() - .withStatus(500))); - } - - public static void mockSDNCAdapter(int statusCode) { - stubFor(post(urlEqualTo("/SDNCAdapter")) - .willReturn(aResponse() - .withStatus(statusCode))); - } - - public static void mockSDNCAdapter(String endpoint, int statusCode, String responseFile) { - stubFor(post(urlEqualTo(endpoint)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void mockSDNCAdapter(String responseFile) { - stubFor(post(urlEqualTo("/SDNCAdapter")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void mockSDNCAdapter(String endpoint, String requestContaining, int statusCode, String responseFile) { - stubFor(post(urlEqualTo(endpoint)) - .withRequestBody(containing(requestContaining)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void mockSDNCAdapterSimulator(String responseFile) { - MockResource mockResource = new MockResource(); - mockResource.updateProperties("sdnc_delay", "300"); - stubFor(post(urlEqualTo("/SDNCAdapter")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "application/soap+xml") - .withTransformers("sdnc-adapter-transformer") - .withBodyFile(responseFile))); - } - - public static void mockSDNCAdapterSimulator(String responseFile, String requestContaining) { - MockResource mockResource = new MockResource(); - mockResource.updateProperties("sdnc_delay", "300"); - stubFor(post(urlEqualTo("/SDNCAdapter")) - .withRequestBody(containing(requestContaining)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "application/soap+xml") - .withTransformers("sdnc-adapter-transformer") - .withBodyFile(responseFile))); - } - - public static void mockSDNCAdapterRest() { - stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services")) - .willReturn(aResponse() - .withStatus(202) - .withHeader("Content-Type", "application/json"))); - } - - public static void mockSDNCAdapterRest_500() { - stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services")) - .willReturn(aResponse() - .withStatus(500) - .withHeader("Content-Type", "application/json"))); - } - - public static void mockSDNCAdapterRest(String requestContaining) { - stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services")) - .withRequestBody(containing(requestContaining)) - .willReturn(aResponse() - .withStatus(202) - .withHeader("Content-Type", "application/json"))); - } - - public static void mockSDNCAdapterRest_500(String requestContaining) { - stubFor(post(urlEqualTo("/SDNCAdapter/v1/sdnc/services")) - .withRequestBody(containing(requestContaining)) - .willReturn(aResponse() - .withStatus(500) - .withHeader("Content-Type", "application/json"))); - } - - public static void mockSDNCAdapterTopology(String responseFile, String requestContaining) { - MockResource mockResource = new MockResource(); - mockResource.updateProperties("sdnc_delay", "300"); - stubFor(post(urlEqualTo("/SDNCAdapter")) - .withRequestBody(containing(requestContaining)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withTransformers("network-topology-operation-transformer") - .withBodyFile(responseFile))); - } - - -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseSNIRO.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseSNIRO.java deleted file mode 100644 index c16ac43d41..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseSNIRO.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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========================================================= - */ - -/* - * © 2014 AT&T Intellectual Property. All rights reserved. Used under license from AT&T Intellectual Property. - */ -package org.openecomp.mso.bpmn.mock; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; - -/** - * Please describe the StubResponseSNIRO.java class - * - * @author cb645j - */ -public class StubResponseSNIRO { - - public static void setupAllMocks() { - - } - - public static void mockSNIRO() { - stubFor(post(urlEqualTo("/sniro/api/v2/placement")) - .willReturn(aResponse() - .withStatus(202) - .withHeader("Content-Type", "application/json"))); - } - - public static void mockSNIRO(String responseFile) { - stubFor(post(urlEqualTo("/sniro/api/v2/placement")) - .willReturn(aResponse() - .withStatus(202) - .withHeader("Content-Type", "application/json") - .withBodyFile(responseFile))); - } - - public static void mockSNIRO_400() { - stubFor(post(urlEqualTo("/sniro/api/v2/placement")) - .willReturn(aResponse() - .withStatus(400) - .withHeader("Content-Type", "application/json"))); - } - - public static void mockSNIRO_500() { - stubFor(post(urlEqualTo("/sniro/api/v2/placement")) - .willReturn(aResponse() - .withStatus(500) - .withHeader("Content-Type", "application/json"))); - } - -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseVNFAdapter.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseVNFAdapter.java deleted file mode 100644 index d518ab0b1c..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseVNFAdapter.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.bpmn.mock; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.containing; -import static com.github.tomakehurst.wiremock.client.WireMock.delete; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.put; -import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; - -/** - * Please describe the StubResponseVNF.java class - */ -public class StubResponseVNFAdapter { - - public static void mockVNFAdapter() { - stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync")) - .willReturn(aResponse() - .withStatus(200))); - } - - public static void mockVNFAdapter(String responseFile) { - stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "text/xml") - .withBodyFile(responseFile))); - } - - public static void mockVNFAdapter_500() { - stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync")) - .willReturn(aResponse() - .withStatus(500))); - } - - public static void mockVNFAdapterTransformer(String transformer, String responseFile) { - MockResource mockResource = new MockResource(); - mockResource.updateProperties("vnf_delay", "300"); - stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync")) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "application/soap+xml") - .withTransformers(transformer) - .withBodyFile(responseFile))); - } - - public static void mockVNFAdapterTransformer(String transformer, String responseFile, String requestContaining) { - MockResource mockResource = new MockResource(); - mockResource.updateProperties("vnf_delay", "300"); - stubFor(post(urlEqualTo("/vnfs/VnfAdapterAsync")) - .withRequestBody(containing(requestContaining)) - .willReturn(aResponse() - .withStatus(200) - .withHeader("Content-Type", "application/soap+xml") - .withTransformers(transformer) - .withBodyFile(responseFile))); - } - - public static void mockVNFPost(String vfModuleId, int statusCode, String vnfId) { - stubFor(post(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "application/xml"))); - stubFor(post(urlEqualTo("/vnfs/rest/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "application/xml"))); - } - - public static void mockVNFPut(String vfModuleId, int statusCode) { - stubFor(put(urlEqualTo("/vnfs/v1/vnfs/vnfId/vf-modules" + vfModuleId)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "application/xml"))); - stubFor(put(urlEqualTo("/vnfs/rest/v1/vnfs/vnfId/vf-modules" + vfModuleId)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "application/xml"))); - } - - public static void mockVNFPut(String vnfId, String vfModuleId, int statusCode) { - stubFor(put(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "application/xml"))); - stubFor(put(urlEqualTo("/vnfs/rest/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "application/xml"))); - } - - public static void mockVNFDelete(String vnfId, String vfModuleId, int statusCode) { - stubFor(delete(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "application/xml"))); - stubFor(delete(urlEqualTo("/vnfs/rest/v1/vnfs/" + vnfId + "/vf-modules" + vfModuleId)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "application/xml"))); - } - - public static void mockVNFRollbackDelete(String vfModuleId, int statusCode) { - stubFor(delete(urlEqualTo("/vnfs/v1/vnfs/vnfId/vf-modules" + vfModuleId + "/rollback")) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "application/xml"))); - stubFor(delete(urlEqualTo("/vnfs/rest/v1/vnfs/vnfId/vf-modules" + vfModuleId + "/rollback")) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "application/xml"))); - } - - public static void mockPutVNFVolumeGroup(String volumeGroupId, int statusCode) { - stubFor(put(urlEqualTo("/vnfs/v1/volume-groups/" + volumeGroupId)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "application/xml"))); - stubFor(put(urlEqualTo("/vnfs/rest/v1/volume-groups/" + volumeGroupId)) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "application/xml"))); - } - - public static void mockPutVNFVolumeGroupRollback(String volumeGroupId, int statusCode) { - stubFor(delete(urlMatching("/vnfs/v1/volume-groups/" + volumeGroupId + "/rollback")) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "application/xml"))); - stubFor(delete(urlMatching("/vnfs/rest/v1/volume-groups/" + volumeGroupId + "/rollback")) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "application/xml"))); - } - public static void mockPostVNFVolumeGroup(int statusCode) { - stubFor(post(urlEqualTo("/vnfs/v1/volume-groups")) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "application/xml"))); - stubFor(post(urlEqualTo("/vnfs/rest/v1/volume-groups")) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "application/xml"))); - } - - public static void mockVNFAdapterRest(String vnfId) { - stubFor(post(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules")) - .willReturn(aResponse() - .withStatus(200))); - stubFor(post(urlEqualTo("/vnfs/rest/v1/vnfs/" + vnfId + "/vf-modules")) - .willReturn(aResponse() - .withStatus(200))); - } - - public static void mockVNFAdapterRest_500(String vnfId) { - stubFor(post(urlEqualTo("/vnfs/v1/vnfs/" + vnfId + "/vf-modules")) - .willReturn(aResponse() - .withStatus(500))); - stubFor(post(urlEqualTo("/vnfs/rest/v1/vnfs/" + vnfId + "/vf-modules")) - .willReturn(aResponse() - .withStatus(500))); - } - - public static void mockVfModuleDelete(String volumeGroupId) { - stubFor(delete(urlMatching("/vnfs/v1/volume-groups/"+ volumeGroupId)) - .willReturn(aResponse() - .withStatus(202) - .withHeader("Content-Type", "application/xml"))); - stubFor(delete(urlMatching("/vnfs/rest/v1/volume-groups/"+ volumeGroupId)) - .willReturn(aResponse() - .withStatus(202) - .withHeader("Content-Type", "application/xml"))); - } - - public static void mockVfModuleDelete(String volumeGroupId, int statusCode) { - stubFor(delete(urlMatching("/vnfs/v1/volume-groups/78987")) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "application/xml"))); - stubFor(delete(urlMatching("/vnfs/rest/v1/volume-groups/78987")) - .willReturn(aResponse() - .withStatus(statusCode) - .withHeader("Content-Type", "application/xml"))); - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterAsyncTransformer.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterAsyncTransformer.java deleted file mode 100644 index 2eebe94f2b..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterAsyncTransformer.java +++ /dev/null @@ -1,163 +0,0 @@ -/*- - * ============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.openecomp.mso.bpmn.mock; - -import org.jboss.resteasy.client.ClientRequest; -import org.jboss.resteasy.client.ClientResponse; - -import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder; -import com.github.tomakehurst.wiremock.common.BinaryFile; -import com.github.tomakehurst.wiremock.common.FileSource; -import com.github.tomakehurst.wiremock.extension.ResponseTransformer; -import com.github.tomakehurst.wiremock.http.Request; -import com.github.tomakehurst.wiremock.http.ResponseDefinition; - -/** - * - * Simulates VNF Adapter Asynch Callback response. - * This should work for any of the operations. - * - * This transformer uses the mapped message as the asynchronous response. - * By definition, the async API sends a 202 (with no body) in the sync response. - * - */ -public class VnfAdapterAsyncTransformer extends ResponseTransformer { - - public VnfAdapterAsyncTransformer() { - } - - public String name() { - return "vnf-adapter-async"; - } - - /** - * Grab the incoming request, extract properties to be copied to the response - * (request id, vnf id, vf module ID, message ID). Then fetch the actual response - * body from its FileSource, make the replacements. - * - * The sync response is an empty 202 response. - * The transformed mapped response file is sent asynchronously after a delay. - * - * Mock Resource can be used to add dynamic properties. If vnf_delay is not in the list by - * default waits for 5s before the callback response is sent - */ - @Override - public ResponseDefinition transform(Request request, ResponseDefinition responseDefinition, - FileSource fileSource) { - - String requestBody = request.getBodyAsString(); - - // Note: Should recognize both XML and JSON. But current BPMN uses XML. - String notificationUrl = requestBody.substring(requestBody.indexOf("<notificationUrl>")+17, requestBody.indexOf("</notificationUrl>")); - - String vnfId = requestBody.substring(requestBody.indexOf("<vnfId>")+7, requestBody.indexOf("</vnfId>")); - String vfModuleId = requestBody.substring(requestBody.indexOf("<vfModuleId>")+12, requestBody.indexOf("</vfModuleId>")); - String messageId = requestBody.substring(requestBody.indexOf("<messageId>")+11, requestBody.indexOf("</messageId>")); - String requestId = requestBody.substring(requestBody.indexOf("<requestId>")+11, requestBody.indexOf("</requestId>")); - - System.out.println("responseDefinition: " + responseDefinition); - - // For this mock, the mapped response body is the Async callback (since the sync response is generic for all requests) - String vnfResponse = responseDefinition.getBody(); - System.out.println("VNF Response:" + vnfResponse); - - if (vnfResponse == null) { - // Body wasn't specified. Check for a body file - String bodyFileName = responseDefinition.getBodyFileName(); - System.out.println("bodyFileName" + bodyFileName); - if (bodyFileName != null) { - System.out.println("fileSource Class: " + fileSource.getClass().getName()); - BinaryFile bodyFile = fileSource.getBinaryFileNamed(bodyFileName); - byte[] responseFile = bodyFile.readContents(); - vnfResponse = new String(responseFile); - System.out.println("vnfResponse(2):" + vnfResponse); - } - } - - // Transform the SDNC response to escape < and > - vnfResponse = vnfResponse.replaceAll ("VNF_ID", vnfId); - vnfResponse = vnfResponse.replaceAll ("VF_MODULE_ID", vfModuleId); - vnfResponse = vnfResponse.replaceAll ("REQUEST_ID", requestId); - vnfResponse = vnfResponse.replaceAll ("MESSAGE_ID", messageId); - - Object vnfDelay = MockResource.getMockProperties().get("vnf_delay"); - int delay = 5000; - if (vnfDelay != null) { - delay = Integer.parseInt(vnfDelay.toString()); - } - - //Kick off callback thread - System.out.println("notification Url:" + notificationUrl + ":delay:" + delay); - CallbackResponseThread calbackResponseThread = new CallbackResponseThread(notificationUrl,vnfResponse, delay); - calbackResponseThread.start(); - - //return 200 OK with empty body - return ResponseDefinitionBuilder - .like(responseDefinition).but() - .withStatus(202).withBody("").withHeader("Content-Type", "text/xml") - .build(); - } - - @Override - public boolean applyGlobally() { - return false; - } - - /** - * - * Callback response thread which sends the callback response asynchronously - * - */ - private class CallbackResponseThread extends Thread { - - private String callbackUrl; - private String payLoad; - private int delay; - - public CallbackResponseThread(String callbackUrl, String payLoad, int delay) { - this.callbackUrl = callbackUrl; - this.payLoad = payLoad; - this.delay = delay; - } - - public void run () { - try { - //Delay sending callback response - sleep(delay); - } catch (InterruptedException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - System.out.println("Sending callback response:" + callbackUrl); - ClientRequest request = new ClientRequest(callbackUrl); - request.body("text/xml", payLoad); - System.err.println(payLoad); - try { - ClientResponse result = request.post(); - //System.err.println("Successfully posted callback:" + result.getStatus()); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterCreateMockTransformer.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterCreateMockTransformer.java deleted file mode 100644 index 23921da8d8..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterCreateMockTransformer.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.bpmn.mock; - -import javax.xml.ws.Endpoint; - -import org.jboss.resteasy.client.ClientRequest; -import org.jboss.resteasy.client.ClientResponse; -import org.openecomp.mso.logger.MsoLogger; - -import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder; -import com.github.tomakehurst.wiremock.common.FileSource; -import com.github.tomakehurst.wiremock.extension.ResponseTransformer; -import com.github.tomakehurst.wiremock.http.Request; -import com.github.tomakehurst.wiremock.http.ResponseDefinition; - -import org.openecomp.mso.logger.MsoLogger; -/** - * Please describe the VnfAdapterCreateMockTransformer.java class - * - */ -public class VnfAdapterCreateMockTransformer extends ResponseTransformer { - - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); - - private String notifyCallbackResponse; - private String ackResponse; - - public VnfAdapterCreateMockTransformer() { - notifyCallbackResponse = FileUtil.readResourceFile("__files/vnfAdapterMocks/vnfCreateSimResponse.xml"); // default response - } - - @Override - public String name() { - return "vnf-adapter-create-transformer"; - } - - @Override - public ResponseDefinition transform(Request request, ResponseDefinition responseDefinition, - FileSource fileSource) { - - String requestBody = request.getBodyAsString(); - - String notficationUrl = requestBody.substring(requestBody.indexOf("<notificationUrl>")+17, requestBody.indexOf("</notificationUrl>")); - String messageId = requestBody.substring(requestBody.indexOf("<messageId>")+11, requestBody.indexOf("</messageId>")); - String responseMessageId = ""; - String updatedResponse = ""; - - try { - // try supplied response file (if any) - System.out.println(" Supplied fileName: " + responseDefinition.getBodyFileName()); - ackResponse = FileUtil.readResourceFile("__files/" + responseDefinition.getBodyFileName()); - notifyCallbackResponse = ackResponse; - responseMessageId = ackResponse.substring(ackResponse.indexOf("<messageId>")+11, ackResponse.indexOf("</messageId>")); - updatedResponse = ackResponse.replace(responseMessageId, messageId); - } catch (Exception ex) { - LOGGER.debug("Exception :",ex); - System.out.println(" ******* Use default response file in '__files/vnfAdapterMocks/vnfCreateSimResponse.xml'"); - responseMessageId = notifyCallbackResponse.substring(notifyCallbackResponse.indexOf("<messageId>")+11, notifyCallbackResponse.indexOf("</messageId>")); - updatedResponse = notifyCallbackResponse.replace(responseMessageId, messageId); - } - - System.out.println("response (mock) messageId : " + responseMessageId); - System.out.println("request (replacement) messageId: " + messageId); - - System.out.println("vnf Response (before):" + notifyCallbackResponse); - System.out.println("vnf Response (after):" + updatedResponse); - - Object vnfDelay = MockResource.getMockProperties().get("vnf_delay"); - int delay = 300; - if (vnfDelay != null) { - delay = Integer.parseInt(vnfDelay.toString()); - } - - //Kick off callback thread - System.out.println("VnfAdapterCreateMockTransformer notficationUrl: " + notficationUrl + ":delay: " + delay); - CallbackResponseThread callbackResponseThread = new CallbackResponseThread(notficationUrl,updatedResponse, delay); - callbackResponseThread.start(); - - return ResponseDefinitionBuilder - .like(responseDefinition).but() - .withStatus(200).withBody(updatedResponse).withHeader("Content-Type", "text/xml") - .build(); - - } - - @Override - public boolean applyGlobally() { - return false; - } - - private class CallbackResponseThread extends Thread { - - private String callbackUrl; - private String payLoad; - private int delay; - - public CallbackResponseThread(String callbackUrl, String payLoad, int delay) { - this.callbackUrl = callbackUrl; - this.payLoad = payLoad; - this.delay = delay; - } - - @SuppressWarnings("deprecation") - public void run () { - try { - //Delay sending callback response - sleep(delay); - } catch (InterruptedException e1) { - // TODO Auto-generated catch block - LOGGER.debug("Exception :",e1); - } - LOGGER.debug("Sending callback response to url: " + callbackUrl); - ClientRequest request = new ClientRequest(callbackUrl); - request.body("text/xml", payLoad); - //System.out.println("payLoad: " + payLoad); - - try { - ClientResponse result = request.post(); - LOGGER.debug("Successfully posted callback? Status: " + result.getStatus()); - //System.err.println("Successfully posted callback:" + result.getStatus()); - } catch (Exception e) { - // TODO Auto-generated catch block - LOGGER.debug("catch error in - request.post() "); - LOGGER.debug("Exception :",e); - } - } - - } - - -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterDeleteMockTransformer.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterDeleteMockTransformer.java deleted file mode 100644 index ee6972e46e..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterDeleteMockTransformer.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.bpmn.mock; - -import org.jboss.resteasy.client.ClientRequest; -import org.jboss.resteasy.client.ClientResponse; -import org.openecomp.mso.logger.MsoLogger; - -import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder; -import com.github.tomakehurst.wiremock.common.FileSource; -import com.github.tomakehurst.wiremock.extension.ResponseTransformer; -import com.github.tomakehurst.wiremock.http.Request; -import com.github.tomakehurst.wiremock.http.ResponseDefinition; -/** - * Please describe the VnfAdapterCreateMockTransformer.java class - * - */ -public class VnfAdapterDeleteMockTransformer extends ResponseTransformer { - - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); - - private String notifyCallbackResponse; - private String ackResponse; - - public VnfAdapterDeleteMockTransformer() { - notifyCallbackResponse = FileUtil.readResourceFile("__files/vnfAdapterMocks/vnfDeleteSimResponse.xml"); - } - - @Override - public String name() { - return "vnf-adapter-delete-transformer"; - } - - @Override - public ResponseDefinition transform(Request request, ResponseDefinition responseDefinition, - FileSource fileSource) { - - // System.err.println("notifyCallbackResponse:" + notifyCallbackResponse); - - String requestBody = request.getBodyAsString(); - - String notficationUrl = requestBody.substring(requestBody.indexOf("<notificationUrl>")+17, requestBody.indexOf("</notificationUrl>")); - String messageId = requestBody.substring(requestBody.indexOf("<messageId>")+11, requestBody.indexOf("</messageId>")); - String responseMessageId = ""; - String updatedResponse = ""; - - try { - // try supplied response file (if any) - System.out.println(" Supplied fileName: " + responseDefinition.getBodyFileName()); - ackResponse = FileUtil.readResourceFile("__files/" + responseDefinition.getBodyFileName()); - notifyCallbackResponse = ackResponse; - responseMessageId = ackResponse.substring(ackResponse.indexOf("<messageId>")+11, ackResponse.indexOf("</messageId>")); - updatedResponse = ackResponse.replace(responseMessageId, messageId); - } catch (Exception ex) { - LOGGER.debug("Exception :",ex); - System.out.println(" ******* Use default response file in '__files/vnfAdapterMocks/vnfDeleteSimResponse.xml'"); - responseMessageId = notifyCallbackResponse.substring(notifyCallbackResponse.indexOf("<messageId>")+11, notifyCallbackResponse.indexOf("</messageId>")); - updatedResponse = notifyCallbackResponse.replace(responseMessageId, messageId); - } - - System.out.println("response (mock) messageId : " + responseMessageId); - System.out.println("request (replacement) messageId: " + messageId); - - System.out.println("vnf Response (before):" + notifyCallbackResponse); - System.out.println("vnf Response (after):" + updatedResponse); - - Object vnfDelay = MockResource.getMockProperties().get("vnf_delay"); - int delay = 300; - if (vnfDelay != null) { - delay = Integer.parseInt(vnfDelay.toString()); - } - - //Kick off callback thread - System.out.println("VnfAdapterDeleteMockTransformer notficationUrl: " + notficationUrl + ":delay: " + delay); - CallbackResponseThread callbackResponseThread = new CallbackResponseThread(notficationUrl,updatedResponse, delay); - callbackResponseThread.start(); - - return ResponseDefinitionBuilder - .like(responseDefinition).but() - .withStatus(200).withBody(updatedResponse).withHeader("Content-Type", "text/xml") - .build(); - - } - - @Override - public boolean applyGlobally() { - return false; - } - - private class CallbackResponseThread extends Thread { - - private String callbackUrl; - private String payLoad; - private int delay; - - public CallbackResponseThread(String callbackUrl, String payLoad, int delay) { - this.callbackUrl = callbackUrl; - this.payLoad = payLoad; - this.delay = delay; - } - - @SuppressWarnings("deprecation") - public void run () { - try { - //Delay sending callback response - sleep(delay); - } catch (InterruptedException e1) { - // TODO Auto-generated catch block - LOGGER.debug("Exception :",e1); - } - System.out.println("Sending callback response to url: " + callbackUrl); - ClientRequest request = new ClientRequest(callbackUrl); - request.body("text/xml", payLoad); - //System.err.println(payLoad); - try { - ClientResponse result = request.post(); - System.out.println("Successfully posted callback? Status: " + result.getStatus()); - //System.err.println("Successfully posted callback:" + result.getStatus()); - } catch (Exception e) { - // TODO Auto-generated catch block - System.out.println("catch error in - request.post() "); - LOGGER.debug("Exception :",e); - } - } - - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterQueryMockTransformer.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterQueryMockTransformer.java deleted file mode 100644 index 1582071d3a..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterQueryMockTransformer.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.bpmn.mock; - - -import com.github.tomakehurst.wiremock.extension.ResponseTransformer; - -import org.jboss.resteasy.client.ClientRequest; -import org.jboss.resteasy.client.ClientResponse; -import org.openecomp.mso.logger.MsoLogger; - -import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder; -import com.github.tomakehurst.wiremock.common.FileSource; -import com.github.tomakehurst.wiremock.extension.ResponseTransformer; -import com.github.tomakehurst.wiremock.http.Request; -import com.github.tomakehurst.wiremock.http.ResponseDefinition; - -import org.openecomp.mso.logger.MsoLogger; -/** - * Please describe the VnfAdapterQueryMockTransformer.java class - * - */ - - -public class VnfAdapterQueryMockTransformer extends ResponseTransformer{ - - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); - - private String notifyCallbackResponse; - private String ackResponse; - private String messageId; - - public VnfAdapterQueryMockTransformer() { - notifyCallbackResponse = FileUtil.readResourceFile("__files/vnfAdapterMocks/vnfQuerySimResponse.xml"); - } - - public VnfAdapterQueryMockTransformer(String messageId) { - this.messageId = messageId; - } - - @Override - public String name() { - return "vnf-adapter-query-transformer"; - } - - @Override - public ResponseDefinition transform(Request request, ResponseDefinition responseDefinition, - FileSource fileSource) { - - String requestBody = request.getBodyAsString(); - - String notficationUrl = requestBody.substring(requestBody.indexOf("<notificationUrl>")+17, requestBody.indexOf("</notificationUrl>")); - String messageId = requestBody.substring(requestBody.indexOf("<messageId>")+11, requestBody.indexOf("</messageId>")); - // String updatedResponse = notifyCallbackResponse.replace("b1a82ce6-7f5c-45fd-9273-acaf88fc2137", messageId); - - String responseMessageId = ""; - String updatedResponse = ""; - - // if (ackResponse == null) { - //System.err.println("file:" + responseDefinition.getBodyFileName()); - // ackResponse = FileUtil.readResourceFile("__files/" + responseDefinition.getBodyFileName()); - //} - - - try { - // try supplied response file (if any) - System.out.println(" Supplied fileName: " + responseDefinition.getBodyFileName()); - ackResponse = FileUtil.readResourceFile("__files/" + responseDefinition.getBodyFileName()); - notifyCallbackResponse = ackResponse; - responseMessageId = ackResponse.substring(ackResponse.indexOf("<messageId>")+11, ackResponse.indexOf("</messageId>")); - updatedResponse = ackResponse.replace(responseMessageId, messageId); - } catch (Exception ex) { - LOGGER.debug("Exception :",ex); - System.out.println(" ******* Use default response file in '__files/vnfAdapterMocks/vnfQuerySimResponse.xml'"); - responseMessageId = notifyCallbackResponse.substring(notifyCallbackResponse.indexOf("<messageId>")+11, notifyCallbackResponse.indexOf("</messageId>")); - updatedResponse = notifyCallbackResponse.replace(responseMessageId, messageId); - } - - System.out.println("response (mock) messageId : " + responseMessageId); - System.out.println("request (replacement) messageId: " + messageId); - - System.out.println("vnf Response (before):" + notifyCallbackResponse); - System.out.println("vnf Response (after):" + updatedResponse); - - - Object vnfDelay = MockResource.getMockProperties().get("vnf_delay"); - int delay = 300; - if (vnfDelay != null) { - delay = Integer.parseInt(vnfDelay.toString()); - } - - //Kick off callback thread - - //System.out.println("notficationUrl" + notficationUrl); - //System.out.println("updatedResponse" + updatedResponse); - System.out.println("VnfAdapterQueryMockTransformer notficationUrl: " + notficationUrl + ":delay: " + delay); - CallbackResponseThread callbackResponseThread = new CallbackResponseThread(notficationUrl,updatedResponse, delay); - System.out.println("Inside Callback" ); - callbackResponseThread.start(); - - return ResponseDefinitionBuilder - .like(responseDefinition).but() - .withStatus(200).withBody(updatedResponse).withHeader("Content-Type", "text/xml") - .build(); - } - - @Override - public boolean applyGlobally() { - return false; - } - - private class CallbackResponseThread extends Thread { - - private String callbackUrl; - private String payLoad; - private int delay; - - public CallbackResponseThread(String callbackUrl, String payLoad, int delay) { - this.callbackUrl = callbackUrl; - this.payLoad = payLoad; - this.delay = delay; - } - - public void run () { - try { - //Delay sending callback response - sleep(delay); - } catch (InterruptedException e1) { - LOGGER.debug("Exception :",e1); - } - ClientRequest request = new ClientRequest(callbackUrl); - request.body("text/xml", payLoad); - //System.err.println(payLoad); - try { - ClientResponse result = request.post(); - //System.err.println("Successfully posted callback:" + result.getStatus()); - } catch (Exception e) { - LOGGER.debug("Exception :",e); - } - } - - } - - -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterRollbackMockTransformer.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterRollbackMockTransformer.java deleted file mode 100644 index 186fd35b6f..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterRollbackMockTransformer.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * 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.openecomp.mso.bpmn.mock; - -import org.jboss.resteasy.client.ClientRequest; -import org.jboss.resteasy.client.ClientResponse; - -import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder; -import com.github.tomakehurst.wiremock.common.FileSource; -import com.github.tomakehurst.wiremock.extension.ResponseTransformer; -import com.github.tomakehurst.wiremock.http.Request; -import com.github.tomakehurst.wiremock.http.ResponseDefinition; - -import org.openecomp.mso.logger.MsoLogger; -/** - * Please describe the VnfAdapterCreateMockTransformer.java class - * - */ -public class VnfAdapterRollbackMockTransformer extends ResponseTransformer { - - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); - - private String notifyCallbackResponse; - private String ackResponse; - private String messageId; - - public VnfAdapterRollbackMockTransformer() { - notifyCallbackResponse = FileUtil.readResourceFile("__files/vnfAdapterMocks/vnfRollbackSimResponse.xml"); - } - - public VnfAdapterRollbackMockTransformer(String messageId) { - this.messageId = messageId; - } - - @Override - public String name() { - return "vnf-adapter-rollback-transformer"; - } - - @Override - public ResponseDefinition transform(Request request, ResponseDefinition responseDefinition, - FileSource fileSource) { - - String requestBody = request.getBodyAsString(); - - String notficationUrl = requestBody.substring(requestBody.indexOf("<notificationUrl>")+17, requestBody.indexOf("</notificationUrl>")); - String messageId = requestBody.substring(requestBody.indexOf("<messageId>")+11, requestBody.indexOf("</messageId>")); - String responseMessageId = ""; - String updatedResponse = ""; - - try { - // try supplied response file (if any) - System.out.println(" Supplied fileName: " + responseDefinition.getBodyFileName()); - ackResponse = FileUtil.readResourceFile("__files/" + responseDefinition.getBodyFileName()); - notifyCallbackResponse = ackResponse; - responseMessageId = ackResponse.substring(ackResponse.indexOf("<messageId>")+11, ackResponse.indexOf("</messageId>")); - updatedResponse = ackResponse.replace(responseMessageId, messageId); - } catch (Exception ex) { - LOGGER.debug("Exception :",ex); - System.out.println(" ******* Use default response file in '__files/vnfAdapterMocks/vnfRollbackSimResponse.xml'"); - responseMessageId = notifyCallbackResponse.substring(notifyCallbackResponse.indexOf("<messageId>")+11, notifyCallbackResponse.indexOf("</messageId>")); - updatedResponse = notifyCallbackResponse.replace(responseMessageId, messageId); - } - - System.out.println("response (mock) messageId : " + responseMessageId); - System.out.println("request (replacement) messageId: " + messageId); - - System.out.println("vnf Response (before):" + notifyCallbackResponse); - System.out.println("vnf Response (after):" + updatedResponse); - - Object vnfDelay = MockResource.getMockProperties().get("vnf_delay"); - int delay = 300; - if (vnfDelay != null) { - delay = Integer.parseInt(vnfDelay.toString()); - } - - //Kick off callback thread - System.out.println("VnfAdapterRollbackMockTransformer notficationUrl: " + notficationUrl + ":delay: " + delay); - CallbackResponseThread callbackResponseThread = new CallbackResponseThread(notficationUrl,updatedResponse, delay); - callbackResponseThread.start(); - - return ResponseDefinitionBuilder - .like(responseDefinition).but() - .withStatus(200).withBody(updatedResponse).withHeader("Content-Type", "text/xml") - .build(); - - } - - @Override - public boolean applyGlobally() { - return false; - } - - private class CallbackResponseThread extends Thread { - - private String callbackUrl; - private String payLoad; - private int delay; - - public CallbackResponseThread(String callbackUrl, String payLoad, int delay) { - this.callbackUrl = callbackUrl; - this.payLoad = payLoad; - this.delay = delay; - } - - public void run () { - try { - //Delay sending callback response - sleep(delay); - } catch (InterruptedException e1) { - LOGGER.debug("Exception :",e1); - } - System.out.println("Sending callback response to url: " + callbackUrl); - ClientRequest request = new ClientRequest(callbackUrl); - request.body("text/xml", payLoad); - //System.err.println(payLoad); - try { - ClientResponse result = request.post(); - System.out.println("Successfully posted callback? Status: " + result.getStatus()); - //System.err.println("Successfully posted callback:" + result.getStatus()); - } catch (Exception e) { - System.out.println("catch error in - request.post() "); - LOGGER.debug("Exception :",e); - } - } - - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterUpdateMockTransformer.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterUpdateMockTransformer.java deleted file mode 100644 index 7808b47d24..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterUpdateMockTransformer.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.openecomp.mso.bpmn.mock; - -import org.jboss.resteasy.client.ClientRequest; -import org.jboss.resteasy.client.ClientResponse; -import org.openecomp.mso.logger.MsoLogger; - -import com.github.tomakehurst.wiremock.client.ResponseDefinitionBuilder; -import com.github.tomakehurst.wiremock.common.FileSource; -import com.github.tomakehurst.wiremock.extension.ResponseTransformer; -import com.github.tomakehurst.wiremock.http.Request; -import com.github.tomakehurst.wiremock.http.ResponseDefinition; - -import org.openecomp.mso.logger.MsoLogger; -/** - * Please describe the VnfAdapterUpdateMockTransformer.java class - * - */ -public class VnfAdapterUpdateMockTransformer extends ResponseTransformer { - - private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL); - - private String notifyCallbackResponse; - private String requestId; - private String ackResponse; - - public VnfAdapterUpdateMockTransformer() { - notifyCallbackResponse = FileUtil.readResourceFile("vnfAdapter/vnfUpdateSimResponse.xml"); - } - - public VnfAdapterUpdateMockTransformer(String requestId) { - this.requestId = requestId; - } - - - public String name() { - return "vnf-adapter-update-transformer"; - } - - @Override - public ResponseDefinition transform(Request request, ResponseDefinition responseDefinition, - FileSource fileSource) { - - String requestBody = request.getBodyAsString(); - - String notficationUrl = requestBody.substring(requestBody.indexOf("<notificationUrl>")+17, requestBody.indexOf("</notificationUrl>")); - String messageId = requestBody.substring(requestBody.indexOf("<messageId>")+11, requestBody.indexOf("</messageId>")); - String responseMessageId = ""; - String updatedResponse = ""; - - try { - // try supplied response file (if any) - System.out.println(" Supplied fileName: " + responseDefinition.getBodyFileName()); - ackResponse = FileUtil.readResourceFile("__files/" + responseDefinition.getBodyFileName()); - notifyCallbackResponse = ackResponse; - responseMessageId = ackResponse.substring(ackResponse.indexOf("<messageId>")+11, ackResponse.indexOf("</messageId>")); - updatedResponse = ackResponse.replace(responseMessageId, messageId); - } catch (Exception ex) { - LOGGER.debug("Exception :",ex); - System.out.println(" ******* Use default response file in 'vnfAdapter/vnfUpdateSimResponse.xml'"); - responseMessageId = notifyCallbackResponse.substring(notifyCallbackResponse.indexOf("<messageId>")+11, notifyCallbackResponse.indexOf("</messageId>")); - updatedResponse = notifyCallbackResponse.replace(responseMessageId, messageId); - } - - System.out.println("response (mock) messageId : " + responseMessageId); - System.out.println("request (replacement) messageId: " + messageId); - - System.out.println("vnf Response (before):" + notifyCallbackResponse); - System.out.println("vnf Response (after):" + updatedResponse); - - Object vnfDelay = MockResource.getMockProperties().get("vnf_delay"); - int delay = 300; - if (vnfDelay != null) { - delay = Integer.parseInt(vnfDelay.toString()); - } - - //Kick off callback thread - System.out.println("VnfAdapterUpdateMockTransformer notficationUrl: " + notficationUrl + ":delay: " + delay); - CallbackResponseThread callbackResponseThread = new CallbackResponseThread(notficationUrl,updatedResponse, delay); - callbackResponseThread.start(); - - return ResponseDefinitionBuilder - .like(responseDefinition).but() - .withStatus(200).withBody(updatedResponse).withHeader("Content-Type", "text/xml") - .build(); - - } - - @Override - public boolean applyGlobally() { - return false; - } - - private class CallbackResponseThread extends Thread { - - private String callbackUrl; - private String payLoad; - private int delay; - - public CallbackResponseThread(String callbackUrl, String payLoad, int delay) { - this.callbackUrl = callbackUrl; - this.payLoad = payLoad; - this.delay = delay; - } - - public void run () { - try { - //Delay sending callback response - sleep(delay); - } catch (InterruptedException e1) { - LOGGER.debug("Exception :", e1); - } - System.out.println("Sending callback response to url: " + callbackUrl); - ClientRequest request = new ClientRequest(callbackUrl); - request.body("text/xml", payLoad); - //System.err.println(payLoad); - try { - ClientResponse result = request.post(); - System.out.println("Successfully posted callback? Status: " + result.getStatus()); - //System.err.println("Successfully posted callback:" + result.getStatus()); - } catch (Exception e) { - System.out.println("catch error in - request.post() "); - LOGGER.debug("Exception :",e); - } - } - - } -} - diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/ResponseExceptionMapperImplTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/ResponseExceptionMapperImplTest.java deleted file mode 100644 index 8943014ad0..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/ResponseExceptionMapperImplTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/*- - * ============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.openecomp.mso.client; - -import static org.assertj.core.api.Assertions.assertThatCode; -import static org.assertj.core.api.Assertions.assertThatThrownBy; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.google.common.base.Charsets; -import javax.ws.rs.BadRequestException; -import javax.ws.rs.ForbiddenException; -import javax.ws.rs.InternalServerErrorException; -import javax.ws.rs.NotAcceptableException; -import javax.ws.rs.NotAllowedException; -import javax.ws.rs.NotAuthorizedException; -import javax.ws.rs.NotFoundException; -import javax.ws.rs.NotSupportedException; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.client.ClientResponseContext; -import javax.ws.rs.core.Response.Status; -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; -import org.apache.commons.io.IOUtils; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(JUnitParamsRunner.class) -public class ResponseExceptionMapperImplTest { - - private static final ResponseExceptionMapperImpl mapper = new ResponseExceptionMapperImpl(); - - public static Object[][] statusesAndCorrespondingExceptions() { - return new Object[][]{ - {Status.BAD_REQUEST, BadRequestException.class}, - {Status.UNAUTHORIZED, NotAuthorizedException.class}, - {Status.FORBIDDEN, ForbiddenException.class}, - {Status.NOT_FOUND, NotFoundException.class}, - {Status.METHOD_NOT_ALLOWED, NotAllowedException.class}, - {Status.NOT_ACCEPTABLE, NotAcceptableException.class}, - {Status.PRECONDITION_FAILED, PreconditionFailedException.class}, - {Status.UNSUPPORTED_MEDIA_TYPE, NotSupportedException.class}, - {Status.INTERNAL_SERVER_ERROR, InternalServerErrorException.class}, - {Status.SERVICE_UNAVAILABLE, WebApplicationException.class}, - {Status.BAD_GATEWAY, WebApplicationException.class}, - }; - } - - @Test - @Parameters(method = "statusesAndCorrespondingExceptions") - public void shouldThrowExceptionWhenStatusIsNotOk(Status status, Class<Exception> expectedException) { - // given - ClientResponseContext responseContext = createMockResponseContext(status); - // when, then - assertThatThrownBy(() -> mapper.filter(null, responseContext)).isInstanceOf(expectedException); - } - - @Test - public void shouldNotThrowExceptionWhenStatusIsOk() { - // given - ClientResponseContext responseContext = createMockResponseContext(Status.OK); - // when, then - assertThatCode(() -> mapper.filter(null, responseContext)).doesNotThrowAnyException(); - } - - @Test - public void shouldThrowExceptionWithCustomMessageWhenResponseHasEntity() { - // given - ClientResponseContext responseContext = createMockResponseContext(Status.BAD_REQUEST); - when(responseContext.hasEntity()).thenReturn(true); - when(responseContext.getEntityStream()).thenReturn(IOUtils.toInputStream("test message", Charsets.UTF_8)); - // when, then - assertThatThrownBy(() -> mapper.filter(null, responseContext)).isInstanceOf(BadRequestException.class) - .hasMessage("test message"); - } - - @Test - public void shouldThrowExceptionWithDefaultMessageWhenResponseHasNoEntity() { - // given - ClientResponseContext responseContext = createMockResponseContext(Status.BAD_REQUEST); - when(responseContext.hasEntity()).thenReturn(false); - // when, then - assertThatThrownBy(() -> mapper.filter(null, responseContext)).isInstanceOf(BadRequestException.class) - .hasMessage("empty message"); - } - - private static ClientResponseContext createMockResponseContext(Status status) { - ClientResponseContext responseContext = mock(ClientResponseContext.class); - when(responseContext.getStatusInfo()).thenReturn(status); - when(responseContext.getStatus()).thenReturn(status.getStatusCode()); - return responseContext; - } -}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClientTest.java deleted file mode 100644 index 0584bea012..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClientTest.java +++ /dev/null @@ -1,146 +0,0 @@ -/*- - * ============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.openecomp.mso.client.adapter.network;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
-import static org.junit.Assert.assertEquals;
-
-import org.junit.BeforeClass;
-import org.junit.Ignore; -import org.junit.Rule;
-import org.junit.Test;
-import org.openecomp.mso.adapters.nwrest.CreateNetworkRequest;
-import org.openecomp.mso.adapters.nwrest.CreateNetworkResponse;
-import org.openecomp.mso.adapters.nwrest.DeleteNetworkRequest;
-import org.openecomp.mso.adapters.nwrest.DeleteNetworkResponse;
-import org.openecomp.mso.adapters.nwrest.QueryNetworkResponse;
-import org.openecomp.mso.adapters.nwrest.RollbackNetworkRequest;
-import org.openecomp.mso.adapters.nwrest.RollbackNetworkResponse;
-import org.openecomp.mso.adapters.nwrest.UpdateNetworkRequest;
-import org.openecomp.mso.adapters.nwrest.UpdateNetworkResponse;
-import org.openecomp.mso.openstack.beans.NetworkRollback;
-
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-
-public class NetworkAdapterClientTest {
-
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(28090));
-
- private static final String TESTING_ID = "___TESTING___";
- private static final String AAI_NETWORK_ID = "test";
- private static final String REST_ENDPOINT = "/networks/rest/v1/networks";
-
- private NetworkAdapterClientImpl client = new NetworkAdapterClientImpl();
-
- @BeforeClass
- public static void setUp() {
- System.setProperty("mso.config.path", "src/test/resources");
- }
-
- @Test
- public void createNetworkTest() {
- CreateNetworkRequest request = new CreateNetworkRequest();
- request.setCloudSiteId(TESTING_ID);
-
- CreateNetworkResponse mockResponse = new CreateNetworkResponse();
- mockResponse.setNetworkCreated(true);
- wireMockRule.stubFor(post(urlPathEqualTo(REST_ENDPOINT)).willReturn(aResponse()
- .withHeader("Content-Type", "application/json").withBody(mockResponse.toJsonString()).withStatus(200)));
-
- CreateNetworkResponse response = client.createNetwork(request);
- assertEquals("Testing CreateVfModule response", true, response.getNetworkCreated());
- }
-
- @Test
- public void deleteNetworkTest() {
- DeleteNetworkRequest request = new DeleteNetworkRequest();
- request.setCloudSiteId(TESTING_ID);
-
- DeleteNetworkResponse mockResponse = new DeleteNetworkResponse();
- mockResponse.setNetworkDeleted(true);
-
- wireMockRule.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID)).willReturn(aResponse()
- .withHeader("Content-Type", "application/json").withBody(mockResponse.toJsonString()).withStatus(200)));
-
- DeleteNetworkResponse response = client.deleteNetwork(AAI_NETWORK_ID, request);
- assertEquals("Testing DeleteVfModule response", true, response.getNetworkDeleted());
- }
-
- @Test
- public void rollbackNetworkTest() {
- RollbackNetworkRequest request = new RollbackNetworkRequest();
- NetworkRollback rollback = new NetworkRollback();
- rollback.setCloudId(TESTING_ID);
- request.setNetworkRollback(rollback);
-
- RollbackNetworkResponse mockResponse = new RollbackNetworkResponse();
- mockResponse.setNetworkRolledBack(true);
-
- wireMockRule.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID)).willReturn(aResponse()
- .withHeader("Content-Type", "application/json").withBody(mockResponse.toJsonString()).withStatus(200)));
-
- RollbackNetworkResponse response = client.rollbackNetwork(AAI_NETWORK_ID, request);
- assertEquals("Testing DeleteVfModule response", true, response.getNetworkRolledBack());
- }
-
- @Test
- public void queryNetworkTest() {
- QueryNetworkResponse mockResponse = new QueryNetworkResponse();
- mockResponse.setNetworkExists(true);
-
- wireMockRule.stubFor(get(urlPathEqualTo(REST_ENDPOINT))
- .withQueryParam("cloudSiteId", equalTo(TESTING_ID))
- .withQueryParam("tenantId", equalTo(TESTING_ID))
- .withQueryParam("networkStackId", equalTo("networkStackId"))
- .withQueryParam("skipAAI", equalTo("true"))
- .withQueryParam("msoRequest.requestId", equalTo("testRequestId"))
- .withQueryParam("msoRequest.serviceInstanceId", equalTo("serviceInstanceId"))
- .willReturn(aResponse()
- .withHeader("Content-Type", "application/json").withBody(mockResponse.toJsonString()).withStatus(200)));
-
- QueryNetworkResponse response = client.queryNetwork(AAI_NETWORK_ID, TESTING_ID, TESTING_ID,
- "networkStackId", true, "testRequestId", "serviceInstanceId");
- assertEquals("Testing QueryVfModule response", true, response.getNetworkExists());
- }
-
- @Ignore - @Test
- public void updateNetworkTest() {
- UpdateNetworkRequest request = new UpdateNetworkRequest();
- request.setCloudSiteId(TESTING_ID);
- request.setNetworkId("test1");
-
- UpdateNetworkResponse mockResponse = new UpdateNetworkResponse();
- mockResponse.setNetworkId("test1");
- wireMockRule.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_NETWORK_ID)).willReturn(aResponse()
- .withHeader("Content-Type", "application/json").withBody(mockResponse.toJsonString()).withStatus(200)));
-
- UpdateNetworkResponse response = client.updateNetwork(AAI_NETWORK_ID, request);
- assertEquals("Testing UpdateVfModule response", "test1", response.getNetworkId());
- }
-}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/requests/db/RequestsDbAdapterClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/requests/db/RequestsDbAdapterClientTest.java deleted file mode 100644 index 2c35151895..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/requests/db/RequestsDbAdapterClientTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============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.openecomp.mso.client.adapter.requests.db;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class RequestsDbAdapterClientTest {
-
- @BeforeClass
- public static void setUp() {
- System.setProperty("mso.config.path", "src/test/resources");
- }
-
- @Test
- public void updateInfraRequestTest()
- {
-
- }
-
- @Test
- public void getInfraRequestTest()
- {
-
- }
-
- @Test
- public void getSiteStatusTest()
- {
-
- }
-}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbExceptionBeanTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbExceptionBeanTest.java deleted file mode 100644 index f0c6e7ec52..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbExceptionBeanTest.java +++ /dev/null @@ -1,33 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.openecomp.mso.client.adapter.requests.db.entities; - -import org.junit.Test; - -public class MsoRequestsDbExceptionBeanTest { - - @Test - public void test() { - MsoRequestsDbExceptionBean mrde=new MsoRequestsDbExceptionBean("msg"); - mrde.setMessage("msg"); - assert(mrde.getMessage().equals("msg")); - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbExceptionTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbExceptionTest.java deleted file mode 100644 index 28b8cc991f..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/requests/db/entities/MsoRequestsDbExceptionTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.openecomp.mso.client.adapter.requests.db.entities; - -import org.junit.Test; - -public class MsoRequestsDbExceptionTest { - - @Test - public void test() { - Throwable e = new Throwable(); - MsoRequestsDbExceptionBean mredb=new MsoRequestsDbExceptionBean(); - MsoRequestsDbException mrde=new MsoRequestsDbException("msg",e); - MsoRequestsDbException mrd=new MsoRequestsDbException("msg"); - MsoRequestsDbException mrd1=new MsoRequestsDbException(e); - mrde.setFaultInfo(mredb); - assert(mrde.getFaultInfo().equals(mredb)); - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/requests/db/entities/UpdateInfraRequestTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/requests/db/entities/UpdateInfraRequestTest.java deleted file mode 100644 index d01c11948b..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/requests/db/entities/UpdateInfraRequestTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.openecomp.mso.client.adapter.requests.db.entities; - -import org.junit.Test; - -public class UpdateInfraRequestTest { - - @Test - public void test() { - UpdateInfraRequest uir=new UpdateInfraRequest(); - RequestStatusType requestStatus=RequestStatusType.COMPLETE; - uir.setConfigurationId("configurationId"); - uir.setConfigurationName("configurationName"); - uir.setLastModifiedBy("lastModifiedBy"); - uir.setNetworkId("networkId"); - uir.setProgress("progress"); - uir.setRequestId("requestId"); - uir.setRequestStatus(requestStatus); - uir.setResponseBody("responseBody"); - uir.setServiceInstanceId("serviceInstanceId"); - uir.setServiceInstanceName("serviceInstanceName"); - uir.setStatusMessage("statusMessage"); - uir.setVfModuleId("vfModuleId"); - uir.setVfModuleName("vfModuleName"); - uir.setVnfId("vnfId"); - uir.setVnfOutputs("vnfOutputs"); - uir.setVolumeGroupId("volumeGroupId"); - assert(uir.getConfigurationId().equals("configurationId")); - assert(uir.getConfigurationName().equals("configurationName")); - assert(uir.getLastModifiedBy().equals("lastModifiedBy")); - assert(uir.getNetworkId().equals("networkId")); - assert(uir.getProgress().equals("progress")); - assert(uir.getRequestId().equals("requestId")); - assert(uir.getRequestStatus().equals(requestStatus)); - assert(uir.getResponseBody().equals("responseBody")); - assert(uir.getServiceInstanceId().equals("serviceInstanceId")); - assert(uir.getServiceInstanceName().equals("serviceInstanceName")); - assert(uir.getStatusMessage().equals("statusMessage")); - assert(uir.getVfModuleId().equals("vfModuleId")); - assert(uir.getVnfOutputs().equals("vnfOutputs")); - assert(uir.getVolumeGroupId().equals("volumeGroupId")); - assert(uir.getVfModuleName().equals("vfModuleName")); - assert(uir.getVnfId().equals("vnfId")); - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClientTest.java deleted file mode 100644 index 21448256ed..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClientTest.java +++ /dev/null @@ -1,156 +0,0 @@ -/*- - * ============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.openecomp.mso.client.adapter.vnf;
-
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.equalTo;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.post;
-import static com.github.tomakehurst.wiremock.client.WireMock.put;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
-import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
-import static org.junit.Assert.assertEquals;
-
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.openecomp.mso.adapters.vnfrest.CreateVfModuleRequest;
-import org.openecomp.mso.adapters.vnfrest.CreateVfModuleResponse;
-import org.openecomp.mso.adapters.vnfrest.DeleteVfModuleRequest;
-import org.openecomp.mso.adapters.vnfrest.DeleteVfModuleResponse;
-import org.openecomp.mso.adapters.vnfrest.QueryVfModuleResponse;
-import org.openecomp.mso.adapters.vnfrest.RollbackVfModuleRequest;
-import org.openecomp.mso.adapters.vnfrest.RollbackVfModuleResponse;
-import org.openecomp.mso.adapters.vnfrest.UpdateVfModuleRequest;
-import org.openecomp.mso.adapters.vnfrest.UpdateVfModuleResponse;
-import org.openecomp.mso.adapters.vnfrest.VfModuleRollback;
-
-import com.github.tomakehurst.wiremock.junit.WireMockRule;
-
-public class VnfAdapterClientTest {
-
- @Rule
- public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(28090));
-
- private static final String TESTING_ID = "___TESTING___";
- private static final String AAI_VNF_ID = "test";
- private static final String AAI_VF_MODULE_ID = "test";
- private static final String REST_ENDPOINT = "/vnfs/rest/v1/vnfs";
-
- private VnfAdapterClientImpl client = new VnfAdapterClientImpl();
-
- @BeforeClass
- public static void setUp() {
- System.setProperty("mso.config.path", "src/test/resources");
- }
-
- @Test
- public void createVfModuleTest() {
- CreateVfModuleRequest request = new CreateVfModuleRequest();
- request.setCloudSiteId(TESTING_ID);
-
- CreateVfModuleResponse mockResponse = new CreateVfModuleResponse();
- mockResponse.setVfModuleCreated(true);
- wireMockRule.stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mockResponse.toJsonString()).withStatus(200)));
-
- CreateVfModuleResponse response = client.createVfModule(AAI_VNF_ID, request);
- assertEquals("Testing CreateVfModule response", true, response.getVfModuleCreated());
- }
-
- @Test
- public void rollbackVfModuleTest() {
- RollbackVfModuleRequest request = new RollbackVfModuleRequest();
- VfModuleRollback rollback = new VfModuleRollback();
- rollback.setCloudSiteId(TESTING_ID);
- request.setVfModuleRollback(rollback);
-
- RollbackVfModuleResponse mockResponse = new RollbackVfModuleResponse();
- mockResponse.setVfModuleRolledback(true);
- wireMockRule.stubFor(
- put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID + "/rollback"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mockResponse.toJsonString()).withStatus(200)));
-
- RollbackVfModuleResponse response = client.rollbackVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
- assertEquals("Testing RollbackVfModule response", true, response.getVfModuleRolledback());
- }
-
- @Test
- public void deleteVfModuleTest() {
- DeleteVfModuleRequest request = new DeleteVfModuleRequest();
- request.setCloudSiteId(TESTING_ID);
-
- DeleteVfModuleResponse mockResponse = new DeleteVfModuleResponse();
- mockResponse.setVfModuleDeleted(true);
- wireMockRule.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/" + AAI_VF_MODULE_ID))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mockResponse.toJsonString()).withStatus(200)));
-
- DeleteVfModuleResponse response = client.deleteVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
- assertEquals("Testing DeleteVfModule response", true, response.getVfModuleDeleted());
- }
-
- @Test
- public void updateVfModuleTest() {
- UpdateVfModuleRequest request = new UpdateVfModuleRequest();
- request.setCloudSiteId(TESTING_ID);
- request.setVfModuleId("test1");
-
- UpdateVfModuleResponse mockResponse = new UpdateVfModuleResponse();
- mockResponse.setVfModuleId("test1");
- wireMockRule.stubFor(put(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules/"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mockResponse.toJsonString()).withStatus(200)));
-
- UpdateVfModuleResponse response = client.updateVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, request);
- assertEquals("Testing UpdateVfModule response", "test1", response.getVfModuleId());
- }
-
- @Test
- public void queryVfModuleTest() {
- QueryVfModuleResponse mockResponse = new QueryVfModuleResponse();
- mockResponse.setVnfId(AAI_VNF_ID);
- mockResponse.setVfModuleId(AAI_VF_MODULE_ID);
- wireMockRule.stubFor(get(urlPathEqualTo(REST_ENDPOINT))
- .withQueryParam("cloudSiteId", equalTo(TESTING_ID))
- .withQueryParam("tenantId", equalTo(TESTING_ID))
- .withQueryParam("vfModuleName", equalTo("someName"))
- .withQueryParam("skipAAI", equalTo("true"))
- .withQueryParam("msoRequest.requestId", equalTo("testRequestId"))
- .withQueryParam("msoRequest.serviceInstanceId", equalTo("serviceInstanceId"))
- .willReturn(aResponse().withHeader("Content-Type", "application/json")
- .withBody(mockResponse.toJsonString()).withStatus(200)));
- QueryVfModuleResponse response = client.queryVfModule(AAI_VNF_ID, AAI_VF_MODULE_ID, TESTING_ID, TESTING_ID,
- "someName", true, "testRequestId", "serviceInstanceId");
- assertEquals("Testing QueryVfModule response", AAI_VF_MODULE_ID, response.getVfModuleId());
- }
-
- @Test
- public void healthCheckTest() {
- wireMockRule.stubFor(get(urlPathEqualTo("/vnfs/rest/v1/vnfs")).willReturn(
- aResponse().withHeader("Content-Type", "text/plain").withBody("healthCheck").withStatus(200)));
-
- String healthCheck = client.healthCheck();
- assertEquals("HealthCheck is correct", "healthCheck", healthCheck);
- }
-}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/appc/ApplicationControllerClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/appc/ApplicationControllerClientTest.java deleted file mode 100644 index 59be8235fe..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/appc/ApplicationControllerClientTest.java +++ /dev/null @@ -1,113 +0,0 @@ -/*-
- * ============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.openecomp.mso.client.appc;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-import java.util.Properties;
-import java.util.UUID;
-
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.onap.appc.client.lcm.model.Action;
-import org.onap.appc.client.lcm.model.ActionIdentifiers;
-import org.onap.appc.client.lcm.model.CheckLockInput;
-import org.onap.appc.client.lcm.model.Status;
-
-public class ApplicationControllerClientTest {
-
- @BeforeClass
- public static void beforeClass() {
- System.setProperty("mso.config.path", "src/test/resources");
- }
-
- @Test
- public void testClientCreation() {
- ApplicationControllerClient client = new ApplicationControllerClient("appc");
- assertEquals(client.getControllerType(), "APPC");
- assertNotNull(client.getAppCClient());
- }
-
- @Test
- public void createRequest_CheckLock_RequestBuilt() {
- ApplicationControllerClient client = new ApplicationControllerClient("APPC");
- ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
- actionIdentifiers.setVnfId("vnfId");
- CheckLockInput checkLockInput = (CheckLockInput) client.createRequest(Action.CheckLock, actionIdentifiers, null,
- "requestId");
- assertEquals(checkLockInput.getAction().name(), "CheckLock");
- }
-
- @Test
- @Ignore // 1802 merge
- public void runCommand_liveAppc() {
- ApplicationControllerClient client = new ApplicationControllerClient("appc");
- ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
- //actionIdentifiers.setVnfId("ca522254-2ba4-4fbd-b15b-0ef0d9cfda5f");
- actionIdentifiers.setVnfId("2d2bf10e-81a5-");
- Status status;
- try {
- status = client.runCommand(Action.Lock, actionIdentifiers, null, UUID.randomUUID().toString());
- } catch (ApplicationControllerOrchestratorException e) {
- status = new Status();
- status.setCode(e.getAppcCode());
- status.setMessage(e.getMessage());
- }
- assertEquals("Status of run command is correct", status.getCode(), 306);
- }
-
- @Test
- @Ignore // 1802 merge
- public void runCommand_CheckLock_RequestBuilt() {
- ApplicationControllerClient client = new ApplicationControllerClient("appc");
- ActionIdentifiers actionIdentifiers = new ActionIdentifiers();
- actionIdentifiers.setVnfId("fusion-vpp-vnf-001");
- Status status;
- try {
- status = client.runCommand(Action.Unlock, actionIdentifiers, null, "requestId");
- } catch (ApplicationControllerOrchestratorException e) {
- status = new Status();
- status.setCode(e.getAppcCode());
- status.setMessage(e.getMessage());
- }
- assertEquals("Status of run command is correct", status.getCode(), 309);
- }
-
- @Test
- public void test_getLCMPropertiesHelper() {
- ApplicationControllerClient client = new ApplicationControllerClient();
- Properties properties = client.getLCMProperties();
- assertEquals(properties.get("topic.read"), "APPC-TEST-AMDOCS2");
- assertEquals(properties.get("topic.write"), "APPC-TEST-AMDOCS1-DEV3");
- assertEquals(properties.get("SDNC-topic.read"), "SDNC-LCM-READ");
- assertEquals(properties.get("SDNC-topic.write"), "SDNC-LCM-WRITE");
- assertEquals(properties.get("topic.read.timeout"), "120000");
- assertEquals(properties.get("client.response.timeout"), "120000");
- assertEquals(properties.get("poolMembers"),
- "uebsb93kcdc.it.att.com:3904,uebsb92kcdc.it.att.com:3904,uebsb91kcdc.it.att.com:3904");
- assertEquals(properties.get("client.key"), "iaEMAfjsVsZnraBP");
- assertEquals(properties.get("client.secret"), "wcivUjsjXzmGFBfxMmyJu9dz");
- assertEquals(properties.get("controllerType"), "appc");
- }
-
-}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestratorTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestratorTest.java deleted file mode 100644 index d9c5654989..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestratorTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/*- - * ============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.openecomp.mso.client.appc;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.Optional;
-import java.util.UUID;
-
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import org.onap.appc.client.lcm.model.Action;
-import org.onap.appc.client.lcm.model.Status;
-
-public class ApplicationControllerOrchestratorTest {
-
- @BeforeClass
- public static void beforeClass() {
- System.setProperty("mso.config.path", "src/test/resources");
- }
-
- @Test
- @Ignore
- public void vnfCommandTest() {
- ApplicationControllerOrchestrator client = new ApplicationControllerOrchestrator();
- Status status;
- try {
- status = client.vnfCommand(Action.Lock, UUID.randomUUID().toString(),
- "3ffdee3c-94d2-45fe-904d-fc1efa0f8b59", Optional.of(""), "appc");
- } catch (ApplicationControllerOrchestratorException e) {
- status = new Status();
- status.setCode(e.getAppcCode());
- status.setMessage(e.getMessage());
- }
- assertEquals("Status of vnfCommand is correct", status.getCode(), 306);
- }
-
- @Test
- @Ignore
- public void vnfCommandTest1() {
- ApplicationControllerOrchestrator client = new ApplicationControllerOrchestrator();
- Status status;
- try {
- status = client.vnfCommand(Action.Unlock, UUID.randomUUID().toString(),
- "ca522254-2ba4-4fbd-b15b-0ef0d9cfda5f", Optional.of(""), "appc");
- } catch (ApplicationControllerOrchestratorException e) {
- status = new Status();
- status.setCode(e.getAppcCode());
- status.setMessage(e.getMessage());
- }
- assertEquals("Status of vnfCommand is correct", status.getCode(), 306);
- }
-}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/appc/ApplicationControllerSupportTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/appc/ApplicationControllerSupportTest.java deleted file mode 100644 index d2d4f5002a..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/appc/ApplicationControllerSupportTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * ============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.openecomp.mso.client.appc; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.appc.client.lcm.model.Status; -import org.openecomp.mso.client.appc.ApplicationControllerSupport.StatusCategory; - -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; - -@RunWith(JUnitParamsRunner.class) -public class ApplicationControllerSupportTest { - - public static Object[][] statusesAndCategories() { - return new Object[][]{ - {100, StatusCategory.NORMAL}, - {200, StatusCategory.ERROR}, - {300, StatusCategory.ERROR}, - {400, StatusCategory.NORMAL}, - {401, StatusCategory.ERROR}, - {500, StatusCategory.NORMAL}, - {501, StatusCategory.ERROR}, - {502, StatusCategory.WARNING}, - {800, StatusCategory.WARNING}, - }; - } - - public static Object[][] statusesAndFinalities() { - return new Object[][]{ - {100, false}, - {200, true}, - {300, true}, - {400, true}, - {500, false}, - {800, true}, - }; - } - - @Test - @Parameters(method = "statusesAndCategories") - public void shouldReturnCategoryForCode(int code, StatusCategory category) throws Exception { - // when - StatusCategory detectedCategory = ApplicationControllerSupport.getCategoryOf(createStatus(code)); - // then - assertThat(detectedCategory).isEqualTo(category); - } - - @Test - @Parameters(method = "statusesAndFinalities") - public void shouldReturnFinalityForCode(int code, boolean expectedFinality) throws Exception { - // when - boolean finality = ApplicationControllerSupport.getFinalityOf(createStatus(code)); - // then - assertThat(finality).isEqualTo(expectedFinality); - } - - private Status createStatus(int code) { - Status status = new Status(); - status.setCode(code); - return status; - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/policy/CommonObjectMapperProviderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/policy/CommonObjectMapperProviderTest.java deleted file mode 100644 index e1b1770180..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/policy/CommonObjectMapperProviderTest.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============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.openecomp.mso.client.policy; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.MapperFeature; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import org.junit.Test; - -public class CommonObjectMapperProviderTest { - - @Test - public void shouldSetCorrectMapperProperties() throws Exception { - // given - CommonObjectMapperProvider provider = new CommonObjectMapperProvider(); - // when - ObjectMapper context = provider.getContext(Object.class); - // then - assertThat(context.isEnabled(MapperFeature.USE_ANNOTATIONS)).isTrue(); - assertThat(context.isEnabled(SerializationFeature.WRAP_ROOT_VALUE)).isFalse(); - assertThat(context.isEnabled(DeserializationFeature.UNWRAP_ROOT_VALUE)).isFalse(); - } -}
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sdnc/beans/SDNCRequestTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sdnc/beans/SDNCRequestTest.java deleted file mode 100644 index 3fd433d017..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sdnc/beans/SDNCRequestTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : SO -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.openecomp.mso.client.sdnc.beans; - -import static org.junit.Assert.*; - - - -import org.junit.Test; -public class SDNCRequestTest { - private SDNCRequest sdncrequest = new SDNCRequest(); - SDNCSvcAction svcaction = SDNCSvcAction.ACTIVATE; - SDNCSvcOperation svcoperation = SDNCSvcOperation.VNF_TOPOLOGY_OPERATION; - @Test - public void testSDNCRequestTest() { - sdncrequest.setRequestId("requestId"); - sdncrequest.setSvcInstanceId("svcInstanceId"); - sdncrequest.setSvcAction(svcaction); - sdncrequest.setSvcOperation(svcoperation); - sdncrequest.setCallbackUrl("callbackUrl"); - sdncrequest.setMsoAction("msoAction"); - sdncrequest.setRequestData("requestData"); - assertEquals(sdncrequest.getRequestId(), "requestId"); - assertEquals(sdncrequest.getSvcInstanceId(), "svcInstanceId"); - assertEquals(sdncrequest.getSvcAction(), svcaction); - assertEquals(sdncrequest.getSvcOperation(), svcoperation); - assertEquals(sdncrequest.getCallbackUrl(), "callbackUrl"); - assertEquals(sdncrequest.getMsoAction(), "msoAction"); - assertEquals(sdncrequest.getRequestData(), "requestData"); - } - @Test - public void testToString(){ - assert(sdncrequest.toString()!=null); - } - -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sdnc/sync/CallbackHeaderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sdnc/sync/CallbackHeaderTest.java deleted file mode 100644 index 995bb5b19c..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sdnc/sync/CallbackHeaderTest.java +++ /dev/null @@ -1,42 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* 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.openecomp.mso.client.sdnc.sync;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class CallbackHeaderTest {
-
- CallbackHeader cbh = new CallbackHeader();
- CallbackHeader cbh1 = new CallbackHeader("reqId", "respCode", "respMsg");
-
- @Test
- public void testCallbackHeader() {
- cbh.setRequestId("requestId");
- cbh.setResponseCode("responseCode");
- cbh.setResponseMessage("responseMessage");
- assertEquals(cbh.getRequestId(), "requestId");
- assertEquals(cbh.getResponseCode(), "responseCode");
- assertEquals(cbh.getResponseMessage(), "responseMessage");
- assert(cbh.toString()!=null);
- }
-
-}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sdnc/sync/ObjectFactoryTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sdnc/sync/ObjectFactoryTest.java deleted file mode 100644 index 04bc7dc132..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sdnc/sync/ObjectFactoryTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* 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.openecomp.mso.client.sdnc.sync;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class ObjectFactoryTest {
- ObjectFactory of = new ObjectFactory();
-
- @Test
- public void testObjectFactory() {
- of.createRequestHeader();
- of.createSDNCAdapterRequest();
- of.createSDNCAdapterResponse();
-
-
- }
-
-}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sdnc/sync/RequestHeaderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sdnc/sync/RequestHeaderTest.java deleted file mode 100644 index 1d04572207..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sdnc/sync/RequestHeaderTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* 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.openecomp.mso.client.sdnc.sync;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class RequestHeaderTest {
- RequestHeader rh = new RequestHeader();
-
- @Test
- public void testRequestHeader() {
- rh.setRequestId("requestId");
- rh.setSvcInstanceId("svcInstanceId");
- rh.setSvcAction("svcAction");
- rh.setSvcOperation("svcOperation");
- rh.setCallbackUrl("callbackUrl");
- rh.setMsoAction("msoAction");
- assertEquals(rh.getRequestId(), "requestId");
- assertEquals(rh.getSvcInstanceId(), "svcInstanceId");
- assertEquals(rh.getSvcAction(), "svcAction");
- assertEquals(rh.getSvcOperation(), "svcOperation");
- assertEquals(rh.getCallbackUrl(), "callbackUrl");
- assertEquals(rh.getMsoAction(), "msoAction");
- assert(rh.toString()!=null);
- }
-}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sdnc/sync/RequestTunablesTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sdnc/sync/RequestTunablesTest.java deleted file mode 100644 index 1219f69874..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sdnc/sync/RequestTunablesTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* 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.openecomp.mso.client.sdnc.sync;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-
-public class RequestTunablesTest {
- MsoPropertiesFactory mpf = new MsoPropertiesFactory();
-
- RequestTunables rt = new RequestTunables("reqId", "msoAction", "operation", "action", mpf);
-
- @Test
- public void testRequestTunables() {
- rt.setReqId("reqId");
- rt.setReqMethod("reqMethod");
- rt.setMsoAction("msoAction");
- rt.setAction("action");
- rt.setOperation("operation");
- rt.setSdncUrl("sdncUrl");
- rt.setTimeout("timeout");
- rt.setAsyncInd("asyncInd");
- rt.setHeaderName("headerName");
- rt.setSdncaNotificationUrl("sdncaNotificationUrl");
- rt.setNamespace("namespace");
- assertEquals(rt.getReqId(), "reqId");
- assertEquals(rt.getReqMethod(), "reqMethod");
- assertEquals(rt.getMsoAction(), "msoAction");
- assertEquals(rt.getAction(), "action");
- assertEquals(rt.getOperation(), "operation");
- assertEquals(rt.getSdncUrl(), "sdncUrl");
- assertEquals(rt.getTimeout(), "timeout");
- assertEquals(rt.getAsyncInd(), "asyncInd");
- assertEquals(rt.getHeaderName(), "headerName");
- assertEquals(rt.getSdncaNotificationUrl(), "sdncaNotificationUrl");
- assertEquals(rt.getNamespace(), "namespace");
- assert(rt.toString()!=null);
- }
-}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterCallbackRequestTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterCallbackRequestTest.java deleted file mode 100644 index 53fbb0a4aa..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterCallbackRequestTest.java +++ /dev/null @@ -1,41 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* 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.openecomp.mso.client.sdnc.sync;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class SDNCAdapterCallbackRequestTest {
-
- SDNCAdapterCallbackRequest sdnccall = new SDNCAdapterCallbackRequest();
- CallbackHeader cbh = new CallbackHeader();
- Object o = new Object();
-
- @Test
- public void testSDNCAdapterCallbackRequest() {
- sdnccall.setCallbackHeader(cbh);
- sdnccall.setRequestData(o);
- assertEquals(sdnccall.getCallbackHeader(), cbh);
- assertEquals(sdnccall.getRequestData(), o);
- assert(sdnccall.toString()!=null);
- }
-
-}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterRequestTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterRequestTest.java deleted file mode 100644 index 6b10f25e70..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sdnc/sync/SDNCAdapterRequestTest.java +++ /dev/null @@ -1,39 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* 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.openecomp.mso.client.sdnc.sync;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class SDNCAdapterRequestTest {
-
- SDNCAdapterRequest adapter = new SDNCAdapterRequest();
- RequestHeader rh = new RequestHeader();
- Object o = new Object();
-
- @Test
- public void testSDNCAdapterRequest() {
- adapter.setRequestHeader(rh);
- adapter.setRequestData(o);
- assertEquals(adapter.getRequestHeader(), rh);
- assertEquals(adapter.getRequestData(), o);
- }
-}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sdnc/sync/SDNCResponseTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sdnc/sync/SDNCResponseTest.java deleted file mode 100644 index d8c23249c4..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sdnc/sync/SDNCResponseTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* 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.openecomp.mso.client.sdnc.sync;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class SDNCResponseTest {
-
- SDNCResponse sdnc = new SDNCResponse("reqId");
- SDNCResponse sdnc1 = new SDNCResponse("reqId", 0, "respMsg");
-
- @Test
- public void testSDNCResponse() {
- sdnc.setReqId("reqId");
- sdnc.setRespCode(0);
- sdnc.setRespMsg("respMsg");
- sdnc.setSdncResp("sdncResp");
- assertEquals(sdnc.getReqId(), "reqId");
- assertEquals(sdnc.getRespCode(), 0);
- assertEquals(sdnc.getRespMsg(), "respMsg");
- assertEquals(sdnc.getSdncResp(), "sdncResp");
- assert(sdnc.toString()!= null);
- }
-}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sndc/SDNCOrchTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sndc/SDNCOrchTest.java deleted file mode 100644 index 724ae4a90d..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sndc/SDNCOrchTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/*- - * ============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.openecomp.mso.client.sndc; - -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.openecomp.mso.bpmn.core.domain.Customer; -import org.openecomp.mso.bpmn.core.domain.ModelInfo; -import org.openecomp.mso.bpmn.core.domain.Request; -import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition; -import org.openecomp.mso.bpmn.core.domain.ServiceInstance; -import org.openecomp.mso.bpmn.core.json.JsonDecomposingException; -import org.openecomp.mso.client.orchestration.SDNCOrchestrator; -import org.openecomp.mso.client.sdnc.sync.SDNCSyncRpcClient; - -public class SDNCOrchTest { - - @BeforeClass - public static void setup() { - System.setProperty("mso.config.path", "src/test/resources/"); - } - - @Ignore // 1802 merge - @Test - public void run () throws JsonDecomposingException { - ServiceDecomposition serviceDecomp = new ServiceDecomposition ("{\"serviceResources\":{}}","123"); - - ServiceInstance servInst = new ServiceInstance(); - servInst.setInstanceId("RaaTest-1-id"); - servInst.setServiceType(""); - servInst.setInstanceName("some-junk-name"); - servInst.setServiceId("a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb"); - - ModelInfo model = new ModelInfo(); - model.setModelInvariantUuid("uuid-miu-svc-011-abcdef"); - model.setModelName("SIModelName1"); - model.setModelUuid(""); - model.setModelVersion("2"); - - Request req = new Request(); - req.setRequestId("RaaCSIRequestId-1"); - req.setSdncRequestId("c0c5e8bf-d5c4-4d81-b2a9-78832c2c789e"); - req.setModelInfo(model); - - Customer cust = new Customer(); - cust.setGlobalSubscriberId("MCBH-1610"); - cust.setSubscriptionServiceType("viprsvc"); - - serviceDecomp.setCustomer(cust); - serviceDecomp.setRequest(req); - serviceDecomp.setCallbackURN("http://localhost:28080/mso/SDNCAdapterCallbackService"); - serviceDecomp.setServiceInstance(servInst); - - SDNCOrchestrator sdncO = new SDNCOrchestrator(); - sdncO.createServiceInstance(serviceDecomp); - } - - @Test - public void runValidateSdncResponse () { - SDNCSyncRpcClient client = new SDNCSyncRpcClient(null, null); - client.validateSDNCResponse("{\"v1:RequestData\": {\"output\": {\"svc-request-id\": \"0ca5bf8f-c944-4318-810b-6ddfbec13cc5\",\"response-code\": \"200\",\"response-message\": \"a\"}}}"); - } -} |