From 0b15f3bf60162a62505593186737bca98bd4349c Mon Sep 17 00:00:00 2001 From: liamfallon Date: Mon, 8 Apr 2019 17:30:54 +0000 Subject: Add lists and tests for PDP filters The policy type and policy filters for PDP groups are added in this review. Also filter tests for PDP group filter is completed. Issue-ID: POLICY-1095 Change-Id: Ia28776c809f2ab879af4007b3480621637a83f69 Signed-off-by: liamfallon --- .../policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java | 5 ++--- .../models/tosca/authorative/concepts/ToscaPolicyTypeFilter.java | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'models-tosca/src/main/java') diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java index 102b1fe2e..bb0026e9a 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilter.java @@ -30,8 +30,7 @@ import lombok.NonNull; import org.onap.policy.models.base.PfObjectFilter; /** - * Filter class for searches for {@link ToscaPolicy} instances. - * If any fields are null, they are ignored. + * Filter class for searches for {@link ToscaPolicy} instances. If any fields are null, they are ignored. * * @author Liam Fallon (liam.fallon@est.tech) */ @@ -58,7 +57,7 @@ public class ToscaPolicyFilter implements PfObjectFilter { // @formatter:off List returnList = originalList.stream() .filter(p -> filterString(p.getName(), name)) - .filter(p -> (version != null && LATEST_VERSION.equals(version)) + .filter(p -> LATEST_VERSION.equals(version) || filterString(p.getVersion(), version)) .filter(p -> filterString(p.getType(), type)) .filter(p -> filterString(p.getTypeVersion(), typeVersion)) diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilter.java index 7d6fbacee..c72192927 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilter.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilter.java @@ -30,8 +30,7 @@ import lombok.NonNull; import org.onap.policy.models.base.PfObjectFilter; /** - * Filter class for searches for {@link ToscaPolicyType} instances. - * If any fields are null, they are ignored. + * Filter class for searches for {@link ToscaPolicyType} instances. If any fields are null, they are ignored. * * @author Liam Fallon (liam.fallon@est.tech) */ @@ -52,7 +51,7 @@ public class ToscaPolicyTypeFilter implements PfObjectFilter { // @formatter:off List returnList = originalList.stream() .filter(p -> filterString(p.getName(), name)) - .filter(p -> (version != null && LATEST_VERSION.equals(version)) + .filter(p -> LATEST_VERSION.equals(version) || filterString(p.getVersion(), version)) .collect(Collectors.toList()); // @formatter:off -- cgit 1.2.3-korg