summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2021-04-28 15:45:22 -0400
committerJim Hahn <jrh3@att.com>2021-05-03 15:44:08 -0400
commite168ce2fad71650ad730519c772a9b093c0a8f43 (patch)
tree8d97f8823eb4f97916b2c19909c6b13e6a008e4a /core
parentcb09008c4d252dbc9a62f3a1d0b463a74380aa77 (diff)
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: I2c0c01fac355e6cde4d8d6998dc42f8a2e2ebb65 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'core')
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/EngineParameters.java43
-rw-r--r--core/core-engine/src/main/java/org/onap/policy/apex/core/engine/ExecutorParameters.java31
-rw-r--r--core/core-engine/src/test/java/org/onap/policy/apex/core/engine/EngineParametersTest.java4
-rw-r--r--core/core-engine/src/test/java/org/onap/policy/apex/core/engine/ExecutorParametersTest.java15
4 files changed, 28 insertions, 65 deletions
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/EngineParameters.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/EngineParameters.java
index 3ca74153e..3cf43c581 100644
--- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/EngineParameters.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/EngineParameters.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* 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.
@@ -24,14 +25,13 @@ package org.onap.policy.apex.core.engine;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.TreeMap;
import lombok.Getter;
import lombok.Setter;
import org.onap.policy.apex.context.parameters.ContextParameters;
-import org.onap.policy.common.parameters.GroupValidationResult;
-import org.onap.policy.common.parameters.ParameterGroup;
-import org.onap.policy.common.parameters.ValidationResult;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
+import org.onap.policy.common.parameters.annotations.NotNull;
+import org.onap.policy.common.parameters.annotations.Valid;
/**
* This class holds the parameters for a single Apex engine. This parameter class holds parameters for context schemas
@@ -51,44 +51,21 @@ import org.onap.policy.common.parameters.ValidationResult;
*/
@Getter
@Setter
-public class EngineParameters implements ParameterGroup {
- private ContextParameters contextParameters = new ContextParameters();
+@NotNull
+public class EngineParameters extends ParameterGroupImpl {
+ private @Valid ContextParameters contextParameters = new ContextParameters();
- // Parameter group name
- private String name;
// A map of parameters for executors of various logic types
- private Map<String, ExecutorParameters> executorParameterMap = new TreeMap<>();
+ private Map<String, @NotNull @Valid ExecutorParameters> executorParameterMap = new TreeMap<>();
// A list of parameters to be passed to the task, so that they can be used in the logic
- private List<TaskParameters> taskParameters = new ArrayList<>();
+ private List<@NotNull @Valid TaskParameters> taskParameters = new ArrayList<>();
/**
* Constructor to create an engine parameters instance and register the instance with the parameter service.
*/
public EngineParameters() {
- super();
-
- // Set the name for the parameters
- this.name = EngineParameterConstants.MAIN_GROUP_NAME;
+ super(EngineParameterConstants.MAIN_GROUP_NAME);
}
-
- @Override
- public GroupValidationResult validate() {
- final GroupValidationResult result = new GroupValidationResult(this);
-
- result.setResult("contextParameters", contextParameters.validate());
-
- for (Entry<String, ExecutorParameters> executorParEntry : executorParameterMap.entrySet()) {
- result.setResult("executorParameterMap", executorParEntry.getKey(), executorParEntry.getValue().validate());
- }
- for (TaskParameters taskParam : taskParameters) {
- ValidationResult taskParamValidationResult = taskParam.validate("taskParameters");
- result.setResult(taskParamValidationResult.getName(), taskParamValidationResult.getStatus(),
- taskParamValidationResult.getResult());
- }
- return result;
- }
-
-
}
diff --git a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/ExecutorParameters.java b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/ExecutorParameters.java
index 7de121d66..7bff07d9a 100644
--- a/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/ExecutorParameters.java
+++ b/core/core-engine/src/main/java/org/onap/policy/apex/core/engine/ExecutorParameters.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * 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.
@@ -20,8 +21,7 @@
package org.onap.policy.apex.core.engine;
-import org.onap.policy.common.parameters.GroupValidationResult;
-import org.onap.policy.common.parameters.ParameterGroup;
+import org.onap.policy.common.parameters.ParameterGroupImpl;
/**
* This class provides the executors for a logic flavour. Plugin classes for execution of task
@@ -32,10 +32,7 @@ import org.onap.policy.common.parameters.ParameterGroup;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ExecutorParameters implements ParameterGroup {
- // Parameter group name
- private String name;
-
+public class ExecutorParameters extends ParameterGroupImpl {
// Executor Plugin classes for executors
private String taskExecutorPluginClass;
private String taskSelectionExecutorPluginClass;
@@ -46,10 +43,7 @@ public class ExecutorParameters implements ParameterGroup {
* parameter service.
*/
public ExecutorParameters() {
- super();
-
- // Set the name for the parameters
- this.name = EngineParameterConstants.EXECUTOR_GROUP_NAME;
+ super(EngineParameterConstants.EXECUTOR_GROUP_NAME);
}
/**
@@ -110,23 +104,8 @@ public class ExecutorParameters implements ParameterGroup {
@Override
public String toString() {
- return "ExecutorParameters [name=" + name + ", taskExecutorPluginClass=" + taskExecutorPluginClass
+ return "ExecutorParameters [name=" + getName() + ", taskExecutorPluginClass=" + taskExecutorPluginClass
+ ", taskSelectionExecutorPluginClass=" + taskSelectionExecutorPluginClass
+ ", stateFinalizerExecutorPluginClass=" + stateFinalizerExecutorPluginClass + "]";
}
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public void setName(final String name) {
- this.name = name;
- }
-
- @Override
- public GroupValidationResult validate() {
- return new GroupValidationResult(this);
- }
}
diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/EngineParametersTest.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/EngineParametersTest.java
index ba936f24a..5427c3515 100644
--- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/EngineParametersTest.java
+++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/EngineParametersTest.java
@@ -2,6 +2,7 @@
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* 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.
@@ -21,6 +22,7 @@
package org.onap.policy.apex.core.engine;
+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;
@@ -59,6 +61,8 @@ public class EngineParametersTest {
taskParameters.add(new TaskParameters("param1key", "param1value", "param1taskId"));
taskParameters.add(new TaskParameters("param1key", "param1value", null));
pars.setTaskParameters(taskParameters);
+
+ assertThat(pars.validate().getResult()).isNull();
assertTrue(pars.validate().isValid());
ParameterService.register(pars);
diff --git a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/ExecutorParametersTest.java b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/ExecutorParametersTest.java
index 88c8c852d..784580422 100644
--- a/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/ExecutorParametersTest.java
+++ b/core/core-engine/src/test/java/org/onap/policy/apex/core/engine/ExecutorParametersTest.java
@@ -1,25 +1,27 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * 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.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.apex.core.engine;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -47,10 +49,11 @@ public class ExecutorParametersTest {
assertEquals("ExecutorParameters [name=Name, taskExecutorPluginClass=some.task.executor.plugin.class, "
+ "taskSelectionExecutorPluginClass=some.task.selection.executor.plugin.class, "
+ "stateFinalizerExecutorPluginClass=some.state.finalizer.plugin.class]", pars.toString());
-
+
+ assertThat(pars.validate().getResult()).isNull();
assertTrue(pars.validate().isValid());
-
-
+
+
ParameterService.register(pars);
ParameterService.deregister(pars);
}