aboutsummaryrefslogtreecommitdiffstats
path: root/models-tosca/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'models-tosca/src/test')
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/concepts/ToscaPolicyTypeFilterTest.java6
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProviderPolicyTypeTest.java30
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicyTypeSerializationTest.java6
-rw-r--r--models-tosca/src/test/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtilsTest.java14
-rw-r--r--models-tosca/src/test/resources/onap.policies.NoVersion.yaml1
5 files changed, 36 insertions, 21 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 30696ce9d..0f038d3cd 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
@@ -163,7 +163,7 @@ public class ToscaPolicyTypeFilterTest {
public void testFilterNameVersion() {
ToscaPolicyTypeFilter filter = ToscaPolicyTypeFilter.builder().name("onap.policies.Monitoring").build();
List<ToscaPolicyType> filteredList = filter.filter(typeList);
- assertEquals(2, filteredList.size());
+ assertEquals(1, filteredList.size());
filter = ToscaPolicyTypeFilter.builder().name("onap.policies.monitoring.cdap.tca.hi.lo.app").build();
filteredList = filter.filter(typeList);
@@ -173,9 +173,9 @@ public class ToscaPolicyTypeFilterTest {
filteredList = filter.filter(typeList);
assertEquals(0, filteredList.size());
- filter = ToscaPolicyTypeFilter.builder().version(VERSION_000).build();
+ filter = ToscaPolicyTypeFilter.builder().version(VERSION_100).build();
filteredList = filter.filter(typeList);
- assertEquals(1, filteredList.size());
+ assertEquals(20, filteredList.size());
filter = ToscaPolicyTypeFilter.builder().name("onap.policies.optimization.Vim_fit").version(VERSION_000)
.build();
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 ae350bd90..3f0d9e2a5 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
@@ -58,11 +58,11 @@ import org.yaml.snakeyaml.Yaml;
*/
public class AuthorativeToscaProviderPolicyTypeTest {
private static final String VERSION = "version";
- private static final String POLICY_NO_VERSION_VERSION0 = "onap.policies.NoVersion:0.0.0";
+ private static final String POLICY_NO_VERSION_VERSION1 = "onap.policies.NoVersion:0.0.1";
private static final String POLICY_NO_VERSION = "onap.policies.NoVersion";
private static final String MISSING_POLICY_TYPES = "no policy types specified on service template";
private static final String DAO_IS_NULL = "^dao is marked .*on.*ull but is null$";
- private static final String VERSION_000 = "0.0.0";
+ private static final String VERSION_001 = "0.0.1";
private static String yamlAsJsonString;
private PfDao pfDao;
private StandardCoder standardCoder;
@@ -135,7 +135,7 @@ public class AuthorativeToscaProviderPolicyTypeTest {
ToscaServiceTemplate createdServiceTemplate =
new AuthorativeToscaProvider().createPolicyTypes(pfDao, toscaServiceTemplate);
- PfConceptKey policyTypeKey = new PfConceptKey(POLICY_NO_VERSION_VERSION0);
+ PfConceptKey policyTypeKey = new PfConceptKey(POLICY_NO_VERSION_VERSION1);
ToscaPolicyType beforePolicyType = toscaServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
ToscaPolicyType createdPolicyType = createdServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
@@ -150,7 +150,7 @@ public class AuthorativeToscaProviderPolicyTypeTest {
assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), createdPolicyType.getDescription()));
List<ToscaPolicyType> gotPolicyTypeList =
- new AuthorativeToscaProvider().getPolicyTypeList(pfDao, POLICY_NO_VERSION, VERSION_000);
+ new AuthorativeToscaProvider().getPolicyTypeList(pfDao, POLICY_NO_VERSION, VERSION_001);
assertEquals(2, gotPolicyTypeList.size());
assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
@@ -162,14 +162,14 @@ public class AuthorativeToscaProviderPolicyTypeTest {
assertEquals(2, gotPolicyTypeList.size());
assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
- gotPolicyTypeList = new AuthorativeToscaProvider().getPolicyTypeList(pfDao, null, VERSION_000);
+ gotPolicyTypeList = new AuthorativeToscaProvider().getPolicyTypeList(pfDao, null, VERSION_001);
assertEquals(2, gotPolicyTypeList.size());
assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
assertThatThrownBy(() -> new AuthorativeToscaProvider().getPolicyTypeList(new DefaultPfDao(), POLICY_NO_VERSION,
- VERSION_000)).hasMessageContaining("Policy Framework DAO has not been initialized");
+ VERSION_001)).hasMessageContaining("Policy Framework DAO has not been initialized");
- assertTrue(new AuthorativeToscaProvider().getPolicyTypeList(pfDao, "i.dont.Exist", VERSION_000).isEmpty());
+ assertTrue(new AuthorativeToscaProvider().getPolicyTypeList(pfDao, "i.dont.Exist", VERSION_001).isEmpty());
}
@Test
@@ -212,7 +212,7 @@ public class AuthorativeToscaProviderPolicyTypeTest {
ToscaServiceTemplate createdServiceTemplate =
new AuthorativeToscaProvider().createPolicyTypes(pfDao, toscaServiceTemplate);
- PfConceptKey policyTypeKey = new PfConceptKey(POLICY_NO_VERSION_VERSION0);
+ PfConceptKey policyTypeKey = new PfConceptKey(POLICY_NO_VERSION_VERSION1);
ToscaPolicyType beforePolicyType = toscaServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
ToscaPolicyType createdPolicyType = createdServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
@@ -234,14 +234,14 @@ public class AuthorativeToscaProviderPolicyTypeTest {
assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), gotPolicyType.getDescription()));
gotServiceTemplate = new AuthorativeToscaProvider().getFilteredPolicyTypes(pfDao,
- ToscaPolicyTypeFilter.builder().name(policyTypeKey.getName()).version(VERSION_000).build());
+ ToscaPolicyTypeFilter.builder().name(policyTypeKey.getName()).version(VERSION_001).build());
gotPolicyType = gotServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
assertEquals(0, ObjectUtils.compare(beforePolicyType.getDescription(), gotPolicyType.getDescription()));
List<ToscaPolicyType> gotPolicyTypeList =
- new AuthorativeToscaProvider().getPolicyTypeList(pfDao, POLICY_NO_VERSION, VERSION_000);
+ new AuthorativeToscaProvider().getPolicyTypeList(pfDao, POLICY_NO_VERSION, VERSION_001);
assertEquals(2, gotPolicyTypeList.size());
assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
@@ -256,7 +256,7 @@ public class AuthorativeToscaProviderPolicyTypeTest {
assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
gotPolicyTypeList = new AuthorativeToscaProvider().getFilteredPolicyTypeList(pfDao,
- ToscaPolicyTypeFilter.builder().name(policyTypeKey.getName()).version(VERSION_000).build());
+ ToscaPolicyTypeFilter.builder().name(policyTypeKey.getName()).version(VERSION_001).build());
assertEquals(1, gotPolicyTypeList.size());
assertEquals(true, beforePolicyType.getName().equals(gotPolicyType.getName()));
@@ -296,7 +296,7 @@ public class AuthorativeToscaProviderPolicyTypeTest {
ToscaServiceTemplate createdServiceTemplate =
new AuthorativeToscaProvider().createPolicyTypes(pfDao, toscaServiceTemplate);
- PfConceptKey policyTypeKey = new PfConceptKey(POLICY_NO_VERSION_VERSION0);
+ PfConceptKey policyTypeKey = new PfConceptKey(POLICY_NO_VERSION_VERSION1);
ToscaPolicyType beforePolicyType = toscaServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
ToscaPolicyType createdPolicyType = createdServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
@@ -328,7 +328,7 @@ public class AuthorativeToscaProviderPolicyTypeTest {
ToscaServiceTemplate createdServiceTemplate =
new AuthorativeToscaProvider().createPolicyTypes(pfDao, toscaServiceTemplate);
- PfConceptKey policyTypeKey = new PfConceptKey(POLICY_NO_VERSION_VERSION0);
+ PfConceptKey policyTypeKey = new PfConceptKey(POLICY_NO_VERSION_VERSION1);
ToscaPolicyType beforePolicyType = toscaServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
ToscaPolicyType createdPolicyType = createdServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
@@ -379,7 +379,7 @@ public class AuthorativeToscaProviderPolicyTypeTest {
ToscaServiceTemplate createdServiceTemplate =
new AuthorativeToscaProvider().createPolicyTypes(pfDao, toscaServiceTemplate);
- PfConceptKey policyTypeKey = new PfConceptKey(POLICY_NO_VERSION_VERSION0);
+ PfConceptKey policyTypeKey = new PfConceptKey(POLICY_NO_VERSION_VERSION1);
ToscaPolicyType beforePolicyType = toscaServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
ToscaPolicyType createdPolicyType = createdServiceTemplate.getPolicyTypes().get(policyTypeKey.getName());
@@ -395,7 +395,7 @@ public class AuthorativeToscaProviderPolicyTypeTest {
assertThatThrownBy(() -> {
new AuthorativeToscaProvider().getPolicyTypes(pfDao, policyTypeKey.getName(), policyTypeKey.getVersion());
- }).hasMessage("policy types for onap.policies.NoVersion:0.0.0 do not exist");
+ }).hasMessage("policy types for onap.policies.NoVersion:0.0.1 do not exist");
}
@Test
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicyTypeSerializationTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicyTypeSerializationTest.java
index 01a52f7bd..3c62a7424 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicyTypeSerializationTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicyTypeSerializationTest.java
@@ -155,9 +155,9 @@ public class MonitoringPolicyTypeSerializationTest {
Entry<PfConceptKey, JpaToscaPolicyType> firstPolicyType = policyTypesIter.next();
assertEquals(MONITORING, firstPolicyType.getKey().getName());
- assertEquals(VERSION_000, firstPolicyType.getKey().getVersion());
+ assertEquals(VERSION_100, firstPolicyType.getKey().getVersion());
assertEquals("tosca.policies.Root", firstPolicyType.getValue().getDerivedFrom().getName());
- assertEquals("a base policy type for all policies that governs monitoring provisioning",
+ assertEquals("a base policy type for all policies that govern monitoring provisioning",
firstPolicyType.getValue().getDescription());
Entry<PfConceptKey, JpaToscaPolicyType> secondPolicyType = policyTypesIter.next();
@@ -376,7 +376,7 @@ public class MonitoringPolicyTypeSerializationTest {
assertEquals(MONITORING, firstPolicyType.getKey().getName());
assertEquals(VERSION_100, firstPolicyType.getKey().getVersion());
assertEquals("tosca.policies.Root", firstPolicyType.getValue().getDerivedFrom().getName());
- assertEquals("a base policy type for all policies that govern monitoring provision",
+ assertEquals("a base policy type for all policies that govern monitoring provisioning",
firstPolicyType.getValue().getDescription());
Entry<PfConceptKey, JpaToscaPolicyType> secondPolicyType = policyTypesIter.next();
diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtilsTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtilsTest.java
index ca46de1c3..f9a0143fd 100644
--- a/models-tosca/src/test/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtilsTest.java
+++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtilsTest.java
@@ -201,5 +201,19 @@ public class ToscaServiceTemplateUtilsTest {
assertEquals(dt1, dtIterator.next());
assertEquals(pt0, compositeTemplate05.getPolicyTypes().getAll(null).iterator().next());
assertEquals(p0, compositeTemplate05.getTopologyTemplate().getPolicies().getAll(null).iterator().next());
+
+ JpaToscaServiceTemplate fragmentTemplate09 = new JpaToscaServiceTemplate();
+
+ fragmentTemplate09.setDataTypes(new JpaToscaDataTypes());
+ fragmentTemplate09.getDataTypes().getConceptMap().put(dt1.getKey(), dt1);
+
+ fragmentTemplate09.setPolicyTypes(new JpaToscaPolicyTypes());
+ fragmentTemplate09.getPolicyTypes().getConceptMap().put(pt0.getKey(), pt0);
+
+ fragmentTemplate09.setTopologyTemplate(null);
+
+ JpaToscaServiceTemplate compositeTemplate06 =
+ ToscaServiceTemplateUtils.addFragment(compositeTemplate05, fragmentTemplate09);
+ assertEquals(compositeTemplate05.getTopologyTemplate(), compositeTemplate06.getTopologyTemplate());
}
}
diff --git a/models-tosca/src/test/resources/onap.policies.NoVersion.yaml b/models-tosca/src/test/resources/onap.policies.NoVersion.yaml
index 5923eb22d..2dda556a6 100644
--- a/models-tosca/src/test/resources/onap.policies.NoVersion.yaml
+++ b/models-tosca/src/test/resources/onap.policies.NoVersion.yaml
@@ -6,6 +6,7 @@ policy_types:
description: The base policy type for all policies that govern optimization
onap.policies.NoVersion:
derived_from: onap.policies.Optimization
+ version: 0.0.1
properties:
applicableResources:
type: list