diff options
Diffstat (limited to 'models-tosca')
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/concepts/LegacyGuardPolicy.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardPolicy.java) | 2 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/concepts/LegacyOperationalPolicy.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalPolicy.java) | 5 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java | 89 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardMessageBodyHandler.java | 56 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalMessageBodyHandler.java | 56 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraint.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraint.java) | 2 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogical.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogical.java) | 2 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogicalKey.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalKey.java) | 2 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogicalString.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalString.java) | 2 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaDataType.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaDataType.java) | 2 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaDataTypes.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaDataTypes.java) | 2 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaEntityType.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaEntityType.java) | 2 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaEntrySchema.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaEntrySchema.java) | 2 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaEventFilter.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaEventFilter.java) | 2 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaModel.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaModel.java) | 2 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicies.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicies.java) | 2 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicy.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicy.java) | 39 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicyType.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicyType.java) | 2 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicyTypes.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypes.java) | 2 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaProperty.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaProperty.java) | 2 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaServiceTemplate.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplate.java) | 2 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaServiceTemplates.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplates.java) | 2 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaTimeInterval.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTimeInterval.java) | 2 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaTopologyTemplate.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTopologyTemplate.java) | 2 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaTrigger.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTrigger.java) | 2 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/mapping/ToscaServiceTemplateMapper.java | 49 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/serialization/ToscaPoliciesJsonAdapter.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaPoliciesJsonAdapter.java) | 6 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/serialization/ToscaPolicyJsonAdapter.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaPolicyJsonAdapter.java) | 4 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/serialization/ToscaServiceTemplateJsonAdapter.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaServiceTemplateJsonAdapter.java) | 6 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/serialization/ToscaServiceTemplateMessageBodyHandler.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaServiceTemplateMessageBodyHandler.java) | 10 | ||||
-rw-r--r-- | models-tosca/src/main/java/org/onap/policy/models/tosca/simple/serialization/ToscaTopologyTemplateJsonAdapter.java (renamed from models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaTopologyTemplateJsonAdapter.java) | 6 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/concepts/LegacyGuardPolicyTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardPolicyTest.java) | 3 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/concepts/LegacyOperationalPolicyTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalPolicyTest.java) | 3 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/serialization/LegacyOperationalPolicySerializationTest.java | 74 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/TestPojos.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/TestPojos.java) | 4 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogicalKeyTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalKeyTest.java) | 3 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogicalStringTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalStringTest.java) | 3 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogicalTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalTest.java) | 5 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaDataTypeTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaDataTypeTest.java) | 8 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaDataTypesTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaDataTypesTest.java) | 4 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaEntrySchemaTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaEntrySchemaTest.java) | 7 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaEventFilterTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaEventFilterTest.java) | 3 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaModelTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaModelTest.java) | 5 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaPoliciesTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPoliciesTest.java) | 4 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicyTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTest.java) | 32 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicyTypeTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypeTest.java) | 6 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicyTypesTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypesTest.java) | 4 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaPropertyTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPropertyTest.java) | 8 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaServiceTemplateTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplateTest.java) | 8 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaServiceTemplatesTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplatesTest.java) | 4 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaTimeIntervalTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTimeIntervalTest.java) | 3 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaTopologyTemplateTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTopologyTemplateTest.java) | 5 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaTriggerTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTriggerTest.java) | 8 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/testconcepts/DummyToscaConstraint.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/testconcepts/DummyToscaConstraint.java) | 4 | ||||
-rw-r--r-- | models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicySerializationTest.java (renamed from models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/MonitoringPolicySerializationTest.java) | 6 |
55 files changed, 364 insertions, 216 deletions
diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardPolicy.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/concepts/LegacyGuardPolicy.java index 30e62eb93..2454b51be 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardPolicy.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/concepts/LegacyGuardPolicy.java @@ -19,7 +19,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.serialization.legacy; +package org.onap.policy.models.tosca.legacy.concepts; import java.util.List; import java.util.Map; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalPolicy.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/concepts/LegacyOperationalPolicy.java index 358d70247..60a1e454d 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalPolicy.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/concepts/LegacyOperationalPolicy.java @@ -19,7 +19,9 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.serialization.legacy; +package org.onap.policy.models.tosca.legacy.concepts; + +import com.google.gson.annotations.SerializedName; import lombok.Data; @@ -31,6 +33,7 @@ import lombok.Data; @Data public class LegacyOperationalPolicy { + @SerializedName("policy-id") private String policyId; private String policyVersion; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java new file mode 100644 index 000000000..781602a7e --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/legacy/mapping/LegacyOperationalPolicyMapper.java @@ -0,0 +1,89 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.tosca.legacy.mapping; + +import java.util.HashMap; +import java.util.Map; + +import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.base.PfReferenceKey; +import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy; +import org.onap.policy.models.tosca.simple.concepts.ToscaPolicies; +import org.onap.policy.models.tosca.simple.concepts.ToscaPolicy; +import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.simple.concepts.ToscaTopologyTemplate; +import org.onap.policy.models.tosca.simple.mapping.ToscaServiceTemplateMapper; + +/** + * This class maps a legacy operational policy to and from a TOSCA service template. + * + * @author Liam Fallon (liam.fallon@est.tech) + */ +public class LegacyOperationalPolicyMapper + implements ToscaServiceTemplateMapper<LegacyOperationalPolicy, LegacyOperationalPolicy> { + + // TODO: Do this correctly with an atomic integer + private static int nextVersion = 1; + + @Override + public ToscaServiceTemplate toToscaServiceTemplate(LegacyOperationalPolicy legacyOperationalPolicy) { + PfConceptKey policyKey = + new PfConceptKey(legacyOperationalPolicy.getPolicyId(), getNextVersion()); + + ToscaPolicy toscaPolicy = new ToscaPolicy(policyKey); + + // TODO: Find out how to parse the PolicyType from the content + // TODO: Check if this is the correct way to set the policy type version + toscaPolicy.setType(new PfConceptKey("SomeDerivedPolicyType", "1.0.0")); + + Map<String, Object> propertyMap = new HashMap<>(); + toscaPolicy.setProperties(propertyMap); + toscaPolicy.getProperties().put("Content", legacyOperationalPolicy.getContent()); + + PfConceptKey serviceTemplateKey = new PfConceptKey("ServiceTemplate", "1.0.0"); + ToscaServiceTemplate serviceTemplate = new ToscaServiceTemplate(serviceTemplateKey); + serviceTemplate.setToscaDefinitionsVersion("tosca_simple_yaml_1_0"); + + PfReferenceKey topologyTemplateKey = new PfReferenceKey(serviceTemplateKey, "TopolocyTemplate"); + serviceTemplate.setTopologyTemplate(new ToscaTopologyTemplate(topologyTemplateKey)); + + PfConceptKey policiesKey = new PfConceptKey("Policies", "1.0.0"); + serviceTemplate.getTopologyTemplate().setPolicies(new ToscaPolicies(policiesKey)); + serviceTemplate.getTopologyTemplate().getPolicies().getConceptMap().put(policyKey, toscaPolicy); + + return serviceTemplate; + } + + @Override + public LegacyOperationalPolicy fromToscaServiceTemplate(ToscaServiceTemplate serviceTemplate) { + // TODO Auto-generated method stub + return null; + } + + /** + * Get the next policy version. + * + * @return the next version + */ + private static String getNextVersion() { + return "1.0." + nextVersion++; + } +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardMessageBodyHandler.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardMessageBodyHandler.java deleted file mode 100644 index b343c9e66..000000000 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardMessageBodyHandler.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.models.tosca.serialization.legacy; - -import com.google.gson.GsonBuilder; - -import org.onap.policy.common.gson.GsonMessageBodyHandler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Provider used to serialize and deserialize TOSCA objects using GSON. - */ -public class LegacyGuardMessageBodyHandler extends GsonMessageBodyHandler { - - public static final Logger logger = LoggerFactory.getLogger(LegacyGuardMessageBodyHandler.class); - - /** - * Constructs the object. - */ - public LegacyGuardMessageBodyHandler() { - this(new GsonBuilder()); - - logger.info("Using GSON with TOSCA for REST calls"); - } - - /** - * Constructs the object. - * - * @param builder builder to use to create the gson object - */ - public LegacyGuardMessageBodyHandler(final GsonBuilder builder) { - // @formatter:off - super(builder - .create() - ); - // @formatter:on - } - -} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalMessageBodyHandler.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalMessageBodyHandler.java deleted file mode 100644 index f51a427f0..000000000 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalMessageBodyHandler.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.policy.models.tosca.serialization.legacy; - -import com.google.gson.GsonBuilder; - -import org.onap.policy.common.gson.GsonMessageBodyHandler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Provider used to serialize and deserialize TOSCA objects using GSON. - */ -public class LegacyOperationalMessageBodyHandler extends GsonMessageBodyHandler { - - public static final Logger logger = LoggerFactory.getLogger(LegacyOperationalMessageBodyHandler.class); - - /** - * Constructs the object. - */ - public LegacyOperationalMessageBodyHandler() { - this(new GsonBuilder()); - - logger.info("Using GSON with TOSCA for REST calls"); - } - - /** - * Constructs the object. - * - * @param builder builder to use to create the gson object - */ - public LegacyOperationalMessageBodyHandler(final GsonBuilder builder) { - // @formatter:off - super(builder - .create() - ); - // @formatter:on - } - -} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraint.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraint.java index dadad6fd6..ee153a295 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraint.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraint.java @@ -21,7 +21,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import java.util.List; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogical.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogical.java index f186d8525..25a03c9e1 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogical.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogical.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import javax.persistence.Column; import javax.ws.rs.core.Response; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalKey.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogicalKey.java index 1a63f30c8..0fe50dd71 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalKey.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogicalKey.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import java.util.List; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalString.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogicalString.java index c786d626b..fbf036004 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalString.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogicalString.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import javax.persistence.Column; import javax.persistence.Entity; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaDataType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaDataType.java index 5af24d6ed..e7d91ea40 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaDataType.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaDataType.java @@ -21,7 +21,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import java.util.ArrayList; import java.util.List; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaDataTypes.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaDataTypes.java index 61c3500cb..cbf0e3844 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaDataTypes.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaDataTypes.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import java.util.Map; import java.util.TreeMap; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaEntityType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaEntityType.java index b0dc58d93..8b6dd40d6 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaEntityType.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaEntityType.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import com.google.gson.annotations.SerializedName; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaEntrySchema.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaEntrySchema.java index 72bedbd9e..2dca1ef55 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaEntrySchema.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaEntrySchema.java @@ -21,7 +21,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import java.util.ArrayList; import java.util.List; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaEventFilter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaEventFilter.java index 4e2d73763..e2e5488e0 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaEventFilter.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaEventFilter.java @@ -21,7 +21,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import java.util.List; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaModel.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaModel.java index 9169e6778..a7852976d 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaModel.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaModel.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import java.util.List; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicies.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicies.java index 7209fd081..9dd12ec88 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicies.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicies.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import java.util.Map; import java.util.TreeMap; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicy.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicy.java index 3e1fddd31..af94af08d 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicy.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicy.java @@ -21,10 +21,12 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.Map.Entry; import javax.persistence.Column; import javax.persistence.ElementCollection; @@ -38,6 +40,7 @@ import lombok.EqualsAndHashCode; import lombok.NonNull; import org.onap.policy.common.utils.validation.Assertions; +import org.onap.policy.common.utils.validation.ParameterValidationUtils; import org.onap.policy.models.base.PfConcept; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfKey; @@ -64,7 +67,7 @@ public class ToscaPolicy extends ToscaEntityType { private PfConceptKey type; @ElementCollection - private List<ToscaProperty> properties; + private Map<String, Object> properties; @ElementCollection private List<PfConceptKey> targets; @@ -112,12 +115,6 @@ public class ToscaPolicy extends ToscaEntityType { keyList.addAll(type.getKeys()); - if (properties != null) { - for (ToscaProperty property : properties) { - keyList.addAll(property.getKeys()); - } - } - if (targets != null) { keyList.addAll(targets); } @@ -131,12 +128,6 @@ public class ToscaPolicy extends ToscaEntityType { type.clean(); - if (properties != null) { - for (ToscaProperty property : properties) { - property.clean(); - } - } - if (targets != null) { for (PfConceptKey target : targets) { target.clean(); @@ -151,8 +142,7 @@ public class ToscaPolicy extends ToscaEntityType { if (type == null || type.isNullKey()) { result.addValidationMessage(new PfValidationMessage(type, this.getClass(), ValidationResult.INVALID, "type is null or a null key")); - } - else { + } else { result = type.validate(result); } @@ -176,12 +166,13 @@ public class ToscaPolicy extends ToscaEntityType { private PfValidationResult validateProperties(@NonNull final PfValidationResult resultIn) { PfValidationResult result = resultIn; - for (ToscaProperty property : properties) { - if (property == null) { + for (Entry<String, Object> propertyEntry : properties.entrySet()) { + if (!ParameterValidationUtils.validateStringParameter(propertyEntry.getKey())) { result.addValidationMessage(new PfValidationMessage(getKey(), this.getClass(), ValidationResult.INVALID, - "policy property may not be null ")); - } else { - result = property.validate(result); + "policy property key may not be null ")); + } else if (propertyEntry.getValue() == null) { + result.addValidationMessage(new PfValidationMessage(getKey(), this.getClass(), ValidationResult.INVALID, + "policy property value may not be null ")); } } return result; @@ -251,11 +242,7 @@ public class ToscaPolicy extends ToscaEntityType { if (properties == null) { copy.setProperties(null); } else { - final List<ToscaProperty> newProperties = new ArrayList<>(); - for (final ToscaProperty property : properties) { - newProperties.add(new ToscaProperty(property)); - } - copy.setProperties(newProperties); + copy.setProperties(properties); } if (targets == null) { diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicyType.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicyType.java index dbd011468..b155192cb 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicyType.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicyType.java @@ -21,7 +21,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import java.util.ArrayList; import java.util.List; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypes.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicyTypes.java index e33e6c0c9..23159ccfa 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypes.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicyTypes.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import java.util.Map; import java.util.TreeMap; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaProperty.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaProperty.java index ab72ff60e..da13877c6 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaProperty.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaProperty.java @@ -21,7 +21,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import com.google.gson.annotations.SerializedName; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaServiceTemplate.java index acf231a3e..fd8b134ce 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplate.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaServiceTemplate.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import com.google.gson.annotations.SerializedName; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplates.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaServiceTemplates.java index bd1620747..33d774889 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplates.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaServiceTemplates.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import java.util.Map; import java.util.TreeMap; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTimeInterval.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaTimeInterval.java index 10ee6cc7d..69c7c6c97 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTimeInterval.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaTimeInterval.java @@ -21,7 +21,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import com.google.gson.annotations.SerializedName; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTopologyTemplate.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaTopologyTemplate.java index aed181f94..9d156c3df 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTopologyTemplate.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaTopologyTemplate.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import java.util.List; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTrigger.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaTrigger.java index 5f3b6392f..d772d554e 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/concepts/ToscaTrigger.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/concepts/ToscaTrigger.java @@ -21,7 +21,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import com.google.gson.annotations.SerializedName; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/mapping/ToscaServiceTemplateMapper.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/mapping/ToscaServiceTemplateMapper.java new file mode 100644 index 000000000..6dcbfe694 --- /dev/null +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/mapping/ToscaServiceTemplateMapper.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.tosca.simple.mapping; + +import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate; + +/** + * This interface is used to map legacy and proprietary policies into and out of TOSCA service templates. + * + * @author Liam Fallon (liam.fallon@est.tech) + * @param <I> the type for the incoming policy definition + * @param <O> the type for the outgoing policy definition + */ +public interface ToscaServiceTemplateMapper<I, O> { + + /** + * Translate from the other format to a TOSCA service template. + * + * @param otherPolicyType the other policy type + * @return the TOSCA service template + */ + public ToscaServiceTemplate toToscaServiceTemplate(final I otherPolicyType); + + /** + * Translate to the other format from a TOSCA service template. + * + * @param serviceTemplate the TOSCA service template + * @return the policy in the other format + */ + public O fromToscaServiceTemplate(final ToscaServiceTemplate serviceTemplate); +} diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaPoliciesJsonAdapter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/serialization/ToscaPoliciesJsonAdapter.java index a12ba8be9..2b61b6861 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaPoliciesJsonAdapter.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/serialization/ToscaPoliciesJsonAdapter.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.serialization.simple; +package org.onap.policy.models.tosca.simple.serialization; import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; @@ -33,8 +33,8 @@ import java.util.Iterator; import lombok.NonNull; import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.tosca.concepts.ToscaPolicies; -import org.onap.policy.models.tosca.concepts.ToscaPolicy; +import org.onap.policy.models.tosca.simple.concepts.ToscaPolicies; +import org.onap.policy.models.tosca.simple.concepts.ToscaPolicy; /** * GSON type adapter for TOSCA policies. diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaPolicyJsonAdapter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/serialization/ToscaPolicyJsonAdapter.java index ae5e596ba..075445d01 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaPolicyJsonAdapter.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/serialization/ToscaPolicyJsonAdapter.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.serialization.simple; +package org.onap.policy.models.tosca.simple.serialization; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; @@ -35,7 +35,7 @@ import lombok.NonNull; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfModelRuntimeException; -import org.onap.policy.models.tosca.concepts.ToscaPolicy; +import org.onap.policy.models.tosca.simple.concepts.ToscaPolicy; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaServiceTemplateJsonAdapter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/serialization/ToscaServiceTemplateJsonAdapter.java index b08a33d64..286bb7492 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaServiceTemplateJsonAdapter.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/serialization/ToscaServiceTemplateJsonAdapter.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.serialization.simple; +package org.onap.policy.models.tosca.simple.serialization; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; @@ -32,8 +32,8 @@ import java.lang.reflect.Type; import lombok.NonNull; import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.tosca.concepts.ToscaServiceTemplate; -import org.onap.policy.models.tosca.concepts.ToscaTopologyTemplate; +import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.simple.concepts.ToscaTopologyTemplate; /** * GSON type adapter for TOSCA policies. diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaServiceTemplateMessageBodyHandler.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/serialization/ToscaServiceTemplateMessageBodyHandler.java index 9abbf1c72..a386a9cc5 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaServiceTemplateMessageBodyHandler.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/serialization/ToscaServiceTemplateMessageBodyHandler.java @@ -16,15 +16,15 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.serialization.simple; +package org.onap.policy.models.tosca.simple.serialization; import com.google.gson.GsonBuilder; import org.onap.policy.common.gson.GsonMessageBodyHandler; -import org.onap.policy.models.tosca.concepts.ToscaPolicies; -import org.onap.policy.models.tosca.concepts.ToscaPolicy; -import org.onap.policy.models.tosca.concepts.ToscaServiceTemplate; -import org.onap.policy.models.tosca.concepts.ToscaTopologyTemplate; +import org.onap.policy.models.tosca.simple.concepts.ToscaPolicies; +import org.onap.policy.models.tosca.simple.concepts.ToscaPolicy; +import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.simple.concepts.ToscaTopologyTemplate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaTopologyTemplateJsonAdapter.java b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/serialization/ToscaTopologyTemplateJsonAdapter.java index 4f2f590b7..c76b9b027 100644 --- a/models-tosca/src/main/java/org/onap/policy/models/tosca/serialization/simple/ToscaTopologyTemplateJsonAdapter.java +++ b/models-tosca/src/main/java/org/onap/policy/models/tosca/simple/serialization/ToscaTopologyTemplateJsonAdapter.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.serialization.simple; +package org.onap.policy.models.tosca.simple.serialization; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonDeserializer; @@ -33,8 +33,8 @@ import lombok.NonNull; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfReferenceKey; -import org.onap.policy.models.tosca.concepts.ToscaPolicies; -import org.onap.policy.models.tosca.concepts.ToscaTopologyTemplate; +import org.onap.policy.models.tosca.simple.concepts.ToscaPolicies; +import org.onap.policy.models.tosca.simple.concepts.ToscaTopologyTemplate; /** * GSON type adapter for TOSCA policies. diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardPolicyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/concepts/LegacyGuardPolicyTest.java index fa082331a..d2b2216e7 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyGuardPolicyTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/concepts/LegacyGuardPolicyTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.serialization.legacy; +package org.onap.policy.models.tosca.legacy.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -29,6 +29,7 @@ import java.util.List; import java.util.Map; import org.junit.Test; +import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicy; public class LegacyGuardPolicyTest { diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalPolicyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/concepts/LegacyOperationalPolicyTest.java index 13da63247..36cea6372 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/legacy/LegacyOperationalPolicyTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/concepts/LegacyOperationalPolicyTest.java @@ -18,13 +18,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.serialization.legacy; +package org.onap.policy.models.tosca.legacy.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.Test; +import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy; public class LegacyOperationalPolicyTest { diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/serialization/LegacyOperationalPolicySerializationTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/serialization/LegacyOperationalPolicySerializationTest.java new file mode 100644 index 000000000..76721046e --- /dev/null +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/legacy/serialization/LegacyOperationalPolicySerializationTest.java @@ -0,0 +1,74 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.models.tosca.legacy.serialization; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import com.google.gson.Gson; +import com.google.gson.JsonSyntaxException; + +import java.io.IOException; + +import org.junit.Before; +import org.junit.Test; +import org.onap.policy.common.utils.resources.TextFileUtils; +import org.onap.policy.models.base.PfValidationResult; +import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy; +import org.onap.policy.models.tosca.legacy.mapping.LegacyOperationalPolicyMapper; +import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Test serialization of monitoring policies. + * + * @author Liam Fallon (liam.fallon@est.tech) + */ +public class LegacyOperationalPolicySerializationTest { + // Logger for this class + private static final Logger LOGGER = LoggerFactory.getLogger(LegacyOperationalPolicySerializationTest.class); + + private Gson gson; + + @Before + public void setUp() { + gson = new Gson(); + } + + @Test + public void testJsonDeserialization() throws JsonSyntaxException, IOException { + LegacyOperationalPolicy legacyOperationalPolicy = gson.fromJson( + TextFileUtils.getTextFileAsString("src/test/resources/policies/vCPE.policy.operational.input.json"), + LegacyOperationalPolicy.class); + + ToscaServiceTemplate serviceTemplate = + new LegacyOperationalPolicyMapper().toToscaServiceTemplate(legacyOperationalPolicy); + + assertNotNull(serviceTemplate); + LOGGER.info(serviceTemplate.validate(new PfValidationResult()).toString()); + assertTrue(serviceTemplate.validate(new PfValidationResult()).isValid()); + + assertEquals("operational.restart:1.0.1", + serviceTemplate.getTopologyTemplate().getPolicies().get("operational.restart").getId()); + } +} diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/TestPojos.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/TestPojos.java index d5b5f55b3..b3bdedf1c 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/TestPojos.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/TestPojos.java @@ -20,7 +20,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import com.openpojo.reflection.filters.FilterPackageInfo; import com.openpojo.validation.Validator; @@ -41,7 +41,7 @@ import org.onap.policy.common.utils.validation.ToStringTester; */ public class TestPojos { - private static final String POJO_PACKAGE = "org.onap.policy.models.tosca.concepts"; + private static final String POJO_PACKAGE = "org.onap.policy.models.tosca.simple.concepts"; @Test public void testPojos() { diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalKeyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogicalKeyTest.java index 60c6eb976..35a1c0a99 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalKeyTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogicalKeyTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -30,6 +30,7 @@ import org.junit.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.base.PfValidationResult; +import org.onap.policy.models.tosca.simple.concepts.ToscaConstraintLogicalKey; /** * DAO test for ToscaConstraintLogicalKey. diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalStringTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogicalStringTest.java index 5d0fe9332..764a6f46b 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalStringTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogicalStringTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -30,6 +30,7 @@ import org.junit.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.base.PfValidationResult; +import org.onap.policy.models.tosca.simple.concepts.ToscaConstraintLogicalString; /** * DAO test for ToscaConstraintLogicalString. diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogicalTest.java index fc623f1dd..d1617204a 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaConstraintLogicalTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaConstraintLogicalTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -30,7 +30,8 @@ import org.junit.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.base.PfValidationResult; -import org.onap.policy.models.tosca.concepts.testconcepts.DummyToscaConstraint; +import org.onap.policy.models.tosca.simple.concepts.ToscaConstraintLogical; +import org.onap.policy.models.tosca.simple.concepts.testconcepts.DummyToscaConstraint; /** * DAO test for ToscaConstraintLogical. diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaDataTypeTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaDataTypeTest.java index d0b9c7d9b..5adeece5b 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaDataTypeTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaDataTypeTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -33,7 +33,11 @@ import org.junit.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.base.PfValidationResult; -import org.onap.policy.models.tosca.concepts.ToscaConstraintLogical.Operation; +import org.onap.policy.models.tosca.simple.concepts.ToscaConstraint; +import org.onap.policy.models.tosca.simple.concepts.ToscaConstraintLogical.Operation; +import org.onap.policy.models.tosca.simple.concepts.ToscaConstraintLogicalString; +import org.onap.policy.models.tosca.simple.concepts.ToscaDataType; +import org.onap.policy.models.tosca.simple.concepts.ToscaProperty; /** * DAO test for ToscaDatatype. diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaDataTypesTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaDataTypesTest.java index cd9c53e7c..b92b6b08a 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaDataTypesTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaDataTypesTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -28,6 +28,8 @@ import java.util.TreeMap; import org.junit.Test; import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.tosca.simple.concepts.ToscaDataType; +import org.onap.policy.models.tosca.simple.concepts.ToscaDataTypes; public class ToscaDataTypesTest { diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaEntrySchemaTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaEntrySchemaTest.java index 97d71a203..e1a9f0c6f 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaEntrySchemaTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaEntrySchemaTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -33,7 +33,10 @@ import org.junit.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.base.PfValidationResult; -import org.onap.policy.models.tosca.concepts.ToscaConstraintLogical.Operation; +import org.onap.policy.models.tosca.simple.concepts.ToscaConstraint; +import org.onap.policy.models.tosca.simple.concepts.ToscaConstraintLogical.Operation; +import org.onap.policy.models.tosca.simple.concepts.ToscaConstraintLogicalString; +import org.onap.policy.models.tosca.simple.concepts.ToscaEntrySchema; /** * DAO test for ToscaEntrySchema. diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaEventFilterTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaEventFilterTest.java index a45d65d69..b1fb33fce 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaEventFilterTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaEventFilterTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -30,6 +30,7 @@ import org.junit.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.base.PfValidationResult; +import org.onap.policy.models.tosca.simple.concepts.ToscaEventFilter; /** * DAO test for ToscaEventFilter. diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaModelTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaModelTest.java index ca6445f13..af8cc2d3b 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaModelTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaModelTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -33,6 +33,9 @@ import org.junit.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfModelService; import org.onap.policy.models.base.PfValidationResult; +import org.onap.policy.models.tosca.simple.concepts.ToscaModel; +import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplates; /** * DAO test for ToscaDatatype. diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPoliciesTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaPoliciesTest.java index 76fdd538b..127aac4f4 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPoliciesTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaPoliciesTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -28,6 +28,8 @@ import java.util.TreeMap; import org.junit.Test; import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.tosca.simple.concepts.ToscaPolicies; +import org.onap.policy.models.tosca.simple.concepts.ToscaPolicy; public class ToscaPoliciesTest { diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicyTest.java index 295c0f2fd..7af5cc754 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicyTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -27,12 +27,14 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.junit.Test; import org.onap.policy.models.base.PfConceptKey; -import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.base.PfValidationResult; +import org.onap.policy.models.tosca.simple.concepts.ToscaPolicy; /** * DAO test for ToscaDatatype. @@ -87,11 +89,10 @@ public class ToscaPolicyTest { PfConceptKey ptKey = new PfConceptKey("policyType", "0.0.1"); ToscaPolicy tp = new ToscaPolicy(tpKey, ptKey); - List<ToscaProperty> properties = new ArrayList<>(); - ToscaProperty property = new ToscaProperty(new PfReferenceKey(tpKey, "pr"), new PfConceptKey("type", "0.0.1")); - properties.add(property); - tp.setProperties(properties); - assertEquals(properties, tp.getProperties()); + Map<String, Object> propertyMap = new HashMap<>(); + propertyMap.put("Property", "Property Value"); + tp.setProperties(propertyMap); + assertEquals(propertyMap, tp.getProperties()); List<PfConceptKey> targets = new ArrayList<>(); PfConceptKey target = new PfConceptKey("target", "0.0.1"); @@ -120,7 +121,7 @@ public class ToscaPolicyTest { assertFalse(tp.compareTo(otherDt) == 0); otherDt.setType(ptKey); assertFalse(tp.compareTo(otherDt) == 0); - otherDt.setProperties(properties); + otherDt.setProperties(propertyMap); assertFalse(tp.compareTo(otherDt) == 0); otherDt.setTargets(targets); assertEquals(0, tp.compareTo(otherDt)); @@ -132,7 +133,7 @@ public class ToscaPolicyTest { assertEquals("target is marked @NonNull but is null", exc.getMessage()); } - assertEquals(5, tp.getKeys().size()); + assertEquals(3, tp.getKeys().size()); assertEquals(2, new ToscaPolicy().getKeys().size()); new ToscaPolicy().clean(); @@ -140,9 +141,20 @@ public class ToscaPolicyTest { assertEquals(tdtClone0, tp); assertFalse(new ToscaPolicy().validate(new PfValidationResult()).isValid()); + System.err.println(tp.validate(new PfValidationResult())); assertTrue(tp.validate(new PfValidationResult()).isValid()); - tp.getProperties().add(null); + tp.getProperties().put(null, null); + assertFalse(tp.validate(new PfValidationResult()).isValid()); + tp.getProperties().remove(null); + assertTrue(tp.validate(new PfValidationResult()).isValid()); + + tp.getProperties().put("Key", null); + assertFalse(tp.validate(new PfValidationResult()).isValid()); + tp.getProperties().remove("Key"); + assertTrue(tp.validate(new PfValidationResult()).isValid()); + + tp.getProperties().put(null, "Value"); assertFalse(tp.validate(new PfValidationResult()).isValid()); tp.getProperties().remove(null); assertTrue(tp.validate(new PfValidationResult()).isValid()); diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypeTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicyTypeTest.java index 7926bfe78..3be0cff3d 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypeTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicyTypeTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -35,6 +35,10 @@ import org.junit.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.base.PfValidationResult; +import org.onap.policy.models.tosca.simple.concepts.ToscaEntityType; +import org.onap.policy.models.tosca.simple.concepts.ToscaPolicyType; +import org.onap.policy.models.tosca.simple.concepts.ToscaProperty; +import org.onap.policy.models.tosca.simple.concepts.ToscaTrigger; /** * DAO test for ToscaPolicyType. diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypesTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicyTypesTest.java index 069346331..a85c8285e 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPolicyTypesTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaPolicyTypesTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -28,6 +28,8 @@ import java.util.TreeMap; import org.junit.Test; import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.tosca.simple.concepts.ToscaPolicyType; +import org.onap.policy.models.tosca.simple.concepts.ToscaPolicyTypes; public class ToscaPolicyTypesTest { diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPropertyTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaPropertyTest.java index d0563fd26..a33da605e 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaPropertyTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaPropertyTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -33,7 +33,11 @@ import org.junit.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.base.PfValidationResult; -import org.onap.policy.models.tosca.concepts.ToscaConstraintLogical.Operation; +import org.onap.policy.models.tosca.simple.concepts.ToscaConstraint; +import org.onap.policy.models.tosca.simple.concepts.ToscaConstraintLogical.Operation; +import org.onap.policy.models.tosca.simple.concepts.ToscaConstraintLogicalString; +import org.onap.policy.models.tosca.simple.concepts.ToscaEntrySchema; +import org.onap.policy.models.tosca.simple.concepts.ToscaProperty; /** * DAO test for ToscaProperty. diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplateTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaServiceTemplateTest.java index 5d8615814..aad410e89 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplateTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaServiceTemplateTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -33,6 +33,12 @@ import org.junit.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.base.PfValidationResult; +import org.onap.policy.models.tosca.simple.concepts.ToscaDataType; +import org.onap.policy.models.tosca.simple.concepts.ToscaDataTypes; +import org.onap.policy.models.tosca.simple.concepts.ToscaPolicyType; +import org.onap.policy.models.tosca.simple.concepts.ToscaPolicyTypes; +import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.simple.concepts.ToscaTopologyTemplate; /** * DAO test for ToscaDatatype. diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplatesTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaServiceTemplatesTest.java index c866f11c7..2864be829 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaServiceTemplatesTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaServiceTemplatesTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -28,6 +28,8 @@ import java.util.TreeMap; import org.junit.Test; import org.onap.policy.models.base.PfConceptKey; +import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplates; public class ToscaServiceTemplatesTest { diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTimeIntervalTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaTimeIntervalTest.java index 33af68343..cbfde2d11 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTimeIntervalTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaTimeIntervalTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -32,6 +32,7 @@ import org.junit.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.base.PfValidationResult; +import org.onap.policy.models.tosca.simple.concepts.ToscaTimeInterval; /** * DAO test for ToscaTimeInterval. diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTopologyTemplateTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaTopologyTemplateTest.java index 97bbdbe71..3ea225d19 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTopologyTemplateTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaTopologyTemplateTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -33,6 +33,9 @@ import org.junit.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.base.PfValidationResult; +import org.onap.policy.models.tosca.simple.concepts.ToscaPolicies; +import org.onap.policy.models.tosca.simple.concepts.ToscaPolicy; +import org.onap.policy.models.tosca.simple.concepts.ToscaTopologyTemplate; /** * DAO test for ToscaDatatype. diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTriggerTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaTriggerTest.java index d1423a6a4..be60165ff 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/ToscaTriggerTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/ToscaTriggerTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts; +package org.onap.policy.models.tosca.simple.concepts; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -33,7 +33,11 @@ import org.junit.Test; import org.onap.policy.models.base.PfConceptKey; import org.onap.policy.models.base.PfReferenceKey; import org.onap.policy.models.base.PfValidationResult; -import org.onap.policy.models.tosca.concepts.ToscaConstraintLogical.Operation; +import org.onap.policy.models.tosca.simple.concepts.ToscaConstraintLogical.Operation; +import org.onap.policy.models.tosca.simple.concepts.ToscaConstraintLogicalString; +import org.onap.policy.models.tosca.simple.concepts.ToscaEventFilter; +import org.onap.policy.models.tosca.simple.concepts.ToscaTimeInterval; +import org.onap.policy.models.tosca.simple.concepts.ToscaTrigger; /** * DAO test for ToscaTrigger. diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/testconcepts/DummyToscaConstraint.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/testconcepts/DummyToscaConstraint.java index 3b27e1565..2e03fd215 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/concepts/testconcepts/DummyToscaConstraint.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/concepts/testconcepts/DummyToscaConstraint.java @@ -18,13 +18,13 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.concepts.testconcepts; +package org.onap.policy.models.tosca.simple.concepts.testconcepts; import javax.ws.rs.core.Response; import org.onap.policy.models.base.PfModelRuntimeException; import org.onap.policy.models.base.PfReferenceKey; -import org.onap.policy.models.tosca.concepts.ToscaConstraint; +import org.onap.policy.models.tosca.simple.concepts.ToscaConstraint; /** * Dummy constraint to test abstract ToscaConstraint class. diff --git a/models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/MonitoringPolicySerializationTest.java b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicySerializationTest.java index 8d0c8d440..9977f3b72 100644 --- a/models-tosca/src/test/java/org/onap/policy/models/tosca/serialization/MonitoringPolicySerializationTest.java +++ b/models-tosca/src/test/java/org/onap/policy/models/tosca/simple/serialization/MonitoringPolicySerializationTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.policy.models.tosca.serialization; +package org.onap.policy.models.tosca.simple.serialization; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -33,8 +33,8 @@ import org.junit.Before; import org.junit.Test; import org.onap.policy.common.utils.resources.TextFileUtils; import org.onap.policy.models.base.PfValidationResult; -import org.onap.policy.models.tosca.concepts.ToscaServiceTemplate; -import org.onap.policy.models.tosca.serialization.simple.ToscaServiceTemplateMessageBodyHandler; +import org.onap.policy.models.tosca.simple.concepts.ToscaServiceTemplate; +import org.onap.policy.models.tosca.simple.serialization.ToscaServiceTemplateMessageBodyHandler; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.yaml.snakeyaml.Yaml; |