summaryrefslogtreecommitdiffstats
path: root/controlloop/common/controller-usecases/src/test/java
diff options
context:
space:
mode:
authorjhh <jorge.hernandez-herrero@att.com>2020-02-12 18:20:06 -0600
committerJorge Hernandez <jorge.hernandez-herrero@att.com>2020-02-17 20:25:22 +0000
commit6dfab64262ea5816c761042192c84e498a3177ab (patch)
tree665dd3e68a9fc4303898fc9d7fe34d4c404ef7a4 /controlloop/common/controller-usecases/src/test/java
parent43b12b12c0c427bc89ab88f4d4034821d4c9835d (diff)
tosca compliant op policy support + vcpe test
Tosca Compliant and Toscal Legacy Operational policies are both supported for backwards compatibility. vCPE usecase junits to support 2 equivalent policies, one tosca compliant and the other one legacy. Issue-ID: POLICY-2360 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: Iafbfc92bbec42e6a3fe4ceb4a9a17c85e636ea14 Signed-off-by: jhh <jorge.hernandez-herrero@att.com>
Diffstat (limited to 'controlloop/common/controller-usecases/src/test/java')
-rw-r--r--controlloop/common/controller-usecases/src/test/java/org/onap/policy/controlloop/UsecasesBase.java10
-rw-r--r--controlloop/common/controller-usecases/src/test/java/org/onap/policy/controlloop/VcpeTest.java44
2 files changed, 36 insertions, 18 deletions
diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/controlloop/UsecasesBase.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/controlloop/UsecasesBase.java
index 1fe6ace44..618963a70 100644
--- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/controlloop/UsecasesBase.java
+++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/controlloop/UsecasesBase.java
@@ -146,7 +146,7 @@ public abstract class UsecasesBase {
return usecases
.getDrools()
.facts(USECASES, ControlLoopParams.class).stream()
- .filter((params) -> params.getControlLoopYaml() == policy.getProperties().get("content"))
+ .filter((params) -> params.getToscaPolicy() == policy)
.findFirst()
.get();
}
@@ -178,7 +178,7 @@ public abstract class UsecasesBase {
usecases
.getDrools()
.facts(USECASES, ControlLoopParams.class).stream()
- .filter((params) -> params.getControlLoopYaml() == policy.getProperties().get("content"))
+ .filter((params) -> params.getToscaPolicy() == policy)
.count());
return policy;
@@ -209,18 +209,18 @@ public abstract class UsecasesBase {
usecases
.getDrools()
.facts(USECASES, ControlLoopParams.class).stream()
- .filter((params) -> params.getControlLoopYaml() == policy.getProperties().get("content"))
+ .filter((params) -> params.getPolicyName() == policy.getName())
.count());
}
/**
* Prepare a PDP-D to test the Use Cases.
*/
- protected static void preparePdpD() throws IOException, InterruptedException, CoderException {
+ protected static void preparePdpD() throws IOException {
KieUtils.installArtifact(
Paths.get("src/main/resources/META-INF/kmodule.xml").toFile(),
Paths.get("src/test/resources/usecases.pom").toFile(),
- "src/main/resources/onap.policies.controlloop.Operational/org/onap/policy/controlloop/",
+ "src/main/resources/org/onap/policy/controlloop/",
Collections.singletonList(Paths.get("src/main/resources/usecases.drl").toFile()));
repo.setConfigurationDir("src/test/resources/config");
diff --git a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/controlloop/VcpeTest.java b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/controlloop/VcpeTest.java
index 8690f1a0a..1d9d0dd26 100644
--- a/controlloop/common/controller-usecases/src/test/java/org/onap/policy/controlloop/VcpeTest.java
+++ b/controlloop/common/controller-usecases/src/test/java/org/onap/policy/controlloop/VcpeTest.java
@@ -42,7 +42,8 @@ public class VcpeTest extends UsecasesBase {
/**
* VCPE Tosca Policy File.
*/
- private static final String TOSCA_POLICY_VCPE = "src/test/resources/vcpe/tosca-vcpe.json";
+ private static final String TOSCA_LEGACY_POLICY_VCPE = "src/test/resources/vcpe/tosca-legacy-vcpe.json";
+ private static final String TOSCA_COMPLIANT_POLICY_VCPE = "src/test/resources/vcpe/tosca-compliant-vcpe.json";
/*
* VCPE Use case Messages.
@@ -86,7 +87,6 @@ public class VcpeTest extends UsecasesBase {
/**
* Sunny day scenario for the VCPE use case.
*/
- @Test
public void sunnyDay() throws IOException {
/* Inject an ONSET event over the DCAE topic */
@@ -122,12 +122,40 @@ public class VcpeTest extends UsecasesBase {
}
/**
+ * Sunny Day with Legacy Tosca Policy.
+ */
+ @Test
+ public void sunnyDayLegacy() throws InterruptedException, CoderException, IOException {
+ assertEquals(0, usecases.getDrools().factCount(USECASES));
+ policy = setupPolicy(TOSCA_LEGACY_POLICY_VCPE);
+ assertEquals(2, usecases.getDrools().factCount(USECASES));
+
+ sunnyDay();
+ }
+
+ /**
+ * Sunny Day with Tosca Compliant Policy.
+ */
+ @Test
+ public void sunnyDayCompliant() throws InterruptedException, CoderException, IOException {
+ assertEquals(0, usecases.getDrools().factCount(USECASES));
+ policy = setupPolicy(TOSCA_COMPLIANT_POLICY_VCPE);
+ assertEquals(2, usecases.getDrools().factCount(USECASES));
+
+ sunnyDay();
+ }
+
+ /**
* An ONSET flood prevention test that injects a few ONSETs at once.
* It attempts to simulate the flooding behavior of the DCAE TCA microservice.
* TCA could blast tenths or hundreds of ONSETs within sub-second intervals.
*/
@Test
- public void onsetFloodPrevention() throws IOException {
+ public void onsetFloodPrevention() throws IOException, InterruptedException, CoderException {
+ assertEquals(0, usecases.getDrools().factCount(USECASES));
+ policy = setupPolicy(TOSCA_LEGACY_POLICY_VCPE);
+ assertEquals(2, usecases.getDrools().factCount(USECASES));
+
injectOnTopic(DCAE_TOPIC, Paths.get(ONSET_1));
injectOnTopic(DCAE_TOPIC, Paths.get(ONSET_2));
injectOnTopic(DCAE_TOPIC, Paths.get(ONSET_3));
@@ -169,16 +197,6 @@ public class VcpeTest extends UsecasesBase {
}
/**
- * Install Policy.
- */
- @Before
- public void installPolicy() throws IOException, CoderException, InterruptedException {
- assertEquals(0, usecases.getDrools().factCount(USECASES));
- policy = setupPolicy(TOSCA_POLICY_VCPE);
- assertEquals(2, usecases.getDrools().factCount(USECASES));
- }
-
- /**
* Uninstall Policy.
*/
@After