From 38f720752af4d4aad8c4e467a288d9048659f688 Mon Sep 17 00:00:00 2001 From: Rob Daugherty Date: Wed, 14 Mar 2018 02:07:32 -0400 Subject: AT&T 1712 and 1802 release code This is code from AT&T's 1712 and 1802 releases. Change-Id: Ie1e85851e94bc66c4d9514a0226c221939531a04 Issue-ID: SO-425 Signed-off-by: Rob Daugherty --- .../openecomp/mso/bpmn/common/AppCClientTest.java | 119 +++++++++++++++ .../mso/bpmn/common/DecomposeServiceTest.java | 3 +- .../mso/bpmn/common/GenerateVfModuleNameTest.java | 78 ++++++++++ .../org/openecomp/mso/bpmn/common/HomingTest.java | 112 +++++++++++--- .../mso/bpmn/common/ManualHandlingTest.java | 4 +- .../mso/bpmn/common/RainyDayHandlerTest.java | 4 +- .../bpmn/common/ReceiveWorkflowMessageTest.java | 29 ++-- .../mso/bpmn/common/SDNCAdapterRestV2Test.java | 152 +++++++++++++++++++ .../mso/bpmn/common/SPIPropertiesTest.java | 69 +++++++++ .../mso/bpmn/common/VnfAdapterRestV1Test.java | 8 +- .../openecomp/mso/bpmn/common/WorkflowTest.java | 68 ++++++++- .../mso/bpmn/mock/SDNCAdapterAsyncTransformer.java | 157 ++++++++++++++++++++ .../openecomp/mso/bpmn/mock/StubResponseAAI.java | 30 +++- .../openecomp/mso/bpmn/mock/StubResponseAPPC.java | 65 ++++++++ .../mso/bpmn/mock/StubResponsePolicy.java | 29 ++++ .../mso/bpmn/mock/VnfAdapterAsyncTransformer.java | 163 +++++++++++++++++++++ .../openecomp/mso/client/aai/AAIPServerTest.java | 65 -------- .../openecomp/mso/client/aai/AAIValidatorTest.java | 99 ------------- .../org/openecomp/mso/client/aai/EntitiesTest.java | 41 ------ .../adapter/network/NetworkAdapterClientTest.java | 146 ++++++++++++++++++ .../requests/db/RequestsDbAdapterClientTest.java | 50 +++++++ .../client/adapter/vnf/VnfAdapterClientTest.java | 156 ++++++++++++++++++++ .../appc/ApplicationControllerClientTest.java | 93 ++++++------ .../ApplicationControllerOrchestratorTest.java | 73 +++++++++ .../appc/ApplicationControllerSupportTest.java | 97 ++++++------ .../openecomp/mso/client/sndc/SDNCOrchTest.java | 82 +++++++++++ 26 files changed, 1643 insertions(+), 349 deletions(-) create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/AppCClientTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenerateVfModuleNameTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterRestV2Test.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SPIPropertiesTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/SDNCAdapterAsyncTransformer.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseAPPC.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterAsyncTransformer.java delete mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/aai/AAIPServerTest.java delete mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/aai/AAIValidatorTest.java delete mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/aai/EntitiesTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClientTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/requests/db/RequestsDbAdapterClientTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClientTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestratorTest.java create mode 100644 bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sndc/SDNCOrchTest.java (limited to 'bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso') 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 new file mode 100644 index 0000000000..8561b030eb --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/AppCClientTest.java @@ -0,0 +1,119 @@ +/*- + * ============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 variables = new HashMap(); + 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 setVariablesInstance(){ + Map variables = new HashMap(); + 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\": \"\", \"identy-url\":\"\", \"tenant-id\": \"\"}, \"Hello\":\"Whats up\"" ); + return variables; + } +} 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 index 7295cd8e10..873e87cc49 100644 --- 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 @@ -45,8 +45,7 @@ public class DecomposeServiceTest extends WorkflowTest { @Test @Deployment(resources = {"subprocess/BuildingBlock/DecomposeService.bpmn"}) public void testDecomposeService_success() throws Exception{ - MockGetServiceResourcesCatalogData("cmw-123-456-789", "/getCatalogServiceResourcesData.json", "1.0"); - + MockGetServiceResourcesCatalogData("cmw-123-456-789", "1.0", "/getCatalogServiceResourcesDataWithConfig.json"); String businessKey = UUID.randomUUID().toString(); Map variables = new HashMap<>(); 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 new file mode 100644 index 0000000000..051d935527 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/GenerateVfModuleNameTest.java @@ -0,0 +1,78 @@ +/*- + * ============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 = + "" + EOL + + " " + EOL + + " CREATE_VF_MODULE" + EOL + + " PORTAL" + EOL + + " " + EOL + + " " + EOL + + " STMTN5MMSC22" + EOL + + " STMTN5MMSC22-MMSC::module-0-0" + EOL + + " MMSC::module-0" + EOL + + " 973ed047-d251-4fb9-bf1a-65b8949e0a73" + EOL + + " 1.0" + EOL + + " 00000000-0000-0000-0000-000000000000" + EOL + + " MDTWNJ21" + EOL + + " fba1bd1e195a404cacb9ce17a9b2b421" + EOL + + " " + EOL + + " " + EOL + + "" + EOL; + + MockGetGenericVnfById(".*", "GenericFlows/getGenericVnfByNameResponse.xml"); + RuntimeService runtimeService = processEngineRule.getRuntimeService(); + Map variables = new HashMap(); + 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/HomingTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/HomingTest.java index 3210fe8fc7..79bc96d6fd 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/HomingTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/HomingTest.java @@ -35,11 +35,11 @@ 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; import org.openecomp.mso.bpmn.common.WorkflowTest; @@ -134,6 +134,7 @@ public class HomingTest extends WorkflowTest { } @Test + @Ignore // 1802 merge @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) public void testHoming_success_2AR1Vnf() throws Exception { @@ -167,7 +168,7 @@ public class HomingTest extends WorkflowTest { 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); @@ -177,6 +178,7 @@ public class HomingTest extends WorkflowTest { } @Test + @Ignore // 1802 merge @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) public void testHoming_success_2AR1Vnf2Net() throws Exception { @@ -230,26 +232,23 @@ public class HomingTest extends WorkflowTest { } @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 -//System.out.println("At start of testHoming_success_vnfResourceList"); - MockGetServiceResourcesCatalogDataByModelUuid("2f7f309d-c842-4644-a2e4-34167be5eeb4", "/BuildingBlocks/catalogResp.json"); - //MockGetServiceResourcesCatalogData("1cc4e2e4-eb6e-404d-a66f-c8733cedcce8", "5.0", "/BuildingBlocks/catalogResp.json"); + MockGetServiceResourcesCatalogDataByModelUuid("2f7f309d-c842-4644-a2e4-34167be5eeb4", "/BuildingBlocks/catalogResp.json"); String busKey = UUID.randomUUID().toString(); Map 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 vnfResourceList = sd.getServiceVnfs(); -//System.out.println(" vnfResourceList = " + vnfResourceList); vnfResourceList.get(0).setResourceId("test-resource-id-000"); - - // Invoke Homing - + + // Invoke Homing + mockSNIRO(); String businessKey = UUID.randomUUID().toString(); @@ -259,13 +258,13 @@ public class HomingTest extends WorkflowTest { 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"); @@ -280,10 +279,55 @@ public class HomingTest extends WorkflowTest { //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 variables = new HashMap(); + 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 { @@ -322,6 +366,7 @@ public class HomingTest extends WorkflowTest { } @Test + @Ignore // 1802 merge @Deployment(resources = {"subprocess/BuildingBlock/Homing.bpmn", "subprocess/ReceiveWorkflowMessage.bpmn"}) public void testHoming_error_sniroNoSolution() throws Exception { mockSNIRO(); @@ -383,7 +428,7 @@ public class HomingTest extends WorkflowTest { 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 variables) { @@ -435,12 +480,30 @@ public class HomingTest extends WorkflowTest { } + private void setVariablesExistingLicense(Map 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 + "\" } }"; + 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 + "\", \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ " + licenseList + " ] } }"; + 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; } @@ -448,13 +511,13 @@ public class HomingTest extends WorkflowTest { 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 + "\" } }"; + 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 + "\", \"entitlementPoolList\" : [ " + enList + " ], \"licenseKeyGroupList\" : [ " + licenseList + " ] } }"; + 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 variables, String requestId, String siId) { variables.put("isDebugLogEnabled", "true"); variables.put("mso-request-id", requestId); @@ -469,9 +532,14 @@ public class HomingTest extends WorkflowTest { "}"; 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\",\"optimizer\":[\"placement\",\"license\"],\"numSolutions\":1,\"timeout\":600},\"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\"}}]},\"policyId\":[],\"serviceInstanceId\":\"testServiceInstanceId123\",\"orderInfo\":\"{\\\"requestParameters\\\":null}\"}}"; + 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},\"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\"}}]},\"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},\"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/ManualHandlingTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/ManualHandlingTest.java index a7c2d19aa0..85a0bb789d 100644 --- 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 @@ -74,10 +74,12 @@ public class ManualHandlingTest extends WorkflowTest { variables.put("vnfType", "Y"); variables.put("currentActivity", "BB1"); variables.put("workStep", "1"); - variables.put("failedActivity", ""); + 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(); 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 index 65575ba861..d450dad05e 100644 --- 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 @@ -49,7 +49,6 @@ import org.openecomp.mso.bpmn.core.WorkflowException; public class RainyDayHandlerTest extends WorkflowTest { @Test - @Ignore // IGNORED FOR 1710 MERGE TO ONAP @Deployment(resources = { "subprocess/BuildingBlock/RainyDayHandler.bpmn", "subprocess/BuildingBlock/ManualHandling.bpmn" @@ -67,6 +66,7 @@ public class RainyDayHandlerTest extends WorkflowTest { variables.put("failedActivity", ""); variables.put("errorCode", "123"); variables.put("errorText", "update failed"); + variables.put("vnfName", "vSAMP1"); MockPolicyAbort(); @@ -82,4 +82,4 @@ public class RainyDayHandlerTest extends WorkflowTest { -} \ No newline at end of file +} 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 index a806515974..64b8ba53b7 100644 --- 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 @@ -17,7 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - + package org.openecomp.mso.bpmn.common; import static org.junit.Assert.assertEquals; @@ -53,9 +53,9 @@ public class ReceiveWorkflowMessageTest extends WorkflowTest { " \"eventType\": \"UCPE-ACTIVATION\"," + EOL + " \"eventCorrelatorType\": \"UCPE-HOST-NAME\"," + EOL + " \"eventCorrelator\": \"((CORRELATOR))\"," + EOL + - " \"params\": {\"entry\":[" + EOL + - " {\"key\": \"success-indicator\", \"value\":\"Y\"}" + EOL + - " ]}" +EOL + + " \"params\": {" + EOL + + " \"success-indicator\":\"Y\"" + EOL + + " }" +EOL + " }" + EOL + "}" + EOL); @@ -65,10 +65,10 @@ public class ReceiveWorkflowMessageTest extends WorkflowTest { " \"eventType\": \"UCPE-ACTIVATION\"," + EOL + " \"eventCorrelatorType\": \"UCPE-HOST-NAME\"," + EOL + " \"eventCorrelator\": \"((CORRELATOR))\"," + EOL + - " \"params\": {\"entry\":[" + EOL + - " {\"key\": \"success-indicator\", \"value\":\"N\"}" + EOL + - " {\"key\": \"error-message\", \"value\":\"SOMETHING BAD HAPPENED\"}" + EOL + - " ]}" +EOL + + " \"params\": {" + EOL + + " \"success-indicator\":\"N\"," + EOL + + " \"error-message\":\"SOMETHING BAD HAPPENED\"" + EOL + + " }" +EOL + " }" + EOL + "}" + EOL); } @@ -81,7 +81,7 @@ public class ReceiveWorkflowMessageTest extends WorkflowTest { "subprocess/ReceiveWorkflowMessage.bpmn" }) public void happyPath() throws Exception { - + logStart(); String businessKey = UUID.randomUUID().toString(); @@ -100,7 +100,7 @@ public class ReceiveWorkflowMessageTest extends WorkflowTest { System.out.println("Response:\n" + response); assertTrue(response.contains("\"SDNCEvent\"")); assertTrue((boolean)getVariableFromHistory(businessKey, "RCVWFMSG_SuccessIndicator")); - + logEnd(); } @@ -112,22 +112,23 @@ public class ReceiveWorkflowMessageTest extends WorkflowTest { "subprocess/ReceiveWorkflowMessage.bpmn" }) public void timeout() throws Exception { + logStart(); String businessKey = UUID.randomUUID().toString(); Map variables = new HashMap<>(); variables.put("mso-request-id", "dffbae0e-5588-4bd6-9749-b0f0adb52312"); variables.put("isDebugLogEnabled", "true"); - variables.put("RCVWFMSG_timeout", "PT0.1S"); + 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); @@ -136,7 +137,7 @@ public class ReceiveWorkflowMessageTest extends WorkflowTest { 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/SDNCAdapterRestV2Test.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterRestV2Test.java new file mode 100644 index 0000000000..90336bb391 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SDNCAdapterRestV2Test.java @@ -0,0 +1,152 @@ +/*- + * ============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 variables = new HashMap(); + 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/SPIPropertiesTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SPIPropertiesTest.java new file mode 100644 index 0000000000..e9a5492b6f --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/SPIPropertiesTest.java @@ -0,0 +1,69 @@ +/*- + * ============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/VnfAdapterRestV1Test.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/VnfAdapterRestV1Test.java index fb029fa740..b143204fc9 100644 --- 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 @@ -34,6 +34,7 @@ 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; @@ -228,6 +229,7 @@ public class VnfAdapterRestV1Test extends WorkflowTest { } @Test + @Ignore // 1802 merge @Deployment(resources = { "subprocess/VnfAdapterRestV1.bpmn" }) @@ -252,13 +254,14 @@ public class VnfAdapterRestV1Test extends WorkflowTest { String response = (String) getVariableFromHistory(businessKey, "vnfAdapterRestV1Response"); System.out.println("Response:\n" + response); - assertTrue(response.contains("")); + assertTrue(response!=null && response.contains("")); assertTrue((boolean) getVariableFromHistory(businessKey, "VNFREST_SuccessIndicator")); logEnd(); } @Test + @Ignore // 1802 merge @Deployment(resources = { "subprocess/VnfAdapterRestV1.bpmn" }) @@ -290,6 +293,7 @@ public class VnfAdapterRestV1Test extends WorkflowTest { } @Test + @Ignore // 1802 merge @Deployment(resources = { "subprocess/VnfAdapterRestV1.bpmn" }) @@ -320,6 +324,7 @@ public class VnfAdapterRestV1Test extends WorkflowTest { logEnd(); } + @Ignore // 1802 merge @Test @Deployment(resources = { "subprocess/VnfAdapterRestV1.bpmn" @@ -352,6 +357,7 @@ public class VnfAdapterRestV1Test extends WorkflowTest { } @Test + @Ignore // 1802 merge @Deployment(resources = { "subprocess/VnfAdapterRestV1.bpmn" }) 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 index 849aae8aaa..9b8a249511 100644 --- 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 @@ -22,6 +22,8 @@ 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; @@ -30,8 +32,6 @@ import java.lang.management.RuntimeMXBean; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -61,6 +61,7 @@ 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; @@ -77,12 +78,10 @@ import org.openecomp.mso.bpmn.common.workflow.service.VnfAdapterNotifyServiceImp 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.utils.CamundaDBSetup; import org.openecomp.mso.bpmn.core.PropertyConfigurationSetup; import org.openecomp.mso.bpmn.core.domain.Resource; import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition; - -import static org.openecomp.mso.bpmn.core.json.JsonUtils.*; +import org.openecomp.mso.bpmn.core.utils.CamundaDBSetup; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -1501,17 +1500,72 @@ public class WorkflowTest { for(Resource resource:resourceList){ resourceId = resource.getResourceId(); } + //TODO.. most other locations refer to solutionInfo.placementInfo String homingList = getJsonValue(content, "solutionInfo.placement"); - JSONArray placementArr = new JSONArray(homingList); + 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 = new JSONArray(licenseInfoList); + 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.placementInfo"); + 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")+25, requestBody.indexOf("")); + String requestId = requestBody.substring(requestBody.indexOf("")+23, requestBody.indexOf("")); + + 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/StubResponseAAI.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseAAI.java index f9a6543387..6efd992566 100644 --- 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 @@ -826,6 +826,14 @@ public class StubResponseAAI { .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)) @@ -867,7 +875,7 @@ public class StubResponseAAI { /* AAI Pserver Queries */ public static void MockGetPserverByVnfId(String vnfId, String responseFile, int statusCode) { - stubFor(put(urlMatching("/v10/query.*")) + stubFor(put(urlMatching("/aai/v1[0-9]/query.*")) .willReturn(aResponse() .withStatus(statusCode) .withHeader("Content-Type", "application/json") @@ -875,7 +883,7 @@ public class StubResponseAAI { } public static void MockGetGenericVnfsByVnfId(String vnfId, String responseFile, int statusCode) { - stubFor(get(urlMatching("/v10/network/generic-vnfs/.*")) + stubFor(get(urlMatching("/aai/v1[0-9]/network/generic-vnfs/.*")) .willReturn(aResponse() .withStatus(statusCode) .withHeader("Content-Type", "application/json; charset=utf-8") @@ -883,12 +891,28 @@ public class StubResponseAAI { } public static void MockSetInMaintFlagByVnfId(String vnfId, int statusCode) { - stubFor(patch(urlMatching("/v10/network/generic-vnfs/.*")) + 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(){ 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 new file mode 100644 index 0000000000..e94f0142d2 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponseAPPC.java @@ -0,0 +1,65 @@ +/*- + * ============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/StubResponsePolicy.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/StubResponsePolicy.java index fdaede1b39..fd13084613 100644 --- 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 @@ -61,6 +61,21 @@ public class StubResponsePolicy { .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"))); + } @@ -86,6 +101,20 @@ public class StubResponsePolicy { .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/VnfAdapterAsyncTransformer.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterAsyncTransformer.java new file mode 100644 index 0000000000..2eebe94f2b --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/mock/VnfAdapterAsyncTransformer.java @@ -0,0 +1,163 @@ +/*- + * ============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("")+17, requestBody.indexOf("")); + + String vnfId = requestBody.substring(requestBody.indexOf("")+7, requestBody.indexOf("")); + String vfModuleId = requestBody.substring(requestBody.indexOf("")+12, requestBody.indexOf("")); + String messageId = requestBody.substring(requestBody.indexOf("")+11, requestBody.indexOf("")); + String requestId = requestBody.substring(requestBody.indexOf("")+11, requestBody.indexOf("")); + + 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/client/aai/AAIPServerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/aai/AAIPServerTest.java deleted file mode 100644 index bee0a828ea..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/aai/AAIPServerTest.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.client.aai; - -import java.io.File; -import java.io.IOException; -import java.security.NoSuchAlgorithmException; -import java.util.List; -import java.util.UUID; - -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.onap.aai.domain.yang.Pserver; -import static org.junit.Assert.assertEquals; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -public class AAIPServerTest { - - @BeforeClass - public static void setUp() { - System.setProperty("mso.config.path", "src/test/resources"); - System.setProperty("javax.net.ssl.keyStore", "C:/etc/ecomp/mso/config/msoClientKeyStore.jks"); - System.setProperty("javax.net.ssl.keyStorePassword", "mso4you"); - System.setProperty("javax.net.ssl.trustStore", "C:/etc/ecomp/mso/config/msoTrustStore.jks"); - System.setProperty("javax.net.ssl.trustStorePassword", "mso_Domain2.0_4you"); - } - - @Test - @Ignore // IGNORED FOR 1710 MERGE TO ONAP - public void pserverTest() throws JsonParseException, JsonMappingException, IOException, NoSuchAlgorithmException { - AAIRestClientImpl client = new AAIRestClientImpl(); - File file = new File("src/test/resources/__files/AAI/pserver.json"); - List list = client.getListOfPservers(file); - - assertEquals("", list.get(0).getHostname(), "test"); - } - - @Test - @Ignore // IGNORED FOR 1710 MERGE TO ONAP - public void pserverActualTest() throws JsonParseException, JsonMappingException, IOException, NoSuchAlgorithmException { - AAIRestClientImpl client = new AAIRestClientImpl(); - List list = client.getPhysicalServerByVnfId("d946afed-8ebe-4c5d-9665-54fcc043b8e7", UUID.randomUUID().toString()); - assertEquals("", list.size(), 0); - } - -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/aai/AAIValidatorTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/aai/AAIValidatorTest.java deleted file mode 100644 index 2272f31685..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/aai/AAIValidatorTest.java +++ /dev/null @@ -1,99 +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.aai; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.when; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.List; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aai.domain.yang.GenericVnf; -import org.onap.aai.domain.yang.Pserver; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; - -@RunWith(MockitoJUnitRunner.class) -public class AAIValidatorTest { - - @Mock - protected AAIRestClient client; - String vnfName = "testVnf"; - String uuid = "UUID"; - AAIValidatorImpl validator; - - @Before - public void init(){ - validator = new AAIValidatorImpl(); - validator.setClient(client); - } - - public List getPservers(boolean locked){ - Pserver pserver = new Pserver(); - pserver.setInMaint(locked); - List pservers = new ArrayList(); - pservers.add(pserver); - return pservers; - } - - public GenericVnf createGenericVnfs(boolean locked){ - GenericVnf genericVnf = new GenericVnf(); - genericVnf.setInMaint(locked); - - return genericVnf; - } - - @Test - public void test_IsPhysicalServerLocked_True() throws IOException{ - when(client.getPhysicalServerByVnfId(vnfName,uuid)).thenReturn(getPservers(true)); - boolean locked = validator.isPhysicalServerLocked(vnfName, uuid); - assertEquals(true, locked); - } - - @Test - public void test_IsPhysicalServerLocked_False() throws JsonParseException, JsonMappingException, UnsupportedEncodingException, IOException { - when(client.getPhysicalServerByVnfId(vnfName,uuid)).thenReturn(getPservers(false)); - boolean locked = validator.isPhysicalServerLocked(vnfName, uuid); - assertEquals(false, locked); - } - - @Test - public void test_IsVNFLocked_False() throws Exception{ - when(client.getVnfByName(vnfName,uuid)).thenReturn(createGenericVnfs(false)); - boolean locked = validator.isVNFLocked(vnfName, uuid); - assertEquals(false, locked); - } - - @Test - public void test_IsVNFLocked_True() throws Exception{ - when(client.getVnfByName(vnfName,uuid)).thenReturn(createGenericVnfs(true)); - boolean locked = validator.isVNFLocked(vnfName, uuid); - assertEquals(true,locked ); - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/aai/EntitiesTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/aai/EntitiesTest.java deleted file mode 100644 index 09c2ab5c30..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/aai/EntitiesTest.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.client.aai; - -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; - -public class EntitiesTest { - - private String packageName = "org.openecomp.mso.client.aai.entities"; - - @Test - public void validate() { - Validator validator = ValidatorBuilder.create().with(new SetterMustExistRule(), new GetterMustExistRule()) - .with(new SetterTester(), new GetterTester()).build(); - validator.validate(packageName); - } -} 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 new file mode 100644 index 0000000000..0584bea012 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/network/NetworkAdapterClientTest.java @@ -0,0 +1,146 @@ +/*- + * ============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 new file mode 100644 index 0000000000..2c35151895 --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/requests/db/RequestsDbAdapterClientTest.java @@ -0,0 +1,50 @@ +/*- + * ============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/vnf/VnfAdapterClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClientTest.java new file mode 100644 index 0000000000..21448256ed --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/adapter/vnf/VnfAdapterClientTest.java @@ -0,0 +1,156 @@ +/*- + * ============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 index 2b082f1b8d..7fe32880c6 100644 --- 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 @@ -25,74 +25,79 @@ import static org.junit.Assert.assertEquals; import java.util.Properties; import java.util.UUID; -import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; -import org.openecomp.appc.client.lcm.model.Action; -import org.openecomp.appc.client.lcm.model.ActionIdentifiers; -import org.openecomp.appc.client.lcm.model.CheckLockInput; -import org.openecomp.appc.client.lcm.model.Flags; -import org.openecomp.appc.client.lcm.model.Status; +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 { - private static ApplicationControllerClient client; - private static ApplicationControllerSupport support; - @BeforeClass public static void beforeClass() { - client = new ApplicationControllerClient(); - support = new ApplicationControllerSupport(); - client.appCSupport = support; System.setProperty("mso.config.path", "src/test/resources"); - - } - - @AfterClass - public static void afterClass() throws Exception { - client.shutdownclient(); } @Test - @Ignore // IGNORED FOR 1710 MERGE TO ONAP - public void createRequest_CheckLock_RequestBuilt() throws Exception { - - org.springframework.test.util.ReflectionTestUtils.setField(support, "lcmModelPackage", - "org.openecomp.appc.client.lcm.model"); - Flags flags = new Flags(); + public void createRequest_CheckLock_RequestBuilt() { + ApplicationControllerClient client = new ApplicationControllerClient(); ActionIdentifiers actionIdentifiers = new ActionIdentifiers(); actionIdentifiers.setVnfId("vnfId"); - CheckLockInput checkLockInput = (CheckLockInput) client.createRequest(Action.CheckLock, actionIdentifiers, - flags, null, "requestId"); + CheckLockInput checkLockInput = (CheckLockInput) client.createRequest(Action.CheckLock, actionIdentifiers, null, + "requestId"); assertEquals(checkLockInput.getAction().name(), "CheckLock"); } @Test - @Ignore // IGNORED FOR 1710 MERGE TO ONAP - public void runCommand_liveAppc() throws Exception { - org.springframework.test.util.ReflectionTestUtils.setField(support, "lcmModelPackage", - "org.openecomp.appc.client.lcm.model"); - Flags flags = new Flags(); + @Ignore // 1802 merge + public void runCommand_liveAppc() { + ApplicationControllerClient client = new ApplicationControllerClient(); ActionIdentifiers actionIdentifiers = new ActionIdentifiers(); - actionIdentifiers.setVnfId("ca522254-2ba4-4fbd-b15b-0ef0d9cfda5f"); - - // CheckLockInput checkLockInput = (CheckLockInput) - // client.createRequest(Action.CheckLock,actionIdentifiers,flags,null,"requestId"); - Status status = client.runCommand(Action.Lock, actionIdentifiers, flags, null, UUID.randomUUID().toString()); + //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 // IGNORED FOR 1710 MERGE TO ONAP - public void runCommand_CheckLock_RequestBuilt() throws Exception { - org.springframework.test.util.ReflectionTestUtils.setField(support, "lcmModelPackage", - "org.openecomp.appc.client.lcm.model"); - Flags flags = new Flags(); + @Ignore // 1802 merge + public void runCommand_CheckLock_RequestBuilt() { + ApplicationControllerClient client = new ApplicationControllerClient(); ActionIdentifiers actionIdentifiers = new ActionIdentifiers(); actionIdentifiers.setVnfId("fusion-vpp-vnf-001"); - Status status = client.runCommand(Action.CheckLock, actionIdentifiers, flags, null, "requestId"); - assertEquals("Status of run command is correct", status.getCode(), 400); + 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.write"), "APPC-TEST-AMDOCS1-DEV3"); + assertEquals(properties.get("topic.read.timeout"), "120000"); + assertEquals(properties.get("client.response.timeout"), "120000"); + assertEquals(properties.get("topic.read"), "APPC-TEST-AMDOCS2"); + 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"); + } + +} \ 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 new file mode 100644 index 0000000000..bd026d0b6d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestratorTest.java @@ -0,0 +1,73 @@ +/*- + * ============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("")); + } 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("")); + } 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 index 0a323e43d8..d2d4f5002a 100644 --- 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 @@ -22,62 +22,63 @@ package org.openecomp.mso.client.appc; import static org.assertj.core.api.Assertions.assertThat; -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; import org.junit.Test; import org.junit.runner.RunWith; -import org.openecomp.appc.client.lcm.model.Status; +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[][] 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}, - }; - } + 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 = "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); - } + @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; - } -} \ No newline at end of file + 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/sndc/SDNCOrchTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sndc/SDNCOrchTest.java new file mode 100644 index 0000000000..724ae4a90d --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/sndc/SDNCOrchTest.java @@ -0,0 +1,82 @@ +/*- + * ============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\"}}}"); + } +} -- cgit 1.2.3-korg