From 4fdecb037bd2609a6b977adba6d2f263c977d9e1 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Mon, 26 Apr 2021 18:16:36 -0400 Subject: Remove GroupValidationResult Removed GroupValidationResult, replacing it with BeanValidationResult. Modified the ParameterGroup subclasses to use BeanValidator, adding annotations where needed to trigger the validations that had been automatically performed by GroupValidationResult. Issue-ID: POLICY-2059 Change-Id: I245e4a647fcbb718faa63a7543f9f81c85da958c Signed-off-by: Jim Hahn --- .../provider/PolicyModelsProviderParameters.java | 38 +++++++--------------- 1 file changed, 11 insertions(+), 27 deletions(-) (limited to 'models-provider/src/main/java') diff --git a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProviderParameters.java b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProviderParameters.java index 19345553b..bcd14c82b 100644 --- a/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProviderParameters.java +++ b/models-provider/src/main/java/org/onap/policy/models/provider/PolicyModelsProviderParameters.java @@ -23,10 +23,11 @@ package org.onap.policy.models.provider; import lombok.Data; -import org.onap.policy.common.parameters.GroupValidationResult; +import org.onap.policy.common.parameters.BeanValidationResult; +import org.onap.policy.common.parameters.BeanValidator; import org.onap.policy.common.parameters.ParameterGroup; -import org.onap.policy.common.parameters.ValidationStatus; -import org.onap.policy.common.utils.validation.ParameterValidationUtils; +import org.onap.policy.common.parameters.annotations.NotBlank; +import org.onap.policy.common.parameters.annotations.NotNull; import org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl; // @formatter:off @@ -55,42 +56,25 @@ public class PolicyModelsProviderParameters implements ParameterGroup { private static final String DEFAULT_IMPLEMENTATION = DatabasePolicyModelsProviderImpl.class.getName(); private String name; + @NotNull @NotBlank private String implementation = DEFAULT_IMPLEMENTATION; private String databaseType; + @NotNull @NotBlank private String databaseDriver; + @NotNull @NotBlank private String databaseUrl; private String databaseUser; private String databasePassword; + @NotNull @NotBlank private String persistenceUnit; /** * Validate the model provider parameters. * */ - @Override - public GroupValidationResult validate() { - final GroupValidationResult validationResult = new GroupValidationResult(this); - - if (!ParameterValidationUtils.validateStringParameter(implementation)) { - validationResult.setResult("implementation", ValidationStatus.INVALID, - "a PolicyModelsProvider implementation must be specified"); - } - - if (!ParameterValidationUtils.validateStringParameter(databaseDriver)) { - validationResult.setResult("databaseUrl", ValidationStatus.INVALID, - "a driver must be specified for the JDBC connection to the database"); - } - if (!ParameterValidationUtils.validateStringParameter(databaseUrl)) { - validationResult.setResult("databaseUrl", ValidationStatus.INVALID, - "a URL must be specified for the JDBC connection to the database"); - } - - if (!ParameterValidationUtils.validateStringParameter(persistenceUnit)) { - validationResult.setResult("persistenceUnit", ValidationStatus.INVALID, - "a persistence unit must be specified for connecting to the database"); - } - - return validationResult; + @Override + public BeanValidationResult validate() { + return new BeanValidator().validateTop(getClass().getSimpleName(), this); } } -- cgit 1.2.3-korg