Add some new tests in BBInputSetupUtilsTest 03/100303/7
authormharazin <mateusz.harazin@nokia.com>
Wed, 22 Jan 2020 08:04:01 +0000 (09:04 +0100)
committermharazin <mateusz.harazin@nokia.com>
Wed, 22 Jan 2020 14:15:26 +0000 (15:15 +0100)
To increase the coverage of BBInputSetupUtils class

Issue-ID: SO-2600
Signed-off-by: Mateusz Harazin <mateusz.harazin@nokia.com>
Change-Id: I9aa36344d7390d502476d9604ef194455a39f204

bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java
pom.xml

index 3fdbf39..0bb92e3 100644 (file)
@@ -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);
+    }
 }
diff --git a/pom.xml b/pom.xml
index 9e27d8c..9f453d4 100644 (file)
--- a/pom.xml
+++ b/pom.xml
         <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>