aboutsummaryrefslogtreecommitdiffstats
path: root/feature-lifecycle
diff options
context:
space:
mode:
Diffstat (limited to 'feature-lifecycle')
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java6
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsController.java2
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactController.java9
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java9
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsControllerTest.java2
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactControllerTest.java7
-rw-r--r--feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java8
7 files changed, 18 insertions, 25 deletions
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
index 1326c3b0..8e97d3ef 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
@@ -164,10 +164,10 @@ public class LifecycleFsm implements Startable {
setPdpType(properties.getProperty(PDP_TYPE, DEFAULT_PDP_TYPE));
policyTypesMap.put(POLICY_TYPE_DROOLS_NATIVE_CONTROLLER,
- new PolicyTypeNativeDroolsController(this, POLICY_TYPE_DROOLS_NATIVE_CONTROLLER));
+ new PolicyTypeNativeDroolsController(POLICY_TYPE_DROOLS_NATIVE_CONTROLLER, this));
policyTypesMap.put(
POLICY_TYPE_DROOLS_NATIVE_RULES,
- new PolicyTypeNativeArtifactController(this, POLICY_TYPE_DROOLS_NATIVE_RULES));
+ new PolicyTypeNativeArtifactController(POLICY_TYPE_DROOLS_NATIVE_RULES, this));
String commaSeparatedPolicyTypes = properties.getProperty(MANDATORY_POLICY_TYPES);
if (!StringUtils.isBlank(commaSeparatedPolicyTypes)) {
@@ -234,7 +234,7 @@ public class LifecycleFsm implements Startable {
for (ToscaConceptIdentifier id : controller.getPolicyTypes()) {
PolicyTypeDroolsController ptDc = (PolicyTypeDroolsController) policyTypesMap.get(id); //NOSONAR
if (ptDc == null) {
- policyTypesMap.put(id, new PolicyTypeDroolsController(this, id, controller));
+ policyTypesMap.put(id, new PolicyTypeDroolsController(id, this, controller));
logger.info("policy-type {} added", id);
} else {
ptDc.add(controller);
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsController.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsController.java
index 41d75878..fa87617d 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsController.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsController.java
@@ -62,7 +62,7 @@ public class PolicyTypeDroolsController implements PolicyTypeController {
* Creates a Policy Type Drools Controller.
*/
public PolicyTypeDroolsController(
- LifecycleFsm fsm, ToscaConceptIdentifier policyType, PolicyController controller) {
+ ToscaConceptIdentifier policyType, LifecycleFsm fsm, PolicyController controller) {
this.policyType = policyType;
this.controllers.put(controller.getName(), controller);
this.fsm = fsm;
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactController.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactController.java
index b97d9026..fd98eed3 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactController.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactController.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,6 +21,7 @@
package org.onap.policy.drools.lifecycle;
+import lombok.AllArgsConstructor;
import lombok.Getter;
import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
import org.onap.policy.common.utils.coder.CoderException;
@@ -36,6 +37,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@AllArgsConstructor
public class PolicyTypeNativeArtifactController implements PolicyTypeController {
private static final Logger logger = LoggerFactory.getLogger(PolicyTypeNativeArtifactController.class);
@@ -45,11 +47,6 @@ public class PolicyTypeNativeArtifactController implements PolicyTypeController
@GsonJsonIgnore
protected final LifecycleFsm fsm;
- public PolicyTypeNativeArtifactController(LifecycleFsm fsm, ToscaConceptIdentifier policyType) {
- this.policyType = policyType;
- this.fsm = fsm;
- }
-
@Override
public boolean deploy(ToscaPolicy policy) {
NativeArtifactPolicy nativePolicy;
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java
index 361b4b10..8e62e2a8 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsController.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,6 +26,7 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors;
+import lombok.AllArgsConstructor;
import lombok.Getter;
import org.onap.policy.common.endpoints.event.comm.TopicEndpointManager;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
@@ -47,6 +48,7 @@ import org.onap.policy.models.tosca.authorative.concepts.ToscaPolicy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@AllArgsConstructor
public class PolicyTypeNativeDroolsController implements PolicyTypeController {
private static final Logger logger = LoggerFactory.getLogger(PolicyTypeNativeDroolsController.class);
@@ -56,11 +58,6 @@ public class PolicyTypeNativeDroolsController implements PolicyTypeController {
@GsonJsonIgnore
protected final LifecycleFsm fsm;
- public PolicyTypeNativeDroolsController(LifecycleFsm fsm, ToscaConceptIdentifier policyType) {
- this.policyType = policyType;
- this.fsm = fsm;
- }
-
@Override
public boolean deploy(ToscaPolicy policy) {
var controllerProps = new Properties();
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsControllerTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsControllerTest.java
index 18d00fc9..a3b8d8c9 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsControllerTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeDroolsControllerTest.java
@@ -54,7 +54,7 @@ public class PolicyTypeDroolsControllerTest extends LifecycleStateRunningTest {
policy = getExamplesPolicy(VCPE_OPERATIONAL_DROOLS_POLICY_JSON, OP_POLICY_NAME_VCPE);
fsm.getDomainMaker().convertTo(policy, OperationalPolicy.class);
controller = new PolicyTypeDroolsController(
- fsm, PolicyTypeDroolsController.compliantType, controllerSupport.getController());
+ PolicyTypeDroolsController.compliantType, fsm, controllerSupport.getController());
assertTrue(controllerSupport.getController().getDrools().isBrained());
assertFalse(controllerSupport.getController().isAlive());
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactControllerTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactControllerTest.java
index 3c8be31c..05ed41a4 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactControllerTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeArtifactControllerTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -60,9 +60,8 @@ public class PolicyTypeNativeArtifactControllerTest extends LifecycleStateRunnin
fsm = makeFsmWithPseudoTime();
policy = getPolicyFromFile(EXAMPLE_NATIVE_DROOLS_POLICY_JSON, EXAMPLE_NATIVE_DROOLS_POLICY_NAME);
nativePolicy = fsm.getDomainMaker().convertTo(policy, NativeArtifactPolicy.class);
- controller =
- new PolicyTypeNativeArtifactController(fsm,
- new ToscaConceptIdentifier("onap.policies.native.drools.Artifact", "1.0.0"));
+ controller = new PolicyTypeNativeArtifactController(
+ new ToscaConceptIdentifier("onap.policies.native.drools.Artifact", "1.0.0"), fsm);
assertTrue(controllerSupport.getController().getDrools().isBrained());
assertFalse(controllerSupport.getController().isAlive());
diff --git a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java
index b1ef3042..2d8b8688 100644
--- a/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java
+++ b/feature-lifecycle/src/test/java/org/onap/policy/drools/lifecycle/PolicyTypeNativeDroolsControllerTest.java
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-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.
@@ -73,7 +73,7 @@ public class PolicyTypeNativeDroolsControllerTest extends LifecycleStateRunningT
ToscaPolicy policy = getPolicyFromFile(EXAMPLE_NATIVE_DROOLS_POLICY_JSON, EXAMPLE_NATIVE_DROOLS_POLICY_NAME);
ControllerPolicy controllerPolicy = fsm.getDomainMaker().convertTo(policy, ControllerPolicy.class);
PolicyTypeNativeDroolsController controller =
- new PolicyTypeNativeDroolsController(fsm, policy.getTypeIdentifier());
+ new PolicyTypeNativeDroolsController(policy.getTypeIdentifier(), fsm);
assertTrue(controller.undeploy(policy));
assertThatIllegalArgumentException().isThrownBy(
() -> PolicyControllerConstants.getFactory().get(controllerPolicy.getName()));
@@ -100,7 +100,7 @@ public class PolicyTypeNativeDroolsControllerTest extends LifecycleStateRunningT
ToscaPolicy nativeControllerPolicy =
getExamplesPolicy("policies/usecases.native.controller.policy.input.tosca.json", "usecases");
PolicyTypeNativeDroolsController controller =
- new PolicyTypeNativeDroolsController(fsm, nativeControllerPolicy.getTypeIdentifier());
+ new PolicyTypeNativeDroolsController(nativeControllerPolicy.getTypeIdentifier(), fsm);
assertTrue(controller.deploy(nativeControllerPolicy));
Properties properties = PolicyControllerConstants.getFactory().get("usecases").getProperties();
@@ -176,4 +176,4 @@ public class PolicyTypeNativeDroolsControllerTest extends LifecycleStateRunningT
assertTrue(controller.undeploy(nativeControllerPolicy));
}
-} \ No newline at end of file
+}