package org.onap.policy.coordination;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import java.util.Arrays;
-import org.assertj.core.api.Assertions;
import org.junit.Test;
public class CoordinationDirectiveTest {
package org.onap.policy.coordination;
import static org.assertj.core.api.Assertions.assertThatNullPointerException;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
import org.junit.Test;
import org.onap.policy.aai.RelationshipData;
import org.onap.policy.aai.RelationshipList;
import org.onap.policy.aai.util.AaiException;
-import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.common.utils.io.Serializer;
import org.onap.policy.controlloop.ControlLoopEventStatus;
import org.onap.policy.controlloop.ControlLoopException;
@AfterClass
public static void tearDownSimulator() {
- HttpServletServer.factory.destroy();
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
}
/**
import org.onap.policy.appclcm.LcmRequestWrapper;
import org.onap.policy.appclcm.LcmResponse;
import org.onap.policy.appclcm.LcmResponseWrapper;
-import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.common.utils.io.Serializer;
import org.onap.policy.controlloop.ControlLoopEventStatus;
import org.onap.policy.controlloop.ControlLoopException;
public static void tearDown() {
em.close();
emf.close();
- HttpServletServer.factory.destroy();
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
}
@Test
import org.junit.BeforeClass;
import org.junit.Test;
import org.kie.api.builder.ReleaseId;
-import org.onap.policy.common.endpoints.http.client.HttpClient;
+import org.onap.policy.common.endpoints.http.client.HttpClientFactoryInstance;
import org.onap.policy.common.utils.network.NetworkUtil;
import org.onap.policy.drools.persistence.SystemPersistence;
import org.onap.policy.drools.properties.DroolsProperties;
PolicyEngine.manager.createPolicyController(CONTROLLER, controllerProperties);
PolicyEngine.manager.start();
- HttpClient.factory.build(SystemPersistence.manager.getProperties(CLIENT_CONFIG));
+ HttpClientFactoryInstance.getClientFactory().build(SystemPersistence.manager.getProperties(CLIENT_CONFIG));
if (!NetworkUtil.isTcpPortOpen("localhost", 9696, 6, 10000L)) {
throw new IllegalStateException("cannot connect to port 9696");
*/
@Test
public void testOperationalPolicy() throws IOException {
- assertEquals(Status.OK.getStatusCode(),
- HttpClient.factory.get(CONTROLLER).get(URL_CONTEXT_PATH_CONTROLLOOPS).getStatus());
+ assertEquals(Status.OK.getStatusCode(), HttpClientFactoryInstance.getClientFactory().get(CONTROLLER)
+ .get(URL_CONTEXT_PATH_CONTROLLOOPS).getStatus());
- assertEquals(Status.OK.getStatusCode(),
- HttpClient.factory.get(CONTROLLER).get(URL_CONTEXT_PATH_CONTROLLOOP).getStatus());
+ assertEquals(Status.OK.getStatusCode(), HttpClientFactoryInstance.getClientFactory().get(CONTROLLER)
+ .get(URL_CONTEXT_PATH_CONTROLLOOP).getStatus());
- assertEquals(Status.NOT_FOUND.getStatusCode(),
- HttpClient.factory.get(CONTROLLER).get(URL_CONTEXT_PATH_CONTROLLOOP_POLICY).getStatus());
+ assertEquals(Status.NOT_FOUND.getStatusCode(), HttpClientFactoryInstance.getClientFactory().get(CONTROLLER)
+ .get(URL_CONTEXT_PATH_CONTROLLOOP_POLICY).getStatus());
String policyFromFile = new String(Files.readAllBytes(Paths.get(POLICY)));
- HttpClient.factory.get(CONTROLLER)
- .put(URL_CONTEXT_PATH_CONTROLLOOP_POLICY, Entity.text(policyFromFile), Collections.emptyMap());
+ HttpClientFactoryInstance.getClientFactory().get(CONTROLLER).put(URL_CONTEXT_PATH_CONTROLLOOP_POLICY,
+ Entity.text(policyFromFile), Collections.emptyMap());
- assertEquals(Status.OK.getStatusCode(),
- HttpClient.factory.get(CONTROLLER).get(URL_CONTEXT_PATH_CONTROLLOOP_POLICY).getStatus());
+ assertEquals(Status.OK.getStatusCode(), HttpClientFactoryInstance.getClientFactory().get(CONTROLLER)
+ .get(URL_CONTEXT_PATH_CONTROLLOOP_POLICY).getStatus());
- String policyFromPdpD = HttpClient.factory.get(CONTROLLER)
+ String policyFromPdpD = HttpClientFactoryInstance.getClientFactory().get(CONTROLLER)
.get(URL_CONTEXT_PATH_CONTROLLOOP_POLICY)
.readEntity(String.class);
assertEquals(policyFromFile, policyFromPdpD);
assertEquals(Status.CONFLICT.getStatusCode(),
- HttpClient.factory.get(CONTROLLER).put(URL_CONTEXT_PATH_CONTROLLOOP_POLICY,
+ HttpClientFactoryInstance.getClientFactory().get(CONTROLLER).put(URL_CONTEXT_PATH_CONTROLLOOP_POLICY,
Entity.text(policyFromFile), Collections.emptyMap()).getStatus());
}
============LICENSE_START=======================================================
ONAP
================================================================================
- Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
Modifications Copyright (C) 2019 Nordix Foundation.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.onap.policy.models.policy-models-interactions.model-impl</groupId>
- <artifactId>model-impl</artifactId>
- <version>2.1.0-SNAPSHOT</version>
+ <groupId>org.onap.policy.drools-applications.controlloop.common</groupId>
+ <artifactId>common</artifactId>
+ <version>1.5.1-SNAPSHOT</version>
</parent>
<groupId>org.onap.policy.drools.apps.test</groupId>
<artifactId>op</artifactId>
- <version>1.5.0-SNAPSHOT</version>
<dependencies>
<dependency>
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import static org.junit.Assert.assertNotNull;
import org.junit.Test;
-import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.drools.system.PolicyEngine;
import org.onap.policy.drools.utils.logging.LoggerUtil;
import org.onap.policy.simulators.Util;
LoggerUtil.setLevel("org.eclipse.jetty", "WARN");
final ControlLoopUtilsFeature feature = new ControlLoopUtilsFeature();
feature.afterStart(PolicyEngine.manager);
- assertNotNull(HttpServletServer.factory.get(Util.AAISIM_SERVER_PORT));
- assertNotNull(HttpServletServer.factory.get(Util.SOSIM_SERVER_PORT));
- assertNotNull(HttpServletServer.factory.get(Util.SOSIM_SERVER_PORT));
- assertNotNull(HttpServletServer.factory.get(Util.GUARDSIM_SERVER_PORT));
- assertNotNull(HttpServletServer.factory.get(Util.SDNCSIM_SERVER_PORT));
+ assertNotNull(HttpServletServerFactoryInstance.getServerFactory().get(Util.AAISIM_SERVER_PORT));
+ assertNotNull(HttpServletServerFactoryInstance.getServerFactory().get(Util.SOSIM_SERVER_PORT));
+ assertNotNull(HttpServletServerFactoryInstance.getServerFactory().get(Util.SOSIM_SERVER_PORT));
+ assertNotNull(HttpServletServerFactoryInstance.getServerFactory().get(Util.GUARDSIM_SERVER_PORT));
+ assertNotNull(HttpServletServerFactoryInstance.getServerFactory().get(Util.SDNCSIM_SERVER_PORT));
}
}
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.onap.policy.common.endpoints.http.server.HttpServletServer;
+import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
import org.onap.policy.drools.system.PolicyEngine;
import org.onap.policy.drools.utils.logging.LoggerUtil;
LoggerUtil.setLevel("ROOT", "INFO");
LoggerUtil.setLevel("org.eclipse.jetty", "WARN");
- HttpServletServer.factory.destroy();
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
org.onap.policy.simulators.Util.buildGuardSim();
//
*/
@AfterClass
public static void tearDownSimulator() {
- HttpServletServer.factory.destroy();
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
// Null/ Bad Connection Case
PolicyGuardXacmlRequestAttributes xacmlReq = new PolicyGuardXacmlRequestAttributes(
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;
"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")
kieSession.dispose();
PolicyEngine.manager.stop();
- HttpServletServer.factory.destroy();
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
PolicyController.factory.shutdown();
- TopicEndpoint.manager.shutdown();
+ TopicEndpointManager.getManager().shutdown();
}
@Test
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;
"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")
kieSession.dispose();
PolicyEngine.manager.stop();
- HttpServletServer.factory.destroy();
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
PolicyController.factory.shutdown();
- TopicEndpoint.manager.shutdown();
+ TopicEndpointManager.getManager().shutdown();
}
@Test
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;
"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<TopicSink> noopTopics = TopicEndpoint.manager.addTopicSinks(noopSinkProperties);
+ final List<TopicSink> noopTopics = TopicEndpointManager.getManager().addTopicSinks(noopSinkProperties);
EventProtocolCoder.manager.addEncoder(EventProtocolParams.builder()
.groupId("junit.groupId")
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);
kieSession.fireAllRules();
List<Object> facts = getSessionObjects();
-
+
// should have events for both control loops
assertEquals(2 * CL_OBJECTS, facts.size());
assertTrue(hasEvent(facts, CONTROL_LOOP_NAME));
/**
* 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,
* 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.
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.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;
"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")
kieSession.dispose();
PolicyEngine.manager.stop();
- HttpServletServer.factory.destroy();
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
PolicyController.factory.shutdown();
- TopicEndpoint.manager.shutdown();
+ TopicEndpointManager.getManager().shutdown();
}
/**
* a lock for a different
*/
kieSession.fireUntilHalt();
-
+
// allow object clean-up
kieSession.fireAllRules();
/**
* 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
/*
* 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"));
/*
* (non-Javadoc)
- *
+ *
* @see org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.String)
*/
@Override
/**
* 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
/**
* This method will dump all the facts in the working memory.
- *
+ *
* @param kieSession the session containing the facts
*/
public void dumpFacts(KieSession kieSession) {
* 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.
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.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;
"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")
kieSession.dispose();
PolicyEngine.manager.stop();
- HttpServletServer.factory.destroy();
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
PolicyController.factory.shutdown();
- TopicEndpoint.manager.shutdown();
+ TopicEndpointManager.getManager().shutdown();
}
@Test
sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET, "vCPEInfraVNF13", true);
kieSession.fireUntilHalt();
-
+
// allow object clean-up
kieSession.fireAllRules();
kieSession.fireUntilHalt();
-
+
// allow object clean-up
kieSession.fireAllRules();
/**
* 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
/*
* 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"));
/*
* (non-Javadoc)
- *
+ *
* @see org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.String)
*/
@Override
/**
* 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
/**
* This method will dump all the facts in the working memory.
- *
+ *
* @param kieSession the session containing the facts
*/
public void dumpFacts(KieSession kieSession) {
* 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.
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;
"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")
kieSession.dispose();
PolicyEngine.manager.stop();
- HttpServletServer.factory.destroy();
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
PolicyController.factory.shutdown();
- TopicEndpoint.manager.shutdown();
+ TopicEndpointManager.getManager().shutdown();
}
@Test
sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET);
kieSession.fireUntilHalt();
-
+
// allow object clean-up
kieSession.fireAllRules();
sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET, "error");
kieSession.fireUntilHalt();
-
+
// allow object clean-up
kieSession.fireAllRules();
try {
kieSession.fireUntilHalt();
-
+
// allow object clean-up
kieSession.fireAllRules();
-
+
} catch (Exception e) {
e.printStackTrace();
logger.warn(e.toString());
/**
* 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
/*
* 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"));
/*
* (non-Javadoc)
- *
+ *
* @see org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.String)
*/
@Override
/**
* 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
/**
* This method will dump all the facts in the working memory.
- *
+ *
* @param kieSession the session containing the facts
*/
public void dumpFacts(KieSession kieSession) {
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;
"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")
fail(e.getMessage());
}
/*
- *
+ *
* Start the kie session
*/
try {
kieSession.dispose();
PolicyEngine.manager.stop();
- HttpServletServer.factory.destroy();
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
PolicyController.factory.shutdown();
- TopicEndpoint.manager.shutdown();
+ TopicEndpointManager.getManager().shutdown();
}
@Test
sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET);
kieSession.fireUntilHalt();
-
+
// allow object clean-up
kieSession.fireAllRules();
kieSession.insert(event);
kieSession.fireUntilHalt();
-
+
// allow object clean-up
kieSession.fireAllRules();
/*
* 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"));
/*
* (non-Javadoc)
- *
+ *
* @see org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.String)
*/
@Override
/**
* 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
/**
* Dumps the kie session facts.
- *
+ *
* @param kieSession input session
*/
public static void dumpFacts(KieSession kieSession) {
* 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.
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.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;
"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")
kieSession.dispose();
PolicyEngine.manager.stop();
- HttpServletServer.factory.destroy();
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
PolicyController.factory.shutdown();
- TopicEndpoint.manager.shutdown();
+ TopicEndpointManager.getManager().shutdown();
}
@Test
try {
kieSession.fireUntilHalt();
-
+
// allow object clean-up
kieSession.fireAllRules();
-
+
} catch (Exception e) {
e.printStackTrace();
logger.warn(e.toString());
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());
try {
kieSession.fireUntilHalt();
-
+
// allow object clean-up
kieSession.fireAllRules();
-
+
} catch (Exception e) {
e.printStackTrace();
logger.warn(e.toString());
/**
* 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
/*
* 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"));
/**
* 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
/**
* 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
/**
* This method will dump all the facts in the working memory.
- *
+ *
* @param kieSession the session containing the facts
*/
public void dumpFacts(KieSession kieSession) {
* 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.
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;
"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")
kieSession.dispose();
PolicyEngine.manager.stop();
- HttpServletServer.factory.destroy();
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
PolicyController.factory.shutdown();
- TopicEndpoint.manager.shutdown();
+ TopicEndpointManager.getManager().shutdown();
}
@Test
sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET, true);
kieSession.fireUntilHalt();
-
+
// allow object clean-up
kieSession.fireAllRules();
sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET, false);
kieSession.fireUntilHalt();
-
+
// allow object clean-up
kieSession.fireAllRules();
/**
* This method will start a kie session and instantiate the Policy Engine.
- *
+ *
* @param droolsTemplate
* the DRL rules file
* @param yamlFile
/*
* (non-Javadoc)
- *
+ *
* @see
* org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.
* String)
/**
* 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
/**
* This method will dump all the facts in the working memory.
- *
+ *
* @param kieSession
* the session containing the facts
*/
* 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.
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;
"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")
kieSession.dispose();
PolicyEngine.manager.stop();
- HttpServletServer.factory.destroy();
+ HttpServletServerFactoryInstance.getServerFactory().destroy();
PolicyController.factory.shutdown();
- TopicEndpoint.manager.shutdown();
+ TopicEndpointManager.getManager().shutdown();
}
@Test
sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET, true);
kieSession.fireUntilHalt();
-
+
// allow object clean-up
kieSession.fireAllRules();
sendEvent(pair.first, requestId, ControlLoopEventStatus.ONSET, false);
kieSession.fireUntilHalt();
-
+
// allow object clean-up
kieSession.fireAllRules();
/**
* This method will start a kie session and instantiate the Policy Engine.
- *
+ *
* @param droolsTemplate
* the DRL rules file
* @param yamlFile
/*
* (non-Javadoc)
- *
+ *
* @see
* org.onap.policy.drools.PolicyEngineListener#newEventNotification(java.lang.
* String)
/**
* 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
/**
* This method will dump all the facts in the working memory.
- *
+ *
* @param kieSession
* the session containing the facts
*/