diff options
Diffstat (limited to 'models-base/src/test')
4 files changed, 18 insertions, 17 deletions
diff --git a/models-base/src/test/java/org/onap/policy/models/base/PfKeyImplTest.java b/models-base/src/test/java/org/onap/policy/models/base/PfKeyImplTest.java index 8d6b1b9f4..dc69e2e67 100644 --- a/models-base/src/test/java/org/onap/policy/models/base/PfKeyImplTest.java +++ b/models-base/src/test/java/org/onap/policy/models/base/PfKeyImplTest.java @@ -37,6 +37,7 @@ import lombok.NoArgsConstructor; import lombok.Setter; import org.junit.Test; import org.onap.policy.common.parameters.ValidationResult; +import org.onap.policy.common.parameters.annotations.Pattern; import org.onap.policy.models.base.PfKey.Compatibility; import org.onap.policy.models.base.testconcepts.DummyPfKey; @@ -268,10 +269,13 @@ public class PfKeyImplTest { @Setter @EqualsAndHashCode(callSuper = false) @NoArgsConstructor - private static class MyKey extends PfKeyImpl { + public static class MyKey extends PfKeyImpl { private static final long serialVersionUID = 1L; + @Pattern(regexp = NAME_REGEXP) private String name; + + @Pattern(regexp = VERSION_REGEXP) private String version; public MyKey(String name, String version) { diff --git a/models-base/src/test/java/org/onap/policy/models/base/ValidatedTest.java b/models-base/src/test/java/org/onap/policy/models/base/ValidatedTest.java index 8534d82a6..dab28f636 100644 --- a/models-base/src/test/java/org/onap/policy/models/base/ValidatedTest.java +++ b/models-base/src/test/java/org/onap/policy/models/base/ValidatedTest.java @@ -434,12 +434,14 @@ public class ValidatedTest { private final String text; @Override - public ValidationResult validate(String fieldName) { + public BeanValidationResult validate(String fieldName) { if (TEXT.equals(text)) { return null; } - return new ObjectValidationResult(fieldName, text, ValidationStatus.INVALID, NOT_SAME); + BeanValidationResult result = new BeanValidationResult(fieldName, this); + result.addResult(new ObjectValidationResult(fieldName, text, ValidationStatus.INVALID, NOT_SAME)); + return result; } } } diff --git a/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConcept.java b/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConcept.java index 67a450702..548c26252 100644 --- a/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConcept.java +++ b/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfConcept.java @@ -27,20 +27,25 @@ import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NonNull; import org.apache.commons.lang3.ObjectUtils; -import org.onap.policy.common.parameters.BeanValidationResult; -import org.onap.policy.common.parameters.ValidationResult; +import org.onap.policy.common.parameters.annotations.NotBlank; +import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.models.base.PfAuthorative; import org.onap.policy.models.base.PfConcept; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfKey; +import org.onap.policy.models.base.validation.annotations.VerifyKey; @Data @EqualsAndHashCode(callSuper = false) public class DummyPfConcept extends PfConcept implements PfAuthorative<DummyAuthorativeConcept> { private static final long serialVersionUID = 1L; + @EmbeddedId + @VerifyKey + @NotNull private PfConceptKey key; + @NotBlank private String description; @@ -101,16 +106,6 @@ public class DummyPfConcept extends PfConcept implements PfAuthorative<DummyAuth } @Override - public ValidationResult validate(@NonNull String fieldName) { - BeanValidationResult result = new BeanValidationResult(fieldName, this); - - result.addResult(validateKeyNotNull("key", key)); - result.addResult(validateNotBlank("description", description, false)); - - return result; - } - - @Override public int compareTo(final PfConcept otherConcept) { if (otherConcept == null) { return -1; diff --git a/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfKey.java b/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfKey.java index 5a5891ad6..015d1a950 100644 --- a/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfKey.java +++ b/models-base/src/test/java/org/onap/policy/models/base/testconcepts/DummyPfKey.java @@ -24,7 +24,7 @@ package org.onap.policy.models.base.testconcepts; import java.util.Arrays; import java.util.List; import lombok.NonNull; -import org.onap.policy.common.parameters.ValidationResult; +import org.onap.policy.common.parameters.BeanValidationResult; import org.onap.policy.models.base.PfConcept; import org.onap.policy.models.base.PfKey; @@ -75,7 +75,7 @@ public class DummyPfKey extends PfKey { } @Override - public ValidationResult validate(@NonNull String fieldName) { + public BeanValidationResult validate(@NonNull String fieldName) { return null; } |