Use annotations to do validation
[policy/models.git] / models-base / src / test / java / org / onap / policy / models / base / testconcepts / DummyPfConcept.java
index 67a4507..548c262 100644 (file)
@@ -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;
 
 
@@ -100,16 +105,6 @@ public class DummyPfConcept extends PfConcept implements PfAuthorative<DummyAuth
         description = (description != null ? description.trim() : null);
     }
 
-    @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) {