From 9ede89131044d171187c5be906aefee615a0e568 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Tue, 9 Apr 2019 11:55:57 +0000 Subject: Complete unit test for models-pdp This review completes the unit test for the models-pdp module, for persistence of PDP groups and for PDP group filtering. Added unit test of filters for TOSCA policy types and policies. Added fix to allow filters to pass when the value being checked is null. Issue-ID: POLICY-1095 Change-Id: I982400ef39f0282d813d49e484a58207e03b8a63 Signed-off-by: liamfallon --- .../tosca/authorative/concepts/ToscaEntity.java | 2 +- .../tosca/authorative/concepts/ToscaPolicyType.java | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'models-tosca/src/main/java/org/onap') diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java index e89b31635..f5a178a37 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaEntity.java @@ -54,7 +54,7 @@ public class ToscaEntity implements PfNameVersion { private String description; /** - * Copy COnstructor. + * Copy Constructor. * * @param copyObject object to copy from */ diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyType.java index 75f17ea5b..3a3b1476d 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyType.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyType.java @@ -23,10 +23,14 @@ package org.onap.policy.models.tosca.authorative.concepts; +import java.util.LinkedHashMap; import java.util.Map; +import java.util.Map.Entry; + import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; +import lombok.NonNull; /** * Class to represent TOSCA policy type matching input/output from/to client. @@ -39,6 +43,22 @@ import lombok.NoArgsConstructor; public class ToscaPolicyType extends ToscaEntity implements Comparable { private Map properties; + /** + * Copy Constructor. + * + * @param copyObject object to copy from + */ + public ToscaPolicyType(@NonNull ToscaPolicyType copyObject) { + super(copyObject); + + if (copyObject.properties != null) { + properties = new LinkedHashMap<>(); + for (final Entry propertyEntry : copyObject.properties.entrySet()) { + properties.put(propertyEntry.getKey(), propertyEntry.getValue()); + } + } + } + @Override public int compareTo(final ToscaPolicyType other) { return compareNameVersion(this, other); -- cgit 1.2.3-korg