diff options
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/test')
10 files changed, 176 insertions, 90 deletions
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/BuildingBlockValidatorRunnerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/BuildingBlockValidatorRunnerTest.java index 2c0377d11c..f4fe6d7158 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/BuildingBlockValidatorRunnerTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/BuildingBlockValidatorRunnerTest.java @@ -47,7 +47,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {ValidationConfig.class}) -public class BuildingBlockValidatorRunnerTest { +public class BuildingBlockValidatorRunnerTest extends BuildingBlockValidatorRunner { @Rule public ExpectedException thrown = ExpectedException.none(); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/WorkflowValidatorRunnerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/WorkflowValidatorRunnerTest.java index 0143e567af..596eced1d1 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/WorkflowValidatorRunnerTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/WorkflowValidatorRunnerTest.java @@ -45,7 +45,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {ValidationConfig.class}) -public class WorkflowValidatorRunnerTest { +public class WorkflowValidatorRunnerTest extends WorkflowValidatorRunner { @Rule public ExpectedException thrown = ExpectedException.none(); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyDisabledValidator.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyDisabledValidator.java index af64ed2de6..544d370a3c 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyDisabledValidator.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyDisabledValidator.java @@ -23,8 +23,8 @@ package org.onap.so.bpmn.common.listener.validation; import java.util.Collections; import java.util.Optional; import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.onap.so.bpmn.common.listener.Skip; import org.onap.so.bpmn.common.listener.validation.PreBuildingBlockValidator; +import org.onap.so.listener.Skip; import org.springframework.stereotype.Component; @Component diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/ValidationConfig.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/ValidationConfig.java index 068f433dd5..a3692a50b7 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/ValidationConfig.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/ValidationConfig.java @@ -21,13 +21,13 @@ package org.onap.so.bpmn.common.listener.validation; import org.onap.so.bpmn.common.DefaultToShortClassNameBeanNameGenerator; -import org.onap.so.bpmn.common.listener.ListenerRunner; import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.listener.ListenerRunner; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @Configuration -@ComponentScan(basePackageClasses = {ExceptionBuilder.class, ListenerRunner.class}, +@ComponentScan(basePackageClasses = {ExceptionBuilder.class, ListenerRunner.class, WorkflowValidatorRunner.class}, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class) public class ValidationConfig { diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/util/CryptoHandlerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/util/CryptoHandlerTest.java deleted file mode 100644 index 273e9f0e3c..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/util/CryptoHandlerTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.common.util; - -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import static org.junit.Assert.assertEquals; - -public class CryptoHandlerTest { - private static final String plainPswd = "mso0206"; - private CryptoHandler cryptoHandler; - private static String encryptPwd; - - - @Before - public void setup() { - cryptoHandler = new CryptoHandler(); - encryptPwd = cryptoHandler.encryptMsoPassword(plainPswd); - } - - @Test - @Ignore // ignored until we can mock the properties file. - public void getMsoAaiPasswordTest() { - assertEquals(plainPswd, cryptoHandler.getMsoAaiPassword()); - } - - @Test - public void encryptMsoPasswordTest() { - assertEquals(plainPswd, cryptoHandler.decryptMsoPassword(cryptoHandler.encryptMsoPassword(plainPswd))); - } - - @Test - public void decryptMsoPasswordTest() { - assertEquals(plainPswd, cryptoHandler.decryptMsoPassword(encryptPwd)); - } -} diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java index 80373eb760..18e08917ed 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/ExecuteBuildlingBlockRainyDayTest.java @@ -105,7 +105,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { rainyDayHandlerStatus.setWorkStep(ASTERISK); doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", - "st1", "vnft1", "7000", "*", "errorMessage"); + "st1", "vnft1", "7000", "*", "errorMessage", "*"); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); assertEquals("Rollback", delegateExecution.getVariable("handlingCode")); @@ -128,7 +128,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { rainyDayHandlerStatus.setWorkStep(ASTERISK); doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", - "st1", "vnft1", ASTERISK, ASTERISK, "errorMessage"); + "st1", "vnft1", ASTERISK, ASTERISK, "errorMessage", "*"); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); assertEquals("Rollback", delegateExecution.getVariable("handlingCode")); assertEquals(5, delegateExecution.getVariable("maxRetries")); @@ -141,7 +141,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { vnf.setVnfType("vnft1"); delegateExecution.setVariable("aLaCarte", true); doReturn(null).when(MOCK_catalogDbClient).getRainyDayHandlerStatus(isA(String.class), isA(String.class), - isA(String.class), isA(String.class), isA(String.class), isA(String.class)); + isA(String.class), isA(String.class), isA(String.class), isA(String.class), isA(String.class)); delegateExecution.setVariable("suppressRollback", false); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); @@ -152,7 +152,8 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { @Test public void queryRainyDayTableExceptionTest() { doThrow(RuntimeException.class).when(MOCK_catalogDbClient).getRainyDayHandlerStatus(isA(String.class), - isA(String.class), isA(String.class), isA(String.class), isA(String.class), isA(String.class)); + isA(String.class), isA(String.class), isA(String.class), isA(String.class), isA(String.class), + isA(String.class)); delegateExecution.setVariable("aLaCarte", true); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); delegateExecution.setVariable("suppressRollback", false); @@ -178,7 +179,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { rainyDayHandlerStatus.setSecondaryPolicy("Abort"); doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", - "st1", "vnft1", "7000", "*", "errorMessage"); + "st1", "vnft1", "7000", "*", "errorMessage", "*"); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, false); @@ -203,7 +204,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { rainyDayHandlerStatus.setSecondaryPolicy("Abort"); doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", - "st1", "vnft1", "7000", "*", "errorMessage"); + "st1", "vnft1", "7000", "*", "errorMessage", "*"); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); @@ -229,7 +230,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { rainyDayHandlerStatus.setSecondaryPolicy("Abort"); doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", - "st1", "vnft1", "7000", "*", "errorMessage"); + "st1", "vnft1", "7000", "*", "errorMessage", "*"); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); @@ -255,7 +256,7 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { rainyDayHandlerStatus.setSecondaryPolicy("Abort"); doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", - "st1", "vnft1", "7000", "*", "errorMessage"); + "st1", "vnft1", "7000", "*", "errorMessage", "*"); executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); @@ -272,4 +273,52 @@ public class ExecuteBuildlingBlockRainyDayTest extends BaseTest { assertEquals("Abort", delegateExecution.getVariable("handlingCode")); } + @Test + public void queryRainyDayTableServiceRoleNotDefined() throws Exception { + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); + serviceInstance.getModelInfoServiceInstance().setServiceRole("sr1"); + vnf.setVnfType("vnft1"); + delegateExecution.setVariable("aLaCarte", true); + delegateExecution.setVariable("suppressRollback", false); + delegateExecution.setVariable("WorkflowExceptionCode", "7000"); + RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); + rainyDayHandlerStatus.setErrorCode("7000"); + rainyDayHandlerStatus.setFlowName("AssignServiceInstanceBB"); + rainyDayHandlerStatus.setServiceType("st1"); + rainyDayHandlerStatus.setVnfType("vnft1"); + rainyDayHandlerStatus.setPolicy("Rollback"); + rainyDayHandlerStatus.setWorkStep(ASTERISK); + + doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", + "st1", "vnft1", "7000", "*", "errorMessage", "sr1"); + + executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); + assertEquals("Rollback", delegateExecution.getVariable("handlingCode")); + } + + @Test + public void queryRainyDayTableServiceRoleNC() throws Exception { + customer.getServiceSubscription().getServiceInstances().add(serviceInstance); + serviceInstance.getModelInfoServiceInstance().setServiceType("st1"); + serviceInstance.getModelInfoServiceInstance().setServiceRole("NETWORK-COLLECTION"); + vnf.setVnfType("vnft1"); + delegateExecution.setVariable("aLaCarte", true); + delegateExecution.setVariable("suppressRollback", false); + delegateExecution.setVariable("WorkflowExceptionCode", "7000"); + RainyDayHandlerStatus rainyDayHandlerStatus = new RainyDayHandlerStatus(); + rainyDayHandlerStatus.setErrorCode("7000"); + rainyDayHandlerStatus.setFlowName("ActivateServiceInstanceBB"); + rainyDayHandlerStatus.setServiceType("st1"); + rainyDayHandlerStatus.setVnfType("vnft1"); + rainyDayHandlerStatus.setPolicy("Abort"); + rainyDayHandlerStatus.setWorkStep(ASTERISK); + + doReturn(rainyDayHandlerStatus).when(MOCK_catalogDbClient).getRainyDayHandlerStatus("AssignServiceInstanceBB", + "st1", "vnft1", "7000", "*", "errorMessage", "NETWORK-COLLECTION"); + + executeBuildingBlockRainyDay.queryRainyDayTable(delegateExecution, true); + assertEquals("Abort", delegateExecution.getVariable("handlingCode")); + } + } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerActionTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerActionTest.java index 32db3a7bf6..48c6995715 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerActionTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/appc/ApplicationControllerActionTest.java @@ -481,4 +481,100 @@ public class ApplicationControllerActionTest extends BaseTest { assertEquals(expectedErrorCode, appCAction.getErrorCode()); } + @Test + public void runAppCCommand_Snapshot_vmIdList_Empty_Test() + throws ApplicationControllerOrchestratorException, JsonProcessingException { + Action action = Action.Snapshot; + String msoRequestId = "testMsoRequestId"; + String vnfId = "testVnfId"; + Optional<String> payload = Optional.empty(); + HashMap<String, String> payloadInfo = new HashMap<String, String>(); + payloadInfo.put("identityUrl", "testIdentityUrl"); + String controllerType = "testControllerType"; + + Status status = new Status(); + Optional<String> otherPayloadVm = PayloadClient.snapshotFormat("", "identityUrl"); + doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, null, otherPayloadVm, controllerType); + + appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType); + + verify(client, times(0)).vnfCommand(action, msoRequestId, vnfId, null, otherPayloadVm, controllerType); + } + + @Test + public void runAppCCommand_Snapshot_vmId_null_Test() + throws ApplicationControllerOrchestratorException, JsonProcessingException { + Action action = Action.Snapshot; + String msoRequestId = "testMsoRequestId"; + String vnfId = "testVnfId"; + Optional<String> payload = Optional.empty(); + HashMap<String, String> payloadInfo = new HashMap<String, String>(); + payloadInfo.put("identityUrl", "testIdentityUrl"); + + JSONObject vmIdListJson = new JSONObject(); + payloadInfo.put("vmIdList", vmIdListJson.toString()); + String controllerType = "testControllerType"; + + Status status = new Status(); + Optional<String> otherPayloadVm = PayloadClient.snapshotFormat("", payloadInfo.get("identityUrl")); + doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, null, otherPayloadVm, controllerType); + + appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType); + + verify(client, times(0)).vnfCommand(action, msoRequestId, vnfId, null, otherPayloadVm, controllerType); + } + + @Test + public void runAppCCommand_Snapshot_vserverIdList_Empty_Test() + throws ApplicationControllerOrchestratorException, JsonProcessingException { + Action action = Action.Snapshot; + String msoRequestId = "testMsoRequestId"; + String vnfId = "testVnfId"; + Optional<String> payload = Optional.empty(); + HashMap<String, String> payloadInfo = new HashMap<String, String>(); + payloadInfo.put("identityUrl", "testIdentityUrl"); + ArrayList<String> vmIdList = new ArrayList<String>(); + String vmId = "testlink:testVmId"; + vmIdList.add(vmId); + JSONObject vmIdListJson = new JSONObject(); + vmIdListJson.put("vmIds", vmIdList); + payloadInfo.put("vmIdList", vmIdListJson.toString()); + String controllerType = "testControllerType"; + + Status status = new Status(); + Optional<String> otherPayloadVm = PayloadClient.snapshotFormat(vmId, payloadInfo.get("identityUrl")); + doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, null, otherPayloadVm, controllerType); + + appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType); + + verify(client, times(0)).vnfCommand(action, msoRequestId, vnfId, null, otherPayloadVm, controllerType); + } + + @Test + public void runAppCCommand_Snapshot_vserverId_null_Test() + throws ApplicationControllerOrchestratorException, JsonProcessingException { + Action action = Action.Snapshot; + String msoRequestId = "testMsoRequestId"; + String vnfId = "testVnfId"; + Optional<String> payload = Optional.empty(); + HashMap<String, String> payloadInfo = new HashMap<String, String>(); + payloadInfo.put("identityUrl", "testIdentityUrl"); + ArrayList<String> vmIdList = new ArrayList<String>(); + String vmId = "testlink:testVmId1"; + vmIdList.add(vmId); + JSONObject vmIdListJson = new JSONObject(); + vmIdListJson.put("vmIds", vmIdList); + payloadInfo.put("vmIdList", vmIdListJson.toString()); + JSONObject vserverIdListJson = new JSONObject(); + payloadInfo.put("vserverIdList", vserverIdListJson.toString()); + String controllerType = "testControllerType"; + + Status status = new Status(); + Optional<String> otherPayloadVm = PayloadClient.snapshotFormat(vmId, payloadInfo.get("identityUrl")); + doReturn(status).when(client).vnfCommand(action, msoRequestId, vnfId, null, otherPayloadVm, controllerType); + + appCAction.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType); + + verify(client, times(0)).vnfCommand(action, msoRequestId, vnfId, null, otherPayloadVm, controllerType); + } } diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiL3NetworkInputWithSubnets.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiL3NetworkInputWithSubnets.json index 418396f290..9b32a4c446 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiL3NetworkInputWithSubnets.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiL3NetworkInputWithSubnets.json @@ -69,5 +69,15 @@ } ] }, + "aggregateRoutes": { + "aggregateRoute": [ + { + "routeId": "routeId", + "networkStartAddress": "10.80.12.0", + "cidrMask": "23", + "ipVersion": "4" + } + ] + }, "relationshipList": null }
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/l3NetworkExpectedWithSubnet.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/l3NetworkExpectedWithSubnet.json index ccefe195c9..f65fe17a2e 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/l3NetworkExpectedWithSubnet.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/l3NetworkExpectedWithSubnet.json @@ -52,5 +52,13 @@ "segmentation-id": "segmentationId" } ], + "aggregate-routes": [ + { + "route-id": "routeId", + "network-start-address": "10.80.12.0", + "cidr-mask": "23", + "ip-version": "4" + } + ], "model-info-network": null } diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/bulkprocess/test-request.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/bulkprocess/test-request.json deleted file mode 100644 index f5ffe38285..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/aai/bulkprocess/test-request.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "transactions" : [ { - "put" : [ { - "uri" : "/network/generic-vnfs/generic-vnf/test1/relationship-list/relationship", - "body" : { - "related-link" : "/cloud-infrastructure/pservers/pserver/test2" - } - }, { - "uri" : "/network/generic-vnfs/generic-vnf/test3/relationship-list/relationship", - "body" : { - "related-link" : "/cloud-infrastructure/pservers/pserver/test4" - } - } ] - }, { - "put" : [ { - "uri" : "/network/generic-vnfs/generic-vnf/test5/relationship-list/relationship", - "body" : { - "related-link" : "/cloud-infrastructure/pservers/pserver/test6" - } - } ] - } ] -}
\ No newline at end of file |