summaryrefslogtreecommitdiffstats
path: root/models-tosca/src/test/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'models-tosca/src/test/java/org')
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilterTest.java40
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java46
2 files changed, 45 insertions, 41 deletions
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilterTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilterTest.java
index 5fbad5559..28836a981 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilterTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilterTest.java
@@ -58,16 +58,22 @@ public class ToscaPolicyTypeFilterTest {
// @formatter:off
private static final String[] policyTypeResourceNames = {
- "policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml",
- "policytypes/onap.policies.optimization.AffinityPolicy.yaml",
+ "policytypes/onap.policies.controlloop.Operational.yaml",
"policytypes/onap.policies.optimization.DistancePolicy.yaml",
- "policytypes/onap.policies.optimization.HpaPolicy.yaml",
- "policytypes/onap.policies.optimization.OptimizationPolicy.yaml",
+ "policytypes/onap.policies.optimization.VnfPolicy.yaml",
"policytypes/onap.policies.optimization.PciPolicy.yaml",
- "policytypes/onap.policies.optimization.QueryPolicy.yaml",
- "policytypes/onap.policies.optimization.SubscriberPolicy.yaml",
+ "policytypes/onap.policies.optimization.OptimizationPolicy.yaml",
+ "policytypes/onap.policies.controlloop.guard.Blacklist.yaml",
+ "policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml",
+ "policytypes/onap.policies.optimization.HpaPolicy.yaml",
"policytypes/onap.policies.optimization.Vim_fit.yaml",
- "policytypes/onap.policies.optimization.VnfPolicy.yaml",
+ "policytypes/onap.policies.optimization.SubscriberPolicy.yaml",
+ "policytypes/onap.policies.optimization.AffinityPolicy.yaml",
+ "policytypes/onap.policies.optimization.QueryPolicy.yaml",
+ "policytypes/onap.policies.controlloop.guard.MinMax.yaml",
+ "policytypes/onap.policies.controlloop.guard.FrequencyLimiter.yaml",
+ "policytypes/onap.policies.controlloop.guard.coordination.FirstBlocksSecond.yaml",
+ "policytypes/onap.policies.Optimization.yaml",
"policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app.yaml"
};
// @formatter:on
@@ -90,9 +96,7 @@ public class ToscaPolicyTypeFilterTest {
new StandardCoder().decode(yamlAsJsonString, ToscaServiceTemplate.class);
assertNotNull(serviceTemplate);
- for (Map<String, ToscaPolicyType> foundPolicyTypeMap : serviceTemplate.getPolicyTypes()) {
- addPolicyTypes(foundPolicyTypeMap);
- }
+ addPolicyTypes(serviceTemplate.getPolicyTypes());
}
for (ToscaPolicyType type : typeList) {
@@ -138,21 +142,21 @@ public class ToscaPolicyTypeFilterTest {
ToscaPolicyTypeFilter.builder().version(ToscaPolicyTypeFilter.LATEST_VERSION).build();
List<ToscaPolicyType> filteredList = filter.filter(typeList);
- assertEquals(13, filteredList.size());
+ assertEquals(20, filteredList.size());
assertEquals(VERSION_100, filteredList.get(0).getVersion());
- assertEquals(VERSION_000, filteredList.get(4).getVersion());
+ assertEquals(VERSION_000, filteredList.get(11).getVersion());
typeList.get(12).setVersion("2.0.0");
filteredList = filter.filter(typeList);
- assertEquals(13, filteredList.size());
- assertEquals("2.0.0", filteredList.get(0).getVersion());
- assertEquals(VERSION_000, filteredList.get(4).getVersion());
+ assertEquals(20, filteredList.size());
+ assertEquals("2.0.0", filteredList.get(11).getVersion());
+ assertEquals(VERSION_000, filteredList.get(18).getVersion());
typeList.get(12).setVersion(VERSION_100);
filteredList = filter.filter(typeList);
- assertEquals(13, filteredList.size());
+ assertEquals(20, filteredList.size());
assertEquals(VERSION_100, filteredList.get(0).getVersion());
- assertEquals(VERSION_000, filteredList.get(4).getVersion());
+ assertEquals(VERSION_000, filteredList.get(18).getVersion());
}
@Test
@@ -174,7 +178,7 @@ public class ToscaPolicyTypeFilterTest {
assertEquals(9, filteredList.size());
filter = ToscaPolicyTypeFilter.builder().name("onap.policies.optimization.Vim_fit").version(VERSION_000)
- .build();
+ .build();
filteredList = filter.filter(typeList);
assertEquals(1, filteredList.size());
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java
index 8bed1e4a1..d77b52daa 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java
@@ -27,7 +27,7 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import com.google.gson.GsonBuilder;
-import java.util.ArrayList;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Properties;
import org.apache.commons.lang3.ObjectUtils;
@@ -137,15 +137,15 @@ public class AuthorativeToscaProviderPolicyTypeTest {
PfConceptKey policyTypeKey = new PfConceptKey(POLICY_AFFINITY_VERSION0);
- ToscaPolicyType beforePolicyType = toscaServiceTemplate.getPolicyTypes().get(1).get(policyTypeKey.getName());
- ToscaPolicyType createdPolicyType = createdServiceTemplate.getPolicyTypes().get(1).get(policyTypeKey.getName());
+ ToscaPolicyType beforePolicyType = toscaServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
+ ToscaPolicyType createdPolicyType = createdServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
assertEquals(true, beforePolicyType.getName().equals(createdPolicyType.getName()));
assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), createdPolicyType.getDescription()));
ToscaServiceTemplate gotServiceTemplate = new AuthorativeToscaProvider().getPolicyTypes(pfDao,
policyTypeKey.getName(), policyTypeKey.getVersion());
- ToscaPolicyType gotPolicyType = gotServiceTemplate.getPolicyTypes().get(0).get(policyTypeKey.getName());
+ ToscaPolicyType gotPolicyType = gotServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), createdPolicyType.getDescription()));
@@ -160,11 +160,11 @@ public class AuthorativeToscaProviderPolicyTypeTest {
assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
gotPolicyTypeList = new AuthorativeToscaProvider().getPolicyTypeList(pfDao, null, null);
- assertEquals(2, gotPolicyTypeList.size());
+ assertEquals(1, gotPolicyTypeList.size());
assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
gotPolicyTypeList = new AuthorativeToscaProvider().getPolicyTypeList(pfDao, null, VERSION_000);
- assertEquals(2, gotPolicyTypeList.size());
+ assertEquals(1, gotPolicyTypeList.size());
assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
}
@@ -203,29 +203,29 @@ public class AuthorativeToscaProviderPolicyTypeTest {
PfConceptKey policyTypeKey = new PfConceptKey(POLICY_AFFINITY_VERSION0);
- ToscaPolicyType beforePolicyType = toscaServiceTemplate.getPolicyTypes().get(1).get(policyTypeKey.getName());
- ToscaPolicyType createdPolicyType = createdServiceTemplate.getPolicyTypes().get(1).get(policyTypeKey.getName());
+ ToscaPolicyType beforePolicyType = toscaServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
+ ToscaPolicyType createdPolicyType = createdServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
assertEquals(true, beforePolicyType.getName().equals(createdPolicyType.getName()));
assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), createdPolicyType.getDescription()));
ToscaServiceTemplate gotServiceTemplate =
new AuthorativeToscaProvider().getFilteredPolicyTypes(pfDao, ToscaPolicyTypeFilter.builder().build());
- ToscaPolicyType gotPolicyType = gotServiceTemplate.getPolicyTypes().get(1).get(policyTypeKey.getName());
+ ToscaPolicyType gotPolicyType = gotServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), gotPolicyType.getDescription()));
gotServiceTemplate = new AuthorativeToscaProvider().getFilteredPolicyTypes(pfDao,
ToscaPolicyTypeFilter.builder().name(policyTypeKey.getName()).build());
- gotPolicyType = gotServiceTemplate.getPolicyTypes().get(0).get(policyTypeKey.getName());
+ gotPolicyType = gotServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), gotPolicyType.getDescription()));
gotServiceTemplate = new AuthorativeToscaProvider().getFilteredPolicyTypes(pfDao,
ToscaPolicyTypeFilter.builder().name(policyTypeKey.getName()).version(VERSION_000).build());
- gotPolicyType = gotServiceTemplate.getPolicyTypes().get(0).get(policyTypeKey.getName());
+ gotPolicyType = gotServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), gotPolicyType.getDescription()));
@@ -236,7 +236,7 @@ public class AuthorativeToscaProviderPolicyTypeTest {
gotPolicyTypeList = new AuthorativeToscaProvider().getFilteredPolicyTypeList(pfDao,
ToscaPolicyTypeFilter.builder().build());
- assertEquals(2, gotPolicyTypeList.size());
+ assertEquals(1, gotPolicyTypeList.size());
assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
gotPolicyTypeList = new AuthorativeToscaProvider().getFilteredPolicyTypeList(pfDao,
@@ -251,7 +251,7 @@ public class AuthorativeToscaProviderPolicyTypeTest {
gotPolicyTypeList = new AuthorativeToscaProvider().getFilteredPolicyTypeList(pfDao,
ToscaPolicyTypeFilter.builder().version("1.0.0").build());
- assertEquals(1, gotPolicyTypeList.size());
+ assertEquals(0, gotPolicyTypeList.size());
assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
}
@@ -274,7 +274,7 @@ public class AuthorativeToscaProviderPolicyTypeTest {
new AuthorativeToscaProvider().createPolicyTypes(pfDao, testToscaServiceTemplate);
}).hasMessage(MISSING_POLICY_TYPES);
- testToscaServiceTemplate.setPolicyTypes(new ArrayList<>());
+ testToscaServiceTemplate.setPolicyTypes(new LinkedHashMap<>());
assertThatThrownBy(() -> {
new AuthorativeToscaProvider().createPolicyTypes(pfDao, testToscaServiceTemplate);
}).hasMessage("An incoming list of concepts must have at least one entry");
@@ -287,8 +287,8 @@ public class AuthorativeToscaProviderPolicyTypeTest {
PfConceptKey policyTypeKey = new PfConceptKey(POLICY_AFFINITY_VERSION0);
- ToscaPolicyType beforePolicyType = toscaServiceTemplate.getPolicyTypes().get(1).get(policyTypeKey.getName());
- ToscaPolicyType createdPolicyType = createdServiceTemplate.getPolicyTypes().get(1).get(policyTypeKey.getName());
+ ToscaPolicyType beforePolicyType = toscaServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
+ ToscaPolicyType createdPolicyType = createdServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
assertEquals(true, beforePolicyType.getName().equals(createdPolicyType.getName()));
assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), createdPolicyType.getDescription()));
}
@@ -319,15 +319,15 @@ public class AuthorativeToscaProviderPolicyTypeTest {
PfConceptKey policyTypeKey = new PfConceptKey(POLICY_AFFINITY_VERSION0);
- ToscaPolicyType beforePolicyType = toscaServiceTemplate.getPolicyTypes().get(1).get(policyTypeKey.getName());
- ToscaPolicyType createdPolicyType = createdServiceTemplate.getPolicyTypes().get(1).get(policyTypeKey.getName());
+ ToscaPolicyType beforePolicyType = toscaServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
+ ToscaPolicyType createdPolicyType = createdServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
assertEquals(true, beforePolicyType.getName().equals(createdPolicyType.getName()));
assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), createdPolicyType.getDescription()));
ToscaServiceTemplate updatedServiceTemplate =
new AuthorativeToscaProvider().updatePolicyTypes(pfDao, toscaServiceTemplate);
- ToscaPolicyType updatedPolicy = updatedServiceTemplate.getPolicyTypes().get(1).get(policyTypeKey.getName());
+ ToscaPolicyType updatedPolicy = updatedServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
assertEquals(true, beforePolicyType.getName().equals(updatedPolicy.getName()));
assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), updatedPolicy.getDescription()));
}
@@ -370,15 +370,15 @@ public class AuthorativeToscaProviderPolicyTypeTest {
PfConceptKey policyTypeKey = new PfConceptKey(POLICY_AFFINITY_VERSION0);
- ToscaPolicyType beforePolicyType = toscaServiceTemplate.getPolicyTypes().get(1).get(policyTypeKey.getName());
- ToscaPolicyType createdPolicyType = createdServiceTemplate.getPolicyTypes().get(1).get(policyTypeKey.getName());
+ ToscaPolicyType beforePolicyType = toscaServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
+ ToscaPolicyType createdPolicyType = createdServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
assertEquals(true, beforePolicyType.getName().equals(createdPolicyType.getName()));
assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), createdPolicyType.getDescription()));
ToscaServiceTemplate deletedServiceTemplate = new AuthorativeToscaProvider().deletePolicyType(pfDao,
policyTypeKey.getName(), policyTypeKey.getVersion());
- ToscaPolicyType deletedPolicy = deletedServiceTemplate.getPolicyTypes().get(0).get(policyTypeKey.getName());
+ ToscaPolicyType deletedPolicy = deletedServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
assertEquals(true, beforePolicyType.getName().equals(deletedPolicy.getName()));
assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), deletedPolicy.getDescription()));
@@ -405,7 +405,7 @@ public class AuthorativeToscaProviderPolicyTypeTest {
new AuthorativeToscaProvider().createPolicyTypes(pfDao, testServiceTemplate);
}).hasMessage(MISSING_POLICY_TYPES);
- testServiceTemplate.setPolicyTypes(new ArrayList<>());
+ testServiceTemplate.setPolicyTypes(new LinkedHashMap<>());
assertThatThrownBy(() -> {
new AuthorativeToscaProvider().createPolicyTypes(pfDao, testServiceTemplate);
}).hasMessage("An incoming list of concepts must have at least one entry");