aboutsummaryrefslogtreecommitdiffstats
path: root/models-pdp/src
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-01-05 11:11:26 -0500
committerJim Hahn <jrh3@att.com>2021-01-06 15:59:14 -0500
commite6bea18abd1a1b4ddf7203508832e6a3f9380598 (patch)
tree90b8ae9fde32efcfb2f4662bcf2b87e4c430de60 /models-pdp/src
parentf2b0318f53abf9f2345a5cdca74f3dd635aa9b60 (diff)
Use annotations on parameterized types
Updated the code to place validation annotations directly on the annotated types instead of using the @Items and @Entries annotations. Also added/updated junits for validation code. Issue-ID: POLICY-2648 Change-Id: Ia535da07a38cec77a74c5c3215b5ae784d7a4e1a Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'models-pdp/src')
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdp.java4
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpGroup.java11
-rw-r--r--models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdpSubGroup.java17
3 files changed, 10 insertions, 22 deletions
diff --git a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdp.java b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdp.java
index 2e6a2a60a..87a52fe38 100644
--- a/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdp.java
+++ b/models-pdp/src/main/java/org/onap/policy/models/pdp/persistence/concepts/JpaPdp.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP Policy Model
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -171,7 +171,7 @@ public class JpaPdp extends PfConcept implements PfAuthorative<Pdp>, Serializabl
public BeanValidationResult validate(@NonNull String fieldName) {
BeanValidationResult result = super.validate(fieldName);
- result.addResult(validateKeyNotNull("parent of key", key.getParentConceptKey()));
+ validateKeyNotNull(result, "parent of key", key.getParentConceptKey());
if (PfKey.NULL_KEY_NAME.equals(key.getParentLocalName())) {
addResult(result, "local name of parent of key", key.getParentLocalName(), IS_NULL);
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 5e078bccb..c91bf9a62 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
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP Policy Model
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -44,8 +44,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import org.apache.commons.lang3.ObjectUtils;
-import org.onap.policy.common.parameters.annotations.Entries;
-import org.onap.policy.common.parameters.annotations.Items;
import org.onap.policy.common.parameters.annotations.NotBlank;
import org.onap.policy.common.parameters.annotations.NotNull;
import org.onap.policy.common.parameters.annotations.Valid;
@@ -87,9 +85,7 @@ public class JpaPdpGroup extends PfConcept implements PfAuthorative<PdpGroup> {
private PdpState pdpGroupState;
@ElementCollection
- @Entries(key = @Items(notNull = {@NotNull}, notBlank = {@NotBlank}),
- value = @Items(notNull = {@NotNull}, notBlank = {@NotBlank}))
- private Map<String, String> properties;
+ private Map<@NotNull @NotBlank String, @NotNull @NotBlank String> properties;
// @formatter:off
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
@@ -101,8 +97,7 @@ public class JpaPdpGroup extends PfConcept implements PfAuthorative<PdpGroup> {
})
// @formatter:on
@NotNull
- @Items(notNull = {@NotNull}, valid = {@Valid})
- private List<JpaPdpSubGroup> pdpSubGroups;
+ private List<@NotNull @Valid JpaPdpSubGroup> pdpSubGroups;
/**
* The Default Constructor creates a {@link JpaPdpGroup} object with a null key.
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 27ad34e4a..4c0fe7630 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
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP Policy Model
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019-2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -44,8 +44,6 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NonNull;
import org.onap.policy.common.parameters.BeanValidationResult;
-import org.onap.policy.common.parameters.annotations.Entries;
-import org.onap.policy.common.parameters.annotations.Items;
import org.onap.policy.common.parameters.annotations.Min;
import org.onap.policy.common.parameters.annotations.NotBlank;
import org.onap.policy.common.parameters.annotations.NotNull;
@@ -83,12 +81,10 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative<PdpSubGro
@ElementCollection
@NotNull
- @Items(notNull = {@NotNull}, valid = {@Valid})
- private List<PfSearchableKey> supportedPolicyTypes;
+ private List<@NotNull @Valid PfSearchableKey> supportedPolicyTypes;
@ElementCollection
@NotNull
- @Items(notNull = {@NotNull}, valid = {@Valid})
private List<PfConceptKey> policies;
@Column
@@ -100,9 +96,7 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative<PdpSubGro
private int desiredInstanceCount;
@ElementCollection
- @Entries(key = @Items(notNull = {@NotNull}, notBlank = {@NotBlank}),
- value = @Items(notNull = {@NotNull}, notBlank = {@NotBlank}))
- private Map<String, String> properties;
+ private Map<@NotNull @NotBlank String, @NotNull @NotBlank String> properties;
// @formatter:off
@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
@@ -116,8 +110,7 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative<PdpSubGro
)
// formatter:on
@NotNull
- @Items(notNull = {@NotNull}, valid = {@Valid})
- private List<JpaPdp> pdpInstances;
+ private List<@NotNull @Valid JpaPdp> pdpInstances;
/**
* The Default Constructor creates a {@link JpaPdpSubGroup} object with a null key.
@@ -297,7 +290,7 @@ public class JpaPdpSubGroup extends PfConcept implements PfAuthorative<PdpSubGro
public BeanValidationResult validate(@NonNull String fieldName) {
BeanValidationResult result = super.validate(fieldName);
- result.addResult(validateKeyNotNull("parent of key", key.getParentConceptKey()));
+ validateKeyNotNull(result, "parent of key", key.getParentConceptKey());
if (supportedPolicyTypes != null && supportedPolicyTypes.isEmpty()) {
addResult(result, "supportedPolicyTypes", supportedPolicyTypes, "is empty");