diff options
author | Lukasz Muszkieta <lukasz.muszkieta@nokia.com> | 2020-01-23 13:23:40 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-01-23 13:23:40 +0000 |
commit | 80dafe76d022b6ac97f490a6f54f1e4838cdf1c8 (patch) | |
tree | 5d6824e377a025a7ed979e222a2ba36b50213264 /bpmn/MSOCommonBPMN/src/test | |
parent | 66781db64d1839f283ce99278393f2c65baf9263 (diff) | |
parent | 9f4d6c586c78ea04e6e1489214f4544ca8f209f4 (diff) |
Merge "Add some new tests in BBInputSetupUtilsTest"
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/test')
-rw-r--r-- | bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java | 105 |
1 files changed, 104 insertions, 1 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); + } } |