import javax.ws.rs.core.Response;
 import lombok.AccessLevel;
 import lombok.NoArgsConstructor;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.collections4.MapUtils;
+import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.onap.policy.clamp.models.acm.document.concepts.DocToscaEntity;
 import org.onap.policy.clamp.models.acm.document.concepts.DocToscaServiceTemplate;
         }
         return result;
     }
+
+    /**
+     * Compare two maps of the same type, nulls are allowed.
+     *
+     * @param leftMap the first map
+     * @param rightMap the second map
+     * @return a measure of the comparison
+     */
+    public static <V extends Comparable<? super V>> int compareMaps(final Map<String, V> leftMap,
+            final Map<String, V> rightMap) {
+        if ((MapUtils.isEmpty(leftMap) && MapUtils.isEmpty(rightMap))) {
+            return 0;
+        }
+        if (leftMap == null) {
+            return 1;
+        }
+
+        if (rightMap == null) {
+            return -1;
+        }
+        if (leftMap.size() != rightMap.size()) {
+            return leftMap.hashCode() - rightMap.hashCode();
+        }
+
+        for (var leftEntry : leftMap.entrySet()) {
+            var result = ObjectUtils.compare(leftEntry.getValue(), rightMap.get(leftEntry.getKey()));
+            if (result != 0) {
+                return result;
+            }
+        }
+        return 0;
+    }
+
+    /**
+     * Compare two lists of Map of the same type, nulls are allowed.
+     *
+     * @param leftCollection the first list
+     * @param rightCollection the second list
+     * @return a measure of the comparison
+     */
+    public static <V extends Comparable<? super V>> int compareCollections(final List<Map<String, V>> leftCollection,
+            final List<Map<String, V>> rightCollection) {
+        if ((CollectionUtils.isEmpty(leftCollection) && CollectionUtils.isEmpty(rightCollection))) {
+            return 0;
+        }
+        if (leftCollection == null) {
+            return 1;
+        }
+
+        if (rightCollection == null) {
+            return -1;
+        }
+        if (leftCollection.size() != rightCollection.size()) {
+            return leftCollection.hashCode() - rightCollection.hashCode();
+        }
+
+        for (var i = 0; i < leftCollection.size(); i++) {
+            var result = compareMaps(leftCollection.get(i), rightCollection.get(i));
+            if (result != 0) {
+                return result;
+            }
+        }
+        return 0;
+    }
 }
 
     public DocToscaNodeTemplate(final DocToscaNodeTemplate copyConcept) {
         super(copyConcept);
         this.requirements =
-                PfUtils.mapList(copyConcept.requirements, map -> DocUtil.docMapToMap(map, DocToscaRequirement::new));
-        this.capabilities = DocUtil.docMapToMap(copyConcept.capabilities, DocToscaCapabilityAssignment::new);
+                PfUtils.mapList(copyConcept.requirements, map -> PfUtils.mapMap(map, DocToscaRequirement::new));
+        this.capabilities = PfUtils.mapMap(copyConcept.capabilities, DocToscaCapabilityAssignment::new);
     }
 
     @Override
 
         final var other = (DocToscaNodeTemplate) otherConcept;
 
-        result = PfUtils.compareCollections(requirements, other.requirements);
+        result = DocUtil.compareCollections(requirements, other.requirements);
         if (result != 0) {
             return result;
         }
 
-        return PfUtils.compareMaps(capabilities, other.capabilities);
+        return DocUtil.compareMaps(capabilities, other.capabilities);
     }
 }
 
     public DocToscaNodeType(final DocToscaNodeType copyConcept) {
         super(copyConcept);
         this.requirements =
-                PfUtils.mapList(copyConcept.requirements, map -> DocUtil.docMapToMap(map, DocToscaRequirement::new));
+                PfUtils.mapList(copyConcept.requirements, map -> PfUtils.mapMap(map, DocToscaRequirement::new));
     }
 
     @Override
 
 
         final var other = (DocToscaRequirement) otherConcept;
 
-        result = capability.compareTo(other.capability);
+        result = PfUtils.compareObjects(capability, other.capability);
         if (result != 0) {
             return result;
         }
 
-        result = node.compareTo(other.node);
+        result = PfUtils.compareObjects(node, other.node);
         if (result != 0) {
             return result;
         }
 
-        result = relationship.compareTo(other.relationship);
+        result = PfUtils.compareObjects(relationship, other.relationship);
         if (result != 0) {
             return result;
         }
 
     public DocToscaServiceTemplate(final DocToscaServiceTemplate copyConcept) {
         super(copyConcept);
         this.toscaDefinitionsVersion = copyConcept.toscaDefinitionsVersion;
-        this.dataTypes = DocUtil.docMapToMap(copyConcept.dataTypes, DocToscaDataType::new, new LinkedHashMap<>());
+        this.dataTypes = PfUtils.mapMap(copyConcept.dataTypes, DocToscaDataType::new, new LinkedHashMap<>());
         this.capabilityTypes =
-                DocUtil.docMapToMap(copyConcept.capabilityTypes, DocToscaCapabilityType::new, new LinkedHashMap<>());
-        this.nodeTypes = DocUtil.docMapToMap(copyConcept.nodeTypes, DocToscaNodeType::new, new LinkedHashMap<>());
-        this.relationshipTypes = DocUtil.docMapToMap(copyConcept.relationshipTypes, DocToscaRelationshipType::new,
+                PfUtils.mapMap(copyConcept.capabilityTypes, DocToscaCapabilityType::new, new LinkedHashMap<>());
+        this.nodeTypes = PfUtils.mapMap(copyConcept.nodeTypes, DocToscaNodeType::new, new LinkedHashMap<>());
+        this.relationshipTypes = PfUtils.mapMap(copyConcept.relationshipTypes, DocToscaRelationshipType::new,
                 new LinkedHashMap<>());
-        this.policyTypes = DocUtil.docMapToMap(copyConcept.policyTypes, DocToscaPolicyType::new, new LinkedHashMap<>());
+        this.policyTypes = PfUtils.mapMap(copyConcept.policyTypes, DocToscaPolicyType::new, new LinkedHashMap<>());
         if (copyConcept.toscaTopologyTemplate != null) {
             this.toscaTopologyTemplate = new DocToscaTopologyTemplate(copyConcept.toscaTopologyTemplate);
         }
             return result;
         }
 
-        final DocToscaServiceTemplate other = (DocToscaServiceTemplate) otherConcept;
+        final var other = (DocToscaServiceTemplate) otherConcept;
 
-        result = PfUtils.compareMaps(dataTypes, other.dataTypes);
+        result = DocUtil.compareMaps(dataTypes, other.dataTypes);
         if (result != 0) {
             return result;
         }
 
-        result = PfUtils.compareMaps(capabilityTypes, other.capabilityTypes);
+        result = DocUtil.compareMaps(capabilityTypes, other.capabilityTypes);
         if (result != 0) {
             return result;
         }
 
-        result = PfUtils.compareMaps(relationshipTypes, other.relationshipTypes);
+        result = DocUtil.compareMaps(relationshipTypes, other.relationshipTypes);
         if (result != 0) {
             return result;
         }
 
-        result = PfUtils.compareMaps(nodeTypes, other.nodeTypes);
+        result = DocUtil.compareMaps(nodeTypes, other.nodeTypes);
         if (result != 0) {
             return result;
         }
 
-        result = PfUtils.compareMaps(policyTypes, other.policyTypes);
+        result = DocUtil.compareMaps(policyTypes, other.policyTypes);
         if (result != 0) {
             return result;
         }
 
         this.description = copyConcept.description;
         this.inputs = PfUtils.mapMap(copyConcept.inputs, DocToscaParameter::new);
         this.nodeTemplates =
-                DocUtil.docMapToMap(copyConcept.nodeTemplates, DocToscaNodeTemplate::new, new LinkedHashMap<>());
-        this.policies = DocUtil.docMapToMap(copyConcept.policies, DocToscaPolicy::new, new LinkedHashMap<>());
+                PfUtils.mapMap(copyConcept.nodeTemplates, DocToscaNodeTemplate::new, new LinkedHashMap<>());
+        this.policies = PfUtils.mapMap(copyConcept.policies, DocToscaPolicy::new, new LinkedHashMap<>());
     }
 
     @Override
 
         nodeTemplates = DocUtil.mapToDocMap(toscaTopologyTemplate.getNodeTemplates(), DocToscaNodeTemplate::new);
 
-        policies = DocUtil.listToDocMap(toscaTopologyTemplate.getPolicies(), DocToscaPolicy::new);
+        policies =
+                DocUtil.listToDocMap(toscaTopologyTemplate.getPolicies(), DocToscaPolicy::new, new LinkedHashMap<>());
     }
 
     @Override
             return result;
         }
 
-        result = PfUtils.compareMaps(inputs, otherConcept.inputs);
+        result = DocUtil.compareMaps(inputs, otherConcept.inputs);
         if (result != 0) {
             return result;
         }
 
-        result = PfUtils.compareMaps(nodeTemplates, otherConcept.nodeTemplates);
+        result = DocUtil.compareMaps(nodeTemplates, otherConcept.nodeTemplates);
         if (result != 0) {
             return result;
         }
-        return PfUtils.compareMaps(policies, otherConcept.policies);
+        return DocUtil.compareMaps(policies, otherConcept.policies);
     }
 
     /**
 
 
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.jupiter.api.Assertions.assertNotEquals;
 import static org.junit.jupiter.api.Assertions.fail;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.mock;
         var docServiceTemplate = new DocToscaServiceTemplate(inputServiceTemplateProperties);
         var docServiceTemplateCopy = new DocToscaServiceTemplate(docServiceTemplate);
 
-        assertNotEquals(0, docServiceTemplate.compareTo(docServiceTemplateCopy));
+        assertThat(docServiceTemplate.compareTo(docServiceTemplateCopy)).isEqualByComparingTo(0);
         assertThat(docServiceTemplate.compareToWithoutEntities(docServiceTemplateCopy)).isZero();
 
         var acmDefinition = getAcDefinition(docServiceTemplate);