From fdaae76549bafb2e482c02fb26de719c69431b48 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Tue, 13 Aug 2019 15:52:22 -0400 Subject: Modify to work with new drools-pdp Due to sonar fixes, drools-pdp changed in a way that requires changes to drools-applications. In the case of template.demo, lots of test cases had to be modified, so they were refactored to extract common setup and tear down code. Fixed checkstyle issues. Fixed license date. Change-Id: Ie9e0239b95916ae7ef8c1b669987f7bb07d841b9 Issue-ID: POLICY-1968 Signed-off-by: Jim Hahn --- .../management/ControlLoopManagementFeature.java | 3 ++- .../server/restful/RestControlLoopManager.java | 26 ++++++++++++++-------- 2 files changed, 19 insertions(+), 10 deletions(-) (limited to 'controlloop/common/feature-controlloop-management/src/main/java') diff --git a/controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/apps/controlloop/feature/management/ControlLoopManagementFeature.java b/controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/apps/controlloop/feature/management/ControlLoopManagementFeature.java index 3b5792a42..ae19b914e 100644 --- a/controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/apps/controlloop/feature/management/ControlLoopManagementFeature.java +++ b/controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/apps/controlloop/feature/management/ControlLoopManagementFeature.java @@ -24,6 +24,7 @@ import java.util.stream.Stream; import org.onap.policy.controlloop.params.ControlLoopParams; import org.onap.policy.drools.features.PolicyEngineFeatureApi; import org.onap.policy.drools.system.PolicyController; +import org.onap.policy.drools.system.PolicyControllerConstants; /** * Control Loop Management Feature. @@ -100,7 +101,7 @@ public class ControlLoopManagementFeature implements PolicyEngineFeatureApi { */ public static class Factory { public PolicyController getController(String controllerName) { - return PolicyController.factory.get(controllerName); + return PolicyControllerConstants.getFactory().get(controllerName); } } } diff --git a/controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/server/restful/RestControlLoopManager.java b/controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/server/restful/RestControlLoopManager.java index 4b62e489a..08b218dd6 100644 --- a/controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/server/restful/RestControlLoopManager.java +++ b/controlloop/common/feature-controlloop-management/src/main/java/org/onap/policy/drools/server/restful/RestControlLoopManager.java @@ -47,8 +47,8 @@ import org.onap.policy.controlloop.params.ControlLoopParams; import org.onap.policy.controlloop.processor.ControlLoopProcessor; import org.onap.policy.drools.apps.controlloop.feature.management.ControlLoopManagementFeature; import org.onap.policy.drools.controller.DroolsController; -import org.onap.policy.drools.system.PolicyController; -import org.onap.policy.drools.system.PolicyEngine; +import org.onap.policy.drools.system.PolicyControllerConstants; +import org.onap.policy.drools.system.PolicyEngineConstants; import org.onap.policy.rest.RestManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -206,7 +206,7 @@ public class RestControlLoopManager { .build(); } - DroolsController controller = PolicyController.factory.get(controllerName).getDrools(); + DroolsController controller = PolicyControllerConstants.getFactory().get(controllerName).getDrools(); controlLoop = new ControlLoopParams(); controlLoop.setPolicyScope(controller.getGroupId()); @@ -240,9 +240,13 @@ public class RestControlLoopManager { return Response .status(Status.OK) .entity(new AaiManager(new RestManager()) - .getCustomQueryResponse(PolicyEngine.manager.getEnvironmentProperty(ControlLoopEventManager.AAI_URL), - PolicyEngine.manager.getEnvironmentProperty(ControlLoopEventManager.AAI_USERNAME_PROPERTY), - PolicyEngine.manager.getEnvironmentProperty(ControlLoopEventManager.AAI_PASS_PROPERTY), + .getCustomQueryResponse( + PolicyEngineConstants.getManager() + .getEnvironmentProperty(ControlLoopEventManager.AAI_URL), + PolicyEngineConstants.getManager().getEnvironmentProperty( + ControlLoopEventManager.AAI_USERNAME_PROPERTY), + PolicyEngineConstants.getManager().getEnvironmentProperty( + ControlLoopEventManager.AAI_PASS_PROPERTY), UUID.randomUUID(), vserverId)) .build(); @@ -261,9 +265,13 @@ public class RestControlLoopManager { return Response .status(Status.OK) .entity(new AaiManager(new RestManager()) - .postQuery(PolicyEngine.manager.getEnvironmentProperty(ControlLoopEventManager.AAI_URL), - PolicyEngine.manager.getEnvironmentProperty(ControlLoopEventManager.AAI_USERNAME_PROPERTY), - PolicyEngine.manager.getEnvironmentProperty(ControlLoopEventManager.AAI_PASS_PROPERTY), + .postQuery( + PolicyEngineConstants.getManager() + .getEnvironmentProperty(ControlLoopEventManager.AAI_URL), + PolicyEngineConstants.getManager().getEnvironmentProperty( + ControlLoopEventManager.AAI_USERNAME_PROPERTY), + PolicyEngineConstants.getManager().getEnvironmentProperty( + ControlLoopEventManager.AAI_PASS_PROPERTY), ControlLoopEventManager.getAaiNqRequest(vserverId), UUID.randomUUID())) .build(); -- cgit 1.2.3-korg