aboutsummaryrefslogtreecommitdiffstats
path: root/common/src/main/java
diff options
context:
space:
mode:
authorSmokowski, Steven <steve.smokowski@att.com>2019-08-15 21:40:16 -0400
committerBenjamin, Max (mb388a) <mb388a@att.com>2019-08-15 21:43:44 -0400
commitfa36daa658a50d9ca2e57cae649d63c0e9e2882a (patch)
tree09bec4b384664e59c5e3671eec5f17f8c68e8a02 /common/src/main/java
parente536a1035d0f224de32f76a1226c772b8f8d7c01 (diff)
Initial commit of validation framework to APIH
Move ListenerRunner to common location Adjust request params name, update junit tests Update validations to work properly Properly escape period for the string split Issue-ID: SO-2232 Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com> Change-Id: Ia468cf7062cccf30e28afeb7a5cddc37ceb2e002
Diffstat (limited to 'common/src/main/java')
-rw-r--r--common/src/main/java/org/onap/so/listener/ListenerRunner.java56
-rw-r--r--common/src/main/java/org/onap/so/listener/Skip.java29
-rw-r--r--common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java13
3 files changed, 97 insertions, 1 deletions
diff --git a/common/src/main/java/org/onap/so/listener/ListenerRunner.java b/common/src/main/java/org/onap/so/listener/ListenerRunner.java
new file mode 100644
index 0000000000..a489be6070
--- /dev/null
+++ b/common/src/main/java/org/onap/so/listener/ListenerRunner.java
@@ -0,0 +1,56 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.listener;
+
+import java.lang.annotation.Annotation;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Optional;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+import javax.annotation.Priority;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+
+public abstract class ListenerRunner {
+
+ @Autowired
+ protected ApplicationContext context;
+
+ public <T> List<T> filterListeners(List<T> validators, Predicate<T> predicate) {
+ return validators.stream().filter(item -> {
+ return !item.getClass().isAnnotationPresent(Skip.class) && predicate.test(item);
+ }).sorted(Comparator.comparing(item -> {
+ Priority p = Optional.ofNullable(item.getClass().getAnnotation(Priority.class)).orElse(new Priority() {
+ public int value() {
+ return 1000;
+ }
+
+ @Override
+ public Class<? extends Annotation> annotationType() {
+ return Priority.class;
+ }
+ });
+ return p.value();
+ })).collect(Collectors.toList());
+ }
+
+}
diff --git a/common/src/main/java/org/onap/so/listener/Skip.java b/common/src/main/java/org/onap/so/listener/Skip.java
new file mode 100644
index 0000000000..aa3ec2a204
--- /dev/null
+++ b/common/src/main/java/org/onap/so/listener/Skip.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 - 2019 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.listener;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Skip {
+
+}
diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java
index 9fceed1641..a72229a25c 100644
--- a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java
+++ b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java
@@ -57,6 +57,9 @@ public class RequestParameters implements Serializable {
@JsonProperty("rebuildVolumeGroups")
private Boolean rebuildVolumeGroups;
+ @JsonProperty("enforceValidNfValues")
+ private Boolean enforceValidNfValues = false;
+
@Override
public String toString() {
return new ToStringBuilder(this).append("subscriptionServiceType", subscriptionServiceType)
@@ -64,7 +67,15 @@ public class RequestParameters implements Serializable {
.append("usePreload", usePreload).append("autoBuildVfModules", autoBuildVfModules)
.append("cascadeDelete", cascadeDelete).append("testApi", testApi)
.append("retainAssignments", retainAssignments).append("rebuildVolumeGroups", rebuildVolumeGroups)
- .toString();
+ .append("enforceValidNfValues", enforceValidNfValues).toString();
+ }
+
+ public Boolean getEnforceValidNfValues() {
+ return enforceValidNfValues;
+ }
+
+ public void setEnforceValidNfValues(Boolean enforceValidNfValues) {
+ this.enforceValidNfValues = enforceValidNfValues;
}
public String getSubscriptionServiceType() {