From 2a1a7893b445ebca44ec8e1b90f84bb66fbca92f Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Mon, 8 Jul 2019 10:56:34 -0400 Subject: Fix drools-applications due to sonar changes in common Fixed breakages due to changes made in policy/common to satisfy sonar. Repointed op.pom to correct parent, which allowed the other version to be dropped and properties used in the rest of the pom. Change-Id: Ib19c228c38b7f27fb9e9f508e5cf2566a8939cdd Issue-ID: POLICY-1791 Signed-off-by: Jim Hahn --- .../template/demo/CcvpnBwControlLoopTest.java | 11 +++---- .../policy/template/demo/CcvpnControlLoopTest.java | 11 +++---- .../template/demo/ControlLoopEventCleanupTest.java | 14 ++++---- .../template/demo/ControlLoopFailureTest.java | 27 ++++++++-------- .../policy/template/demo/VcpeControlLoopTest.java | 29 ++++++++--------- .../policy/template/demo/VdnsControlLoopTest.java | 33 ++++++++++--------- .../policy/template/demo/VfcControlLoopTest.java | 25 +++++++-------- .../policy/template/demo/VfwControlLoopTest.java | 37 +++++++++++----------- .../policy/template/demo/VpciControlLoopTest.java | 27 ++++++++-------- .../policy/template/demo/VsonhControlLoopTest.java | 28 ++++++++-------- 10 files changed, 117 insertions(+), 125 deletions(-) (limited to 'controlloop/templates/template.demo/src/test') diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnBwControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnBwControlLoopTest.java index 0ac9c48df..42742b261 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnBwControlLoopTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnBwControlLoopTest.java @@ -32,17 +32,16 @@ import java.util.HashMap; import java.util.List; import java.util.Properties; import java.util.UUID; - import org.junit.AfterClass; 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.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicEndpoint; +import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; import org.onap.policy.common.endpoints.event.comm.TopicListener; import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.common.endpoints.http.server.HttpServletServer; +import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; import org.onap.policy.controlloop.ControlLoopEventStatus; import org.onap.policy.controlloop.ControlLoopNotificationType; @@ -90,7 +89,7 @@ public class CcvpnBwControlLoopTest implements TopicListener { "org.onap.policy.controlloop.VirtualControlLoopNotification"); noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson", "org.onap.policy.controlloop.util.Serialization,gsonPretty"); - noopTopics = TopicEndpoint.manager.addTopicSinks(noopSinkProperties); + noopTopics = TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties); EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder() .groupId("junit.groupId") @@ -137,9 +136,9 @@ public class CcvpnBwControlLoopTest implements TopicListener { kieSession.dispose(); PolicyEngine.manager.stop(); - HttpServletServer.factory.destroy(); + HttpServletServerFactoryInstance.getServerFactory().destroy(); PolicyController.factory.shutdown(); - TopicEndpoint.manager.shutdown(); + TopicEndpointManager.getManager().shutdown(); } @Test diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnControlLoopTest.java index c546248f2..2c2b5d8fb 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnControlLoopTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/CcvpnControlLoopTest.java @@ -31,17 +31,16 @@ import java.util.HashMap; import java.util.List; import java.util.Properties; import java.util.UUID; - import org.junit.AfterClass; 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.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicEndpoint; +import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; import org.onap.policy.common.endpoints.event.comm.TopicListener; import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.common.endpoints.http.server.HttpServletServer; +import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; import org.onap.policy.controlloop.ControlLoopEventStatus; import org.onap.policy.controlloop.ControlLoopNotificationType; @@ -89,7 +88,7 @@ public class CcvpnControlLoopTest implements TopicListener { "org.onap.policy.controlloop.VirtualControlLoopNotification"); noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson", "org.onap.policy.controlloop.util.Serialization,gsonPretty"); - noopTopics = TopicEndpoint.manager.addTopicSinks(noopSinkProperties); + noopTopics = TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties); EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder() .groupId("junit.groupId") @@ -136,9 +135,9 @@ public class CcvpnControlLoopTest implements TopicListener { kieSession.dispose(); PolicyEngine.manager.stop(); - HttpServletServer.factory.destroy(); + HttpServletServerFactoryInstance.getServerFactory().destroy(); PolicyController.factory.shutdown(); - TopicEndpoint.manager.shutdown(); + TopicEndpointManager.getManager().shutdown(); } @Test diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopEventCleanupTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopEventCleanupTest.java index 37e139074..928bcb80c 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopEventCleanupTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopEventCleanupTest.java @@ -38,9 +38,9 @@ import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import org.kie.api.runtime.KieSession; -import org.onap.policy.common.endpoints.event.comm.TopicEndpoint; +import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.common.endpoints.http.server.HttpServletServer; +import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; import org.onap.policy.controlloop.ControlLoopEventStatus; import org.onap.policy.controlloop.VirtualControlLoopEvent; @@ -123,7 +123,7 @@ public class ControlLoopEventCleanupTest { "org.onap.policy.controlloop.VirtualControlLoopNotification"); noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson", "org.onap.policy.controlloop.util.Serialization,gsonPretty"); - final List noopTopics = TopicEndpoint.manager.addTopicSinks(noopSinkProperties); + final List noopTopics = TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties); EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder() .groupId("junit.groupId") @@ -177,9 +177,9 @@ public class ControlLoopEventCleanupTest { kieSession.dispose(); PolicyEngine.manager.stop(); - HttpServletServer.factory.destroy(); + HttpServletServerFactoryInstance.getServerFactory().destroy(); PolicyController.factory.shutdown(); - TopicEndpoint.manager.shutdown(); + TopicEndpointManager.getManager().shutdown(); if (saveGuardFlag == null) { PolicyEngine.manager.getEnvironment().remove(GUARD_DISABLED); @@ -202,7 +202,7 @@ public class ControlLoopEventCleanupTest { kieSession.fireAllRules(); List facts = getSessionObjects(); - + // should have events for both control loops assertEquals(2 * CL_OBJECTS, facts.size()); assertTrue(hasEvent(facts, CONTROL_LOOP_NAME)); @@ -362,7 +362,7 @@ public class ControlLoopEventCleanupTest { /** * Determines if the facts contain an event for the given control loop. - * + * * @param facts session facts to be checked * @param controlLoopName name of the control loop of interest * @return {@code true} if the facts contain an event for the given control loop, diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java index 47bbc63ab..6dbe17ee2 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/ControlLoopFailureTest.java @@ -7,9 +7,9 @@ * 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. @@ -32,7 +32,6 @@ import java.util.HashMap; import java.util.List; import java.util.Properties; import java.util.UUID; - import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -43,10 +42,10 @@ import org.onap.policy.appclcm.LcmRequestWrapper; import org.onap.policy.appclcm.LcmResponse; import org.onap.policy.appclcm.LcmResponseWrapper; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicEndpoint; +import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; import org.onap.policy.common.endpoints.event.comm.TopicListener; import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.common.endpoints.http.server.HttpServletServer; +import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; import org.onap.policy.controlloop.ControlLoopEventStatus; import org.onap.policy.controlloop.ControlLoopNotificationType; @@ -97,7 +96,7 @@ public class ControlLoopFailureTest implements TopicListener { "org.onap.policy.controlloop.VirtualControlLoopNotification"); noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson", "org.onap.policy.controlloop.util.Serialization,gsonPretty"); - noopTopics = TopicEndpoint.manager.addTopicSinks(noopSinkProperties); + noopTopics = TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties); EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder() .groupId("junit.groupId") @@ -148,9 +147,9 @@ public class ControlLoopFailureTest implements TopicListener { kieSession.dispose(); PolicyEngine.manager.stop(); - HttpServletServer.factory.destroy(); + HttpServletServerFactoryInstance.getServerFactory().destroy(); PolicyController.factory.shutdown(); - TopicEndpoint.manager.shutdown(); + TopicEndpointManager.getManager().shutdown(); } /** @@ -205,7 +204,7 @@ public class ControlLoopFailureTest implements TopicListener { * a lock for a different */ kieSession.fireUntilHalt(); - + // allow object clean-up kieSession.fireAllRules(); @@ -223,7 +222,7 @@ public class ControlLoopFailureTest implements TopicListener { /** * This method will start a kie session and instantiate the Policy Engine. - * + * * @param droolsTemplate the DRL rules file * @param yamlFile the yaml file containing the policies * @param policyScope scope for policy @@ -248,7 +247,7 @@ public class ControlLoopFailureTest implements TopicListener { /* * Construct a kie session */ - final KieSession kieSession = SupportUtil.buildContainer(droolsTemplate, + final KieSession kieSession = SupportUtil.buildContainer(droolsTemplate, pair.first.getControlLoop().getControlLoopName(), policyScope, policyName, policyVersion, URLEncoder.encode(pair.second, "UTF-8")); @@ -265,7 +264,7 @@ public class ControlLoopFailureTest implements TopicListener { /* * (non-Javadoc) - * + * * @see org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.String) */ @Override @@ -371,7 +370,7 @@ public class ControlLoopFailureTest implements TopicListener { /** * This method is used to simulate event messages from DCAE that start the control loop (onset * message) or end the control loop (abatement message). - * + * * @param policy the controlLoopName comes from the policy * @param requestId the requestId for this event * @param status could be onset or abated @@ -391,7 +390,7 @@ public class ControlLoopFailureTest implements TopicListener { /** * This method will dump all the facts in the working memory. - * + * * @param kieSession the session containing the facts */ public void dumpFacts(KieSession kieSession) { diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VcpeControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VcpeControlLoopTest.java index d9988b0e4..28706fd66 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VcpeControlLoopTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VcpeControlLoopTest.java @@ -7,9 +7,9 @@ * 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. @@ -32,7 +32,6 @@ import java.util.HashMap; import java.util.List; import java.util.Properties; import java.util.UUID; - import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -43,10 +42,10 @@ import org.onap.policy.appclcm.LcmRequestWrapper; import org.onap.policy.appclcm.LcmResponse; import org.onap.policy.appclcm.LcmResponseWrapper; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicEndpoint; +import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; import org.onap.policy.common.endpoints.event.comm.TopicListener; import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.common.endpoints.http.server.HttpServletServer; +import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; import org.onap.policy.controlloop.ControlLoopEventStatus; import org.onap.policy.controlloop.ControlLoopNotificationType; @@ -97,7 +96,7 @@ public class VcpeControlLoopTest implements TopicListener { "org.onap.policy.controlloop.VirtualControlLoopNotification"); noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson", "org.onap.policy.controlloop.util.Serialization,gsonPretty"); - noopTopics = TopicEndpoint.manager.addTopicSinks(noopSinkProperties); + noopTopics = TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties); EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder() .groupId("junit.groupId") @@ -147,9 +146,9 @@ public class VcpeControlLoopTest implements TopicListener { kieSession.dispose(); PolicyEngine.manager.stop(); - HttpServletServer.factory.destroy(); + HttpServletServerFactoryInstance.getServerFactory().destroy(); PolicyController.factory.shutdown(); - TopicEndpoint.manager.shutdown(); + TopicEndpointManager.getManager().shutdown(); } @Test @@ -176,7 +175,7 @@ public class VcpeControlLoopTest implements TopicListener { sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET, "vCPEInfraVNF13", true); kieSession.fireUntilHalt(); - + // allow object clean-up kieSession.fireAllRules(); @@ -216,7 +215,7 @@ public class VcpeControlLoopTest implements TopicListener { kieSession.fireUntilHalt(); - + // allow object clean-up kieSession.fireAllRules(); @@ -234,7 +233,7 @@ public class VcpeControlLoopTest implements TopicListener { /** * This method will start a kie session and instantiate the Policy Engine. - * + * * @param droolsTemplate the DRL rules file * @param yamlFile the yaml file containing the policies * @param policyScope scope for policy @@ -259,7 +258,7 @@ public class VcpeControlLoopTest implements TopicListener { /* * Construct a kie session */ - final KieSession kieSession = SupportUtil.buildContainer(droolsTemplate, + final KieSession kieSession = SupportUtil.buildContainer(droolsTemplate, pair.first.getControlLoop().getControlLoopName(), policyScope, policyName, policyVersion, URLEncoder.encode(pair.second, "UTF-8")); @@ -276,7 +275,7 @@ public class VcpeControlLoopTest implements TopicListener { /* * (non-Javadoc) - * + * * @see org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.String) */ @Override @@ -367,7 +366,7 @@ public class VcpeControlLoopTest implements TopicListener { /** * This method is used to simulate event messages from DCAE that start the control loop (onset * message) or end the control loop (abatement message). - * + * * @param policy the controlLoopName comes from the policy * @param requestId the requestId for this event * @param status could be onset or abated @@ -410,7 +409,7 @@ public class VcpeControlLoopTest implements TopicListener { /** * This method will dump all the facts in the working memory. - * + * * @param kieSession the session containing the facts */ public void dumpFacts(KieSession kieSession) { diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VdnsControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VdnsControlLoopTest.java index 3694423c0..3e5825bc1 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VdnsControlLoopTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VdnsControlLoopTest.java @@ -7,9 +7,9 @@ * 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. @@ -32,17 +32,16 @@ import java.util.HashMap; import java.util.List; import java.util.Properties; import java.util.UUID; - import org.junit.AfterClass; 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.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicEndpoint; +import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; import org.onap.policy.common.endpoints.event.comm.TopicListener; import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.common.endpoints.http.server.HttpServletServer; +import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; import org.onap.policy.controlloop.ControlLoopEventStatus; import org.onap.policy.controlloop.ControlLoopNotificationType; @@ -91,7 +90,7 @@ public class VdnsControlLoopTest implements TopicListener { "org.onap.policy.controlloop.VirtualControlLoopNotification"); noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson", "org.onap.policy.controlloop.util.Serialization,gsonPretty"); - noopTopics = TopicEndpoint.manager.addTopicSinks(noopSinkProperties); + noopTopics = TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties); EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder() .groupId("junit.groupId") @@ -136,9 +135,9 @@ public class VdnsControlLoopTest implements TopicListener { kieSession.dispose(); PolicyEngine.manager.stop(); - HttpServletServer.factory.destroy(); + HttpServletServerFactoryInstance.getServerFactory().destroy(); PolicyController.factory.shutdown(); - TopicEndpoint.manager.shutdown(); + TopicEndpointManager.getManager().shutdown(); } @Test @@ -165,7 +164,7 @@ public class VdnsControlLoopTest implements TopicListener { sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET); kieSession.fireUntilHalt(); - + // allow object clean-up kieSession.fireAllRules(); @@ -204,7 +203,7 @@ public class VdnsControlLoopTest implements TopicListener { sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET, "error"); kieSession.fireUntilHalt(); - + // allow object clean-up kieSession.fireAllRules(); @@ -244,10 +243,10 @@ public class VdnsControlLoopTest implements TopicListener { try { kieSession.fireUntilHalt(); - + // allow object clean-up kieSession.fireAllRules(); - + } catch (Exception e) { e.printStackTrace(); logger.warn(e.toString()); @@ -268,7 +267,7 @@ public class VdnsControlLoopTest implements TopicListener { /** * This method will start a kie session and instantiate the Policy Engine. - * + * * @param droolsTemplate the DRL rules file * @param yamlFile the yaml file containing the policies * @param policyScope scope for policy @@ -293,7 +292,7 @@ public class VdnsControlLoopTest implements TopicListener { /* * Construct a kie session */ - final KieSession kieSession = SupportUtil.buildContainer(droolsTemplate, + final KieSession kieSession = SupportUtil.buildContainer(droolsTemplate, pair.first.getControlLoop().getControlLoopName(), policyScope, policyName, policyVersion, URLEncoder.encode(pair.second, "UTF-8")); @@ -310,7 +309,7 @@ public class VdnsControlLoopTest implements TopicListener { /* * (non-Javadoc) - * + * * @see org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.String) */ @Override @@ -380,7 +379,7 @@ public class VdnsControlLoopTest implements TopicListener { /** * This method is used to simulate event messages from DCAE that start the control loop (onset * message) or end the control loop (abatement message). - * + * * @param policy the controlLoopName comes from the policy * @param requestId the requestId for this event * @param status could be onset or abated @@ -414,7 +413,7 @@ public class VdnsControlLoopTest implements TopicListener { /** * This method will dump all the facts in the working memory. - * + * * @param kieSession the session containing the facts */ public void dumpFacts(KieSession kieSession) { diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcControlLoopTest.java index 4c0d4f37f..fdf27490c 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcControlLoopTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfcControlLoopTest.java @@ -33,17 +33,16 @@ import java.util.HashMap; import java.util.List; import java.util.Properties; import java.util.UUID; - import org.junit.AfterClass; 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.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicEndpoint; +import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; import org.onap.policy.common.endpoints.event.comm.TopicListener; import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.common.endpoints.http.server.HttpServletServer; +import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; import org.onap.policy.controlloop.ControlLoopEventStatus; import org.onap.policy.controlloop.ControlLoopNotificationType; @@ -94,7 +93,7 @@ public class VfcControlLoopTest implements TopicListener { "org.onap.policy.controlloop.VirtualControlLoopNotification"); noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson", "org.onap.policy.controlloop.util.Serialization,gsonPretty"); - noopTopics = TopicEndpoint.manager.addTopicSinks(noopSinkProperties); + noopTopics = TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties); EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder() .groupId("junit.groupId") @@ -112,7 +111,7 @@ public class VfcControlLoopTest implements TopicListener { fail(e.getMessage()); } /* - * + * * Start the kie session */ try { @@ -139,9 +138,9 @@ public class VfcControlLoopTest implements TopicListener { kieSession.dispose(); PolicyEngine.manager.stop(); - HttpServletServer.factory.destroy(); + HttpServletServerFactoryInstance.getServerFactory().destroy(); PolicyController.factory.shutdown(); - TopicEndpoint.manager.shutdown(); + TopicEndpointManager.getManager().shutdown(); } @Test @@ -168,7 +167,7 @@ public class VfcControlLoopTest implements TopicListener { sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET); kieSession.fireUntilHalt(); - + // allow object clean-up kieSession.fireAllRules(); @@ -219,7 +218,7 @@ public class VfcControlLoopTest implements TopicListener { kieSession.insert(event); kieSession.fireUntilHalt(); - + // allow object clean-up kieSession.fireAllRules(); @@ -261,7 +260,7 @@ public class VfcControlLoopTest implements TopicListener { /* * Construct a kie session */ - final KieSession kieSession = SupportUtil.buildContainer(droolsTemplate, + final KieSession kieSession = SupportUtil.buildContainer(droolsTemplate, pair.first.getControlLoop().getControlLoopName(), policyScope, policyName, policyVersion, URLEncoder.encode(pair.second, "UTF-8")); @@ -278,7 +277,7 @@ public class VfcControlLoopTest implements TopicListener { /* * (non-Javadoc) - * + * * @see org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.String) */ @Override @@ -346,7 +345,7 @@ public class VfcControlLoopTest implements TopicListener { /** * This method is used to simulate event messages from DCAE that start the control loop (onset * message) or end the control loop (abatement message). - * + * * @param policy the controlLoopName comes from the policy * @param requestId the requestId for this event * @param status could be onset or abated @@ -373,7 +372,7 @@ public class VfcControlLoopTest implements TopicListener { /** * Dumps the kie session facts. - * + * * @param kieSession input session */ public static void dumpFacts(KieSession kieSession) { diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfwControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfwControlLoopTest.java index d29eabd2a..327a1b4dc 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfwControlLoopTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VfwControlLoopTest.java @@ -7,9 +7,9 @@ * 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. @@ -32,7 +32,6 @@ import java.util.HashMap; import java.util.List; import java.util.Properties; import java.util.UUID; - import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -42,10 +41,10 @@ import org.onap.policy.appc.Request; import org.onap.policy.appc.Response; import org.onap.policy.appc.ResponseCode; import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicEndpoint; +import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; import org.onap.policy.common.endpoints.event.comm.TopicListener; import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.common.endpoints.http.server.HttpServletServer; +import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; import org.onap.policy.controlloop.ControlLoopEventStatus; import org.onap.policy.controlloop.ControlLoopNotificationType; @@ -95,7 +94,7 @@ public class VfwControlLoopTest implements TopicListener { "org.onap.policy.controlloop.VirtualControlLoopNotification"); noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson", "org.onap.policy.controlloop.util.Serialization,gsonPretty"); - noopTopics = TopicEndpoint.manager.addTopicSinks(noopSinkProperties); + noopTopics = TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties); EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder() .groupId("junit.groupId") @@ -147,9 +146,9 @@ public class VfwControlLoopTest implements TopicListener { kieSession.dispose(); PolicyEngine.manager.stop(); - HttpServletServer.factory.destroy(); + HttpServletServerFactoryInstance.getServerFactory().destroy(); PolicyController.factory.shutdown(); - TopicEndpoint.manager.shutdown(); + TopicEndpointManager.getManager().shutdown(); } @Test @@ -177,10 +176,10 @@ public class VfwControlLoopTest implements TopicListener { try { kieSession.fireUntilHalt(); - + // allow object clean-up kieSession.fireAllRules(); - + } catch (Exception e) { e.printStackTrace(); logger.warn(e.toString()); @@ -223,10 +222,10 @@ public class VfwControlLoopTest implements TopicListener { sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET, "error"); try { kieSession.fireUntilHalt(); - + // allow object clean-up kieSession.fireAllRules(); - + } catch (Exception e) { e.printStackTrace(); logger.warn(e.toString()); @@ -257,10 +256,10 @@ public class VfwControlLoopTest implements TopicListener { try { kieSession.fireUntilHalt(); - + // allow object clean-up kieSession.fireAllRules(); - + } catch (Exception e) { e.printStackTrace(); logger.warn(e.toString()); @@ -280,7 +279,7 @@ public class VfwControlLoopTest implements TopicListener { /** * This method will start a kie session and instantiate the Policy Engine. - * + * * @param droolsTemplate the DRL rules file * @param yamlFile the yaml file containing the policies * @param policyScope scope for policy @@ -305,7 +304,7 @@ public class VfwControlLoopTest implements TopicListener { /* * Construct a kie session */ - final KieSession kieSession = SupportUtil.buildContainer(droolsTemplate, + final KieSession kieSession = SupportUtil.buildContainer(droolsTemplate, pair.first.getControlLoop().getControlLoopName(), policyScope, policyName, policyVersion, URLEncoder.encode(pair.second, "UTF-8")); @@ -406,7 +405,7 @@ public class VfwControlLoopTest implements TopicListener { /** * This method is used to simulate event messages from DCAE that start the control loop (onset * message) or end the control loop (abatement message). - * + * * @param policy the controlLoopName comes from the policy * @param requestId the requestId for this event * @param status could be onset or abated @@ -426,7 +425,7 @@ public class VfwControlLoopTest implements TopicListener { /** * This method is used to simulate event messages from DCAE that start the control loop (onset * message) or end the control loop (abatement message). - * + * * @param policy the controlLoopName comes from the policy * @param requestId the requestId for this event * @param status could be onset or abated @@ -445,7 +444,7 @@ public class VfwControlLoopTest implements TopicListener { /** * This method will dump all the facts in the working memory. - * + * * @param kieSession the session containing the facts */ public void dumpFacts(KieSession kieSession) { diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VpciControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VpciControlLoopTest.java index 3247aa58d..3278d4396 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VpciControlLoopTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VpciControlLoopTest.java @@ -8,9 +8,9 @@ * 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. @@ -33,17 +33,16 @@ import java.util.HashMap; import java.util.List; import java.util.Properties; import java.util.UUID; - import org.junit.AfterClass; 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.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicEndpoint; +import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; import org.onap.policy.common.endpoints.event.comm.TopicListener; import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.common.endpoints.http.server.HttpServletServer; +import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; import org.onap.policy.controlloop.ControlLoopEventStatus; import org.onap.policy.controlloop.ControlLoopNotificationType; @@ -98,7 +97,7 @@ public class VpciControlLoopTest implements TopicListener { "org.onap.policy.controlloop.VirtualControlLoopNotification"); noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson", "org.onap.policy.controlloop.util.Serialization,gsonPretty"); - noopTopics = TopicEndpoint.manager.addTopicSinks(noopSinkProperties); + noopTopics = TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties); EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder() .groupId("junit.groupId") @@ -146,9 +145,9 @@ public class VpciControlLoopTest implements TopicListener { kieSession.dispose(); PolicyEngine.manager.stop(); - HttpServletServer.factory.destroy(); + HttpServletServerFactoryInstance.getServerFactory().destroy(); PolicyController.factory.shutdown(); - TopicEndpoint.manager.shutdown(); + TopicEndpointManager.getManager().shutdown(); } @Test @@ -175,7 +174,7 @@ public class VpciControlLoopTest implements TopicListener { sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET, true); kieSession.fireUntilHalt(); - + // allow object clean-up kieSession.fireAllRules(); @@ -215,7 +214,7 @@ public class VpciControlLoopTest implements TopicListener { sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET, false); kieSession.fireUntilHalt(); - + // allow object clean-up kieSession.fireAllRules(); @@ -233,7 +232,7 @@ public class VpciControlLoopTest implements TopicListener { /** * This method will start a kie session and instantiate the Policy Engine. - * + * * @param droolsTemplate * the DRL rules file * @param yamlFile @@ -283,7 +282,7 @@ public class VpciControlLoopTest implements TopicListener { /* * (non-Javadoc) - * + * * @see * org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang. * String) @@ -384,7 +383,7 @@ public class VpciControlLoopTest implements TopicListener { /** * This method is used to simulate event messages from DCAE that start the * control loop (onset message). - * + * * @param policy * the controlLoopName comes from the policy * @param requestId @@ -423,7 +422,7 @@ public class VpciControlLoopTest implements TopicListener { /** * This method will dump all the facts in the working memory. - * + * * @param kieSession * the session containing the facts */ diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VsonhControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VsonhControlLoopTest.java index 871755db9..3859b7405 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VsonhControlLoopTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VsonhControlLoopTest.java @@ -3,13 +3,14 @@ * demo * ================================================================================ * Copyright (C) 2019 Wipro Limited Intellectual Property. All rights reserved. + * Modifications 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. @@ -32,17 +33,16 @@ import java.util.HashMap; import java.util.List; import java.util.Properties; import java.util.UUID; - import org.junit.AfterClass; 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.common.endpoints.event.comm.Topic.CommInfrastructure; -import org.onap.policy.common.endpoints.event.comm.TopicEndpoint; +import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager; import org.onap.policy.common.endpoints.event.comm.TopicListener; import org.onap.policy.common.endpoints.event.comm.TopicSink; -import org.onap.policy.common.endpoints.http.server.HttpServletServer; +import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance; import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties; import org.onap.policy.controlloop.ControlLoopEventStatus; import org.onap.policy.controlloop.ControlLoopNotificationType; @@ -97,7 +97,7 @@ public class VsonhControlLoopTest implements TopicListener { "org.onap.policy.controlloop.VirtualControlLoopNotification"); noopSinkProperties.put("noop.sink.topics.POLICY-CL-MGT.events.custom.gson", "org.onap.policy.controlloop.util.Serialization,gsonPretty"); - noopTopics = TopicEndpoint.manager.addTopicSinks(noopSinkProperties); + noopTopics = TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties); EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder() .groupId("junit.groupId") @@ -145,9 +145,9 @@ public class VsonhControlLoopTest implements TopicListener { kieSession.dispose(); PolicyEngine.manager.stop(); - HttpServletServer.factory.destroy(); + HttpServletServerFactoryInstance.getServerFactory().destroy(); PolicyController.factory.shutdown(); - TopicEndpoint.manager.shutdown(); + TopicEndpointManager.getManager().shutdown(); } @Test @@ -174,7 +174,7 @@ public class VsonhControlLoopTest implements TopicListener { sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET, true); kieSession.fireUntilHalt(); - + // allow object clean-up kieSession.fireAllRules(); @@ -214,7 +214,7 @@ public class VsonhControlLoopTest implements TopicListener { sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET, false); kieSession.fireUntilHalt(); - + // allow object clean-up kieSession.fireAllRules(); @@ -232,7 +232,7 @@ public class VsonhControlLoopTest implements TopicListener { /** * This method will start a kie session and instantiate the Policy Engine. - * + * * @param droolsTemplate * the DRL rules file * @param yamlFile @@ -282,7 +282,7 @@ public class VsonhControlLoopTest implements TopicListener { /* * (non-Javadoc) - * + * * @see * org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang. * String) @@ -387,7 +387,7 @@ public class VsonhControlLoopTest implements TopicListener { /** * This method is used to simulate event messages from DCAE that start the * control loop (onset message). - * + * * @param policy * the controlLoopName comes from the policy * @param requestId @@ -429,7 +429,7 @@ public class VsonhControlLoopTest implements TopicListener { /** * This method will dump all the facts in the working memory. - * + * * @param kieSession * the session containing the facts */ -- cgit 1.2.3-korg