aboutsummaryrefslogtreecommitdiffstats
path: root/models-pdp/src/main
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-04-08 13:58:53 +0000
committerliamfallon <liam.fallon@est.tech>2019-04-08 13:58:53 +0000
commit9ce39af891ccf063d46e18ecf5a2a47eb1408930 (patch)
treeeb55cc63c83ea34f73aeaaae5039c96283b66ef8 /models-pdp/src/main
parenteb7127ac85b3df30a09277721a5f9271033843e7 (diff)
Add bug fixes and tests for filters
Fixed bugs on filtering where lack of null checks was blocking all results. Added unit test for PDP related JPA objects. Fixed cascading and orphan control on JPA objects. Added partial testing of PdpProvider. Added partial testing of filters. Changed tag for content of operational policies from "Content" to "content". Issue-ID: POLICY-1095 Change-Id: Ieb22e06955a8434b490bae7d0f6b77d4479515e8 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'models-pdp/src/main')
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/Pdp.java6
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java9
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java8
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java4
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java23
5 files changed, 27 insertions, 23 deletions
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/Pdp.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/Pdp.java
index 1eaa41547..034374c29 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/Pdp.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/Pdp.java
@@ -21,10 +21,9 @@
package org.onap.policy.models.pdp.concepts;
-import lombok.Getter;
+import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
-import lombok.Setter;
import lombok.ToString;
import org.onap.policy.models.pdp.enums.PdpHealthStatus;
import org.onap.policy.models.pdp.enums.PdpState;
@@ -34,10 +33,9 @@ import org.onap.policy.models.pdp.enums.PdpState;
*
* @author Ram Krishna Verma (ram.krishna.verma@est.tech)
*/
-@Getter
-@Setter
@ToString
@NoArgsConstructor
+@Data
public class Pdp {
@NonNull
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java
index 5965b728d..3c07a9d0f 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpGroupFilter.java
@@ -46,7 +46,7 @@ public class PdpGroupFilter implements PfObjectFilter<PdpGroup> {
// Regular expression
private String name;
- // Regular Expression, set to LATEST_VERRSION to get the latest version
+ // Regular Expression, set to to get the latest version
private String version;
private PdpState groupState;
@@ -67,9 +67,10 @@ public class PdpGroupFilter implements PfObjectFilter<PdpGroup> {
// @formatter:off
List<PdpGroup> returnList = originalList.stream()
- .filter(p -> filterOnRegexp(p.getName(), name))
- .filter(p -> version.equals(LATEST_VERSION) || filterOnRegexp(p.getVersion(), version))
- .filter(p -> ObjectUtils.compare(p.getPdpGroupState(), groupState) == 0)
+ .filter(p -> filterString(p.getName(), name))
+ .filter(p -> (version != null && LATEST_VERSION.equals(version))
+ || filterString(p.getVersion(), version))
+ .filter(p -> groupState == null || ObjectUtils.compare(p.getPdpGroupState(), groupState) == 0)
.filter(p -> filterOnPdpType(p, pdpType))
.filter(p -> filterOnPolicyType(p, policyType))
.filter(p -> filterOnPolicy(p, policy))
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java
index 4e5843678..405408946 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/concepts/PdpSubGroup.java
@@ -25,10 +25,8 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import lombok.Getter;
+import lombok.Data;
import lombok.NonNull;
-import lombok.Setter;
-import lombok.ToString;
import org.onap.policy.models.base.PfUtils;
import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyIdentifier;
@@ -39,9 +37,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicyTypeIdentifi
*
* @author Ram Krishna Verma (ram.krishna.verma@est.tech)
*/
-@Getter
-@Setter
-@ToString
+@Data
public class PdpSubGroup {
private String pdpType;
private List<ToscaPolicyTypeIdentifier> supportedPolicyTypes;
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java
index 71f27c48b..d0fc216c2 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java
@@ -29,11 +29,13 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import javax.persistence.CascadeType;
import javax.persistence.CollectionTable;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
+import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
@@ -87,7 +89,7 @@ public class JpaPdpGroup extends PfConcept implements PfAuthorative<PdpGroup> {
private Map<String, String> properties;
// @formatter:off
- @OneToMany
+ @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
@CollectionTable(joinColumns = {
@JoinColumn(name = "pdpGroupParentKeyName", referencedColumnName = "parentKeyName"),
@JoinColumn(name = "pdpGroupParentKeyVersion", referencedColumnName = "parentKeyVersion"),
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java
index d51cfc67e..20e43f0b5 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java
@@ -28,19 +28,23 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import javax.persistence.CollectionTable;
+
+import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
+import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
+import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
+
import org.onap.policy.common.utils.validation.Assertions;
import org.onap.policy.common.utils.validation.ParameterValidationUtils;
import org.onap.policy.models.base.PfAuthorative;
@@ -89,13 +93,16 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative<PdpSubGro
@ElementCollection
private Map<String, String> properties;
- // @formatter:ofF
- @OneToMany
- @CollectionTable(
- joinColumns = { @JoinColumn(name = "pdpSubGroupParentKeyName", referencedColumnName = "parentKeyName"),
- @JoinColumn(name = "pdpSubGroupParentKeyVersion", referencedColumnName = "parentKeyVersion"),
- @JoinColumn(name = "pdpSubGroupParentLocalName", referencedColumnName = "parentLocalName"),
- @JoinColumn(name = "pdpSubGroupLocalName", referencedColumnName = "localName") })
+ // @formatter:off
+ @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
+ @JoinTable (
+ joinColumns = {
+ @JoinColumn(name = "pdpParentKeyName", referencedColumnName = "parentKeyName"),
+ @JoinColumn(name = "pdpParentKeyVersion", referencedColumnName = "parentKeyVersion"),
+ @JoinColumn(name = "pdpParentLocalName", referencedColumnName = "parentLocalName"),
+ @JoinColumn(name = "pdpLocalName", referencedColumnName = "localName")
+ }
+ )
// formatter:on
private List<JpaPdp> pdpInstances;