summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAjith Sreekumar <ajith.sreekumar@bell.ca>2022-03-09 17:43:56 +0000
committerGerrit Code Review <gerrit@onap.org>2022-03-09 17:43:56 +0000
commit636940708cd73f8b9571cf93804ee07987b69c53 (patch)
treef75372ef0aa766e62dd6e00e1efd07347830bfbe
parent5db295d6498aa0b3b1deda8b24ace8a71a229b58 (diff)
parentf4d465bc7391a39410836ceb1c1d25b20eaae74a (diff)
Merge "remove init, mdc, and controller logging features"
-rwxr-xr-xfeature-controller-logging/pom.xml103
-rwxr-xr-xfeature-controller-logging/src/assembly/assemble_zip.xml68
-rw-r--r--feature-controller-logging/src/main/feature/install/disable26
-rw-r--r--feature-controller-logging/src/main/feature/install/enable29
-rwxr-xr-xfeature-controller-logging/src/main/java/org/onap/policy/drools/controller/logging/ControllerLoggingFeature.java100
-rwxr-xr-xfeature-controller-logging/src/main/resources/META-INF/services/org.onap.policy.drools.features.DroolsControllerFeatureApi1
-rwxr-xr-xfeature-controller-logging/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyControllerFeatureApi1
-rwxr-xr-xfeature-controller-logging/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureApi1
-rwxr-xr-xfeature-controller-logging/src/test/java/org/onap/policy/drools/controller/logging/ControllerLoggingTest.java230
-rwxr-xr-xfeature-controller-logging/src/test/resources/kmodule.xml26
-rwxr-xr-xfeature-controller-logging/src/test/resources/logback-test.xml41
-rwxr-xr-xfeature-controller-logging/src/test/resources/test.drl35
-rwxr-xr-xfeature-controller-logging/src/test/resources/test.pom32
-rw-r--r--feature-drools-init/pom.xml86
-rw-r--r--feature-drools-init/src/assembly/assemble_zip.xml76
-rw-r--r--feature-drools-init/src/main/java/org/onap/policy/drools/droolsinit/DroolsInitFeature.java81
-rw-r--r--feature-drools-init/src/main/resources/META-INF/services/org.onap.policy.drools.core.PolicySessionFeatureApi1
-rw-r--r--feature-drools-init/src/test/java/org/onap/policy/drools/droolsinit/DroolsInitFeatureTest.java110
-rw-r--r--feature-lifecycle/src/test/resources/lifecycle.kmodule6
-rwxr-xr-xfeature-mdc-filters/pom.xml119
-rwxr-xr-xfeature-mdc-filters/src/assembly/assemble_zip.xml55
-rwxr-xr-xfeature-mdc-filters/src/main/feature/config/feature-mdc-filters.properties55
-rwxr-xr-xfeature-mdc-filters/src/main/feature/install/disable32
-rwxr-xr-xfeature-mdc-filters/src/main/feature/install/enable32
-rwxr-xr-xfeature-mdc-filters/src/main/java/org/onap/policy/drools/mdc/filters/MdcFilterFeature.java201
-rwxr-xr-xfeature-mdc-filters/src/main/java/org/onap/policy/drools/mdc/filters/MdcTopicFilter.java330
-rwxr-xr-xfeature-mdc-filters/src/main/resources/META-INF/services/org.onap.policy.common.endpoints.features.NetLoggerFeatureApi1
-rwxr-xr-xfeature-mdc-filters/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyControllerFeatureApi1
-rwxr-xr-xfeature-mdc-filters/src/test/java/org/onap/policy/drools/mdc/filters/MdcFilterFeatureTest.java166
-rwxr-xr-xfeature-mdc-filters/src/test/java/org/onap/policy/drools/mdc/filters/MdcTopicFilterTest.java644
-rwxr-xr-xfeature-mdc-filters/src/test/resources/onset.json18
-rw-r--r--packages/install/pom.xml12
-rw-r--r--pom.xml3
33 files changed, 3 insertions, 2719 deletions
diff --git a/feature-controller-logging/pom.xml b/feature-controller-logging/pom.xml
deleted file mode 100755
index 053633cf..00000000
--- a/feature-controller-logging/pom.xml
+++ /dev/null
@@ -1,103 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- feature-controller-logging
- ================================================================================
- Copyright (C) 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=========================================================
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onap.policy.drools-pdp</groupId>
- <artifactId>drools-pdp</artifactId>
- <version>1.10.1-SNAPSHOT</version>
- </parent>
-
- <artifactId>feature-controller-logging</artifactId>
-
- <name>feature-controller-logging</name>
- <description>Loadable module that enables individual network logs per controller</description>
-
- <properties>
- <maven.compiler.source>1.8</maven.compiler.source>
- <maven.compiler.target>1.8</maven.compiler.target>
- </properties>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>zipfile</id>
- <goals>
- <goal>single</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <attach>true</attach>
- <finalName>${project.artifactId}-${project.version}</finalName>
- <descriptors>
- <descriptor>src/assembly/assemble_zip.xml</descriptor>
- </descriptors>
- <appendAssemblyId>false</appendAssemblyId>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-dependencies</id>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <phase>prepare-package</phase>
- <configuration>
- <outputDirectory>${project.build.directory}/assembly/lib</outputDirectory>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>true</overWriteSnapshots>
- <overWriteIfNewer>true</overWriteIfNewer>
- <useRepositoryLayout>false</useRepositoryLayout>
- <addParentPoms>false</addParentPoms>
- <copyPom>false</copyPom>
- <includeScope>runtime</includeScope>
- <excludeTransitive>true</excludeTransitive>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.onap.policy.drools-pdp</groupId>
- <artifactId>policy-management</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
diff --git a/feature-controller-logging/src/assembly/assemble_zip.xml b/feature-controller-logging/src/assembly/assemble_zip.xml
deleted file mode 100755
index 6832604d..00000000
--- a/feature-controller-logging/src/assembly/assemble_zip.xml
+++ /dev/null
@@ -1,68 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- feature-controller-logging
- ================================================================================
- Copyright (C) 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=========================================================
- -->
-
-<!-- Defines how we build the .zip file which is our distribution. -->
-
-<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
- <id>feature-controller-logging</id>
- <formats>
- <format>zip</format>
- </formats>
-
- <includeBaseDirectory>false</includeBaseDirectory>
-
- <fileSets>
- <fileSet>
- <directory>target</directory>
- <outputDirectory>lib/feature</outputDirectory>
- <includes>
- <include>feature-controller-logging-${project.version}.jar</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>target/assembly/lib</directory>
- <outputDirectory>lib/dependencies</outputDirectory>
- <includes>
- <include>*.jar</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>src/main/feature/config</directory>
- <outputDirectory>config</outputDirectory>
- <fileMode>0644</fileMode>
- <excludes />
- </fileSet>
- <fileSet>
- <directory>src/main/feature/bin</directory>
- <outputDirectory>bin</outputDirectory>
- <fileMode>0744</fileMode>
- <excludes />
- </fileSet>
- <fileSet>
- <directory>src/main/feature/install</directory>
- <outputDirectory>install</outputDirectory>
- <fileMode>0744</fileMode>
- <excludes />
- </fileSet>
- </fileSets>
-
-</assembly>
diff --git a/feature-controller-logging/src/main/feature/install/disable b/feature-controller-logging/src/main/feature/install/disable
deleted file mode 100644
index f35c1dac..00000000
--- a/feature-controller-logging/src/main/feature/install/disable
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env sh
-
-# ============LICENSE_START=======================================================
-# feature-controller-logging
-# ================================================================================
-# Copyright (C) 2019-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.
-# ============LICENSE_END=========================================================
-
-configDir=${POLICY_HOME}/config
-for mainConfig in ${configDir}/logback.xml ${configDir}/logback-eelf.xml; do
- if [ -e "${mainConfig}" ]; then
- sed -i --follow-symlinks "/\<include.*logback\-include\-.*\.xml\>/d" "${mainConfig}"
- fi
-done
diff --git a/feature-controller-logging/src/main/feature/install/enable b/feature-controller-logging/src/main/feature/install/enable
deleted file mode 100644
index 55ae942c..00000000
--- a/feature-controller-logging/src/main/feature/install/enable
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/env sh
-
-# ============LICENSE_START=======================================================
-# feature-controller-logging
-# ================================================================================
-# Copyright (C) 2019-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.
-# ============LICENSE_END=========================================================
-
-configDir=${POLICY_HOME}/config
-for includedConfig in $(ls "${configDir}" | grep "logback-include-.*.xml"); do
- include="\t\<include optional\=\"true\" resource\=\"${includedConfig}\"/\>"
- for mainConfig in ${configDir}/logback.xml ${configDir}/logback-eelf.xml; do
- if [ -e "${mainConfig}" ]; then
- sed -i --follow-symlinks "/\<configuration.*\> /a\ ${include}" "${mainConfig}"
- fi
- done
-done
diff --git a/feature-controller-logging/src/main/java/org/onap/policy/drools/controller/logging/ControllerLoggingFeature.java b/feature-controller-logging/src/main/java/org/onap/policy/drools/controller/logging/ControllerLoggingFeature.java
deleted file mode 100755
index 6cca9cef..00000000
--- a/feature-controller-logging/src/main/java/org/onap/policy/drools/controller/logging/ControllerLoggingFeature.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * feature-controller-logging
- * ================================================================================
- * Copyright (C) 2019-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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.drools.controller.logging;
-
-import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.drools.controller.DroolsController;
-import org.onap.policy.drools.features.DroolsControllerFeatureApi;
-import org.onap.policy.drools.features.PolicyControllerFeatureApi;
-import org.onap.policy.drools.features.PolicyEngineFeatureApi;
-import org.onap.policy.drools.protocol.configuration.ControllerConfiguration;
-import org.onap.policy.drools.protocol.configuration.PdpdConfiguration;
-import org.onap.policy.drools.system.PolicyController;
-import org.onap.policy.drools.system.PolicyControllerConstants;
-import org.onap.policy.drools.system.PolicyEngine;
-import org.slf4j.LoggerFactory;
-
-/**
- * This class hooks the network logging implementation into DroolsPDP. It will disable the
- * default network logger where all topic traffic is logged and segregates the topic
- * traffic by controller for each supported control loop use case.
- */
-
-/*
- * PolicyControllerFeatureAPI - the 'beforeStart' hook is used to shut off the default
- * network logger and the 'beforeOffer' hook is used to log incoming topic messages
- *
- * DroolsControllerFeatureAPI - the 'afterDeliver' hook is where the outgoing topic
- * messages are logged
- *
- */
-public class ControllerLoggingFeature
- implements PolicyEngineFeatureApi, DroolsControllerFeatureApi, PolicyControllerFeatureApi {
-
- private static final String LINE_SEP = System.lineSeparator();
-
- @Override
- public int getSequenceNumber() {
- return 1000;
- }
-
- /**
- * The 'beforeOffer' hook will intercept an incoming topic message and append it to
- * the log file that is configured for the controller logger.
- */
- @Override
- public boolean beforeOffer(PolicyController controller, CommInfrastructure protocol, String topic, String event) {
- var controllerLogger = LoggerFactory.getLogger(controller.getName());
- controllerLogger.info("[IN|{}|{}]{}{}", protocol, topic, LINE_SEP, event);
- return false;
- }
-
- /**
- * The 'afterDeliver' hook will intercept an outgoing topic message and append it to
- * the log file that is configured for the controller logger.
- */
- @Override
- public boolean afterDeliver(DroolsController controller, TopicSink sink, Object fact, String json,
- boolean success) {
- if (success) {
- var controllerLogger = LoggerFactory
- .getLogger(PolicyControllerConstants.getFactory().get(controller).getName());
- controllerLogger.info("[OUT|{}|{}]{}{}", sink.getTopicCommInfrastructure(), sink.getTopic(),
- LINE_SEP, json);
- }
- return false;
- }
-
- /**
- * The 'afterOnTopicEvent' hook will determine which controllers were updated and log
- * the event to the appropriate controller logs.
- */
- @Override
- public boolean afterOnTopicEvent(PolicyEngine engine, PdpdConfiguration configuration, CommInfrastructure commType,
- String topic, String event) {
- for (ControllerConfiguration controller : configuration.getControllers()) {
- var controllerLogger = LoggerFactory.getLogger(controller.getName());
- controllerLogger.info("[IN|{}|{}]{}{}", commType, topic, LINE_SEP, event);
- }
- return false;
- }
-}
diff --git a/feature-controller-logging/src/main/resources/META-INF/services/org.onap.policy.drools.features.DroolsControllerFeatureApi b/feature-controller-logging/src/main/resources/META-INF/services/org.onap.policy.drools.features.DroolsControllerFeatureApi
deleted file mode 100755
index dbde0a80..00000000
--- a/feature-controller-logging/src/main/resources/META-INF/services/org.onap.policy.drools.features.DroolsControllerFeatureApi
+++ /dev/null
@@ -1 +0,0 @@
-org.onap.policy.drools.controller.logging.ControllerLoggingFeature
diff --git a/feature-controller-logging/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyControllerFeatureApi b/feature-controller-logging/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyControllerFeatureApi
deleted file mode 100755
index dbde0a80..00000000
--- a/feature-controller-logging/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyControllerFeatureApi
+++ /dev/null
@@ -1 +0,0 @@
-org.onap.policy.drools.controller.logging.ControllerLoggingFeature
diff --git a/feature-controller-logging/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureApi b/feature-controller-logging/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureApi
deleted file mode 100755
index dbde0a80..00000000
--- a/feature-controller-logging/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyEngineFeatureApi
+++ /dev/null
@@ -1 +0,0 @@
-org.onap.policy.drools.controller.logging.ControllerLoggingFeature
diff --git a/feature-controller-logging/src/test/java/org/onap/policy/drools/controller/logging/ControllerLoggingTest.java b/feature-controller-logging/src/test/java/org/onap/policy/drools/controller/logging/ControllerLoggingTest.java
deleted file mode 100755
index ecbb320d..00000000
--- a/feature-controller-logging/src/test/java/org/onap/policy/drools/controller/logging/ControllerLoggingTest.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * feature-controller-logging
- * ================================================================================
- * Copyright (C) 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.policy.drools.controller.logging;
-
-import static org.junit.Assert.assertEquals;
-
-import ch.qos.logback.classic.spi.LoggingEvent;
-import ch.qos.logback.core.AppenderBase;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import java.io.IOException;
-import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Properties;
-import org.junit.After;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.policy.common.endpoints.event.comm.Topic;
-import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.event.comm.bus.NoopTopicSink;
-import org.onap.policy.drools.controller.DroolsController;
-import org.onap.policy.drools.controller.DroolsControllerConstants;
-import org.onap.policy.drools.properties.DroolsPropertyConstants;
-import org.onap.policy.drools.protocol.configuration.ControllerConfiguration;
-import org.onap.policy.drools.protocol.configuration.PdpdConfiguration;
-import org.onap.policy.drools.system.PolicyController;
-import org.onap.policy.drools.system.PolicyEngineConstants;
-import org.onap.policy.drools.util.KieUtils;
-
-/**
- * Controller Logger Tests.
- */
-public class ControllerLoggingTest {
-
- /**
- * These properties are for installing a test artifact that the drools controller can
- * fetch while testing.
- */
- private static final String JUNIT_KMODULE_DRL_PATH = "src/test/resources/test.drl";
- private static final String JUNIT_KMODULE_POM_PATH = "src/test/resources/test.pom";
- private static final String JUNIT_KMODULE_PATH = "src/test/resources/kmodule.xml";
- private static final String JUNIT_KJAR_DRL_PATH = "src/main/resources/org/onap/policy/drools/test/";
-
- /**
- * These properties are used for the Policy Controller to point to the test artifact.
- */
- private static final String TEST_CONTROLLER_NAME = "test-controller";
- private static final String TEST_GROUP_ID = "org.onap.policy.drools.test";
- private static final String TEST_ARTIFACT_ID = "test";
- private static final String TEST_VERSION = "1.0.0";
-
- /**
- * A test topic used for delivery and network logging.
- */
- private static final String TEST_TOPIC = "test-topic";
- private static final String TEST_SERVER = "http://test.com";
-
- private static String message = null;
- private static PdpdConfiguration pdpdNotification = null;
- private static PolicyController policyController = null;
-
- /**
- * This is a list of events that are appended to the controller-test logger.
- */
- private static List<LoggingEvent> events = new ArrayList<>();
-
- /**
- * A custom appender used to intercept events and add them to a list of events that
- * the junits can use to determine logging was successful.
- */
- public static class NetworkAppender extends AppenderBase<LoggingEvent> {
-
- @Override
- protected void append(LoggingEvent event) {
- events.add(event);
- }
-
- }
-
- /**
- * Runs before all the test cases to install the drools artifact, create a policy
- * controller, and create a PDPD configuration notification.
- */
- @BeforeClass
- public static void setUp() throws IOException {
- KieUtils.installArtifact(Paths.get(JUNIT_KMODULE_PATH).toFile(), Paths.get(JUNIT_KMODULE_POM_PATH).toFile(),
- JUNIT_KJAR_DRL_PATH, Paths.get(JUNIT_KMODULE_DRL_PATH).toFile());
-
- // These properties are used for sending PDPD configuration notifications to a policy controller.
- Properties controllerProps = new Properties();
- controllerProps.put(DroolsPropertyConstants.PROPERTY_CONTROLLER_NAME, TEST_CONTROLLER_NAME);
- controllerProps.put(DroolsPropertyConstants.RULES_GROUPID, TEST_GROUP_ID);
- controllerProps.put(DroolsPropertyConstants.RULES_ARTIFACTID, TEST_ARTIFACT_ID);
- controllerProps.put(DroolsPropertyConstants.RULES_VERSION, TEST_VERSION);
-
- policyController =
- PolicyEngineConstants.getManager().createPolicyController(TEST_CONTROLLER_NAME, controllerProps);
-
- message = "{\"requestID\":\"38adde30-cc22-11e8-a8d5-f2801f1b9fd1\",\"entity\":\"controller\",\"controllers\":"
- + "[{\"name\":\"test-controller\",\"drools\":{\"groupId\":\"org.onap.policy.drools.test\","
- + "\"artifactId\":\"test\",\"version\":\"0.0.1\"},\"operation\":\"update\"}]}";
-
- Gson decoder = new GsonBuilder().disableHtmlEscaping().create();
- pdpdNotification = decoder.fromJson(message, PdpdConfiguration.class);
- }
-
- /**
- * Runs after every test case to clean up the events added to the event list during
- * unit test.
- */
- @After
- public void cleanUpLogs() {
- events.clear();
- }
-
- /**
- * Obtains the sequence number of the controller logging feature. This should return
- * 1000.
- */
- @Test
- public void getSequenceNumberTest() {
- ControllerLoggingFeature nlf = new ControllerLoggingFeature();
- assertEquals(1000, nlf.getSequenceNumber());
- }
-
- /**
- * Asserts that the controller-test logger appends the incoming message to the event
- * list.
- */
- @Test
- public void beforeOffer() {
- ControllerLoggingFeature nlf = new ControllerLoggingFeature();
-
- nlf.beforeOffer(policyController, Topic.CommInfrastructure.UEB, TEST_TOPIC, "{\"test\":\"test\"}");
-
- assertEquals(1, events.size());
- }
-
- /**
- * Asserts that the controller-test logger appends the outgoing message to the event
- * list.
- */
- @Test
- public void afterDeliverSuccess() {
-
- final ControllerLoggingFeature nlf = new ControllerLoggingFeature();
-
- DroolsController droolsController =
- DroolsControllerConstants.getFactory().get(TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION);
-
- NoopTopicSink sinkTopic = new NoopTopicSink(Arrays.asList(TEST_SERVER), TEST_TOPIC);
-
- nlf.afterDeliver(droolsController, sinkTopic, null, "{\"test\":\"test\"}", true);
-
- assertEquals(1, events.size());
-
- }
-
- /**
- * Asserts that the controller-test logger does not append the outgoing message to the
- * event list if there was a failure.
- */
- @Test
- public void afterDeliverFailure() {
-
- final ControllerLoggingFeature nlf = new ControllerLoggingFeature();
-
- DroolsController droolsController =
- DroolsControllerConstants.getFactory().get(TEST_GROUP_ID, TEST_ARTIFACT_ID, TEST_VERSION);
-
- NoopTopicSink sinkTopic = new NoopTopicSink(Arrays.asList(TEST_SERVER), TEST_TOPIC);
-
- nlf.afterDeliver(droolsController, sinkTopic, null, "{\"test\":\"test\"}", false);
-
- assertEquals(0, events.size());
- }
-
- /**
- * Asserts that the controller logging feature can log the messages to the proper
- * controller based on the message containing the controller name.
- */
- @Test
- public void afterOnTopicEventSuccess() {
- final ControllerLoggingFeature nlf = new ControllerLoggingFeature();
-
- nlf.afterOnTopicEvent(PolicyEngineConstants.getManager(), pdpdNotification, CommInfrastructure.UEB, TEST_TOPIC,
- message);
-
- assertEquals(1, events.size());
- }
-
- /**
- * Asserts that the controller logging feature can skip logging messages that don't
- * contain the controller names in it.
- */
- @Test
- public void afterOnTopicEventFailure() {
- final ControllerLoggingFeature nlf = new ControllerLoggingFeature();
-
- PdpdConfiguration notification = new PdpdConfiguration();
- ControllerConfiguration config = new ControllerConfiguration();
- config.setName("test-controller-2");
- notification.setControllers(Arrays.asList(config));
-
- nlf.afterOnTopicEvent(PolicyEngineConstants.getManager(), notification, CommInfrastructure.UEB, TEST_TOPIC,
- message);
-
- assertEquals(0, events.size());
- }
-}
diff --git a/feature-controller-logging/src/test/resources/kmodule.xml b/feature-controller-logging/src/test/resources/kmodule.xml
deleted file mode 100755
index 2410a0f7..00000000
--- a/feature-controller-logging/src/test/resources/kmodule.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============LICENSE_START=======================================================
- feature-controller-logging
- ================================================================================
- Copyright (C) 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=========================================================
- -->
-
-<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
- <kbase name="controller-logs">
- <ksession name="test" />
- </kbase>
-</kmodule>
diff --git a/feature-controller-logging/src/test/resources/logback-test.xml b/feature-controller-logging/src/test/resources/logback-test.xml
deleted file mode 100755
index dfe9a459..00000000
--- a/feature-controller-logging/src/test/resources/logback-test.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- feature-controller-logging
- ================================================================================
- Copyright (C) 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=========================================================
- -->
-<configuration>
-
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
- <Pattern>
- %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36}.%M\(%line\) - %msg%n
- </Pattern>
- </encoder>
- </appender>
- <logger name="org.onap.policy.drools.system.test" level="INFO" />
-
- <appender name="network"
- class="org.onap.policy.drools.controller.logging.ControllerLoggingTest$NetworkAppender" />
- <logger name="test-controller" level="INFO">
- <appender-ref ref="network" />
- </logger>
-
- <root level="INFO">
- <appender-ref ref="STDOUT" />
- </root>
-
-</configuration> \ No newline at end of file
diff --git a/feature-controller-logging/src/test/resources/test.drl b/feature-controller-logging/src/test/resources/test.drl
deleted file mode 100755
index dcae7fa3..00000000
--- a/feature-controller-logging/src/test/resources/test.drl
+++ /dev/null
@@ -1,35 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * feature-controller-logging
- * ================================================================================
- * Copyright (C) 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.policy.drools.test;
-
-rule "INIT"
-when
-then
- insert("This is a test");
-end
-
-rule "PRINT_MSG"
-when
- $o : Object();
-then
- System.out.println("MSG: " + $o);
- retract($o);
-end
diff --git a/feature-controller-logging/src/test/resources/test.pom b/feature-controller-logging/src/test/resources/test.pom
deleted file mode 100755
index 64be32f0..00000000
--- a/feature-controller-logging/src/test/resources/test.pom
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ============LICENSE_START=======================================================
- feature-controller-logging
- ================================================================================
- Copyright (C) 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=========================================================
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.onap.policy.drools.test</groupId>
- <artifactId>test</artifactId>
- <!-- the version below is irrelevant, as long as it matches what is in ControllerLoggingTest -->
- <version>1.0.0</version>
-
-</project>
diff --git a/feature-drools-init/pom.xml b/feature-drools-init/pom.xml
deleted file mode 100644
index 40ae9de6..00000000
--- a/feature-drools-init/pom.xml
+++ /dev/null
@@ -1,86 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- ONAP Policy Engine - Drools PDP
- ================================================================================
- Copyright (C) 2019-2020 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=========================================================
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.onap.policy.drools-pdp</groupId>
- <artifactId>drools-pdp</artifactId>
- <version>1.10.1-SNAPSHOT</version>
- </parent>
-
- <artifactId>feature-drools-init</artifactId>
- <name>feature-drools-init</name>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>zipfile</id>
- <goals>
- <goal>single</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <attach>true</attach>
- <finalName>${project.artifactId}-${project.version}</finalName>
- <descriptors>
- <descriptor>src/assembly/assemble_zip.xml</descriptor>
- </descriptors>
- <appendAssemblyId>false</appendAssemblyId>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.onap.policy.drools-pdp</groupId>
- <artifactId>policy-core</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.drools-pdp</groupId>
- <artifactId>policy-management</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.powermock</groupId>
- <artifactId>powermock-api-mockito2</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/feature-drools-init/src/assembly/assemble_zip.xml b/feature-drools-init/src/assembly/assemble_zip.xml
deleted file mode 100644
index 948cb11c..00000000
--- a/feature-drools-init/src/assembly/assemble_zip.xml
+++ /dev/null
@@ -1,76 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- feature-drools-init
- ================================================================================
- Copyright (C) 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=========================================================
- -->
-
-<!-- Defines how we build the .zip file which is our distribution. -->
-
-<assembly
- xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
-
- <id>feature-drools-init-package</id>
- <formats>
- <format>zip</format>
- </formats>
-
- <includeBaseDirectory>false</includeBaseDirectory>
-
- <fileSets>
- <fileSet>
- <directory>target</directory>
- <outputDirectory>lib/feature</outputDirectory>
- <includes>
- <include>feature-drools-init-${project.version}.jar</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>target/assembly/lib</directory>
- <outputDirectory>lib/dependencies</outputDirectory>
- <includes>
- <include>*.jar</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>src/main/feature/config</directory>
- <outputDirectory>config</outputDirectory>
- <fileMode>0644</fileMode>
- <excludes/>
- </fileSet>
- <fileSet>
- <directory>src/main/feature/bin</directory>
- <outputDirectory>bin</outputDirectory>
- <fileMode>0744</fileMode>
- <excludes/>
- </fileSet>
- <fileSet>
- <directory>src/main/feature/db</directory>
- <outputDirectory>db</outputDirectory>
- <fileMode>0744</fileMode>
- <excludes/>
- </fileSet>
- <fileSet>
- <directory>src/main/feature/install</directory>
- <outputDirectory>install</outputDirectory>
- <fileMode>0744</fileMode>
- <excludes/>
- </fileSet>
- </fileSets>
-
-</assembly>
diff --git a/feature-drools-init/src/main/java/org/onap/policy/drools/droolsinit/DroolsInitFeature.java b/feature-drools-init/src/main/java/org/onap/policy/drools/droolsinit/DroolsInitFeature.java
deleted file mode 100644
index 923083cb..00000000
--- a/feature-drools-init/src/main/java/org/onap/policy/drools/droolsinit/DroolsInitFeature.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * feature-drools-init
- * ================================================================================
- * Copyright (C) 2019, 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.drools.droolsinit;
-
-import java.io.Serializable;
-import java.util.concurrent.TimeUnit;
-import org.onap.policy.drools.core.PolicySession;
-import org.onap.policy.drools.core.PolicySessionFeatureApi;
-import org.onap.policy.drools.system.PolicyEngineConstants;
-
-/**
- * This feature inserts an object of class 'DroolsInitFeature.Init' into
- * every newly-created or updated Drools session, including those that were
- * initialized with persistent data. Rules matching on objects of this type
- * can then do things like initialize global data.
- */
-public class DroolsInitFeature implements PolicySessionFeatureApi {
- // default delay is 10 minutes
- private static final long DELAY = 600000L;
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public int getSequenceNumber() {
- return 0;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public PolicySession.ThreadModel selectThreadModel(PolicySession policySession) {
- new Init(policySession);
- return null;
- }
-
- /**
- * Instances of this class are inserted into Drools memory.
- */
- public static class Init implements Serializable {
- private static final long serialVersionUID = 1L;
-
- /**
- * Place this instance in Drools memory, and then remove it after
- * one minute, if it is still there.
- *
- * @param policySession the associated session
- */
- public Init(final PolicySession policySession) {
- // insert this instance into Drools memory
- final var factHandle = policySession.getKieSession().insert(this);
-
- // after 10 minutes, remove the object from Drools memory (if needed)
- PolicyEngineConstants.getManager().getExecutorService().schedule(() -> {
- if (policySession.getKieSession().getObject(factHandle) != null) {
- // object has not been removed by application -- remove it here
- policySession.getKieSession().delete(factHandle);
- }
- }, DELAY, TimeUnit.MILLISECONDS);
- }
- }
-}
diff --git a/feature-drools-init/src/main/resources/META-INF/services/org.onap.policy.drools.core.PolicySessionFeatureApi b/feature-drools-init/src/main/resources/META-INF/services/org.onap.policy.drools.core.PolicySessionFeatureApi
deleted file mode 100644
index 9c088eee..00000000
--- a/feature-drools-init/src/main/resources/META-INF/services/org.onap.policy.drools.core.PolicySessionFeatureApi
+++ /dev/null
@@ -1 +0,0 @@
-org.onap.policy.drools.droolsinit.DroolsInitFeature
diff --git a/feature-drools-init/src/test/java/org/onap/policy/drools/droolsinit/DroolsInitFeatureTest.java b/feature-drools-init/src/test/java/org/onap/policy/drools/droolsinit/DroolsInitFeatureTest.java
deleted file mode 100644
index 28b4d5e9..00000000
--- a/feature-drools-init/src/test/java/org/onap/policy/drools/droolsinit/DroolsInitFeatureTest.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * feature-drools-init
- * ================================================================================
- * Copyright (C) 2019-2020 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.policy.drools.droolsinit;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.kie.api.runtime.KieSession;
-import org.kie.api.runtime.rule.FactHandle;
-import org.onap.policy.drools.core.PolicySession;
-import org.onap.policy.drools.system.PolicyEngineConstants;
-import org.powermock.reflect.Whitebox;
-
-public class DroolsInitFeatureTest {
- private static final String POLICY_ENGINE_EXECUTOR_FIELD = "executorService";
- private static ScheduledExecutorService saveExec;
- private static PolicySession policySession;
- private static KieSession kieSession;
-
- private DroolsInitFeature feature;
-
- /**
- * Class-level initialization.
- */
- @BeforeClass
- public static void setUpBeforeClass() {
- saveExec = Whitebox.getInternalState(PolicyEngineConstants.getManager(), POLICY_ENGINE_EXECUTOR_FIELD);
-
- policySession = mock(PolicySession.class);
- kieSession = mock(KieSession.class);
- when(policySession.getKieSession()).thenReturn(kieSession);
- }
-
- /**
- * Restore 'PolicyEngineConstants.manager'.
- */
- @AfterClass
- public static void cleanup() {
- Whitebox.setInternalState(PolicyEngineConstants.getManager(), POLICY_ENGINE_EXECUTOR_FIELD, saveExec);
- }
-
- @Before
- public void setUp() {
- feature = new DroolsInitFeature();
- }
-
- @Test
- public void getSequenceNumberTest() {
- assertEquals(0, feature.getSequenceNumber());
- }
-
- @Test
- public void selectThreadModelTest() {
- assertNull(feature.selectThreadModel(policySession));
- }
-
- @Test
- public void testInit() {
- FactHandle factHandle = mock(FactHandle.class);
- when(kieSession.insert(any())).thenReturn(factHandle);
- when(kieSession.getObject(factHandle)).thenReturn(new Object());
-
- // dummy 'ScheduledExecutorService' -- 'schedule' runs immediately
- ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(3) {
- @Override
- public ScheduledFuture<?> schedule(Runnable runnable, long delay, TimeUnit unit) {
- runnable.run();
- return null;
- }
- };
-
- Whitebox.setInternalState(PolicyEngineConstants.getManager(), POLICY_ENGINE_EXECUTOR_FIELD, executorService);
-
- // triggers creation of 'DroolsInitFeature.Init'
- feature.selectThreadModel(policySession);
-
- // prove that the 'delete' code ran
- verify(kieSession).delete(factHandle);
- }
-}
diff --git a/feature-lifecycle/src/test/resources/lifecycle.kmodule b/feature-lifecycle/src/test/resources/lifecycle.kmodule
index 56ca0923..9ea1670a 100644
--- a/feature-lifecycle/src/test/resources/lifecycle.kmodule
+++ b/feature-lifecycle/src/test/resources/lifecycle.kmodule
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
============LICENSE_START=======================================================
- feature-controller-logging
+ ONAP
================================================================================
- Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ Copyright (C) 2019-2020, 2022 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.
@@ -26,4 +26,4 @@
<kbase name="onap.policies.type1.type2" includes="onap.policies.controlloop.operational.common.Drools">
<ksession name="junits" />
</kbase>
-</kmodule> \ No newline at end of file
+</kmodule>
diff --git a/feature-mdc-filters/pom.xml b/feature-mdc-filters/pom.xml
deleted file mode 100755
index f3c88fa4..00000000
--- a/feature-mdc-filters/pom.xml
+++ /dev/null
@@ -1,119 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- feature-mdc-filters
- ================================================================================
- Copyright (C) 2019-2020 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=========================================================
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <artifactId>drools-pdp</artifactId>
- <groupId>org.onap.policy.drools-pdp</groupId>
- <version>1.10.1-SNAPSHOT</version>
- </parent>
-
- <artifactId>feature-mdc-filters</artifactId>
-
- <name>feature-mdc-filters</name>
- <description>Loadable module that marks key fields in messages through logback mdc.</description>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-assembly-plugin</artifactId>
- <executions>
- <execution>
- <id>zipfile</id>
- <goals>
- <goal>single</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <attach>true</attach>
- <finalName>${project.artifactId}-${project.version}</finalName>
- <descriptors>
- <descriptor>src/assembly/assemble_zip.xml</descriptor>
- </descriptors>
- <appendAssemblyId>false</appendAssemblyId>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-dependencies</id>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <phase>prepare-package</phase>
- <configuration>
- <outputDirectory>${project.build.directory}/assembly/lib</outputDirectory>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>true</overWriteSnapshots>
- <overWriteIfNewer>true</overWriteIfNewer>
- <useRepositoryLayout>false</useRepositoryLayout>
- <addParentPoms>false</addParentPoms>
- <copyPom>false</copyPom>
- <includeScope>runtime</includeScope>
- <excludeTransitive>true</excludeTransitive>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
-
- <dependency>
- <groupId>org.onap.policy.common</groupId>
- <artifactId>policy-endpoints</artifactId>
- <version>${policy.common.version}</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.onap.policy.drools-pdp</groupId>
- <artifactId>policy-management</artifactId>
- <version>${project.version}</version>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-</project>
diff --git a/feature-mdc-filters/src/assembly/assemble_zip.xml b/feature-mdc-filters/src/assembly/assemble_zip.xml
deleted file mode 100755
index c85bbe52..00000000
--- a/feature-mdc-filters/src/assembly/assemble_zip.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- feature-mdc-filters
- ================================================================================
- Copyright (C) 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=========================================================
- -->
-
-<!-- Defines how we build the .zip file which is our distribution. -->
-
-<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
- <id>feature-mdc-filters</id>
- <formats>
- <format>zip</format>
- </formats>
-
- <includeBaseDirectory>false</includeBaseDirectory>
-
- <fileSets>
- <fileSet>
- <directory>target</directory>
- <outputDirectory>lib/feature</outputDirectory>
- <includes>
- <include>feature-mdc-filters-${project.version}.jar</include>
- </includes>
- </fileSet>
- <fileSet>
- <directory>src/main/feature/config</directory>
- <outputDirectory>config</outputDirectory>
- <fileMode>0644</fileMode>
- <excludes />
- </fileSet>
- <fileSet>
- <directory>src/main/feature/install</directory>
- <outputDirectory>install</outputDirectory>
- <fileMode>0744</fileMode>
- <excludes />
- </fileSet>
- </fileSets>
-
-</assembly>
diff --git a/feature-mdc-filters/src/main/feature/config/feature-mdc-filters.properties b/feature-mdc-filters/src/main/feature/config/feature-mdc-filters.properties
deleted file mode 100755
index 7402151c..00000000
--- a/feature-mdc-filters/src/main/feature/config/feature-mdc-filters.properties
+++ /dev/null
@@ -1,55 +0,0 @@
-###
-# ============LICENSE_START=======================================================
-# feature-mdc-filters
-# ================================================================================
-# Copyright (C) 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=========================================================
-###
-
-# The properties keys follow the controller topic configurations followed by a
-# a new topic property, 'mdcFilters'.
-#<protocol>.<type>.topics.<topic-name>.mdcFilters
-
-# The value of the property is broken down to the MDC key name to be used by the
-# feature followed by the path(s) to the desired field's value.
-#dmaap.sink.topics.example.mdcFilters=sampleKey=$.path.to.sample.key
-
-# The path always begins with '$' as this signifies the root of the JSON document.
-# The underlying library used is Jayway JsonPath. The library's query syntax is
-# supported for searching a JSON document. The query syntax and some examples
-# can be found at: https://github.com/json-path/JsonPath
-
-# Multiple fields can be found for a given JSON document by a comma separated list
-# of <mdcKey,jsonPath> pairs.
-#dmaap.sink.topics.example.mdcFilters=field1=$.field1,field2=$.field2
-
-# If a given topic supports multiple message types that have fields with the same
-# name, a '|' separated list can define multiple paths to a field. The feature
-# will loop through each path until it finds a match and returns it.
-#dmaap.sink.topics.example.mdcFilters=field1=$.field1|$.body.field1
-
-# dmaap source filters
-dmaap.source.topics.PDPD-CONFIGURATION.mdcFilters=requestID=$.requestID
-dmaap.source.topics.DCAE_TOPIC.mdcFilters=requestID=$.requestID
-dmaap.source.topics.APPC-CL.mdcFilters=requestID=$.CommonHeader.RequestID
-dmaap.source.topics.APPC-LCM-WRITE.mdcFilters=requestID=$.body.output.common-header.request-id
-dmaap.source.topics.SDNR-CL-RSP.mdcFilters=requestID=$.body.CommonHeader.RequestID
-
-# dmaap sink filters
-dmaap.sink.topics.POLICY-CL-MGT.mdcFilters=requestID=$.requestID
-dmaap.sink.topics.APPC-CL.mdcFilters=requestID=$.CommonHeader.RequestID
-dmaap.sink.topics.APPC-LCM-READ.mdcFilters=requestID=$.body.input.common-header.request-id
-dmaap.sink.topics.SDNR-CL.mdcFilters=requestID=$.body.CommonHeader.RequestID
-dmaap.sink.topics.DCAE_CL_RSP.mdcFilters=requestID=$.requestID
diff --git a/feature-mdc-filters/src/main/feature/install/disable b/feature-mdc-filters/src/main/feature/install/disable
deleted file mode 100755
index c95f6f9b..00000000
--- a/feature-mdc-filters/src/main/feature/install/disable
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/usr/bin/env sh
-
-###
-# ============LICENSE_START=======================================================
-# feature-mdc-filters
-# ================================================================================
-# Copyright (C) 2019-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.
-# ============LICENSE_END=========================================================
-##
-
-if [ "${DEBUG}" = "y" ]; then
- set -x
-fi
-
-CONFIG_DIR="${POLICY_HOME}"/config
-for mainConfig in ${CONFIG_DIR}/logback.xml ${CONFIG_DIR}/logback-eelf.xml; do
- if [ -e "${mainConfig}" ]; then
- sed -i --follow-symlinks 's/${abstractNetworkPattern}/${networkPattern}/' "${mainConfig}"
- fi
-done
diff --git a/feature-mdc-filters/src/main/feature/install/enable b/feature-mdc-filters/src/main/feature/install/enable
deleted file mode 100755
index 9066d9d7..00000000
--- a/feature-mdc-filters/src/main/feature/install/enable
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/usr/bin/env sh
-
-###
-# ============LICENSE_START=======================================================
-# feature-mdc-filters
-# ================================================================================
-# Copyright (C) 2019-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.
-# ============LICENSE_END=========================================================
-##
-
-if [ "${DEBUG}" = "y" ]; then
- set -x
-fi
-
-CONFIG_DIR="${POLICY_HOME}"/config
-for mainConfig in ${CONFIG_DIR}/logback.xml ${CONFIG_DIR}/logback-eelf.xml; do
- if [ -e "${mainConfig}" ]; then
- sed -i --follow-symlinks 's/${networkPattern}/${abstractNetworkPattern}/' "${mainConfig}"
- fi
-done
diff --git a/feature-mdc-filters/src/main/java/org/onap/policy/drools/mdc/filters/MdcFilterFeature.java b/feature-mdc-filters/src/main/java/org/onap/policy/drools/mdc/filters/MdcFilterFeature.java
deleted file mode 100755
index 015aac21..00000000
--- a/feature-mdc-filters/src/main/java/org/onap/policy/drools/mdc/filters/MdcFilterFeature.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * feature-mdc-filters
- * ================================================================================
- * Copyright (C) 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.policy.drools.mdc.filters;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import org.onap.policy.common.endpoints.event.comm.Topic;
-import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.features.NetLoggerFeatureApi;
-import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
-import org.onap.policy.drools.features.PolicyControllerFeatureApi;
-import org.onap.policy.drools.persistence.SystemPersistenceConstants;
-import org.onap.policy.drools.system.PolicyController;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-
-public class MdcFilterFeature implements NetLoggerFeatureApi, PolicyControllerFeatureApi {
-
- /**
- * Logger.
- */
- private static final Logger logger = LoggerFactory.getLogger(MdcFilterFeature.class);
-
- /**
- * Feature properties.
- */
- public static final String FEATURE_NAME = "feature-mdc-filters";
- public static final String SOURCE = "source";
- public static final String SINK = "sink";
- public static final String MDC_FILTERS = ".mdcFilters";
-
- /**
- * Mapping of 'protocol:type:topic' key to a 'MdcTopicFilter' object.
- */
- private Map<String, MdcTopicFilter> topicFilters = new HashMap<>();
-
- /**
- * Feature properties map obtained from the feature properties file.
- */
- private Properties featureProps = null;
-
- /**
- * Constructor.
- */
- public MdcFilterFeature() {
- super();
- featureProps = getFeatureProps();
- }
-
- /**
- * Gets the feature properties.
- *
- * @return the properties for this feature.
- */
- protected Properties getFeatureProps() {
- return SystemPersistenceConstants.getManager().getProperties(FEATURE_NAME);
- }
-
- /**
- * Sequence number to be used for order of feature implementer execution.
- */
- @Override
- public int getSequenceNumber() {
- return 1;
- }
-
- /**
- * Loops through all source and sink topics to find which topics have mdc filters and
- * inserts an MdcTopicFilter in to the topicFilters map.
- */
- @Override
- public boolean afterCreate(PolicyController controller) {
- createSourceTopicFilters(controller);
- createSinkTopicFilters(controller);
- return false;
- }
-
- /**
- * Extracts the fields in a JSON string that are to be logged in an abbreviated
- * message. The event delivery infrastructure details are put in the MDC as well using
- * the keys networkEventType (IN/OUT), networkProtocol (UEB/DMAAP/NOOP/REST), and
- * networkTopic.
- */
- @Override
- public boolean beforeLog(Logger eventLogger, EventType type, CommInfrastructure protocol, String topic,
- String message) {
-
- String filterKey = null;
- if (type == EventType.IN) {
- filterKey = getTopicKey(protocol.name().toLowerCase(), SOURCE, topic);
- } else {
- filterKey = getTopicKey(protocol.name().toLowerCase(), SINK, topic);
- }
-
- MDC.put("networkEventType", type.name());
- MDC.put("networkProtocol", protocol.name());
- MDC.put("networkTopic", topic);
-
- MdcTopicFilter filter = topicFilters.get(filterKey);
- if (filter != null) {
- for (Map.Entry<String, List<String>> entry : filter.find(message).entrySet()) {
- String mdcKey = entry.getKey();
- List<String> results = entry.getValue();
- if (results.isEmpty()) {
- logger.debug("No results found for key {}", mdcKey);
- } else if (results.size() > 1) {
- logger.debug("Multple results found for key {}, returning list as a string", mdcKey);
- MDC.put(mdcKey, results.toString());
- } else {
- MDC.put(mdcKey, results.get(0));
- }
- }
- } else {
- logger.debug("No mdc topic filters exist for key {}", filterKey);
- }
-
- return false;
- }
-
- /**
- * Clears the MDC mapping after a message is logged.
- */
- @Override
- public boolean afterLog(Logger eventLogger, EventType type, CommInfrastructure protocol, String topic,
- String message) {
- MDC.clear();
- return false;
- }
-
- /**
- * Creates a key using the protocol, type, and topic name.
- *
- * @param protocol defined as ueb, dmaap, noop
- * @param type defined as source or sink
- * @param topic name of the topic
- * @return a key that is the concatenation of the protocol, type, and topic name
- */
- private String getTopicKey(String protocol, String type, String topic) {
- return protocol + ":" + type + ":" + topic;
- }
-
- /**
- * Creates MdcTopicFilters for a source/sink topic based on the type.
- *
- * @param topic the topic name
- * @param type 'source' or 'sink'
- */
- private void createTopicFilter(Topic topic, String type) {
- String protocol = topic.getTopicCommInfrastructure().name().toLowerCase();
- String topicName = topic.getTopic();
-
- String propertyKey = protocol + "." + type + ".topics." + topicName + MDC_FILTERS;
- String propertyValue = featureProps.getProperty(propertyKey);
- if (propertyValue != null) {
- String topicKey = getTopicKey(protocol, type, topicName);
- if (!topicFilters.containsKey(topicKey)) {
- logger.debug("MdcTopicFilter created for {} {} topic {}", protocol, type, topicName);
- topicFilters.put(topicKey, new MdcTopicFilter(propertyValue));
- } else {
- logger.debug("An MdcTopicFilter already exists for key {}", topicKey);
- }
- } else {
- logger.debug("No MDC filters defined for {} {} topic {}", protocol, type, topicName);
- }
- }
-
- /**
- * Creates MdcTopicFilters for the controller's source topics.
- */
- private void createSourceTopicFilters(PolicyController controller) {
- controller.getTopicSources().forEach(sourceTopic -> createTopicFilter(sourceTopic, SOURCE));
- }
-
- /**
- * Creates MdcTopicFilters for the controller's sink topics.
- */
- private void createSinkTopicFilters(PolicyController controller) {
- controller.getTopicSinks().forEach(sinkTopic -> createTopicFilter(sinkTopic, SINK));
- }
-}
diff --git a/feature-mdc-filters/src/main/java/org/onap/policy/drools/mdc/filters/MdcTopicFilter.java b/feature-mdc-filters/src/main/java/org/onap/policy/drools/mdc/filters/MdcTopicFilter.java
deleted file mode 100755
index 36f63efd..00000000
--- a/feature-mdc-filters/src/main/java/org/onap/policy/drools/mdc/filters/MdcTopicFilter.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP
- * ================================================================================
- * Copyright (C) 2019, 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.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.drools.mdc.filters;
-
-import com.google.re2j.Pattern;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-import org.apache.commons.lang3.StringUtils;
-import org.onap.policy.drools.protocol.coders.JsonProtocolFilter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class MdcTopicFilter {
-
- private static final Logger logger = LoggerFactory.getLogger(MdcTopicFilter.class);
- private static final Pattern COMMA_SPACE_PAT = Pattern.compile("\\s*,\\s*");
- private static final Pattern EQUAL_PAT = Pattern.compile("\\s*=\\s*");
-
- public static final String MDC_KEY_ERROR = "mdcKey must be provided";
- public static final String JSON_PATH_ERROR = "json path(s) must be provided";
-
- private final Map<String, FilterRule> rules = new HashMap<>();
-
- @Getter
- @AllArgsConstructor
- public static class FilterRule {
- private String mdcKey;
- private List<String> paths;
-
- public FilterRule(String mdcKey, String path) {
- this.mdcKey = mdcKey;
- this.paths = Arrays.asList(path);
- }
-
- protected void setMdcKey(String mdcKey) {
- if (StringUtils.isBlank(mdcKey)) {
- throw new IllegalArgumentException(MDC_KEY_ERROR);
- }
- this.mdcKey = mdcKey;
- }
-
- protected void setPaths(List<String> paths) {
- if (nullOrEmpty(paths)) {
- throw new IllegalArgumentException(JSON_PATH_ERROR);
- }
- this.paths = paths;
- }
-
- protected void addPaths(List<String> paths) {
- if (nullOrEmpty(paths)) {
- throw new IllegalArgumentException(JSON_PATH_ERROR);
- }
- this.paths.addAll(paths);
- }
-
- protected void addPath(String path) {
- if (StringUtils.isBlank(path)) {
- throw new IllegalArgumentException(JSON_PATH_ERROR);
- }
- this.paths.add(path);
- }
- }
-
- protected MdcTopicFilter(String rawFilters) {
- for (String filter : COMMA_SPACE_PAT.split(rawFilters)) {
- var rule = createFilterRule(filter);
- rules.put(rule.mdcKey, rule);
- }
- }
-
- private FilterRule createFilterRule(String filter) {
- String[] filterKeyPaths = EQUAL_PAT.split(filter);
- if (filterKeyPaths.length != 2) {
- throw new IllegalArgumentException("could not parse filter rule");
- }
-
- String filterKey = filterKeyPaths[0];
- String paths = filterKeyPaths[1];
- List<String> filterPaths = new ArrayList<>(Arrays.asList(paths.split("(?<!\\|)\\|(?!\\|)")));
- return new FilterRule(filterKey, filterPaths);
- }
-
- /**
- * Gets all the filter rules for the topic.
- *
- * @return an array list of the rules for the topic
- */
- protected List<FilterRule> getFilterRule() {
- return new ArrayList<>(rules.values());
- }
-
- /**
- * Gets the filter rule for the specified key.
- *
- * @param mdcKey the key to the filter rule
- * @return the filter rule associated with the key
- */
- protected FilterRule getFilterRule(String mdcKey) {
- if (StringUtils.isBlank(mdcKey)) {
- throw new IllegalArgumentException(MDC_KEY_ERROR);
- }
- return rules.get(mdcKey);
- }
-
- /**
- * Adds a filter rule for the specified key and path.
- *
- * @param mdcKey the key to the filter rule
- * @param path the json path to the key
- * @return the filter rule that was added for the topic
- */
- protected FilterRule addFilterRule(String mdcKey, String path) {
- if (StringUtils.isBlank(path)) {
- throw new IllegalArgumentException(JSON_PATH_ERROR);
- }
- return addFilterRule(mdcKey, Arrays.asList(path));
- }
-
- /**
- * Adds a filter rule for the specified key and paths.
- *
- * @param mdcKey the key to the filter rule
- * @param paths the list of potential paths to the key
- * @return the filter rule that was added for the topic
- */
- protected FilterRule addFilterRule(String mdcKey, List<String> paths) {
- if (StringUtils.isBlank(mdcKey)) {
- throw new IllegalArgumentException(MDC_KEY_ERROR);
- }
-
- if (nullOrEmpty(paths)) {
- throw new IllegalArgumentException(JSON_PATH_ERROR);
- }
-
- if (rules.containsKey(mdcKey)) {
- throw new IllegalArgumentException("a filter rule already exists for key: " + mdcKey);
- }
-
- var rule = new FilterRule(mdcKey, paths);
- rules.put(mdcKey, rule);
- return rule;
- }
-
- private static boolean nullOrEmpty(List<String> paths) {
- return paths == null || paths.isEmpty();
- }
-
- /**
- * Modifies an existing filter rule by adding the specified path.
- *
- * @param mdcKey the key to the filter rule
- * @param path the path to the key
- * @return the filter rule that was modified
- */
- protected FilterRule modifyFilterRule(String mdcKey, String path) {
- if (StringUtils.isBlank(path)) {
- throw new IllegalArgumentException(JSON_PATH_ERROR);
- }
- return modifyFilterRule(mdcKey, Arrays.asList(path));
- }
-
- /**
- * Modifies an existing filter rule by adding the specified paths.
- *
- * @param mdcKey the key to the filter rule
- * @param paths the list of potential paths to the key
- * @return the filter rule that was modified
- */
- protected FilterRule modifyFilterRule(String mdcKey, List<String> paths) {
- if (StringUtils.isBlank(mdcKey)) {
- throw new IllegalArgumentException(MDC_KEY_ERROR);
- }
-
- if (nullOrEmpty(paths)) {
- throw new IllegalArgumentException(JSON_PATH_ERROR);
- }
-
- if (!rules.containsKey(mdcKey)) {
- throw new IllegalArgumentException("a filter rule doesn't exist for key: " + mdcKey);
- }
-
- FilterRule rule = rules.get(mdcKey);
- rule.addPaths(paths);
- return rule;
- }
-
- /**
- * Modifies an existing filter rule's key and replaces the paths with the specified
- * paths.
- *
- * @param oldMdcKey the old key to the filter rule
- * @param newMdcKey the new key to the filter rule
- * @param paths the list of potential paths to the key
- * @return the filter rule that was modified
- */
- protected FilterRule modifyFilterRule(String oldMdcKey, String newMdcKey, List<String> paths) {
- if (StringUtils.isBlank(oldMdcKey)) {
- throw new IllegalArgumentException("current mdcKey must be provided");
- }
-
- if (StringUtils.isBlank(newMdcKey)) {
- throw new IllegalArgumentException("new mdcKey must be provided");
- }
-
- if (oldMdcKey.equals(newMdcKey)) {
- throw new IllegalArgumentException("the old and new mdcKey are equivalent");
- }
- if (nullOrEmpty(paths)) {
- throw new IllegalArgumentException(JSON_PATH_ERROR);
- }
-
- if (rules.containsKey(newMdcKey)) {
- throw new IllegalArgumentException("a filter rule already exists for key: " + newMdcKey);
- }
-
- FilterRule rule = rules.remove(oldMdcKey);
- if (rule == null) {
- throw new IllegalArgumentException("a filter rule doesn't exist for key: " + oldMdcKey);
- }
-
- rule.setMdcKey(newMdcKey);
- rule.setPaths(paths);
- rules.put(newMdcKey, rule);
- return rule;
- }
-
- /**
- * Deletes all filter rules for the topic filter.
- */
- protected void deleteFilterRule() {
- rules.clear();
- }
-
- /**
- * Deletes an existing filter rule.
- *
- * @param mdcKey the key to the filter rule
- * @return the filter rule that was deleted
- */
- protected FilterRule deleteFilterRule(String mdcKey) {
- if (StringUtils.isBlank(mdcKey)) {
- throw new IllegalArgumentException(MDC_KEY_ERROR);
- }
- return rules.remove(mdcKey);
- }
-
- /**
- * Finds all fields for each topic filter rule. The results are stored in a map that
- * is indexed by the MDC key. Each MDC key has a list of results as multiple
- * occurrences of a key can be found in a JSON document.
- *
- * @param json the json string to be parsed
- * @return a map of mdc keys and list of results for each key
- */
- protected Map<String, List<String>> find(String json) {
- Map<String, List<String>> results = new HashMap<>();
- for (FilterRule rule : rules.values()) {
- List<String> matches = new ArrayList<>();
- for (String path : rule.getPaths()) {
-
- try {
- matches = JsonProtocolFilter.filter(json, path);
- } catch (Exception e) {
- logger.debug("Could not filter on path {} because of {}", path, e.getMessage(), e);
- }
-
- if (!matches.isEmpty()) {
- break;
- } else {
- logger.error("Could not find path {} in json {}", path, json);
- }
-
- }
- results.put(rule.getMdcKey(), matches);
- }
- return results;
- }
-
- /**
- * Finds all occurrences of a field in a JSON document based on the filter rule paths.
- *
- * @param json the json string to be parsed
- * @return a list of matches from the JSON document
- */
- protected List<String> find(String json, String mdcKey) {
- List<String> matches = new ArrayList<>();
- for (String path : rules.get(mdcKey).getPaths()) {
-
- try {
- matches = JsonProtocolFilter.filter(json, path);
- } catch (Exception e) {
- logger.debug("Could not filter on path {} because of {}", path, e.getMessage(), e);
- }
-
- if (!matches.isEmpty()) {
- break;
- }
-
- }
-
- if (matches.isEmpty()) {
- logger.error("Could not find any matches for key {} in json {}", mdcKey, json);
- }
-
- return matches;
- }
-}
diff --git a/feature-mdc-filters/src/main/resources/META-INF/services/org.onap.policy.common.endpoints.features.NetLoggerFeatureApi b/feature-mdc-filters/src/main/resources/META-INF/services/org.onap.policy.common.endpoints.features.NetLoggerFeatureApi
deleted file mode 100755
index f2fdb402..00000000
--- a/feature-mdc-filters/src/main/resources/META-INF/services/org.onap.policy.common.endpoints.features.NetLoggerFeatureApi
+++ /dev/null
@@ -1 +0,0 @@
-org.onap.policy.drools.mdc.filters.MdcFilterFeature
diff --git a/feature-mdc-filters/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyControllerFeatureApi b/feature-mdc-filters/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyControllerFeatureApi
deleted file mode 100755
index f2fdb402..00000000
--- a/feature-mdc-filters/src/main/resources/META-INF/services/org.onap.policy.drools.features.PolicyControllerFeatureApi
+++ /dev/null
@@ -1 +0,0 @@
-org.onap.policy.drools.mdc.filters.MdcFilterFeature
diff --git a/feature-mdc-filters/src/test/java/org/onap/policy/drools/mdc/filters/MdcFilterFeatureTest.java b/feature-mdc-filters/src/test/java/org/onap/policy/drools/mdc/filters/MdcFilterFeatureTest.java
deleted file mode 100755
index a8e0cf16..00000000
--- a/feature-mdc-filters/src/test/java/org/onap/policy/drools/mdc/filters/MdcFilterFeatureTest.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * feature-mdc-filters
- * ================================================================================
- * Copyright (C) 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.policy.drools.mdc.filters;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.List;
-import java.util.Properties;
-import org.junit.Before;
-import org.junit.Test;
-import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
-import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
-import org.onap.policy.common.endpoints.event.comm.TopicSink;
-import org.onap.policy.common.endpoints.event.comm.TopicSource;
-import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType;
-import org.onap.policy.drools.system.PolicyController;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.MDC;
-
-public class MdcFilterFeatureTest {
-
- /**
- * Logger.
- */
- private static final Logger logger = LoggerFactory.getLogger(MdcFilterFeatureTest.class);
-
- /**
- * Test topic names for mdc topic filters.
- */
- private static final String TEST_TOPIC_A = "org.onap.policy.test-topic-a";
- private static final String TEST_TOPIC_B = "org.onap.policy.test-topic-b";
-
- /**
- * The mock properties to be used for the junits.
- */
- private Properties props;
-
- /**
- * An instance of the MdcFilterFeature.
- */
- private MdcFilterFeature mdcFilterFeature;
-
- /**
- * Sample json string to be logged.
- */
- private String message;
-
- /**
- * Setup.
- * @throws IOException thrown if onset.json file could not be read
- */
- @Before
- public void setUp() throws IOException {
- message = new String(Files.readAllBytes(Paths.get("src/test/resources/onset.json")));
-
- props = mockFeatureProperties();
-
- props.setProperty("dmaap.source.topics", TEST_TOPIC_A);
- props.setProperty("dmaap.source.topics." + TEST_TOPIC_A + ".servers", "http://testing123.com/");
- props.setProperty("noop.sink.topics", TEST_TOPIC_B);
-
- // The mock PolicyController to be used for the junits.
- PolicyController controller = mock(PolicyController.class);
-
- List<TopicSource> topicSources = TopicEndpointManager.getManager().addTopicSources(props);
- doReturn(topicSources).when(controller).getTopicSources();
-
- List<TopicSink> topicSinks = TopicEndpointManager.getManager().addTopicSinks(props);
- doReturn(topicSinks).when(controller).getTopicSinks();
-
- mdcFilterFeature = new MdcFilterFeatureImpl();
- mdcFilterFeature.afterCreate(controller);
- }
-
- /**
- * Tests extracting fields from a JSON message and place them in the MDC and
- * then clearing the MDC.
- */
- @Test
- public void mdcLogTest() {
- mdcFilterFeature.beforeLog(logger, EventType.IN,
- CommInfrastructure.DMAAP, TEST_TOPIC_A, message);
-
- assertEquals("8c1b8bd8-06f7-493f-8ed7-daaa4cc481bc", MDC.get("requestID"));
- assertEquals("CL-TEST", MDC.get("closedLoopControlName"));
-
- assertNotNull(MDC.getCopyOfContextMap());
-
- mdcFilterFeature.afterLog(logger, EventType.IN,
- CommInfrastructure.DMAAP, TEST_TOPIC_A, message);
-
- assertNull(MDC.getCopyOfContextMap());
- }
-
- /**
- * Tests that the feature does not search for fields in a JSON message
- * if there is not an MdcTopicFilter object for the generated key.
- */
- @Test
- public void noTopicFilterTest() {
- mdcFilterFeature.beforeLog(logger, EventType.OUT,
- CommInfrastructure.NOOP, "no-topic", message);
-
- assertEquals("OUT", MDC.get("networkEventType"));
- assertEquals("NOOP", MDC.get("networkProtocol"));
- assertEquals("no-topic", MDC.get("networkTopic"));
- assertNull(MDC.get("requestID"));
- }
-
- /**
- * Creates a simple properties map containing an mdc filter for a test
- * topic.
- *
- * @return a properties map with mdc filter properties.
- */
- private Properties mockFeatureProperties() {
- Properties props = new Properties();
-
- String key = "dmaap.source.topics." + TEST_TOPIC_A + ".mdcFilters";
- String value = "requestID=$.requestID,closedLoopControlName=$.closedLoopControlName";
- props.setProperty(key, value);
-
- return props;
- }
-
- /**
- * Subclass of MdcFilterFeature for junit usage.
- */
- private class MdcFilterFeatureImpl extends MdcFilterFeature {
-
- public MdcFilterFeatureImpl() {
- super();
- }
-
- @Override
- protected Properties getFeatureProps() {
- return props;
- }
- }
-}
diff --git a/feature-mdc-filters/src/test/java/org/onap/policy/drools/mdc/filters/MdcTopicFilterTest.java b/feature-mdc-filters/src/test/java/org/onap/policy/drools/mdc/filters/MdcTopicFilterTest.java
deleted file mode 100755
index 2a3f251d..00000000
--- a/feature-mdc-filters/src/test/java/org/onap/policy/drools/mdc/filters/MdcTopicFilterTest.java
+++ /dev/null
@@ -1,644 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * feature-mdc-filters
- * ================================================================================
- * Copyright (C) 2019-2020 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.policy.drools.mdc.filters;
-
-import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import org.junit.Test;
-import org.onap.policy.drools.mdc.filters.MdcTopicFilter.FilterRule;
-
-public class MdcTopicFilterTest {
-
- /**
- * Test the simple case of having one filter rule for a key.
- */
- @Test
- public void singleFilterOnePathTest() {
- String topicFilterProp = "requestID=$.requestID";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
-
- FilterRule rule = topicFilter.getFilterRule("requestID");
- assertEquals("requestID", rule.getMdcKey());
- assertEquals("[$.requestID]", rule.getPaths().toString());
- }
-
- /**
- * Tests having one filter rule with a set of potential paths to the key.
- */
- @Test
- public void singleFilterMultiPathTest() {
- String topicFilterProp = "requestID=$.requestID|$.request-id";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
-
- FilterRule rule = topicFilter.getFilterRule("requestID");
- assertEquals("requestID", rule.getMdcKey());
- assertEquals(2, rule.getPaths().size());
- assertEquals("[$.requestID, $.request-id]", rule.getPaths().toString());
- }
-
- /**
- * Tests having two filter rules that each have one key/path pair.
- */
- @Test
- public void multiFilterSinglePathTest() {
- String topicFilterProp = "requestID=$.requestID,closedLoopControlName=$.closedLoopControlName";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
-
- FilterRule rule = topicFilter.getFilterRule("requestID");
- assertEquals("requestID", rule.getMdcKey());
- assertEquals(1, rule.getPaths().size());
- assertEquals("[$.requestID]", rule.getPaths().toString());
-
- FilterRule rule2 = topicFilter.getFilterRule("closedLoopControlName");
- assertEquals("closedLoopControlName", rule2.getMdcKey());
- assertEquals(1, rule2.getPaths().size());
- assertEquals("[$.closedLoopControlName]", rule2.getPaths().toString());
- }
-
- /**
- * Tests having two filter rules that each have two key/path pairs.
- */
- @Test
- public void multiFilterMultiPathTest() {
- String topicFilterProp = "requestID=$.requestID|$.body.request-id,"
- + "closedLoopControlName=$.closedLoopControlName"
- + "|$.body.closedLoopControlName";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
-
- FilterRule rule = topicFilter.getFilterRule("requestID");
- assertEquals("requestID", rule.getMdcKey());
- assertEquals(2, rule.getPaths().size());
- assertEquals("[$.requestID, $.body.request-id]", rule.getPaths().toString());
-
- FilterRule rule2 = topicFilter.getFilterRule("closedLoopControlName");
- assertEquals("closedLoopControlName", rule2.getMdcKey());
- assertEquals(2, rule2.getPaths().size());
- assertEquals("[$.closedLoopControlName, $.body.closedLoopControlName]", rule2.getPaths().toString());
- }
-
- /**
- * Tests that the regex split logic for '|' in the feature code doesn't
- * break parsing when "||" is used as a predicate in a JsonPath query.
- */
- @Test
- public void addOrPredicateFilterTest() {
- String topicFilterProp = "requestID=$.requestID||$.body.requestID";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
- assertEquals(1, topicFilter.getFilterRule().size());
- assertEquals("requestID", topicFilter.getFilterRule("requestID").getMdcKey());
- assertEquals(Arrays.asList("$.requestID||$.body.requestID"), topicFilter
- .getFilterRule("requestID").getPaths());
- }
-
- /**
- * Tests getting all filter rules for a given topic.
- */
- @Test
- public void getAllFilterRulesTest() {
- String topicFilterProp = "requestID=$.requestID,subRequestID=$.subRequestID,"
- + "closedLoopControlName=$.closedLoopControlName";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
- assertEquals(3, topicFilter.getFilterRule().size());
- }
-
- /**
- * Tests getting a filter rule by its key.
- */
- @Test
- public void getFilterRuleTest() {
- String topicFilterProp = "requestID=$.requestID,subRequestID=$.subRequestID,"
- + "closedLoopControlName=$.closedLoopControlName";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
-
- FilterRule rule = topicFilter.getFilterRule("requestID");
- assertNotNull(rule);
- }
-
- /**
- * Tests throwing an exception for passing in a null key.
- */
- @Test(expected = IllegalArgumentException.class)
- public void getFilterRuleNullKeyTest() {
- String topicFilterProp = "requestID=$.requestID,subRequestID=$.subRequestID";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
- topicFilter.getFilterRule(null);
- }
-
- /**
- * Tests throwing an exception for passing in an empty key.
- */
- @Test(expected = IllegalArgumentException.class)
- public void getFilterRuleEmptyKeyTest() {
- String topicFilterProp = "requestID=$.requestID,subRequestID=$.subRequestID";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
- topicFilter.getFilterRule("");
- }
-
- /**
- * Tests adding a filter rule with a single path.
- */
- @Test
- public void addFilterRuleSinglePathTest() {
- String topicFilterProp = "requestID=$.requestID";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
-
- String key = "subRequestID";
- String path = "$.subRequestID";
- FilterRule rule = topicFilter.addFilterRule(key, path);
- assertEquals(topicFilter.getFilterRule(key), rule);
- }
-
- /**
- * Tests adding a filter rule with multiple paths.
- */
- @Test
- public void addFilterRuleMultiPathTest() {
- String topicFilterProp = "requestID=$.requestID";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
-
- String key = "subRequestID";
- List<String> paths = Arrays.asList("$.subRequestID", "$.sub-request-id");
- FilterRule rule = topicFilter.addFilterRule(key, paths);
- assertEquals(topicFilter.getFilterRule(key), rule);
- }
-
- /**
- * Tests throwing an exception for passing a null key and a
- * single path.
- */
- @Test(expected = IllegalArgumentException.class)
- public void addFilterRuleNullKeyStringPathTest() {
- addFilterRuleValidateFailure(null, "$.subRequestID");
- }
-
- /**
- * Tests throwing an exception for passing a null key and a list
- * of paths.
- */
- @Test(expected = IllegalArgumentException.class)
- public void addFilterRuleNullKeyPathListTest() {
- addFilterRuleValidateFailure(null, Arrays.asList("$.subRequestID"));
- }
-
- /**
- * Tests throwing an exception for passing an empty key and
- * a single path.
- */
- @Test(expected = IllegalArgumentException.class)
- public void addFilterRuleEmptyKeyStringPathTest() {
- addFilterRuleValidateFailure("", "$.subRequestID");
- }
-
- /**
- * Tests throwing an exception for passing an empty key and
- * a list of paths.
- */
- @Test(expected = IllegalArgumentException.class)
- public void addFilterRuleEmptyKeyPathListTest() {
- addFilterRuleValidateFailure("", Arrays.asList("$.subRequestID"));
- }
-
- /**
- * Tests throwing an exception for passing an empty path string.
- */
- @Test(expected = IllegalArgumentException.class)
- public void addFilterRuleEmptyPathTest() {
- addFilterRuleValidateFailure("subRequestID", "");
- }
-
- /**
- * Tests throwing an exception for passing an empty paths list.
- */
- @Test(expected = IllegalArgumentException.class)
- public void addFilterRuleEmptyPathsTest() {
- addFilterRuleValidateFailure("subRequestID", Arrays.asList());
- }
-
- /**
- * Tests throwing an exception for trying to add a filter with a key that
- * already exists with a single filter.
- */
- @Test(expected = IllegalArgumentException.class)
- public void addExistingFilterRuleStringTest() {
- addFilterRuleValidateFailure("requestID", "$.test");
- }
-
- /**
- * Tests throwing an exception for trying to add a filter with a key that
- * already exists with a list of filters.
- */
- @Test(expected = IllegalArgumentException.class)
- public void addExistingFilterRuleListTest() {
- addFilterRuleValidateFailure("requestID", Arrays.asList("$.test"));
- }
-
- @Test
- public void createFilterRuleExceptionTest() {
- assertThatIllegalArgumentException().isThrownBy(() -> new MdcTopicFilter("invalid filter"))
- .withMessage("could not parse filter rule");
- }
-
- /**
- * Tests modifying a filter rule to add a new path.
- */
- @Test
- public void modifyFilterRuleSinglePathTest() {
- String topicFilterProp = "requestID=$.requestID";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
-
- FilterRule rule = topicFilter.modifyFilterRule("requestID", "$.request-id");
- assertEquals(topicFilter.getFilterRule("requestID"), rule);
- assertEquals(Arrays.asList("$.requestID", "$.request-id"), rule.getPaths());
- }
-
- /**
- * Tests modifying a filter rule to add a list of new paths.
- */
- @Test
- public void modifyFilterRuleMultiPathTest() {
- String topicFilterProp = "requestID=$.requestID";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
-
- FilterRule rule = topicFilter.modifyFilterRule("requestID",
- Arrays.asList("$.request-id", "$.requestId"));
- assertEquals(topicFilter.getFilterRule("requestID"), rule);
- assertEquals(
- Arrays.asList("$.requestID", "$.request-id", "$.requestId"),
- rule.getPaths());
- }
-
- @Test
- public void testModifyFilterRuleMultiPathException() {
- MdcTopicFilter filter = new MdcTopicFilter("abc=$a.value");
- assertThatIllegalArgumentException()
- .isThrownBy(() -> filter.modifyFilterRule("def", "abc", Arrays.asList("$.b", "$.c")))
- .withMessage("a filter rule already exists for key: abc");
- }
-
- /**
- * Tests modifying a filter rule key.
- */
- @Test
- public void modifyFilterRuleKeyTest() {
- String topicFilterProp = "requestID=$.requestID";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
-
- FilterRule rule = topicFilter.modifyFilterRule("requestID",
- "request-id", Arrays.asList("$.request-id"));
- assertEquals(topicFilter.getFilterRule("request-id"), rule);
- assertEquals("[$.request-id]", rule.getPaths().toString());
- }
-
- /**
- * Tests throwing an exception when passing a null key and
- * a single path.
- */
- @Test(expected = IllegalArgumentException.class)
- public void modifyFilterRuleNullKeyStringPathTest() {
- modifyFilterRuleValidateFailure(null, "$.request-id");
- }
-
- /**
- * Tests throwing an exception when passing a null key and
- * a list of multiple paths.
- */
- @Test(expected = IllegalArgumentException.class)
- public void modifyFilterRuleNullKeyPathListTest() {
- modifyFilterRuleValidateFailure(null, Arrays.asList("$.request-id"));
- }
-
- /**
- * Tests throwing an exception when passing an empty key and
- * a single path.
- */
- @Test(expected = IllegalArgumentException.class)
- public void modifyFilterRuleEmptyKeyStringPathTest() {
- modifyFilterRuleValidateFailure("", "$.request-id");
- }
-
- /**
- * Tests throwing an exception when passing an empty key and
- * a list of multiple paths.
- */
- @Test(expected = IllegalArgumentException.class)
- public void modifyFilterRuleEmptyKeyPathListTest() {
- modifyFilterRuleValidateFailure("", Arrays.asList("$.request-id"));
- }
-
- /**
- * Tests throwing an exception when passing an empty string path.
- */
- @Test(expected = IllegalArgumentException.class)
- public void modifyFilterRuleEmptyPathStringTest() {
- modifyFilterRuleValidateFailure("requestID", "");
- }
-
- /**
- * Tests throwing an exception when passing an empty list of paths.
- */
- @Test(expected = IllegalArgumentException.class)
- public void modifyFilterRuleEmptyPathListTest() {
- modifyFilterRuleValidateFailure("requestID", Arrays.asList());
- }
-
- /**
- * Tests throwing an exception when passing a key that is
- * not in the filter rules map and a string path.
- */
- @Test(expected = IllegalArgumentException.class)
- public void modifyFilterRuleMissingKeyStringPathTest() {
- modifyFilterRuleValidateFailure("request-id", "$.request-id");
- }
-
- /**
- * Tests throwing an exception when passing a key that is
- * not in the filter rules map and a list of paths.
- */
- @Test(expected = IllegalArgumentException.class)
- public void modifyFilterRuleMissingKeyPathListTest() {
- modifyFilterRuleValidateFailure("request-id", Arrays.asList("$.request-id"));
- }
-
-
- /**
- * Tests throwing an exception when passing a null oldKey.
- */
- @Test(expected = IllegalArgumentException.class)
- public void modifyFilterRuleNullOldKeyTest() {
- modifyFilterRuleValidateFailure(null, "request-id", Arrays.asList("$.request-id"));
- }
-
- /**
- * Tests throwing an exception when passing an empty oldKey.
- */
- @Test(expected = IllegalArgumentException.class)
- public void modifyFilterRuleEmptyOldKeyTest() {
- modifyFilterRuleValidateFailure("", "request-id", Arrays.asList("$.request-id"));
- }
-
- /**
- * Tests throwing an exception when passing a null newKey.
- */
- @Test(expected = IllegalArgumentException.class)
- public void modifyFilterRuleNullNewKeyTest() {
- modifyFilterRuleValidateFailure("requestID", null, Arrays.asList("$.request-id"));
- }
-
- /**
- * Tests throwing an exception when passing an empty newKey.
- */
- @Test(expected = IllegalArgumentException.class)
- public void modifyFilterRuleEmptyNewKeyTest() {
- modifyFilterRuleValidateFailure("requestID", "", Arrays.asList("$.request-id"));
- }
-
- /**
- * Tests throwing an exception when the old and new key are the same.
- */
- @Test(expected = IllegalArgumentException.class)
- public void modifyFilterRuleSameKeyTest() {
- modifyFilterRuleValidateFailure("requestID", "requestID", Arrays.asList("$.request-id"));
- }
-
- /**
- * Tests throwing an exception when passing an empty paths list.
- */
- @Test(expected = IllegalArgumentException.class)
- public void modifyFilterRuleEmptyPathsTest() {
- modifyFilterRuleValidateFailure("requestID", "request-id", Arrays.asList());
- }
-
- /**
- * Tests throwing an exception when the old key doesn't exist
- * in the rules map.
- */
- @Test(expected = IllegalArgumentException.class)
- public void modifyFilterRuleNonExistingOldKeyTest() {
- modifyFilterRuleValidateFailure("request-id", "id", Arrays.asList("$.request-id"));
- }
-
- /**
- * Tests deleting all filter rules in the rules map.
- */
- @Test
- public void deleteAllFilterRulesTest() {
- String topicFilterProp = "requestID=$.requestID,subRequestID=$.subRequestID,"
- + "closedLoopControlName=$.closedLoopControlName";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
-
- assertEquals(3, topicFilter.getFilterRule().size());
- topicFilter.deleteFilterRule();
- assertEquals(0, topicFilter.getFilterRule().size());
- }
-
- /**
- * Tests deleting a single filter rule by its key from the rules map.
- */
- @Test
- public void deleteFilterRuleTest() {
- String topicFilterProp = "requestID=$.requestID,subRequestID=$.subRequestID,"
- + "closedLoopControlName=$.closedLoopControlName";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
-
- assertEquals(3, topicFilter.getFilterRule().size());
- topicFilter.deleteFilterRule("closedLoopControlName");
- assertEquals(2, topicFilter.getFilterRule().size());
- }
-
- /**
- * Tests throwing an exception if the key is null.
- */
- @Test(expected = IllegalArgumentException.class)
- public void deleteFilterRuleNullKeyTest() {
- String topicFilterProp = "requestID=$.requestID,subRequestID=$.subRequestID,"
- + "closedLoopControlName=$.closedLoopControlName";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
- topicFilter.deleteFilterRule(null);
- }
-
- /**
- * Tests throwing an exception if the key is empty.
- */
- @Test(expected = IllegalArgumentException.class)
- public void deleteFilterRuleEmptyKeyTest() {
- String topicFilterProp = "requestID=$.requestID,subRequestID=$.subRequestID,"
- + "closedLoopControlName=$.closedLoopControlName";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
- topicFilter.deleteFilterRule("");
- }
-
- /**
- * Tests finding all results for each filter rule corresponding to a topic.
- */
- @Test
- public void findAllTest() {
- String message = "{\"requestID\":\"38adde30-cc22-11e8-a8d5-f2801f1b9fd1\",\"entity\":\"controller\","
- + "\"controllers\":[{\"name\":\"test-controller\","
- + "\"drools\":{\"groupId\":\"org.onap.policy.drools.test\","
- + "\"artifactId\":\"test\",\"version\":\"0.0.1\"},\"operation\":\"update\"}]}";
-
- String topicFilterProp = "requestID=$.requestID,controllerName=$.controllers[0].name,"
- + "operation=$.controllers[0].operation";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
-
- Map<String, List<String>> results = topicFilter.find(message);
- assertEquals("38adde30-cc22-11e8-a8d5-f2801f1b9fd1",
- results.get("requestID").get(0));
- assertEquals("test-controller", results.get("controllerName").get(0));
- assertEquals("update", results.get("operation").get(0));
- }
-
- @Test
- public void testFindAllNotFound() {
- String message = "{\"requestID\":\"38adde30-cc22-11e8-a8d5-f2801f1b9fd1\",\"entity\":\"controller\","
- + "\"controllers\":[{\"name\":\"test-controller\","
- + "\"drools\":{\"groupId\":\"org.onap.policy.drools.test\","
- + "\"artifactId\":\"test\",\"version\":\"0.0.1\"},\"operation\":\"update\"}]}";
-
- String topicFilterProp = "requestID=$.requestID[3]";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
-
- assertTrue(topicFilter.find(message).get("requestID").isEmpty());
- }
-
- /**
- * Tests finding field matches for a filter rule corresponding to a topic.
- */
- @Test
- public void findTest() {
- String message = "{\"requestID\":\"38adde30-cc22-11e8-a8d5-f2801f1b9fd1\",\"entity\":\"controller\","
- + "\"controllers\":[{\"name\":\"test-controller\","
- + "\"drools\":{\"groupId\":\"org.onap.policy.drools.test\","
- + "\"artifactId\":\"test\",\"version\":\"0.0.1\"},\"operation\":\"update\"}]}";
-
- String topicFilterProp = "requestID=$.requestID,controllerName=$.controllers[0].name,"
- + "operation=$.controllers[0].operation";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
-
- List<String> results = topicFilter.find(message, "requestID");
- assertEquals("38adde30-cc22-11e8-a8d5-f2801f1b9fd1", results.get(0));
- }
-
- @Test
- public void testFindNotFound() {
- String message = "{\"requestID\":\"38adde30-cc22-11e8-a8d5-f2801f1b9fd1\",\"entity\":\"controller\","
- + "\"controllers\":[{\"name\":\"test-controller\","
- + "\"drools\":{\"groupId\":\"org.onap.policy.drools.test\","
- + "\"artifactId\":\"test\",\"version\":\"0.0.1\"},\"operation\":\"update\"}]}";
-
- String topicFilterProp = "requestID=$.requestID[3]";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
-
- assertTrue(topicFilter.find(message, "requestID").isEmpty());
- }
-
- @Test
- public void testFilterRuleStringString() {
- FilterRule rule = new FilterRule("hello", "world");
-
- assertEquals("hello", rule.getMdcKey());
- assertEquals("[world]", rule.getPaths().toString());
- }
-
- @Test
- public void testFilterRuleMdcKey() {
- FilterRule rule = new FilterRule("abc", "def");
-
- // check error cases first
- assertThatIllegalArgumentException().isThrownBy(() -> rule.setMdcKey(null))
- .withMessage(MdcTopicFilter.MDC_KEY_ERROR);
- assertThatIllegalArgumentException().isThrownBy(() -> rule.setMdcKey(""))
- .withMessage(MdcTopicFilter.MDC_KEY_ERROR);
-
- // success cases
- rule.setMdcKey("my-mdc-key");
- assertEquals("my-mdc-key", rule.getMdcKey());
- }
-
- @Test
- public void testFilterRulePaths() {
- FilterRule rule = new FilterRule("abc", "def");
-
- // check error cases first
- assertThatIllegalArgumentException().isThrownBy(() -> rule.setPaths(null))
- .withMessage(MdcTopicFilter.JSON_PATH_ERROR);
- assertThatIllegalArgumentException().isThrownBy(() -> rule.setPaths(Collections.emptyList()))
- .withMessage(MdcTopicFilter.JSON_PATH_ERROR);
-
- assertThatIllegalArgumentException().isThrownBy(() -> rule.addPaths(null))
- .withMessage(MdcTopicFilter.JSON_PATH_ERROR);
- assertThatIllegalArgumentException().isThrownBy(() -> rule.addPaths(Collections.emptyList()))
- .withMessage(MdcTopicFilter.JSON_PATH_ERROR);
-
- assertThatIllegalArgumentException().isThrownBy(() -> rule.addPath(null))
- .withMessage(MdcTopicFilter.JSON_PATH_ERROR);
- assertThatIllegalArgumentException().isThrownBy(() -> rule.addPath(""))
- .withMessage(MdcTopicFilter.JSON_PATH_ERROR);
-
- // success cases
- rule.setPaths(new ArrayList<>(Arrays.asList("pathA", "pathB")));
- assertEquals("[pathA, pathB]", rule.getPaths().toString());
-
- rule.addPath("pathC");
- assertEquals("[pathA, pathB, pathC]", rule.getPaths().toString());
-
- rule.addPaths(Arrays.asList("pathD", "pathE"));
- assertEquals("[pathA, pathB, pathC, pathD, pathE]", rule.getPaths().toString());
- }
-
- private void addFilterRuleValidateFailure(String mdcKey, String path) {
- String topicFilterProp = "requestID=$.requestID";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
- topicFilter.addFilterRule(mdcKey, path);
- }
-
- private void addFilterRuleValidateFailure(String mdcKey, List<String> paths) {
- String topicFilterProp = "requestID=$.requestID";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
- topicFilter.addFilterRule(mdcKey, paths);
- }
-
- private void modifyFilterRuleValidateFailure(String mdcKey, String path) {
- String topicFilterProp = "requestID=$.requestID";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
- topicFilter.modifyFilterRule(mdcKey, path);
- }
-
- private void modifyFilterRuleValidateFailure(String mdcKey, List<String> paths) {
- String topicFilterProp = "requestID=$.requestID";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
- topicFilter.modifyFilterRule(mdcKey, paths);
- }
-
- private void modifyFilterRuleValidateFailure(String oldMdcKey, String newMdcKey, List<String> paths) {
- String topicFilterProp = "requestID=$.requestID";
- MdcTopicFilter topicFilter = new MdcTopicFilter(topicFilterProp);
- topicFilter.modifyFilterRule(oldMdcKey, newMdcKey, paths);
- }
-}
diff --git a/feature-mdc-filters/src/test/resources/onset.json b/feature-mdc-filters/src/test/resources/onset.json
deleted file mode 100755
index fafc93a3..00000000
--- a/feature-mdc-filters/src/test/resources/onset.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "closedLoopEventClient": "DCAE_INSTANCE_ID.dcae-tca",
- "policyVersion": "1.0.0.5",
- "policyName": "policyTest",
- "policyScope": "type=SampleType,closedLoopControlName=SampleClosedLoop",
- "target_type": "VM",
- "AAI": {
- "vserver.is-closed-loop-disabled": false,
- "vserver.vserver-name": "example-vserver-name"
- },
- "closedLoopAlarmStart": 1484855291527925,
- "closedLoopEventStatus": "ONSET",
- "closedLoopControlName": "CL-TEST",
- "version": "1.0.2",
- "target": "vserver.vserver-name",
- "requestID": "8c1b8bd8-06f7-493f-8ed7-daaa4cc481bc",
- "from": "DCAE"
-} \ No newline at end of file
diff --git a/packages/install/pom.xml b/packages/install/pom.xml
index 1470ac0c..ac4a4840 100644
--- a/packages/install/pom.xml
+++ b/packages/install/pom.xml
@@ -99,18 +99,6 @@
</dependency>
<dependency>
<groupId>org.onap.policy.drools-pdp</groupId>
- <artifactId>feature-controller-logging</artifactId>
- <version>${project.version}</version>
- <type>zip</type>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.drools-pdp</groupId>
- <artifactId>feature-mdc-filters</artifactId>
- <version>${project.version}</version>
- <type>zip</type>
- </dependency>
- <dependency>
- <groupId>org.onap.policy.drools-pdp</groupId>
<artifactId>feature-lifecycle</artifactId>
<version>${project.version}</version>
<type>zip</type>
diff --git a/pom.xml b/pom.xml
index effaf291..426ff998 100644
--- a/pom.xml
+++ b/pom.xml
@@ -64,10 +64,7 @@
<module>feature-pooling-dmaap</module>
<module>feature-test-transaction</module>
<module>feature-distributed-locking</module>
- <module>feature-controller-logging</module>
- <module>feature-mdc-filters</module>
<module>feature-lifecycle</module>
- <module>feature-drools-init</module>
<module>feature-no-locking</module>
<module>feature-legacy-config</module>
<module>packages</module>