diff options
14 files changed, 64 insertions, 33 deletions
diff --git a/models-examples/src/main/resources/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app.yaml b/models-examples/src/main/resources/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app.yaml index 2f5abdde3..5fa4308db 100644 --- a/models-examples/src/main/resources/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app.yaml +++ b/models-examples/src/main/resources/policytypes/onap.policies.monitoring.cdap.tca.hi.lo.app.yaml @@ -2,7 +2,8 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 policy_types: onap.policies.Monitoring: derived_from: tosca.policies.Root - description: a base policy type for all policies that governs monitoring provisioning + version: 1.0.0 + description: a base policy type for all policies that govern monitoring provisioning onap.policies.monitoring.cdap.tca.hi.lo.app: derived_from: onap.policies.Monitoring version: 1.0.0 diff --git a/models-examples/src/main/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml b/models-examples/src/main/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml index cf70e9bb2..4f124a2f1 100644 --- a/models-examples/src/main/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml +++ b/models-examples/src/main/resources/policytypes/onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server.yaml @@ -2,7 +2,7 @@ tosca_definitions_version: tosca_simple_yaml_1_0_0 policy_types: onap.policies.Monitoring: derived_from: tosca.policies.Root - description: a base policy type for all policies that govern monitoring provision + description: a base policy type for all policies that govern monitoring provisioning version: 1.0.0 onap.policies.monitoring.dcaegen2.collectors.datafile.datafile-app-server: derived_from: policy.nodes.Root diff --git a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyLegacyOperationalPersistenceTest.java b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyLegacyOperationalPersistenceTest.java index 0eee4b2b6..47855c4cd 100644 --- a/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyLegacyOperationalPersistenceTest.java +++ b/models-provider/src/test/java/org/onap/policy/models/provider/impl/PolicyLegacyOperationalPersistenceTest.java @@ -148,8 +148,8 @@ public class PolicyLegacyOperationalPersistenceTest { private void createPolicyTypes() throws CoderException, PfModelException, URISyntaxException { Set<String> policyTypeResources = ResourceUtils.getDirectoryContents("policytypes"); - for (String policyTyoeResource : policyTypeResources) { - Object yamlObject = new Yaml().load(ResourceUtils.getResourceAsString(policyTyoeResource)); + for (String policyTypeResource : policyTypeResources) { + Object yamlObject = new Yaml().load(ResourceUtils.getResourceAsString(policyTypeResource)); String yamlAsJsonString = new StandardCoder().encode(yamlObject); ToscaServiceTemplate toscaServiceTemplatePolicyType = diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java index 6e60303a0..a65cdbe69 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/authorative/provider/AuthorativeToscaProvider.java @@ -423,6 +423,7 @@ public class AuthorativeToscaProvider { */ private <T extends ToscaEntity> List<T> handlePfModelRuntimeException(final PfModelRuntimeException pfme) { if (Status.NOT_FOUND.equals(pfme.getErrorResponse().getResponseCode())) { + LOGGER.trace("request did not find any results", pfme); return Collections.emptyList(); } else { throw pfme; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider.java index f5335fe79..09cc6c0ca 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/provider/LegacyProvider.java @@ -93,13 +93,13 @@ public class LegacyProvider { LOGGER.debug("->createOperationalPolicy: legacyOperationalPolicy={}", legacyOperationalPolicy); - JpaToscaServiceTemplate incomingServiceTemplate = + JpaToscaServiceTemplate legacyOperationalServiceTemplate = new LegacyOperationalPolicyMapper().toToscaServiceTemplate(legacyOperationalPolicy); - JpaToscaServiceTemplate outgoingingServiceTemplate = - new SimpleToscaProvider().createPolicies(dao, incomingServiceTemplate); + + new SimpleToscaProvider().createPolicies(dao, legacyOperationalServiceTemplate); LegacyOperationalPolicy createdLegacyOperationalPolicy = - new LegacyOperationalPolicyMapper().fromToscaServiceTemplate(outgoingingServiceTemplate); + new LegacyOperationalPolicyMapper().fromToscaServiceTemplate(legacyOperationalServiceTemplate); LOGGER.debug("<-createOperationalPolicy: createdLegacyOperationalPolicy={}", createdLegacyOperationalPolicy); return createdLegacyOperationalPolicy; @@ -223,7 +223,6 @@ public class LegacyProvider { return updatedLegacyGuardPolicyMap; } - /** * Delete legacy guard policy. * diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java index 2816df004..b500a8bc9 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicy.java @@ -261,6 +261,11 @@ public class JpaToscaPolicy extends JpaToscaEntityType<ToscaPolicy> implements P public PfValidationResult validate(@NonNull final PfValidationResult resultIn) { PfValidationResult result = super.validate(resultIn); + if (PfKey.NULL_KEY_VERSION.equals(getKey().getVersion())) { + result.addValidationMessage(new PfValidationMessage(getKey(), this.getClass(), ValidationResult.INVALID, + "key version is a null version")); + } + if (type == null || type.isNullKey()) { result.addValidationMessage(new PfValidationMessage(getKey(), this.getClass(), ValidationResult.INVALID, "type is null or a null key")); diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyType.java index b068beaa0..423620dd7 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyType.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/JpaToscaPolicyType.java @@ -203,6 +203,11 @@ public class JpaToscaPolicyType extends JpaToscaEntityType<ToscaPolicyType> impl public PfValidationResult validate(@NonNull final PfValidationResult resultIn) { PfValidationResult result = super.validate(resultIn); + if (PfKey.NULL_KEY_VERSION.equals(getKey().getVersion())) { + result.addValidationMessage(new PfValidationMessage(getKey(), this.getClass(), ValidationResult.INVALID, + "key version is a null version")); + } + if (properties != null) { result = validateProperties(result); } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java index 9c7d6d305..17eae006d 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/provider/SimpleToscaProvider.java @@ -264,6 +264,9 @@ public class SimpleToscaProvider { "policy types for " + name + ":" + version + DO_NOT_EXIST); } + JpaToscaServiceTemplate dataTypeServiceTemplate = new JpaToscaServiceTemplate(serviceTemplate); + dataTypeServiceTemplate.setPolicyTypes(null); + for (JpaToscaPolicyType policyType : serviceTemplate.getPolicyTypes().getConceptMap().values()) { Collection<PfConceptKey> referencedDataTypeKeys = policyType.getReferencedDataTypes(); @@ -271,11 +274,13 @@ public class SimpleToscaProvider { JpaToscaServiceTemplate dataTypeEntityTreeServiceTemplate = getDataTypes(dao, referencedDataTypeKey.getName(), referencedDataTypeKey.getVersion()); - serviceTemplate = - ToscaServiceTemplateUtils.addFragment(serviceTemplate, dataTypeEntityTreeServiceTemplate); + dataTypeServiceTemplate = ToscaServiceTemplateUtils.addFragment(dataTypeServiceTemplate, + dataTypeEntityTreeServiceTemplate); } } + serviceTemplate = ToscaServiceTemplateUtils.addFragment(serviceTemplate, dataTypeServiceTemplate); + LOGGER.debug("<-getPolicyTypes: name={}, version={}, serviceTemplate={}", name, version, serviceTemplate); return serviceTemplate; } diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java index 87b499b4c..aae45e5ce 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/utils/ToscaServiceTemplateUtils.java @@ -74,7 +74,7 @@ public class ToscaServiceTemplateUtils { compositeTemplate.setPolicyTypes( addFragmentEntitites(compositeTemplate.getPolicyTypes(), fragmentTemplate.getPolicyTypes(), result)); - if (originalTemplate.getTopologyTemplate() != null) { + if (originalTemplate.getTopologyTemplate() != null && fragmentTemplate.getTopologyTemplate() != null) { if (originalTemplate.getTopologyTemplate() .compareToWithoutEntities(fragmentTemplate.getTopologyTemplate()) == 0) { compositeTemplate.getTopologyTemplate() 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 |