Added null checks to prevent crashes at
method calls

Issue-ID: SO-1841
Signed-off-by: Oleksandr Moliavko <o.moliavko@samsung.com>
Change-Id: Ie3b70aa59cf73ca6203d0f1aab1ed096af906050
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
index 9a39334..433aa0c 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java
@@ -1388,8 +1388,10 @@
                     vnfs.getInstanceParams(), productFamilyId);
         } else if (bbName.contains(VF_MODULE) || bbName.contains(VOLUME_GROUP)) {
             Pair<Vnfs, VfModules> vnfsAndVfModules = getVfModulesAndItsVnfsByKey(key, resources);
-            vfModules = vnfsAndVfModules.getValue1();
-            vnfs = vnfsAndVfModules.getValue0();
+            if (vnfsAndVfModules != null) {
+                vfModules = vnfsAndVfModules.getValue1();
+                vnfs = vnfsAndVfModules.getValue0();
+            }
             lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, getVnfId(executeBB, lookupKeyMap));
             if (vnfs == null) {
                 throw new Exception("Could not find Vnf to orchestrate VfModule");
@@ -1410,8 +1412,10 @@
         } else if (bbName.contains(NETWORK)) {
             networks = findNetworksByKey(key, resources);
             String networkId = lookupKeyMap.get(ResourceKey.NETWORK_ID);
-            this.populateL3Network(networks.getInstanceName(), networks.getModelInfo(), service, bbName,
-                    serviceInstance, lookupKeyMap, networkId, networks.getInstanceParams());
+            if (networks != null) {
+                this.populateL3Network(networks.getInstanceName(), networks.getModelInfo(), service, bbName,
+                        serviceInstance, lookupKeyMap, networkId, networks.getInstanceParams());
+            }
         } else if (bbName.contains("Configuration")) {
             String configurationId = lookupKeyMap.get(ResourceKey.CONFIGURATION_ID);
             ModelInfo configurationModelInfo = new ModelInfo();
@@ -1608,8 +1612,10 @@
 
     protected void mapCatalogNetworkCollectionInstanceGroup(Service service, InstanceGroup instanceGroup, String key) {
         CollectionResourceCustomization collectionCust = this.findCatalogNetworkCollection(service, key);
-        org.onap.so.db.catalog.beans.InstanceGroup catalogInstanceGroup =
-                collectionCust.getCollectionResource().getInstanceGroup();
+        org.onap.so.db.catalog.beans.InstanceGroup catalogInstanceGroup = null;
+        if (collectionCust != null) {
+            catalogInstanceGroup = collectionCust.getCollectionResource().getInstanceGroup();
+        }
         instanceGroup.setModelInfoInstanceGroup(
                 mapperLayer.mapCatalogInstanceGroupToInstanceGroup(collectionCust, catalogInstanceGroup));
     }