diff options
author | mharazin <mateusz.harazin@nokia.com> | 2020-01-22 09:04:01 +0100 |
---|---|---|
committer | mharazin <mateusz.harazin@nokia.com> | 2020-01-22 15:15:26 +0100 |
commit | 9f4d6c586c78ea04e6e1489214f4544ca8f209f4 (patch) | |
tree | 64bef38ce74e1f4d9dd96754f85115ad31c89d66 | |
parent | 17413ddf83ba8a51e978b368313cd366d57b1e48 (diff) |
Add some new tests in BBInputSetupUtilsTest
To increase the coverage of BBInputSetupUtils class
Issue-ID: SO-2600
Signed-off-by: Mateusz Harazin <mateusz.harazin@nokia.com>
Change-Id: I9aa36344d7390d502476d9604ef194455a39f204
-rw-r--r-- | bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java | 105 | ||||
-rw-r--r-- | pom.xml | 16 |
2 files changed, 112 insertions, 9 deletions
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java index 3fdbf39756..0bb92e32ff 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java @@ -4,6 +4,8 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ + * Modifications Copyright (C) 2020 Nokia + * ================================================================================ * 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 @@ -57,6 +59,7 @@ import org.onap.aai.domain.yang.ServiceInstance; import org.onap.aai.domain.yang.ServiceInstances; import org.onap.aai.domain.yang.VolumeGroup; import org.onap.aai.domain.yang.VolumeGroups; +import org.onap.aai.domain.yang.VpnBinding; import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; @@ -69,9 +72,13 @@ import org.onap.so.client.aai.AAIResourcesClient; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.graphinventory.entities.uri.Depth; +import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; +import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; +import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization; +import org.onap.so.db.catalog.beans.VfModuleCustomization; +import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.Service; -import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.beans.RequestProcessingData; @@ -997,4 +1004,100 @@ public class BBInputSetupUtilsTest { bbInputSetupUtils.existsAAIVolumeGroupGloballyByName("testVoumeGroup"); verify(MOCK_aaiResourcesClient, times(1)).exists(expectedUri); } + + @Test + public void shouldChangeInfraActiveRequestVnfId() throws IOException { + final String vnfId = "vnfId"; + InfraActiveRequests infraActiveRequests = loadExpectedInfraActiveRequest(); + + bbInputSetupUtils.updateInfraActiveRequestVnfId(infraActiveRequests, vnfId); + + assertEquals(infraActiveRequests.getVnfId(), vnfId); + } + + @Test + public void shouldChangeInfraActiveRequestVfModuleId() throws IOException { + final String vfModuleId = "vfModuleId"; + InfraActiveRequests infraActiveRequests = loadExpectedInfraActiveRequest(); + + bbInputSetupUtils.updateInfraActiveRequestVfModuleId(infraActiveRequests, vfModuleId); + + assertEquals(infraActiveRequests.getVfModuleId(), vfModuleId); + } + + @Test + public void shouldChangeInfraActiveRequestVolumeGroupId() throws IOException { + final String volumeGroupId = "volumeGroupId"; + InfraActiveRequests infraActiveRequests = loadExpectedInfraActiveRequest(); + + bbInputSetupUtils.updateInfraActiveRequestVolumeGroupId(infraActiveRequests, volumeGroupId); + + assertEquals(infraActiveRequests.getVolumeGroupId(), volumeGroupId); + } + + @Test + public void shouldChangeInfraActiveRequestNetworkId() throws IOException { + final String networkId = "activeRequestNetworkId"; + InfraActiveRequests infraActiveRequests = loadExpectedInfraActiveRequest(); + + bbInputSetupUtils.updateInfraActiveRequestNetworkId(infraActiveRequests, networkId); + + assertEquals(infraActiveRequests.getNetworkId(), networkId); + } + + @Test + public void getAAIVpnBindingNullTest() { + assertNull(bbInputSetupUtils.getAAIVpnBinding("vpnBindingId")); + } + + @Test + public void getAAIVolumeGroupNullTest() { + VolumeGroup actualAaiVnf = + bbInputSetupUtils.getAAIVolumeGroup("cloudOwnerId", "cloudRegionId", "volumeGroupId"); + assertNull(actualAaiVnf); + } + + @Test + public void getAAIVfModuleNullTest() { + assertNull(bbInputSetupUtils.getAAIVfModule("vnfId", "vfModuleId")); + } + + @Test + public void getAAIL3NetworkNullTest() { + assertNull(bbInputSetupUtils.getAAIL3Network("networkId")); + } + + @Test + public void getAICVpnBindingFromNetwork_noVpnBindingTest() throws IOException { + L3Network l3Network = + mapper.readValue(new File(RESOURCE_PATH + "aaiL3NetworkInputWithSubnets.json"), L3Network.class); + + Optional<VpnBinding> actual = bbInputSetupUtils.getAICVpnBindingFromNetwork(l3Network); + assertEquals(actual, Optional.empty()); + } + + @Test + public void getAAIServiceInstancesGloballyByName_noAAIResourceTest() { + final String serviceInstanceName = "serviceInstanceName"; + + doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class)); + ServiceInstances actualServiceInstances = + bbInputSetupUtils.getAAIServiceInstancesGloballyByName(serviceInstanceName); + + assertNull(actualServiceInstances); + } + + @Test + public void getAAIVnfsGloballyByName_noAAIResourceTest() { + final String vnfName = "vnfName"; + + doReturn(Optional.empty()).when(MOCK_aaiResourcesClient).get(isA(Class.class), isA(AAIResourceUri.class)); + GenericVnfs actualGenericVnfs = bbInputSetupUtils.getAAIVnfsGloballyByName(vnfName); + + assertNull(actualGenericVnfs); + } + + private InfraActiveRequests loadExpectedInfraActiveRequest() throws IOException { + return mapper.readValue(new File(RESOURCE_PATH + "InfraActiveRequestExpected.json"), InfraActiveRequests.class); + } } @@ -503,16 +503,16 @@ <version>3.0.0-M3</version> <executions> <execution> - <id>enforce-property</id> - <configuration> - <skip>true</skip> - </configuration> + <id>enforce-property</id> + <configuration> + <skip>true</skip> + </configuration> </execution> <execution> - <id>enforce-no-snapshots</id> - <configuration> - <skip>true</skip> - </configuration> + <id>enforce-no-snapshots</id> + <configuration> + <skip>true</skip> + </configuration> </execution> <execution> <id>enforce-banned-dependencies</id> |