summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParameters.java5
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandlerConfigurationParameterGroup.java26
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandlerConfigurationParameterGroup.java12
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandlerConfigurationParameterGroup.java7
4 files changed, 26 insertions, 24 deletions
diff --git a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParameters.java b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParameters.java
index 4d141a95..c266a1ba 100644
--- a/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParameters.java
+++ b/plugins/forwarding-plugins/src/main/java/org/onap/policy/distribution/forwarding/lifecycle/api/LifecycleApiForwarderParameters.java
@@ -24,6 +24,7 @@ package org.onap.policy.distribution.forwarding.lifecycle.api;
import lombok.Getter;
import org.onap.policy.common.parameters.annotations.NotBlank;
import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.common.parameters.annotations.Valid;
import org.onap.policy.distribution.main.parameters.PolicyForwarderConfigurationParameterGroup;
/**
@@ -37,8 +38,8 @@ import org.onap.policy.distribution.main.parameters.PolicyForwarderConfiguration
public class LifecycleApiForwarderParameters extends PolicyForwarderConfigurationParameterGroup {
public static final String POLICY_FORWARDER_PLUGIN_CLASS = LifecycleApiPolicyForwarder.class.getName();
- private LifecycleApiParameters apiParameters;
- private LifecycleApiParameters papParameters;
+ private @Valid LifecycleApiParameters apiParameters;
+ private @Valid LifecycleApiParameters papParameters;
private boolean isHttps;
private boolean allowSelfSignedCerts;
private boolean deployPolicies = true;
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandlerConfigurationParameterGroup.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandlerConfigurationParameterGroup.java
index 9c596f76..44e89c07 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandlerConfigurationParameterGroup.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandlerConfigurationParameterGroup.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Intel. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +25,10 @@ package org.onap.policy.distribution.reception.handling.file;
import java.io.File;
import lombok.Getter;
import lombok.Setter;
-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.ObjectValidationResult;
+import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
import org.onap.policy.common.parameters.annotations.NotBlank;
import org.onap.policy.common.parameters.annotations.NotNull;
@@ -51,9 +55,9 @@ public class FileSystemReceptionHandlerConfigurationParameterGroup extends Recep
* {@inheritDoc}.
*/
@Override
- public GroupValidationResult validate() {
- final GroupValidationResult validationResult = new GroupValidationResult(this);
- validatePathElement(validationResult, watchPath, "watchPath");
+ public BeanValidationResult validate() {
+ final BeanValidationResult validationResult = new BeanValidator().validateTop(getClass().getSimpleName(), this);
+ validationResult.addResult(validatePathElement(watchPath, "watchPath"));
return validationResult;
}
@@ -61,23 +65,17 @@ public class FileSystemReceptionHandlerConfigurationParameterGroup extends Recep
/**
* Validate the string element.
*
- * @param validationResult the result object
* @param element the element to validate
* @param elementName the element name for error message
*/
- private void validatePathElement(final GroupValidationResult validationResult, final String element,
- final String elementName) {
- boolean valid = false;
+ private ValidationResult validatePathElement(final String element, final String elementName) {
if (element != null) {
final File file = new File(element);
if (file.exists() && file.isDirectory()) {
- valid = true;
+ return null;
}
}
- if (!valid) {
- validationResult.setResult(elementName, ValidationStatus.INVALID,
- elementName + " must be a valid directory");
- }
+
+ return new ObjectValidationResult(elementName, element, ValidationStatus.INVALID, "is not a valid directory");
}
}
-
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandlerConfigurationParameterGroup.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandlerConfigurationParameterGroup.java
index 03455b84..c8bcc7bd 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandlerConfigurationParameterGroup.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandlerConfigurationParameterGroup.java
@@ -3,6 +3,7 @@
* Copyright (C) 2018 Intel. All rights reserved.
* Copyright (C) 2019 Nordix Foundation.
* Modifications Copyright (C) 2020 Nordix Foundation
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +23,7 @@
package org.onap.policy.distribution.reception.handling.file;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@@ -33,7 +35,7 @@ import java.io.IOException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationResult;
/**
* Class to perform unit test of {@link FileSystemReceptionHandlerConfigurationParameterGroup}.
@@ -54,7 +56,7 @@ public class TestFileSystemReceptionHandlerConfigurationParameterGroup {
configParameters.setWatchPath(validPath);
configParameters.setMaxThread(2);
- final GroupValidationResult validationResult = configParameters.validate();
+ final ValidationResult validationResult = configParameters.validate();
assertTrue(validationResult.isValid());
assertEquals(validPath, configParameters.getWatchPath());
assertEquals(2, configParameters.getMaxThread());
@@ -66,7 +68,7 @@ public class TestFileSystemReceptionHandlerConfigurationParameterGroup {
final Gson gson = new GsonBuilder().create();
configParameters = gson.fromJson(new FileReader("src/test/resources/handling-sdcInvalid.json"),
FileSystemReceptionHandlerConfigurationParameterGroup.class);
- final GroupValidationResult validationResult = configParameters.validate();
+ final ValidationResult validationResult = configParameters.validate();
assertFalse(validationResult.isValid());
}
@@ -79,8 +81,8 @@ public class TestFileSystemReceptionHandlerConfigurationParameterGroup {
new FileSystemReceptionHandlerConfigurationParameterGroup();
configParameters.setWatchPath(invalidPath);
- final GroupValidationResult validateResult = configParameters.validate();
+ final ValidationResult validateResult = configParameters.validate();
assertFalse(validateResult.isValid());
- assertTrue(validateResult.getResult().contains("must be a valid directory"));
+ assertThat(validateResult.getResult()).contains("is not a valid directory");
}
}
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandlerConfigurationParameterGroup.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandlerConfigurationParameterGroup.java
index 51298c1e..cd7f2614 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandlerConfigurationParameterGroup.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandlerConfigurationParameterGroup.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Intel. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,7 +32,7 @@ import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
import org.junit.Test;
-import org.onap.policy.common.parameters.GroupValidationResult;
+import org.onap.policy.common.parameters.ValidationResult;
import org.onap.policy.common.parameters.ValidationStatus;
/**
@@ -47,7 +48,7 @@ public class TestSdcReceptionHandlerConfigurationParameterGroup {
configParameters = gson.fromJson(new FileReader("src/test/resources/handling-sdc.json"),
SdcReceptionHandlerConfigurationParameterGroup.class);
- final GroupValidationResult validationResult = configParameters.validate();
+ final ValidationResult validationResult = configParameters.validate();
assertTrue(validationResult.isValid());
final SdcConfiguration config = new SdcConfiguration(configParameters);
assertEquals(Arrays.asList("a.com", "b.com", "c.com"), config.getMsgBusAddress());
@@ -75,7 +76,7 @@ public class TestSdcReceptionHandlerConfigurationParameterGroup {
configParameters = gson.fromJson(new FileReader("src/test/resources/handling-sdcInvalid.json"),
SdcReceptionHandlerConfigurationParameterGroup.class);
- final GroupValidationResult validationResult = configParameters.validate();
+ final ValidationResult validationResult = configParameters.validate();
assertFalse(validationResult.isValid());
}