fixed interfaces + interface_types when no op 79/47779/2
authorkaty.rotman <katy.rotman@amdocs.com>
Wed, 16 May 2018 08:42:00 +0000 (11:42 +0300)
committerOren Kleks <orenkle@amdocs.com>
Thu, 17 May 2018 07:47:07 +0000 (07:47 +0000)
Issue-ID: SDC-1337
Change-Id: I0038b29e7cb667efb53dee5cbc1192cfd74e387a
Signed-off-by: katy.rotman <katy.rotman@amdocs.com>
catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InterfacesOperationsToscaUtil.java

index f14164b..85b2d17 100644 (file)
 
 package org.openecomp.sdc.be.tosca.utils;
 
+import com.fasterxml.jackson.databind.ObjectMapper;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
-
+import org.apache.commons.collections.MapUtils;
 import org.openecomp.sdc.be.datatypes.elements.OperationDataDefinition;
 import org.openecomp.sdc.be.datatypes.elements.OperationInputDefinition;
 import org.openecomp.sdc.be.model.Component;
@@ -35,8 +36,6 @@ import org.openecomp.sdc.be.tosca.model.ToscaLifecycleOperationDefinition;
 import org.openecomp.sdc.be.tosca.model.ToscaNodeType;
 import org.openecomp.sdc.be.tosca.model.ToscaProperty;
 
-import com.fasterxml.jackson.databind.ObjectMapper;
-
 /**
  * @author KATYR
  * @since March 20, 2018
@@ -68,6 +67,10 @@ public class InterfacesOperationsToscaUtil {
         }
 
         final Map<String, InterfaceDefinition> interfaces = ((Resource) component).getInterfaces();
+        if ( MapUtils.isEmpty(interfaces)) {
+            return null;
+        }
+
         for (InterfaceDefinition interfaceDefinition : interfaces.values()) {
             ToscaInterfaceNodeType toscaInterfaceType = new ToscaInterfaceNodeType();
             toscaInterfaceType.setDerived_from(DERIVED_FROM_STANDARD_INTERFACE);
@@ -105,7 +108,7 @@ public class InterfacesOperationsToscaUtil {
         }
 
         final Map<String, InterfaceDefinition> interfaces = ((Resource) component).getInterfaces();
-        if (Objects.isNull(interfaces)) {
+        if ( MapUtils.isEmpty(interfaces)) {
             return;
         }
         for (InterfaceDefinition interfaceDefinition : interfaces.values()) {
@@ -143,7 +146,7 @@ public class InterfacesOperationsToscaUtil {
 
     /***
      * workaround for : currently "defaultp" is not being converted to "default" by the relevant code in ToscaExportHandler
-     * any string key named "defaultp" will have its named changed to "default"
+     * so, any string Map key named "defaultp" will have its named changed to "default"
      * @param operationsMap the map to update
      */
     private static void handleDefaults(Map<String, Object> operationsMap) {