aboutsummaryrefslogtreecommitdiffstats
path: root/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilterTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilterTest.java')
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilterTest.java81
1 files changed, 63 insertions, 18 deletions
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilterTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilterTest.java
index 858ac09fe..9ee3ec8bb 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilterTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyFilterTest.java
@@ -21,6 +21,7 @@
package org.onap.policy.models.tosca.authorative.concepts;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -62,12 +63,11 @@ public class ToscaPolicyFilterTest {
"policies/vCPE.policy.monitoring.input.tosca.json",
"policies/vCPE.policy.monitoring.input.tosca.yaml",
"policies/vCPE.policy.operational.input.tosca.yaml",
- "policies/vDNS.policy.guard.frequency.input.tosca.json",
- "policies/vDNS.policy.guard.frequency.input.tosca.yaml",
- "policies/vDNS.policy.guard.minmax.input.tosca.yaml",
"policies/vDNS.policy.monitoring.input.tosca.json",
"policies/vDNS.policy.monitoring.input.tosca.yaml",
"policies/vDNS.policy.operational.input.tosca.yaml",
+ "policies/vDNS.policy.guard.frequencylimiter.input.tosca.yaml",
+ "policies/vDNS.policy.guard.minmaxvnfs.input.tosca.yaml",
"policies/vFirewall.policy.monitoring.input.tosca.json",
"policies/vFirewall.policy.monitoring.input.tosca.yaml",
"policies/vFirewall.policy.operational.input.tosca.json",
@@ -151,22 +151,67 @@ public class ToscaPolicyFilterTest {
assertEquals(VERSION_100, filteredList.get(7).getVersion());
assertEquals(VERSION_100, filteredList.get(12).getVersion());
- assertEquals(23, policyList.size());
+ assertEquals(22, policyList.size());
assertEquals(22, filteredList.size());
- policyList.get(10).setVersion("2.0.0");
- policyList.get(16).setVersion("3.4.5");
+ //
+ // Change versions to a couple of policies
+ //
+ policyList.forEach(policy -> {
+ if ("onap.vfirewall.tca".equals(policy.getName())) {
+ policy.setVersion("2.0.0");
+ } else if ("operational.modifyconfig".equals(policy.getName())) {
+ policy.setVersion("3.4.5");
+ }
+ });
+ //
+ // We'll still get back the same number of policies
+ //
filteredList = filter.filter(policyList);
assertEquals(22, filteredList.size());
- assertEquals("2.0.0", filteredList.get(12).getVersion());
- assertEquals("3.4.5", filteredList.get(14).getVersion());
-
- policyList.get(10).setVersion(VERSION_100);
- policyList.get(16).setVersion(VERSION_100);
+ //
+ // Assert that the correct versions are returned
+ //
+ policyList.forEach(policy -> {
+ if ("onap.vfirewall.tca".equals(policy.getName())) {
+ assertThat(policy.getVersion()).isEqualTo("2.0.0");
+ } else if ("operational.modifyconfig".equals(policy.getName())) {
+ assertThat(policy.getVersion()).isEqualTo("3.4.5");
+ } else if ("operational.scaleout".equals(policy.getName())) {
+ assertThat(policy.getVersion()).isEqualTo(VERSION_000);
+ } else {
+ assertThat(policy.getVersion()).isEqualTo(VERSION_100);
+ }
+ });
+
+ //
+ // Change versions back
+ //
+ policyList.forEach(policy -> {
+ if ("onap.vfirewall.tca".equals(policy.getName())) {
+ policy.setVersion(VERSION_100);
+ } else if ("operational.modifyconfig".equals(policy.getName())) {
+ policy.setVersion(VERSION_100);
+ }
+ });
+ //
+ // We'll still get back the same number of policies
+ //
filteredList = filter.filter(policyList);
assertEquals(22, filteredList.size());
- assertEquals(VERSION_100, filteredList.get(12).getVersion());
- assertEquals(VERSION_100, filteredList.get(14).getVersion());
+ //
+ // Assert that the correct versions are returned
+ //
+ policyList.forEach(policy -> {
+ //
+ // Should we fix this to be 1.0.0??
+ //
+ if ("operational.scaleout".equals(policy.getName())) {
+ assertThat(policy.getVersion()).isEqualTo(VERSION_000);
+ } else {
+ assertThat(policy.getVersion()).isEqualTo(VERSION_100);
+ }
+ });
}
@Test
@@ -177,7 +222,7 @@ public class ToscaPolicyFilterTest {
filter = ToscaPolicyFilter.builder().name("guard.frequency.scaleout").build();
filteredList = filter.filter(policyList);
- assertEquals(2, filteredList.size());
+ assertEquals(1, filteredList.size());
filter = ToscaPolicyFilter.builder().name("guard.frequency.scalein").build();
filteredList = filter.filter(policyList);
@@ -193,7 +238,7 @@ public class ToscaPolicyFilterTest {
filter = ToscaPolicyFilter.builder().name("operational.modifyconfig").version(VERSION_100).build();
filteredList = filter.filter(policyList);
- assertEquals(0, filteredList.size());
+ assertEquals(1, filteredList.size());
}
@Test
@@ -201,11 +246,11 @@ public class ToscaPolicyFilterTest {
// null pattern
ToscaPolicyFilter filter = ToscaPolicyFilter.builder().versionPrefix(null).build();
List<ToscaPolicy> filteredList = filter.filter(policyList);
- assertEquals(23, filteredList.size());
+ assertEquals(22, filteredList.size());
filter = ToscaPolicyFilter.builder().versionPrefix("1.").build();
filteredList = filter.filter(policyList);
- assertEquals(21, filteredList.size());
+ assertEquals(20, filteredList.size());
filter = ToscaPolicyFilter.builder().versionPrefix("100.").build();
filteredList = filter.filter(policyList);
@@ -236,7 +281,7 @@ public class ToscaPolicyFilterTest {
filter = ToscaPolicyFilter.builder().typeVersion(VERSION_000).build();
filteredList = filter.filter(policyList);
- assertEquals(3, filteredList.size());
+ assertEquals(0, filteredList.size());
filter = ToscaPolicyFilter.builder().type("onap.policies.optimization.resource.HpaPolicy")
.typeVersion(VERSION_100).build();