From fa36daa658a50d9ca2e57cae649d63c0e9e2882a Mon Sep 17 00:00:00 2001 From: "Smokowski, Steven" Date: Thu, 15 Aug 2019 21:40:16 -0400 Subject: 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) Change-Id: Ia468cf7062cccf30e28afeb7a5cddc37ceb2e002 --- .../so/bpmn/common/listener/ListenerRunner.java | 60 ---------------------- .../org/onap/so/bpmn/common/listener/Skip.java | 29 ----------- .../listener/db/RequestsDbListenerRunner.java | 2 +- .../FlowManipulatorListenerRunner.java | 2 +- .../listener/validation/FlowValidatorRunner.java | 7 ++- .../listener/BuildingBlockValidatorRunnerTest.java | 2 +- .../listener/WorkflowValidatorRunnerTest.java | 2 +- .../listener/validation/MyDisabledValidator.java | 2 +- .../listener/validation/ValidationConfig.java | 4 +- 9 files changed, 13 insertions(+), 97 deletions(-) delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/ListenerRunner.java delete mode 100644 bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/Skip.java (limited to 'bpmn/MSOCommonBPMN/src') diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/ListenerRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/ListenerRunner.java deleted file mode 100644 index 3c36052dca..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/ListenerRunner.java +++ /dev/null @@ -1,60 +0,0 @@ -/*- - * ============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.bpmn.common.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.onap.so.client.exception.ExceptionBuilder; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; - -public abstract class ListenerRunner { - - @Autowired - protected ApplicationContext context; - - @Autowired - protected ExceptionBuilder exceptionBuilder; - - protected List filterListeners(List validators, Predicate 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 annotationType() { - return Priority.class; - } - }); - return p.value(); - })).collect(Collectors.toList()); - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/Skip.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/Skip.java deleted file mode 100644 index a0543fd3cc..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/Skip.java +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * ============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.bpmn.common.listener; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@Retention(RetentionPolicy.RUNTIME) -public @interface Skip { - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/db/RequestsDbListenerRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/db/RequestsDbListenerRunner.java index 68cda5c22b..69151ff74f 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/db/RequestsDbListenerRunner.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/db/RequestsDbListenerRunner.java @@ -27,9 +27,9 @@ import java.util.Optional; import java.util.stream.Collectors; import javax.annotation.PostConstruct; import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.onap.so.bpmn.common.listener.ListenerRunner; import org.onap.so.bpmn.common.listener.flowmanipulator.FlowManipulatorListenerRunner; import org.onap.so.db.request.beans.InfraActiveRequests; +import org.onap.so.listener.ListenerRunner; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java index 5f4dc871fb..ea7de687ee 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/flowmanipulator/FlowManipulatorListenerRunner.java @@ -27,8 +27,8 @@ import java.util.Optional; import java.util.stream.Collectors; import javax.annotation.PostConstruct; import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.onap.so.bpmn.common.listener.ListenerRunner; import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.listener.ListenerRunner; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/FlowValidatorRunner.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/FlowValidatorRunner.java index 040522b576..02cddf3655 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/FlowValidatorRunner.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/listener/validation/FlowValidatorRunner.java @@ -28,9 +28,11 @@ import org.camunda.bpm.engine.delegate.DelegateExecution; import org.javatuples.Pair; import org.onap.so.bpmn.common.BuildingBlockExecution; import org.onap.so.bpmn.common.DelegateExecutionImpl; -import org.onap.so.bpmn.common.listener.ListenerRunner; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.listener.ListenerRunner; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -47,6 +49,9 @@ public abstract class FlowValidatorRunner preFlowValidators; protected List postFlowValidators; diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/BuildingBlockValidatorRunnerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/BuildingBlockValidatorRunnerTest.java index 2c0377d11c..f4fe6d7158 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/BuildingBlockValidatorRunnerTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/BuildingBlockValidatorRunnerTest.java @@ -47,7 +47,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {ValidationConfig.class}) -public class BuildingBlockValidatorRunnerTest { +public class BuildingBlockValidatorRunnerTest extends BuildingBlockValidatorRunner { @Rule public ExpectedException thrown = ExpectedException.none(); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/WorkflowValidatorRunnerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/WorkflowValidatorRunnerTest.java index 0143e567af..596eced1d1 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/WorkflowValidatorRunnerTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/WorkflowValidatorRunnerTest.java @@ -45,7 +45,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = {ValidationConfig.class}) -public class WorkflowValidatorRunnerTest { +public class WorkflowValidatorRunnerTest extends WorkflowValidatorRunner { @Rule public ExpectedException thrown = ExpectedException.none(); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyDisabledValidator.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyDisabledValidator.java index af64ed2de6..544d370a3c 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyDisabledValidator.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/MyDisabledValidator.java @@ -23,8 +23,8 @@ package org.onap.so.bpmn.common.listener.validation; import java.util.Collections; import java.util.Optional; import org.onap.so.bpmn.common.BuildingBlockExecution; -import org.onap.so.bpmn.common.listener.Skip; import org.onap.so.bpmn.common.listener.validation.PreBuildingBlockValidator; +import org.onap.so.listener.Skip; import org.springframework.stereotype.Component; @Component diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/ValidationConfig.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/ValidationConfig.java index 068f433dd5..a3692a50b7 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/ValidationConfig.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/common/listener/validation/ValidationConfig.java @@ -21,13 +21,13 @@ package org.onap.so.bpmn.common.listener.validation; import org.onap.so.bpmn.common.DefaultToShortClassNameBeanNameGenerator; -import org.onap.so.bpmn.common.listener.ListenerRunner; import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.listener.ListenerRunner; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; @Configuration -@ComponentScan(basePackageClasses = {ExceptionBuilder.class, ListenerRunner.class}, +@ComponentScan(basePackageClasses = {ExceptionBuilder.class, ListenerRunner.class, WorkflowValidatorRunner.class}, nameGenerator = DefaultToShortClassNameBeanNameGenerator.class) public class ValidationConfig { -- cgit 1.2.3-korg